* Get (mostly) rid of CFG_MONITOR_LEN definition; compute real length
  instead CFG_MONITOR_LEN is now only used to determine  _at_compile_
  _time_  (!) if the environment is embedded within the U-Boot image,
  or in a separate flash sector.

* Cleanup CFG_DER #defines in config files (wd maintained only)
diff --git a/board/LEOX/elpt860/flash.c b/board/LEOX/elpt860/flash.c
index a9238e1..7107aaa 100644
--- a/board/LEOX/elpt860/flash.c
+++ b/board/LEOX/elpt860/flash.c
@@ -118,7 +118,7 @@
   /* monitor protection ON by default */
   flash_protect (FLAG_PROTECT_SET,
 		 CFG_MONITOR_BASE,
-		 CFG_MONITOR_BASE + CFG_MONITOR_LEN-1,
+		 CFG_MONITOR_BASE + monitor_flash_len-1,
 		 &flash_info[0]);
 #endif
   
diff --git a/board/MAI/AmigaOneG3SE/flash_new.c b/board/MAI/AmigaOneG3SE/flash_new.c
index 6eebeba..3fb9f12 100644
--- a/board/MAI/AmigaOneG3SE/flash_new.c
+++ b/board/MAI/AmigaOneG3SE/flash_new.c
@@ -120,7 +120,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+			      CFG_MONITOR_BASE + monitor_flash_len - 1,
 			      &flash_info[0]);
 #endif
 
diff --git a/board/RPXClassic/flash.c b/board/RPXClassic/flash.c
index 6293497..fdf90cf 100644
--- a/board/RPXClassic/flash.c
+++ b/board/RPXClassic/flash.c
@@ -64,7 +64,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/RPXlite/flash.c b/board/RPXlite/flash.c
index 78c1838..846794d 100644
--- a/board/RPXlite/flash.c
+++ b/board/RPXlite/flash.c
@@ -85,7 +85,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/RRvision/flash.c b/board/RRvision/flash.c
index 06f7c4b..d8e07e6 100644
--- a/board/RRvision/flash.c
+++ b/board/RRvision/flash.c
@@ -73,7 +73,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/atc/flash.c b/board/atc/flash.c
index 7e97182..6d7b38b 100644
--- a/board/atc/flash.c
+++ b/board/atc/flash.c
@@ -91,7 +91,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      flash_get_info(CFG_MONITOR_BASE));
 #endif
 
diff --git a/board/bmw/flash.c b/board/bmw/flash.c
index 6a7649f..be62274 100644
--- a/board/bmw/flash.c
+++ b/board/bmw/flash.c
@@ -219,7 +219,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
     flash_protect(FLAG_PROTECT_SET,
 		CFG_MONITOR_BASE,
-		CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+		CFG_MONITOR_BASE + monitor_flash_len - 1,
 		&flash_info[0]);
 #endif
 
diff --git a/board/c2mon/flash.c b/board/c2mon/flash.c
index 181f82a..b2be21c 100644
--- a/board/c2mon/flash.c
+++ b/board/c2mon/flash.c
@@ -91,7 +91,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -118,7 +118,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/cmi/flash.c b/board/cmi/flash.c
index b41ff12..9c802b9 100644
--- a/board/cmi/flash.c
+++ b/board/cmi/flash.c
@@ -106,7 +106,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/cogent/flash.c b/board/cogent/flash.c
index 86da80e..969520d 100644
--- a/board/cogent/flash.c
+++ b/board/cogent/flash.c
@@ -323,7 +323,7 @@
 #if CFG_MONITOR_BASE == CFG_FLASH_BASE
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/cpc45/flash.c b/board/cpc45/flash.c
index 6e81b9c33..a289d08 100644
--- a/board/cpc45/flash.c
+++ b/board/cpc45/flash.c
@@ -132,12 +132,12 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE + FLASH_BANK_SIZE
     flash_protect(FLAG_PROTECT_SET,
               CFG_MONITOR_BASE,
-              CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+              CFG_MONITOR_BASE + monitor_flash_len - 1,
               &flash_info[1]);
 #else
     flash_protect(FLAG_PROTECT_SET,
               CFG_MONITOR_BASE,
-              CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+              CFG_MONITOR_BASE + monitor_flash_len - 1,
               &flash_info[0]);
 #endif
 #endif
diff --git a/board/cpu86/flash.c b/board/cpu86/flash.c
index 8cf761f..0769dc5 100644
--- a/board/cpu86/flash.c
+++ b/board/cpu86/flash.c
@@ -218,14 +218,14 @@
 
 		flash_protect  (FLAG_PROTECT_SET,
 				CFG_MONITOR_BASE,
-				CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[1]
+				CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[1]
 		);
 	}
 #else
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_MONITOR_BASE,
-		       CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]
+		       CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]
 	);
 #endif
 #endif
