diff --git a/usb-loader/samba_applets/at91lib/boards/at91sam9g45-ek/board_memories.c b/usb-loader/samba_applets/at91lib/boards/at91sam9g45-ek/board_memories.c
index 1efc83ae1a6537bd800a58bb1ffd0cd3e23f444a..b775e54ee86eaea7619dd1cae0d2314af665b720 100644
--- a/usb-loader/samba_applets/at91lib/boards/at91sam9g45-ek/board_memories.c
+++ b/usb-loader/samba_applets/at91lib/boards/at91sam9g45-ek/board_memories.c
@@ -53,8 +53,8 @@
 //------------------------------------------------------------------------------
 //         External definitions
 //------------------------------------------------------------------------------
-#ifndef AT91C_DDRC2_NR_VAL
-	#define AT91C_DDRC2_NR_VAL 13 //This value should be 13 for WRS3-18
+#ifndef AT91C_DDRC2_NR_XX
+	#define AT91C_DDRC2_NR_XX AT91C_DDRC2_NR_13 /*This value should be 13 for WRS3-18*/
 #endif
 
 //------------------------------------------------------------------------------
@@ -142,7 +142,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
             // 4. Program the features of DDR2-SDRAM device into the Timing Register HDDRSDRC2_T2PR.            
 
             WRITE(pDdrc, HDDRSDRC2_CR, AT91C_DDRC2_NC_DDR10_SDR9  |     // 10 column bits (1K)
-                                       AT91C_DDRC2_NR_VAL          |     // 13 row bits    (8K) 
+                                       AT91C_DDRC2_NR_XX         |     // 13 row bits    (8K) 
                                        AT91C_DDRC2_CAS_3          |     // CAS Latency 3
                                        AT91C_DDRC2_DLL_RESET_DISABLED
                                        ); // DLL not reset
diff --git a/usb-loader/samba_applets/isp-project/build.sh b/usb-loader/samba_applets/isp-project/build.sh
index 1b917e814c14c8453f4b3faedbaf211c76ec6833..d84f61f8a7659ac56214cff267774f6d0fecddee 100755
--- a/usb-loader/samba_applets/isp-project/build.sh
+++ b/usb-loader/samba_applets/isp-project/build.sh
@@ -24,7 +24,7 @@ compile_module()
 		make $2
 	else
 		#Compile the module
-		make CROSS_COMPILE=${CROSS_COMPILE} CHIP=at91sam9g45 BOARD=at91sam9g45-ek MEMORIES=sram TRACE_LEVEL=5 DYN_TRACES=1 DEFINES="-D__GIT__=\\\"${GITR}${GITS}\\\"" INSTALLDIR=../../
+		make CROSS_COMPILE=${CROSS_COMPILE} CHIP=at91sam9g45 BOARD=at91sam9g45-ek MEMORIES=sram TRACE_LEVEL=5 DYN_TRACES=1 DEFINES="-D__GIT__=\\\"${GITR}${GITS}\\\" $DEFINES" INSTALLDIR=../../
 	fi
 }
 
@@ -36,6 +36,15 @@ root="$(dirname $(pwd)/$0)"
 compile_module dataflash $1
 
 #### Compilation of extern ram module
+DEFINES="-DAT91C_DDRC2_NR_XX=AT91C_DDRC2_NR_13"
+compile_module extram $1 
+cp ${root}/../isp-extram-at91sam9g45.bin ${root}/../isp-extram-at91sam9g45-NR13.bin
+
+DEFINES="-DAT91C_DDRC2_NR_XX=AT91C_DDRC2_NR_14"
 compile_module extram $1
+cp ${root}/../isp-extram-at91sam9g45.bin ${root}/../isp-extram-at91sam9g45-NR14.bin 
 
+DEFINES="-DAT91C_DDRC2_NR_XX=$1"
 
+#### Compilation of extern ram module
+compile_module extram
\ No newline at end of file