# http://olimex.com/dev/stm32-h103.html
#
+#Set flash size to 128k for STM32103RB device
+set WORKAREASIZE 0x20000
+
source [find target/stm32.cfg]
set _ENDIAN little
}
+#Checking if user had set the work-area-size for the chip
+#If not, the value will be set to 16k
+if { [info exists WORKAREASIZE] } {
+ set _WORKAREASIZE $WORKAREASIZE
+} else {
+ set _WORKAREASIZE 0x4000
+}
+
# jtag speed
jtag_khz 500
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
-$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 16384 -work-area-backup 0
+$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
flash bank stm32x 0 0 0 0 0