diff --git a/board/cradle/flash.c b/board/cradle/flash.c
index 265b609..463026d 100644
--- a/board/cradle/flash.c
+++ b/board/cradle/flash.c
@@ -73,7 +73,7 @@
     */
    flash_protect(FLAG_PROTECT_SET,
                   CFG_FLASH_BASE,
-                  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+                  CFG_FLASH_BASE + monitor_flash_len - 1,
                   &flash_info[0]);
 
    flash_protect(FLAG_PROTECT_SET,
diff --git a/board/cray/L1/flash.c b/board/cray/L1/flash.c
index 6d66905..829dbae 100644
--- a/board/cray/L1/flash.c
+++ b/board/cray/L1/flash.c
@@ -88,7 +88,7 @@
 	    /* Monitor protection ON by default */
 	    (void)flash_protect(FLAG_PROTECT_SET,
 				FLASH_BASE0_PRELIM,
-				FLASH_BASE0_PRELIM+CFG_MONITOR_LEN-1,
+				FLASH_BASE0_PRELIM+monitor_flash_len-1,
 				&flash_info[0]);
 #endif
 	    size_b1 = 0 ;
diff --git a/board/csb226/flash.c b/board/csb226/flash.c
index c6cb95e..0ee78e6 100644
--- a/board/csb226/flash.c
+++ b/board/csb226/flash.c
@@ -74,7 +74,7 @@
 	/* Protect monitor and environment sectors */
 	flash_protect(FLAG_PROTECT_SET,
 			CFG_FLASH_BASE,
-			CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+			CFG_FLASH_BASE + monitor_flash_len - 1,
 			&flash_info[0]);
 
 	flash_protect(FLAG_PROTECT_SET,
diff --git a/board/cu824/flash.c b/board/cu824/flash.c
index 0cec41e..61b759e 100644
--- a/board/cu824/flash.c
+++ b/board/cu824/flash.c
@@ -125,12 +125,12 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE + FLASH_BANK_SIZE
     flash_protect(FLAG_PROTECT_SET,
               CFG_MONITOR_BASE,
-              CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+              CFG_MONITOR_BASE + monitor_flash_len - 1,
               &flash_info[1]);
 #else
     flash_protect(FLAG_PROTECT_SET,
               CFG_MONITOR_BASE,
-              CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+              CFG_MONITOR_BASE + monitor_flash_len - 1,
               &flash_info[0]);
 #endif
 #endif
diff --git a/board/dnp1110/flash.c b/board/dnp1110/flash.c
index bb6d2e7..f4a8b99 100644
--- a/board/dnp1110/flash.c
+++ b/board/dnp1110/flash.c
@@ -84,7 +84,7 @@
      */
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len  - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/eltec/bab7xx/flash.c b/board/eltec/bab7xx/flash.c
index 5834c99..73496a1 100644
--- a/board/eltec/bab7xx/flash.c
+++ b/board/eltec/bab7xx/flash.c
@@ -83,21 +83,21 @@
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 FLASH_BASE0_PRELIM,
-                FLASH_BASE0_PRELIM+CFG_MONITOR_LEN-1,
+                FLASH_BASE0_PRELIM+monitor_flash_len-1,
                 &flash_info[0]);
     }
     if (size2 == 512*1024)
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 FLASH_BASE1_PRELIM,
-                FLASH_BASE1_PRELIM+CFG_MONITOR_LEN-1,
+                FLASH_BASE1_PRELIM+monitor_flash_len-1,
                 &flash_info[1]);
     }
     if (size2 == 4*1024*1024)
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 CFG_FLASH_BASE,
-                CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+                CFG_FLASH_BASE+monitor_flash_len-1,
                 &flash_info[1]);
     }
 
diff --git a/board/eltec/elppc/flash.c b/board/eltec/elppc/flash.c
index 5834c99..73496a1 100644
--- a/board/eltec/elppc/flash.c
+++ b/board/eltec/elppc/flash.c
@@ -83,21 +83,21 @@
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 FLASH_BASE0_PRELIM,
-                FLASH_BASE0_PRELIM+CFG_MONITOR_LEN-1,
+                FLASH_BASE0_PRELIM+monitor_flash_len-1,
                 &flash_info[0]);
     }
     if (size2 == 512*1024)
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 FLASH_BASE1_PRELIM,
-                FLASH_BASE1_PRELIM+CFG_MONITOR_LEN-1,
+                FLASH_BASE1_PRELIM+monitor_flash_len-1,
                 &flash_info[1]);
     }
     if (size2 == 4*1024*1024)
     {
         (void)flash_protect(FLAG_PROTECT_SET,
                 CFG_FLASH_BASE,
-                CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+                CFG_FLASH_BASE+monitor_flash_len-1,
                 &flash_info[1]);
     }
 
diff --git a/board/eltec/mhpc/flash.c b/board/eltec/mhpc/flash.c
index 58cfd70..e9c8f98 100644
--- a/board/eltec/mhpc/flash.c
+++ b/board/eltec/mhpc/flash.c
@@ -92,7 +92,7 @@
 	/* monitor protection ON by default */
 	(void)flash_protect(FLAG_PROTECT_SET,
 			    CFG_FLASH_BASE,
-			    CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+			    CFG_FLASH_BASE+monitor_flash_len-1,
 			    &flash_info[0]);
 
 	flash_info[0].size = size_b0;
