Page 1 of 1

Jumping to bootloader while keeping USB connected

Posted: Thu Mar 05, 2015 2:06 pm
by LHelge
Hello,

I'm building an application for a STM32F405 where I have my flash divided into 3 sections. Main part (sector 0-9) is the main application, sector 10 contains the bootloader and sector 11 non volatile parameters.

The bootloader is also ChibiOS based and support firmware transfer using both Serial USB and CAN. The jump to the bootloader is initialized by sending a command either over CAN or USB and works like a charm, the firmware flashing as well. The problem I have is that the USB serial port is lost and reconnected during the jump from main application to bootloader. This can be handled in the PC-application, but it would be very nice if I could manage to keep the connection between the two Chibios applications.

Could this be, safely, achieved by for example, skipping the shutdown procedure for the USB module before jumping to the bootloader? Then skipping the initialization of the USB in the bootloader, just setting up a few threads for communicating through the SDU1 device

Re: Jumping to bootloader while keeping USB connected

Posted: Thu Mar 05, 2015 2:26 pm
by Giovanni
Hi,

There are a lot of issues with this idea, I can think of:
- You have to skip usbStart().
- Change the state of the driver manually (doing what usbStart() does).
- Change the state of the EP0 state machine manually and hack all the values in the driver structure and endpoint structures.
- Start the USB driver internal thread manually.

It is something I would not do, it would be a hack and could fail in a lot of ways because during the transition the driver stops responding to the OTG hardware (which is bad tempered).

Giovanni

Re: Jumping to bootloader while keeping USB connected

Posted: Thu Mar 05, 2015 3:16 pm
by LHelge
Just as I expected, I'll have to make the reconnection robust on the PC-side instead.