stlink: STM32F103R8: Problems flashing device - unknown core / chip id! 0
- Programmer/board type: Stlink/v2-onboard (STMF4DISCOVERY board)
- Programmer firmware version: e.g STSW-LINK007 2.27.15
- Operating system: Linux Ubuntu 16.04
- Stlink tools version and/or git commit hash: 7023a9ab62b77102f5d48a34bfb8ad173de22346 and also earlier versions
- Stlink commandline tool name: st-info / st-flash
- Target chip (and optional board): STM32F103R8 (“Blue Pill” board)
I am using stm32f103r8 device (64k flash, 20k RAM) with a ST-LINK/V2 programmer (Discovery board with F407VG). I have multiple boards like these (http://wiki.stm32duino.com/index.php?title=Blue_Pill) and none of them seems to work with stlink. I have connected the GND/SWDIO/SWCLK and RESET pins to the SWD connector. Using this setup has worked for other chips. Problems include:
- not being able to read the flash correctly
- not being able to write the flash at all
- reporting wrong Flash size
Outputs from st-info and st-flash:
$ st-info --probe
Found 1 stlink programmers
serial: 533f6d06493f55573224113f
openocd: "\x53\x3f\x6d\x06\x49\x3f\x55\x57\x32\x24\x11\x3f"
flash: 26230784 (pagesize: 1024)
sram: 20480
chipid: 0x0410
descr: F1 Medium-density device
Stlink recognizes the chip, though somewhat incorrectly, reporting 26230784 bytes of flash. I am not sure about the chipid, as I don’t know the correct value.
$ st-flash read orig.bin 0x8000000 0x10000
2016-09-16T11:14:25 INFO /home/karlis/build/stlink/src/common.c: Loading device parameters....
2016-09-16T11:14:25 INFO /home/karlis/build/stlink/src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2016-09-16T11:14:25 INFO /home/karlis/build/stlink/src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x1904000 bytes (25616 KiB) in pages of 1024 bytes
Returns almost immediately. The file is the correct size but does not seem to contain valid readout.
$ st-flash write orig.bin 0x8000000
2016-09-16T11:17:24 INFO /home/karlis/build/stlink/src/common.c: Loading device parameters....
2016-09-16T11:17:24 INFO /home/karlis/build/stlink/src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2016-09-16T11:17:24 INFO /home/karlis/build/stlink/src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x1904000 bytes (25616 KiB) in pages of 1024 bytes
2016-09-16T11:17:24 INFO /home/karlis/build/stlink/src/common.c: Attempting to write 65536 (0x10000) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x0800fc00 erased
2016-09-16T11:17:26 INFO /home/karlis/build/stlink/src/common.c: Finished erasing 64 pages of 1024 (0x400) bytes
2016-09-16T11:17:26 INFO /home/karlis/build/stlink/src/common.c: Starting Flash write for VL/F0/F3 core id
2016-09-16T11:17:26 INFO /home/karlis/build/stlink/src/flash_loader.c: Successfully loaded flash loader in sram
2016-09-16T11:17:46 ERROR /home/karlis/build/stlink/src/flash_loader.c: flash loader run error
2016-09-16T11:17:46 ERROR /home/karlis/build/stlink/src/common.c: stlink_flash_loader_run(0x8000000) failed! == -1
The tool hangs for about 20 seconds before reporting the flash loader run error.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (12 by maintainers)
@Nightwalker-87 I have a blue pill with such the STM32F103C8. Everything is displayed well:
In the meanwhile I hooked up the same setup to a Windows machine and used the original STM32 ST-Link utility. It complained immediately that the chip had a readout protection. Ok, that might explain some of the flash reading problems. Removed the protection, managed to do an erase, read and flashed another blinker code. The code runs fine.
Now the story gets a twist here. I connect it back to my linux machine, and st-info does not detect any chip any more.
Running with --debug: