Program stats from VSCODE: (using Arduino libs)
RAM: [=== ] 32.9% (used 6740 bytes from 20480 bytes)
Flash: [========= ] 86.9% (used 56936 bytes from 65536 bytes)
1 I upload my program using SWD interface from VSCode - it works and the STM32F103C8 enumerates on USB)
2 with BOOT pins low, I flash bootloder STM32_HID_Bootloader$ STM32_Programmer_CLI -c port=SWD mode=UR -w stm32_binaries/F103/low_and_medium_density/hid_generic_pc13.bin 0x08000000
3 I switch BOOT1 to high, reset - bootloader is active and LED flashing fast
4 I flash same firmware as in step# 1 : hid-flash .pio/build/genericSTM32F103C8/firmware.bin /dev/ttyUSB
Flashing ends with a with > Done! The last count I see is: . 57344 Bytes seems good.
I move the BOOT1 jumper to low. reboot
The device is NOT running normally, does not enumerate on USB (which it did before)
I move the BOOT1 jumper to HIGH, reboot - and the bootloader is alive and ready for next attempt.
What firmware are you uploading exactly? If you don’t configure the uploaded firmware to also start a e.g. USB CDC, it won’t be enumerated on the USB.
It’s a program that uses Arduino framework, built by PlatformIO, the binary file works fine if uploaded by SWD, but does not run if uploaded by the STM HID Bootloader. Unlike a .hex file, I can’t see which address the .bin file is starting at.
here. Then, PlatformIO will also be able to flash it with the regular upload button.
There is special logic to support the uploader as well as reconfiguration of some vector table offsets going on so that booting and interrupts work. It will surely crash very quickly if that is not configured correctly.
In fact, you should also throw -D PIO_FRAMEWORK_ARDUINO_ENABLE_HID into the build_flags
You miss in point 4. FW from point 1 cant be used here. Normal fw place and start is upquote, but for custom bootloader this adress is used with bootloader …
@maxgerhardt It sounds like you are trying to help me make PIO upload using HID.
I actually prefer SWD during development, (and yes, doing so erases the bootloader) So I am good while programming, but I wish to have a way to send somebody a file that can be flashed using the HID method. (from terminal)
@marian.mlcoch The bootloader is at addess 0x0800000 - and id-flash tool does not even have an option to start at some specific address.
Thank you - I will try that. - I assume that requires two different platforio.ini files for that build ?
And while I have attention from you, as a skilled programmer, could you please point me to some example on how to (if a button is pressed on startup) - jump to the bootloader from my program?
Calling the CMSIS function NVIC_SystemReset(); should be the same as pressing the reset button just using a software flag. It should start execution at the start of flash again (0x8000000), if the BOOT pins are set for it; The HID bootloader should live there.
I’m not sure how exactly the HID bootloader works or for how long it stays open. After all, it will want to boot an existing application pretty quickly.
Wow, you are good! I did not try to read the bootloader source and failed to “discover” that it was trigged by DTR (and could be flashed without the use of a jumper - or otherwise running the bootloader.)