diff --git a/board/ep7312/flash.c b/board/ep7312/flash.c
index 373d238..1ee0a37 100644
--- a/board/ep7312/flash.c
+++ b/board/ep7312/flash.c
@@ -61,7 +61,7 @@
 	 */
 	flash_protect ( FLAG_PROTECT_SET,
 			CFG_FLASH_BASE,
-			CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+			CFG_FLASH_BASE + monitor_flash_len - 1,
 			&flash_info[0]);
 
 	flash_protect ( FLAG_PROTECT_SET,
diff --git a/board/ep8260/flash.c b/board/ep8260/flash.c
index cae8a13..d9dbdbe 100644
--- a/board/ep8260/flash.c
+++ b/board/ep8260/flash.c
@@ -140,7 +140,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/eric/flash.c b/board/eric/flash.c
index c3f6e15..5dfb620 100644
--- a/board/eric/flash.c
+++ b/board/eric/flash.c
@@ -83,13 +83,13 @@
 	    /* Monitor protection ON by default */
 #if 0	    /* sand: */
 	    (void)flash_protect(FLAG_PROTECT_SET,
-				FLASH_BASE0_PRELIM-CFG_MONITOR_LEN+size_b0,
+				FLASH_BASE0_PRELIM-monitor_flash_len+size_b0,
 				FLASH_BASE0_PRELIM-1+size_b0,
 				&flash_info[0]);
 #else
 	    (void)flash_protect(FLAG_PROTECT_SET,
 		      		CFG_MONITOR_BASE,
-		      		CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      		CFG_MONITOR_BASE+monitor_flash_len-1,
 		      		&flash_info[0]);
 #endif
 	    size_b1 = 0 ;
@@ -132,13 +132,13 @@
 	    /* monitor protection ON by default */
 #if 0	    /* sand: */
 	    (void)flash_protect(FLAG_PROTECT_SET,
-				FLASH_BASE0_PRELIM-CFG_MONITOR_LEN+size_b0,
+				FLASH_BASE0_PRELIM-monitor_flash_len+size_b0,
 				FLASH_BASE0_PRELIM-1+size_b0,
 				&flash_info[0]);
 #else
 	    (void)flash_protect(FLAG_PROTECT_SET,
 		      		CFG_MONITOR_BASE,
-		      		CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      		CFG_MONITOR_BASE+monitor_flash_len-1,
 		      		&flash_info[0]);
 #endif
 
@@ -150,12 +150,12 @@
 
 	      /* monitor protection ON by default */
 	      (void)flash_protect(FLAG_PROTECT_SET,
-				  base_b1+size_b1-CFG_MONITOR_LEN,
+				  base_b1+size_b1-monitor_flash_len,
 				  base_b1+size_b1-1,
 				  &flash_info[1]);
 	      /* monitor protection OFF by default (one is enough) */
 	      (void)flash_protect(FLAG_PROTECT_CLEAR,
-				  base_b0+size_b0-CFG_MONITOR_LEN,
+				  base_b0+size_b0-monitor_flash_len,
 				  base_b0+size_b0-1,
 				  &flash_info[0]);
 	    } else {
diff --git a/board/esd/adciop/flash.c b/board/esd/adciop/flash.c
index 46ae03b..69618de 100644
--- a/board/esd/adciop/flash.c
+++ b/board/esd/adciop/flash.c
@@ -80,7 +80,7 @@
 
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
-		      FLASH_BASE0_PRELIM+size_b0-CFG_MONITOR_LEN,
+		      FLASH_BASE0_PRELIM+size_b0-monitor_flash_len,
 		      FLASH_BASE0_PRELIM+size_b0-1,
 		      &flash_info[0]);
 
