Hi, I have a bluepill with a F103C8 uC that has 128K of usable flash (64K Reported), the upload and verify works fine with the following platformio.ini:
I also tested it by printing through the serial monitor more than 64K of flash text.
My problem is when uploading in Debug Mode, I managed to make it compile to 128K with the following line: “board_upload.maximum_size = 131072”, but when uploading it autodetects the Flash size as 64K: “Info : flash size = 64kbytes”, to make it upload I had to modify the file “.platformio/packages/tool-openocd/scripts/target/stm32f1x.cfg” by changing the autodetect flash size to the value required:
else {
# autodetect size it was 0
set _FLASH_SIZE 0x20000
}
My question is, is there any way to set this _FLASH_SIZE to the desired value, similar to the command “upload_flags = -c set FLASH_SIZE 0x20000” but for the Debug upload_flags?
You should be able to create a (or locally modify the existing) board definition to inject -c "set FLASH_SIZE 0x20000" through the openocd_extra_args.
Per
you can see the board already has some stuff there for reset config. Does it work if you add to this array
"-c",
"set FLASH_SIZE 0x20000"
in your local <home path>/.platformio/platforms/ststm32/boards/bluepill_f103c8_128k.json file, then restart VSCode and retry debugging without any previous .cfg file modification?
This might a case of the ID code being that of a C8 but internally really having 128KB (C8 come from the same die as CB and are just less tested), and then OpenOCD rejecting the upload. But yes, OP can give that a try too.
and it is still autodetected as 64k and the upload fails.
just in case I also tried putting a random command and I get an invalid command error, so it is executing those commands from that file.
I noticed something, when the command above is present I get a random 0x20000 printed in the console:
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e (2021-03-15-16:43)
Licensed under GNU GPL v2
For bug reports, read http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
0x20000
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 1000 kHz
Info : STLINK V2J31S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.258614
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on pipe
Info : accepting ‘gdb’ connection from pipe
Info : device id = 0x20036410
Info : flash size = 64kbytes
Hi! Were you able to get around the issue?
I’m stuck with the same problem and discovered that openocd_extra_args gets appended at the end of openocd command, after it processes the target/stm32.cfg file, so openocd still does flash autodetect. Interestingly, upload_flags are prepended to openocd command, so it works when uploading.
Was able to fix this by creating a boards folder in my project, creating a new board json using the contents of bluepill_f103c8_128k.json and changing "openocd_target": "stm32f1x", to "openocd_target": "../board/stm32f103c8_blue_pill",. On platformio.ini change the board parameter to the name of the new json.