STM32Duino core does not do well with Maple bootloader
Posted: Thu May 07, 2020 1:52 pm
I am porting several sketches from Roger's core to Arduino IDE + STM32Duino core.
I am using an Olimexino STM32 board, which includes a physical USB interface directly to the USB pins of the STM32F103RBT6, and the original Maple bootloader. I compile using the option "USB CDC generic serial".
This bootloader is the first to start when the chip is reset. If within a few seconds it did not receive a signal (produced by a button ad hoc), it jumps to the application.
On the other hand, when the IDE downloads a binary file to the Flash memory of the chip, it triggers a reset using the DTR signal on the COM port, that restarts the chip and puts the bootstrap loader in program mode.
As soon as the the programming is finished, the bootloader restarts the chip. Then, since no event takes place, after a few seconds, the bootloader jumps to the application (the sketch).
It is this last operation that fails too often. The chip restarts after flashing the memory, but the sketch code is not executed, and the virtual COM port does not initialize (it does not show in the device manager of Windows). This is also the case if I press the reset button of the board.
On the contrary, if I disconnect the USB cable which at the same time powers the board, and I reconnect it, the boot sequence is correct and the sketch starts excuting.
This problem is new. I have used Roger's core for years, and never had this problem.
I just have no idea of what goes wrong. What is the difference between pressing the reset button and disconnecting the USB cable, except that the power goes down and up? Are there floating variables or registers that have a wrong value after triggering a reset, and a good value after a power shortage?
I am using an Olimexino STM32 board, which includes a physical USB interface directly to the USB pins of the STM32F103RBT6, and the original Maple bootloader. I compile using the option "USB CDC generic serial".
This bootloader is the first to start when the chip is reset. If within a few seconds it did not receive a signal (produced by a button ad hoc), it jumps to the application.
On the other hand, when the IDE downloads a binary file to the Flash memory of the chip, it triggers a reset using the DTR signal on the COM port, that restarts the chip and puts the bootstrap loader in program mode.
As soon as the the programming is finished, the bootloader restarts the chip. Then, since no event takes place, after a few seconds, the bootloader jumps to the application (the sketch).
It is this last operation that fails too often. The chip restarts after flashing the memory, but the sketch code is not executed, and the virtual COM port does not initialize (it does not show in the device manager of Windows). This is also the case if I press the reset button of the board.
On the contrary, if I disconnect the USB cable which at the same time powers the board, and I reconnect it, the boot sequence is correct and the sketch starts excuting.
This problem is new. I have used Roger's core for years, and never had this problem.
I just have no idea of what goes wrong. What is the difference between pressing the reset button and disconnecting the USB cable, except that the power goes down and up? Are there floating variables or registers that have a wrong value after triggering a reset, and a good value after a power shortage?