@westfw
umm.
Its a bit complicated - Sorry this is probably going to be a rather verbose response.
We can burn the bootloader using 2 or 3 different "programmers"
i.e The bootloader can be burnt using USB to Serial, using the stm32flash utility, or using the STLink programmer - or using the Black Magic Probe (But STLink and BMP are basically the same sort of thing as they are SWD programmers)
Users have the option to upload using any of the above for normal sketch uploads, if they won't want to have a bootloader on the board.
Actually until recently we didn't have a version of the bootloader that would work with "Generic" STM32F103 boards (i.e basically most boards you can find on AliExpress or TauBao etc) - we only had a bootloader for Maple mini (and clones of that board)
Anyway.
The bootloader functionality would need to do a few things.
-
For "Generic" STM32F103 boards, it would need to allow the user to select their board variant - in practice they just need to select the bootloader that flashes the LED on the board, but there is no standard for which pin the LED is attached to - hence we have a lot of different bootloaders which are 99% identical.
-
The user would also need to be given the option of which programmer to use, i.e USB to Serial or STLink or Black Magic Probe
I suspect adding additional programmers to the list is the simpler of the challenges, as there is a file called Programmers.txt which appears to list the programmers.
For bootloader selection, we can't use the Board menu, because in the IDE we don't select board based on where the LED is attached, we select the board based on the device density / hardware facilities
e.g.
We have the following in the boards menu
"Generic STM32F103C Series"
"Generic STM32F103R Series"
"Generic STM32F103V Series"
"Generic STM32F103Z Series"
Then within these boards there is a sub menu for flash / ram size
(well this is a slight simplification, but its basically the system)
Anyway.
The burn bootloader would need to run a script / bat file, which would prompt the user to select the bootloader variant from a list (probably a list of numbers to choose from with the details e.g. LED pin next to each number"
But I'm not sure if interactivity is allowed by the IDE in the scripts it calls, or whether possibly we'd need to run a small java program to handle the bootloader bin selection
Anyway.
At the moment, I just get null pointer exceptions when I try to add new programmers and even when I try to add the xxx.bootloader.tool stuff into boards.txt
e.g.
genericSTM32F103Z.bootloader.tool=bootloader_upload
even if I select an existing programmer
So I presume I'm missing something in platform.txt
I suspect I need to add some recipies to platform.txt e.g.
tools.MYTOOL.erase.params.verbose=-v
tools.MYTOOL.erase.params.quiet=-q -q
tools.MYTOOL.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
tools.MYTOOL.bootloader.params.verbose=-v
tools.MYTOOL.bootloader.params.quiet=-q -q
tools.MYTOOL.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
But I was hoping that there was some docs for this somewhere, or perhaps some other third party hardware setup for bootloaders e.g. ESP8266 that I could look at
But I"ve not found any.
So it looks like its just a case of trying things and seeing what works (which is not a particularly efficient use of time)