Jumping to bootloader while keeping USB connected

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
LHelge
Posts: 15
Joined: Sun Sep 21, 2014 10:58 pm
Been thanked: 1 time

Jumping to bootloader while keeping USB connected

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Jumping to bootloader while keeping USB connected

Post 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
LHelge
Posts: 15
Joined: Sun Sep 21, 2014 10:58 pm
Been thanked: 1 time

Re: Jumping to bootloader while keeping USB connected

Post by LHelge »

Just as I expected, I'll have to make the reconnection robust on the PC-side instead.
Post Reply