@@ -93,12 +93,12 @@
 
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
-			      FLASH_BASE0_PRELIM+size_b0+size_b1-CFG_MONITOR_LEN,
+			      FLASH_BASE0_PRELIM+size_b0+size_b1-monitor_flash_len,
 			      FLASH_BASE0_PRELIM+size_b0+size_b1-1,
 			      &flash_info[1]);
                 /* monitor protection OFF by default (one is enough) */
                 flash_protect(FLAG_PROTECT_CLEAR,
-			      FLASH_BASE0_PRELIM+size_b0-CFG_MONITOR_LEN,
+			      FLASH_BASE0_PRELIM+size_b0-monitor_flash_len,
 			      FLASH_BASE0_PRELIM+size_b0-1,
 			      &flash_info[0]);
 	} else {
diff --git a/board/esd/ar405/flash.c b/board/esd/ar405/flash.c
index 4fa6b27..3a644f9 100644
--- a/board/esd/ar405/flash.c
+++ b/board/esd/ar405/flash.c
@@ -94,7 +94,7 @@
 
 	/* monitor protection ON by default */
 	(void)flash_protect(FLAG_PROTECT_SET,
-			    base_b0+size_b0-CFG_MONITOR_LEN,
+			    base_b0+size_b0-monitor_flash_len,
 			    base_b0+size_b0-1,
 			    &flash_info[0]);
 
@@ -106,12 +106,12 @@
 
 		/* monitor protection ON by default */
 		(void)flash_protect(FLAG_PROTECT_SET,
-				    base_b1+size_b1-CFG_MONITOR_LEN,
+				    base_b1+size_b1-monitor_flash_len,
 				    base_b1+size_b1-1,
 				    &flash_info[1]);
                 /* monitor protection OFF by default (one is enough) */
                 (void)flash_protect(FLAG_PROTECT_CLEAR,
-                                    base_b0+size_b0-CFG_MONITOR_LEN,
+                                    base_b0+size_b0-monitor_flash_len,
                                     base_b0+size_b0-1,
                                     &flash_info[0]);
 	} else {
diff --git a/board/esd/canbt/flash.c b/board/esd/canbt/flash.c
index 214948f..685850e 100644
--- a/board/esd/canbt/flash.c
+++ b/board/esd/canbt/flash.c
@@ -74,7 +74,7 @@
 
         /* Monitor protection ON by default */
         (void)flash_protect(FLAG_PROTECT_SET,
-                            -CFG_MONITOR_LEN,
+                            -monitor_flash_len,
                             0xffffffff,
                             &flash_info[0]);
 
diff --git a/board/esd/cpci405/flash.c b/board/esd/cpci405/flash.c
index 02de050..e766895 100644
--- a/board/esd/cpci405/flash.c
+++ b/board/esd/cpci405/flash.c
@@ -125,7 +125,7 @@
 
 	/* monitor protection ON by default */
 	flash_protect (FLAG_PROTECT_SET,
-			base_b0 + size_b0 - CFG_MONITOR_LEN,
+			base_b0 + size_b0 - monitor_flash_len,
 			base_b0 + size_b0 - 1, &flash_info[0]);
 
 	if (size_b1) {
@@ -136,11 +136,11 @@
 
 		/* monitor protection ON by default */
 		flash_protect (FLAG_PROTECT_SET,
-				base_b1 + size_b1 - CFG_MONITOR_LEN,
+				base_b1 + size_b1 - monitor_flash_len,
 				base_b1 + size_b1 - 1, &flash_info[1]);
 		/* monitor protection OFF by default (one is enough) */
 		flash_protect (FLAG_PROTECT_CLEAR,
-				base_b0 + size_b0 - CFG_MONITOR_LEN,
+				base_b0 + size_b0 - monitor_flash_len,
 				base_b0 + size_b0 - 1, &flash_info[0]);
 	} else {
 		flash_info[1].flash_id = FLASH_UNKNOWN;
diff --git a/board/esd/cpci440/strataflash.c b/board/esd/cpci440/strataflash.c
index 6f62866..de57318 100644
--- a/board/esd/cpci440/strataflash.c
+++ b/board/esd/cpci440/strataflash.c
@@ -200,7 +200,7 @@
 #if 0 /* test-only */
 	/* Monitor protection ON by default */
 #if (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
-	for(i=0; flash_info[0].start[i] < CFG_MONITOR_BASE+CFG_MONITOR_LEN-1; i++)
+	for(i=0; flash_info[0].start[i] < CFG_MONITOR_BASE+monitor_flash_len-1; i++)
 		(void)flash_real_protect(&flash_info[0], i, 1);
 #endif
 #endif
diff --git a/board/esd/cpciiser4/flash.c b/board/esd/cpciiser4/flash.c
index 214948f..685850e 100644
--- a/board/esd/cpciiser4/flash.c
+++ b/board/esd/cpciiser4/flash.c
@@ -74,7 +74,7 @@
 
         /* Monitor protection ON by default */
         (void)flash_protect(FLAG_PROTECT_SET,
-                            -CFG_MONITOR_LEN,
+                            -monitor_flash_len,
                             0xffffffff,
                             &flash_info[0]);
 
diff --git a/board/esd/dasa_sim/flash.c b/board/esd/dasa_sim/flash.c
index 2574eac..32cd64c 100644
--- a/board/esd/dasa_sim/flash.c
+++ b/board/esd/dasa_sim/flash.c
@@ -67,7 +67,7 @@
 
         /* Monitor protection ON by default */
         (void)flash_protect(FLAG_PROTECT_SET,
-                            -CFG_MONITOR_LEN,
+                            -monitor_flash_len,
                             0xffffffff,
                             &flash_info[0]);
 
diff --git a/board/esd/du405/flash.c b/board/esd/du405/flash.c
index 97d8322..14549c0 100644
--- a/board/esd/du405/flash.c
+++ b/board/esd/du405/flash.c
@@ -94,7 +94,7 @@
 
 	/* monitor protection ON by default */
 	flash_protect (FLAG_PROTECT_SET,
-			base_b0 + size_b0 - CFG_MONITOR_LEN,
+			base_b0 + size_b0 - monitor_flash_len,
 			base_b0 + size_b0 - 1, &flash_info[0]);
 
 	if (size_b1) {
@@ -105,11 +105,11 @@
 
 		/* monitor protection ON by default */
 		flash_protect (FLAG_PROTECT_SET,
-				base_b1 + size_b1 - CFG_MONITOR_LEN,
+				base_b1 + size_b1 - monitor_flash_len,
 				base_b1 + size_b1 - 1, &flash_info[1]);
 		/* monitor protection OFF by default (one is enough) */
 		flash_protect (FLAG_PROTECT_CLEAR,
-				base_b0 + size_b0 - CFG_MONITOR_LEN,
+				base_b0 + size_b0 - monitor_flash_len,
 				base_b0 + size_b0 - 1, &flash_info[0]);
 	} else {
 		flash_info[1].flash_id = FLASH_UNKNOWN;
diff --git a/board/esd/ocrtc/flash.c b/board/esd/ocrtc/flash.c
index 90965ea..c3d8bec 100644
--- a/board/esd/ocrtc/flash.c
+++ b/board/esd/ocrtc/flash.c
@@ -127,7 +127,7 @@
 
 	/* monitor protection ON by default */
 	flash_protect (FLAG_PROTECT_SET,
-			base_b0 + size_b0 - CFG_MONITOR_LEN,
+			base_b0 + size_b0 - monitor_flash_len,
 			base_b0 + size_b0 - 1, &flash_info[0]);
 
 	if (size_b1) {
@@ -138,11 +138,11 @@
 
 		/* monitor protection ON by default */
 		flash_protect (FLAG_PROTECT_SET,
-				base_b1 + size_b1 - CFG_MONITOR_LEN,
+				base_b1 + size_b1 - monitor_flash_len,
 				base_b1 + size_b1 - 1, &flash_info[1]);
 		/* monitor protection OFF by default (one is enough) */
 		flash_protect (FLAG_PROTECT_CLEAR,
-				base_b0 + size_b0 - CFG_MONITOR_LEN,
+				base_b0 + size_b0 - monitor_flash_len,
 				base_b0 + size_b0 - 1, &flash_info[0]);
 	} else {
 		flash_info[1].flash_id = FLASH_UNKNOWN;
diff --git a/board/esd/pci405/flash.c b/board/esd/pci405/flash.c
index f904aff..1707dcf 100644
--- a/board/esd/pci405/flash.c
+++ b/board/esd/pci405/flash.c
@@ -91,7 +91,7 @@
 
         /* Monitor protection ON by default */
         (void)flash_protect(FLAG_PROTECT_SET,
-                            -CFG_MONITOR_LEN,
+                            -monitor_flash_len,
                             0xffffffff,
                             &flash_info[0]);
 
diff --git a/board/esteem192e/flash.c b/board/esteem192e/flash.c
index 55845fa..5322430 100644
--- a/board/esteem192e/flash.c
+++ b/board/esteem192e/flash.c
@@ -104,7 +104,7 @@
 	/* monitor protection ON by default */
 	(void)flash_protect(FLAG_PROTECT_SET,
 			    CFG_MONITOR_BASE,
-			    CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			    CFG_MONITOR_BASE+monitor_flash_len-1,
 			    &flash_info[0]);
 #endif
 
@@ -124,7 +124,7 @@
 		/* monitor protection ON by default */
 		(void)flash_protect(FLAG_PROTECT_SET,
 				    CFG_MONITOR_BASE,
-				    CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+				    CFG_MONITOR_BASE+monitor_flash_len-1,
 				    &flash_info[1]);
 #endif
 	} else {
diff --git a/board/etx094/flash.c b/board/etx094/flash.c
index b3c620e..98a7c0c 100644
--- a/board/etx094/flash.c
+++ b/board/etx094/flash.c
@@ -91,7 +91,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -115,7 +115,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 	} else {
diff --git a/board/fads/flash.c b/board/fads/flash.c
index 22a7c41..680a2dc 100644
--- a/board/fads/flash.c
+++ b/board/fads/flash.c
@@ -112,7 +112,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[i]);
 #endif
 
diff --git a/board/flagadm/flash.c b/board/flagadm/flash.c
index fc5d963..fd0082c 100644
--- a/board/flagadm/flash.c
+++ b/board/flagadm/flash.c
@@ -77,7 +77,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/gen860t/flash.c b/board/gen860t/flash.c
index 902b1b0..ec32d07 100644
--- a/board/gen860t/flash.c
+++ b/board/gen860t/flash.c
@@ -157,7 +157,7 @@
 	 */
 	flash_protect(FLAG_PROTECT_SET,
 		      	  CFG_MONITOR_BASE,
-		      	  CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+		      	  CFG_MONITOR_BASE + monitor_flash_len - 1,
 		      	  &flash_info[0]);
 #endif
 
diff --git a/board/genietv/flash.c b/board/genietv/flash.c
index 2314a53..f12d0be 100644
--- a/board/genietv/flash.c
+++ b/board/genietv/flash.c
@@ -55,7 +55,7 @@
 	/* Monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/gth/flash.c b/board/gth/flash.c
index 562a349..c8b56fb 100644
--- a/board/gth/flash.c
+++ b/board/gth/flash.c
@@ -102,7 +102,7 @@
 	  /* monitor protection ON by default */
 	  (void)flash_protect(FLAG_PROTECT_SET,
 			    CFG_MONITOR_BASE,
-			    CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			    CFG_MONITOR_BASE+monitor_flash_len-1,
 			    &flash_info[0]);
 #endif
 
@@ -121,7 +121,7 @@
 		/* monitor protection ON by default */
 		(void)flash_protect(FLAG_PROTECT_SET,
 				    CFG_MONITOR_BASE,
-				    CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+				    CFG_MONITOR_BASE+monitor_flash_len-1,
 				    &flash_info[1]);
 #endif
 	}
diff --git a/board/gw8260/flash.c b/board/gw8260/flash.c
index 532dd19..5620a1d 100644
--- a/board/gw8260/flash.c
+++ b/board/gw8260/flash.c
@@ -96,7 +96,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/hermes/flash.c b/board/hermes/flash.c
index bb7635e..799fe83 100644
--- a/board/hermes/flash.c
+++ b/board/hermes/flash.c
@@ -71,7 +71,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/hymod/flash.c b/board/hymod/flash.c
index ee052e3..0a09b4a 100644
--- a/board/hymod/flash.c
+++ b/board/hymod/flash.c
@@ -321,7 +321,7 @@
 #if CFG_MONITOR_BASE == CFG_FLASH_BASE
 	(void)flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/icu862/flash.c b/board/icu862/flash.c
index 79e7cc2..6315bd9 100644
--- a/board/icu862/flash.c
+++ b/board/icu862/flash.c
@@ -104,7 +104,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/impa7/flash.c b/board/impa7/flash.c
index c59ffb8..7db0b32 100644
--- a/board/impa7/flash.c
+++ b/board/impa7/flash.c
@@ -72,7 +72,7 @@
      */
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/incaip/flash.c b/board/incaip/flash.c
index 427f14a..e7fd540 100644
--- a/board/incaip/flash.c
+++ b/board/incaip/flash.c
@@ -100,7 +100,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      flash_get_info(CFG_MONITOR_BASE));
 #endif
 
diff --git a/board/ip860/flash.c b/board/ip860/flash.c
index 4b0ea9b..2cf23b3 100644
--- a/board/ip860/flash.c
+++ b/board/ip860/flash.c
@@ -90,7 +90,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/iphase4539/flash.c b/board/iphase4539/flash.c
index 401ffbe..4eca467 100644
--- a/board/iphase4539/flash.c
+++ b/board/iphase4539/flash.c
@@ -71,7 +71,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+			      CFG_MONITOR_BASE + monitor_flash_len - 1,
 			      flash_info + bank);
 #endif
 
