bootloader seems to get overwritten

STM32duino bootloader aka Maple bootloader
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: bootloader seems to get overwritten

Post by BennehBoy »

tcurdt wrote: Wed Mar 01, 2023 12:50 am And when you write "and allows you to flash your program" , well, it allows that via USB.
This is NOT true. The bootloader GETS INVOKED by the sketch that you upload ONLY if you have enabled USB Serial CDC in the compile time options of the sketch that you upload...

How it works is that YOUR sketch listen on USB Serial (and it can only do this if you enabled it) for a magic sequence of characters (L E A F from memory), which then causes YOUR sketch to reset the device to run code from the init vector for the boot loader - ie it enters DFU mode and then accepts a new upload.

There's glue in the config files for the core that determines how this all gets handled, and that includes the correct upload addresses (linker config) for the new sketch. I've not tested this mechanism for quite some time because I switched mainly to F4 based devices shortly after helping fred get this stuff into the core, so it's not inconceivable that something broke.

You should not be using any command line upload utils, the idea for all this was to make uploads seemless from within the IDE. If you've used a dfu util to write to the device, then yes you've almost certainly overwritten the bootloader yourself by not using the intended upload methodology.

KEY POINT: check that you have USB CDC enabled in the compile time options when you first flash your device from Arduino IDE... You either have to reflash the original bootloader, or do the key holding above to be able to get a new sketch with CDC enabled uploaded.

From that point on, the upload scripts the core supplied for the IDE will work.

I hope that helps to clear up the mechanism.
Post Reply

Return to “USB bootloader”