texane/stlink — Issue #33: Odd sequence required when using the flash tool
Author: peabody124
Created: 2011-11-25 21:42:28+00:00
State: open

So in case it's relevant my .bin I'm uploading includes both a bootloader and the application code. However uploading separately caused about the same issues.

I have to repeat this sequence to flash code into an F1 chip
1) execute flash tool. It appears to execute correctly. Chip boots up although some of the timings are off. However rebooting chip doesn't work.
2) power cycle chip and programmer then rerun flash tool. It erases memory but then hangs with this:

2011-11-25T15:38:45 INFO src/stlink-common.c: Successfully unlocked flash
2011-11-25T15:38:45 INFO src/stlink-common.c: Finished erasing 36 pages of 1024 (0x400) bytes
2011-11-25T15:38:45 INFO src/stlink-common.c: Starting Flash write for VL core id
2011-11-25T15:38:45 INFO src/stlink-common.c: Successfully loaded flash loader in sram
2011-11-25T15:38:45 INFO src/stlink-common.c: Writing flash block 0 of size 64 (0x40)
2011-11-25T15:38:45 INFO src/stlink-common.c: Successfully unlocked flash

while consuming lots of cpu. Ctrl-C gives this

2011-11-25T15:38:45 INFO src/stlink-common.c: Successfully unlocked flash
^C^Cflash(53839,0x10e2cc000) malloc: *** error for object 0x7fc4995025c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

3) power cycle chip and programmer then rerun flash tool. succcess

I don't understand why #1 appears to work - my best guess is somehow the boot sector fails to write. #2 my guess is that as a result of #1 it's locked into some loop that prevents jumping to ram. #3 seems to work because a full erase and reset occurred first.

Any suggestions of where I can patch the flash tool to make sure it first erases then really resets the chip before writing?