diff --git a/board/ivm/flash.c b/board/ivm/flash.c
index b5453df..140ba2d 100644
--- a/board/ivm/flash.c
+++ b/board/ivm/flash.c
@@ -87,7 +87,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/kup4k/flash.c b/board/kup4k/flash.c
index 3837457..7297c15 100644
--- a/board/kup4k/flash.c
+++ b/board/kup4k/flash.c
@@ -74,7 +74,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/lantec/flash.c b/board/lantec/flash.c
index df58510..0faa82c 100644
--- a/board/lantec/flash.c
+++ b/board/lantec/flash.c
@@ -134,7 +134,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -166,7 +166,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/lart/flash.c b/board/lart/flash.c
index 7b19524..89ab62c 100644
--- a/board/lart/flash.c
+++ b/board/lart/flash.c
@@ -105,7 +105,7 @@
      */
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/lubbock/flash.c b/board/lubbock/flash.c
index dcf829b..9e07b11 100644
--- a/board/lubbock/flash.c
+++ b/board/lubbock/flash.c
@@ -86,7 +86,7 @@
 	 */
 	flash_protect ( FLAG_PROTECT_SET,
 			CFG_FLASH_BASE,
-			CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+			CFG_FLASH_BASE + monitor_flash_len - 1,
 			&flash_info[0] );
 
 	flash_protect ( FLAG_PROTECT_SET,
diff --git a/board/lwmon/flash.c b/board/lwmon/flash.c
index 3d2a00f..127738a 100644
--- a/board/lwmon/flash.c
+++ b/board/lwmon/flash.c
@@ -123,7 +123,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -156,7 +156,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/mbx8xx/flash.c b/board/mbx8xx/flash.c
index e1aa47b..a491f7b 100644
--- a/board/mbx8xx/flash.c
+++ b/board/mbx8xx/flash.c
@@ -79,7 +79,7 @@
     /* monitor protection ON by default */
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/mpc8260ads/flash.c b/board/mpc8260ads/flash.c
index ec6a3b3..d61bfc6 100644
--- a/board/mpc8260ads/flash.c
+++ b/board/mpc8260ads/flash.c
@@ -100,7 +100,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/mpc8266ads/flash.c b/board/mpc8266ads/flash.c
index b876d1c..9512c72 100644
--- a/board/mpc8266ads/flash.c
+++ b/board/mpc8266ads/flash.c
@@ -101,7 +101,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c
index 483d0ff..563039b 100644
--- a/board/mpl/common/flash.c
+++ b/board/mpl/common/flash.c
@@ -102,7 +102,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
 	flash_protect(FLAG_PROTECT_SET,
 			CFG_MONITOR_BASE,
-			CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			CFG_MONITOR_BASE+monitor_flash_len-1,
 			&flash_info[0]);
 #endif
 	size_b1 = 0 ;
diff --git a/board/mpl/vcma9/flash.c b/board/mpl/vcma9/flash.c
index c2075da..b442c9d 100644
--- a/board/mpl/vcma9/flash.c
+++ b/board/mpl/vcma9/flash.c
@@ -113,7 +113,7 @@
 
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/musenki/flash.c b/board/musenki/flash.c
index a0a038f..1e8bfff 100644
--- a/board/musenki/flash.c
+++ b/board/musenki/flash.c
@@ -146,11 +146,11 @@
 	flash_info[0].size = size_b0;
 
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
-	DEBUGF("protect monitor %x @ %x\n", CFG_MONITOR_BASE, CFG_MONITOR_LEN);
+	DEBUGF("protect monitor %x @ %x\n", CFG_MONITOR_BASE, monitor_flash_len);
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -171,7 +171,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/mvs1/flash.c b/board/mvs1/flash.c
index 75d9048..0845943 100644
--- a/board/mvs1/flash.c
+++ b/board/mvs1/flash.c
@@ -115,7 +115,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_FLASH_BASE,
-		      CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+		      CFG_FLASH_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 
 	if (size_b1) {
@@ -136,7 +136,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_FLASH_BASE,
-			      CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+			      CFG_FLASH_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 	} else {
 		memctl->memc_br1 = 0;		/* invalidate bank */
diff --git a/board/netvia/flash.c b/board/netvia/flash.c
index 4204c34..669031f 100644
--- a/board/netvia/flash.c
+++ b/board/netvia/flash.c
@@ -66,7 +66,7 @@
 	flash_get_offsets(CFG_FLASH_BASE, &flash_info[0]);
 
 	/* monitor protection ON by default */
-	flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE, CFG_FLASH_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]);
+	flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE, CFG_FLASH_BASE + monitor_flash_len - 1, &flash_info[0]);
 
 	flash_info[0].size = size;
 
diff --git a/board/nx823/flash.c b/board/nx823/flash.c
index 616a13f..05ec687 100644
--- a/board/nx823/flash.c
+++ b/board/nx823/flash.c
@@ -93,7 +93,7 @@
 	/* monitor protection ON by default */
 	(void)flash_protect(FLAG_PROTECT_SET,
 			    CFG_FLASH_BASE,
-			    CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+			    CFG_FLASH_BASE+monitor_flash_len-1,
 			    &flash_info[0]);
 
 	flash_info[0].size = size_b0;
diff --git a/board/oxc/flash.c b/board/oxc/flash.c
index 4f0220e..795b7cc 100644
--- a/board/oxc/flash.c
+++ b/board/oxc/flash.c
@@ -69,7 +69,7 @@
     /* monitor protection ON by default */
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/pcippc2/flash.c b/board/pcippc2/flash.c
index 20f4d03..6e9e339 100644
--- a/board/pcippc2/flash.c
+++ b/board/pcippc2/flash.c
@@ -70,7 +70,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+			      CFG_MONITOR_BASE + monitor_flash_len - 1,
 			      &flash_info[0]);
 #endif
 
diff --git a/board/pm826/flash.c b/board/pm826/flash.c
index 4d5147b..770a46d 100644
--- a/board/pm826/flash.c
+++ b/board/pm826/flash.c
@@ -133,7 +133,7 @@
 # if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_MONITOR_BASE,
-		       CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]
+		       CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]
 	);
 # endif
 #endif	/* CONFIG_BOOT_ROM */
diff --git a/board/ppmc8260/strataflash.c b/board/ppmc8260/strataflash.c
index bb21848..6d5a853 100644
--- a/board/ppmc8260/strataflash.c
+++ b/board/ppmc8260/strataflash.c
@@ -201,7 +201,7 @@
 
 	/* Monitor protection ON by default */
 #if (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
-	for(i=0; flash_info[0].start[i] < CFG_MONITOR_BASE+CFG_MONITOR_LEN-1; i++)
+	for(i=0; flash_info[0].start[i] < CFG_MONITOR_BASE+monitor_flash_len-1; i++)
 		(void)flash_real_protect(&flash_info[0], i, 1);
 #endif
 
diff --git a/board/purple/flash.c b/board/purple/flash.c
index 56d3acd..34f1b91 100644
--- a/board/purple/flash.c
+++ b/board/purple/flash.c
@@ -233,7 +233,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      flash_get_info(CFG_MONITOR_BASE));
 #endif
 
diff --git a/board/purple/purple.c b/board/purple/purple.c
index dfd014b..b1eb78f 100644
--- a/board/purple/purple.c
+++ b/board/purple/purple.c
@@ -232,6 +232,7 @@
 */
 void copy_code (ulong dest_addr)
 {
+	extern long uboot_end_data;
 	unsigned long start;
 	unsigned long end;
 
@@ -243,7 +244,7 @@
 	 */
 	copyLongs((ulong *)CFG_MONITOR_BASE,
 		  (ulong *)dest_addr,
-		  (CFG_MONITOR_LEN + 3) / 4);
+		  ((ulong)&uboot_end_data - CFG_MONITOR_BASE + 3) / 4);
 
 
 	/* flush caches
diff --git a/board/r360mpi/flash.c b/board/r360mpi/flash.c
index fef483c..9b42960 100644
--- a/board/r360mpi/flash.c
+++ b/board/r360mpi/flash.c
@@ -107,7 +107,7 @@
 	/* monitor protection ON by default */
 	(void) flash_protect (FLAG_PROTECT_SET,
 				CFG_FLASH_BASE,
-				CFG_FLASH_BASE + CFG_MONITOR_LEN - 1,
+				CFG_FLASH_BASE + monitor_flash_len - 1,
 				&flash_info[0]);
 #endif
 
diff --git a/board/rpxsuper/flash.c b/board/rpxsuper/flash.c
index 0c298ba..73281bd 100644
--- a/board/rpxsuper/flash.c
+++ b/board/rpxsuper/flash.c
@@ -67,7 +67,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/rsdproto/flash.c b/board/rsdproto/flash.c
index 654012f..d90e7db 100644
--- a/board/rsdproto/flash.c
+++ b/board/rsdproto/flash.c
@@ -123,11 +123,11 @@
 #if CFG_MONITOR_BASE >= PHYS_FLASH
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[1]);
 #endif
 
diff --git a/board/sacsng/flash.c b/board/sacsng/flash.c
index 4fd04df..52e01de 100644
--- a/board/sacsng/flash.c
+++ b/board/sacsng/flash.c
@@ -69,7 +69,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -86,7 +86,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/sandpoint/flash.c b/board/sandpoint/flash.c
index 572199d..4b6f2d0 100644
--- a/board/sandpoint/flash.c
+++ b/board/sandpoint/flash.c
@@ -228,7 +228,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
     flash_protect(FLAG_PROTECT_SET,
 		CFG_MONITOR_BASE,
-		CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+		CFG_MONITOR_BASE + monitor_flash_len - 1,
 		&flash_info[0]);
 #endif
 
diff --git a/board/sbc8260/flash.c b/board/sbc8260/flash.c
index ab2bf35..9a8b952 100644
--- a/board/sbc8260/flash.c
+++ b/board/sbc8260/flash.c
@@ -63,7 +63,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_MONITOR_BASE,
-		  CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		  CFG_MONITOR_BASE+monitor_flash_len-1,
 		  &flash_info[0]);
 #endif
 
diff --git a/board/shannon/flash.c b/board/shannon/flash.c
index 8e0f752..c340fea 100644
--- a/board/shannon/flash.c
+++ b/board/shannon/flash.c
@@ -124,7 +124,7 @@
 #else
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/siemens/CCM/flash.c b/board/siemens/CCM/flash.c
index e56114f..9c32785 100644
--- a/board/siemens/CCM/flash.c
+++ b/board/siemens/CCM/flash.c
@@ -87,7 +87,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -106,7 +106,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 	} else {
diff --git a/board/siemens/SCM/flash.c b/board/siemens/SCM/flash.c
index dd7a4cc..056fe81 100644
--- a/board/siemens/SCM/flash.c
+++ b/board/siemens/SCM/flash.c
@@ -204,7 +204,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_MONITOR_BASE,
-		       CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]);
+		       CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]);
 #endif
 
 #if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR)
diff --git a/board/siemens/pcu_e/flash.c b/board/siemens/pcu_e/flash.c
index b8c0df7..05c364b 100644
--- a/board/siemens/pcu_e/flash.c
+++ b/board/siemens/pcu_e/flash.c
@@ -148,7 +148,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      PCU_MONITOR_BASE,
-		      PCU_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      PCU_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 
 #ifdef	CFG_ENV_IS_IN_FLASH
diff --git a/board/sixnet/flash.c b/board/sixnet/flash.c
index c201875..3bf2ff8 100644
--- a/board/sixnet/flash.c
+++ b/board/sixnet/flash.c
@@ -100,7 +100,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/smdk2400/flash.c b/board/smdk2400/flash.c
index 6882b88..eb9eaa0 100644
--- a/board/smdk2400/flash.c
+++ b/board/smdk2400/flash.c
@@ -93,7 +93,7 @@
 	 */
 	flash_protect ( FLAG_PROTECT_SET,
 			CFG_FLASH_BASE,
-			CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+			CFG_FLASH_BASE + monitor_flash_len - 1,
 			&flash_info[0]);
 
 	flash_protect ( FLAG_PROTECT_SET,
diff --git a/board/smdk2410/flash.c b/board/smdk2410/flash.c
index c2ec235..5d04ed4 100644
--- a/board/smdk2410/flash.c
+++ b/board/smdk2410/flash.c
@@ -113,7 +113,7 @@
 
     flash_protect(FLAG_PROTECT_SET,
 		  CFG_FLASH_BASE,
-		  CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+		  CFG_FLASH_BASE + monitor_flash_len - 1,
 		  &flash_info[0]);
 
     flash_protect(FLAG_PROTECT_SET,
diff --git a/board/svm_sc8xx/flash.c b/board/svm_sc8xx/flash.c
index 8c0e229..b50f77b 100644
--- a/board/svm_sc8xx/flash.c
+++ b/board/svm_sc8xx/flash.c
@@ -149,7 +149,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -176,7 +176,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/tqm8260/flash.c b/board/tqm8260/flash.c
index dd7a4cc..056fe81 100644
--- a/board/tqm8260/flash.c
+++ b/board/tqm8260/flash.c
@@ -204,7 +204,7 @@
 #if CFG_MONITOR_BASE >= CFG_FLASH0_BASE
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_MONITOR_BASE,
-		       CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]);
+		       CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]);
 #endif
 
 #if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR)
diff --git a/board/tqm8xx/flash.c b/board/tqm8xx/flash.c
index 2f74ccc..6b4ea7d 100644
--- a/board/tqm8xx/flash.c
+++ b/board/tqm8xx/flash.c
@@ -88,7 +88,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -113,7 +113,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 #endif
 
diff --git a/board/trab/flash.c b/board/trab/flash.c
index 1550e17..a2a21c6 100644
--- a/board/trab/flash.c
+++ b/board/trab/flash.c
@@ -99,7 +99,7 @@
 	 */
 	flash_protect ( FLAG_PROTECT_SET,
 			CFG_FLASH_BASE,
-			CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+			CFG_FLASH_BASE + monitor_flash_len - 1,
 			&flash_info[0]);
 
 	flash_protect ( FLAG_PROTECT_SET,
diff --git a/board/utx8245/flash.c b/board/utx8245/flash.c
index 947fbc3..73bb04d 100644
--- a/board/utx8245/flash.c
+++ b/board/utx8245/flash.c
@@ -145,7 +145,7 @@
      */
 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
      flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE,
-              CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0]);
+              CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]);
 #endif
 
 #if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR)
diff --git a/board/v37/flash.c b/board/v37/flash.c
index cb0e676..b42f335 100644
--- a/board/v37/flash.c
+++ b/board/v37/flash.c
@@ -79,7 +79,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
diff --git a/board/w7o/flash.c b/board/w7o/flash.c
index 0048476..5651e1c 100644
--- a/board/w7o/flash.c
+++ b/board/w7o/flash.c
@@ -83,7 +83,7 @@
 
     /* Monitor protection ON by default */
     (void)flash_protect(FLAG_PROTECT_SET,
-                        base_b0 + size_b0 - CFG_MONITOR_LEN,
+                        base_b0 + size_b0 - monitor_flash_len,
                         base_b0 + size_b0 - 1,
                         &flash_info[0]);
 
diff --git a/board/walnut405/flash.c b/board/walnut405/flash.c
index 81f950b..c9c7cbf 100644
--- a/board/walnut405/flash.c
+++ b/board/walnut405/flash.c
@@ -92,7 +92,7 @@
 	    /* Monitor protection ON by default */
 	    (void)flash_protect(FLAG_PROTECT_SET,
 				FLASH_BASE0_PRELIM,
-				FLASH_BASE0_PRELIM+CFG_MONITOR_LEN-1,
+				FLASH_BASE0_PRELIM+monitor_flash_len-1,
 				&flash_info[0]);
 	    size_b1 = 0 ;
 	    flash_info[0].size = size_b0;
@@ -133,7 +133,7 @@
 
 	    /* monitor protection ON by default */
 	    (void)flash_protect(FLAG_PROTECT_SET,
-				base_b0+size_b0-CFG_MONITOR_LEN,
+				base_b0+size_b0-monitor_flash_len,
 				base_b0+size_b0-1,
 				&flash_info[0]);
 
@@ -145,12 +145,12 @@
 
 	      /* monitor protection ON by default */
 	      (void)flash_protect(FLAG_PROTECT_SET,
-				  base_b1+size_b1-CFG_MONITOR_LEN,
+				  base_b1+size_b1-monitor_flash_len,
 				  base_b1+size_b1-1,
 				  &flash_info[1]);
 	      /* monitor protection OFF by default (one is enough) */
 	      (void)flash_protect(FLAG_PROTECT_CLEAR,
-				  base_b0+size_b0-CFG_MONITOR_LEN,
+				  base_b0+size_b0-monitor_flash_len,
 				  base_b0+size_b0-1,
 				  &flash_info[0]);
 	    } else {
diff --git a/board/wepep250/flash.c b/board/wepep250/flash.c
index 319dddc..5c9d346 100644
--- a/board/wepep250/flash.c
+++ b/board/wepep250/flash.c
@@ -135,7 +135,7 @@
 
 	flash_protect (FLAG_PROTECT_SET,
 				   CFG_FLASH_BASE,
-				   CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
+				   CFG_FLASH_BASE + monitor_flash_len - 1,
 				   &flash_info[0]);
 
 	flash_protect (FLAG_PROTECT_SET,
diff --git a/board/westel/amx860/flash.c b/board/westel/amx860/flash.c
index 28238c1..12a1335 100644
--- a/board/westel/amx860/flash.c
+++ b/board/westel/amx860/flash.c
@@ -130,7 +130,7 @@
 	/* monitor protection ON by default */
 	flash_protect(FLAG_PROTECT_SET,
 		      CFG_MONITOR_BASE,
-		      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+		      CFG_MONITOR_BASE+monitor_flash_len-1,
 		      &flash_info[0]);
 #endif
 
@@ -162,7 +162,7 @@
 		/* monitor protection ON by default */
 		flash_protect(FLAG_PROTECT_SET,
 			      CFG_MONITOR_BASE,
-			      CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+			      CFG_MONITOR_BASE+monitor_flash_len-1,
 			      &flash_info[1]);
 # endif