cancel
Showing results for 
Search instead for 
Did you mean: 

USB Connection going from application to bootloader (and vice versa)

DiBosco
Senior
Posted on November 28, 2016 at 00:47

I have managed to get a VCP/CDC bootloader going and the ability to use USB to tell the unit to go into bootloader mode from the main application. I do this via a Qt program running on Linux (as well as Windows and OS X) that sends an encrypted new image over USB or sends simple, unencrypted, requests such as get version number, change to bootloader etc.

When I have switched from either of these two modes, the USB doesn't work any more unless I power down the unit and power it back up. I can then, after rebooting the Qt application on Linux, access the unit over USB again.

So, for example, I'm in main application, connect the USB, boot the Qt app on Linux, tell the unit to go into bootloader mode and sure enough it does go into bootloader mode. I can quite clearly see the heartbeat LED pattern change to the bootloader pattern. The USB just will not load the new program unless I power cycle the unit and reboot the Qt program. Once I do that, I can install the new version of the software via the bootloader just fine.

Does anyone know whether there is a way round this please?

In case it's useful I'm using an F107 in device mode.

Many thanks!

2 REPLIES 2
DiBosco
Senior
Posted on November 28, 2016 at 13:47

Calling this:

/*******************************************************************************

* Function Name  : PCD_DevDisconnect

* Description    : Disconnect device

* Input         : None

* Output         : None

* Return         : status

*******************************************************************************/

void  PCD_DevDisconnect (void)

{

  USB_OTG_DCTL_TypeDef dctl;

  dctl.d32 = 0;

 

  dctl.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.DEV->DCTL);

  /* Disconnect device for 20ms */

  dctl.b.sftdiscon  = 1;

  USB_OTG_WRITE_REG32(&USB_OTG_FS_regs.DEV->DCTL, dctl.d32);

  mDELAY(25);

}

Before rebooting seems to help going from main app to bootloader. I can now seamlessly go from one to the other with the Qt auto scanning and auto reconnecting, then the bootloader loading the new app. I have to reboot the Qt app to work again with the main app, but that might be an issue with the Qt app. More if I fix it.

Ivan Zilic
Associate
Posted on December 08, 2016 at 11:28

Hi,

Additionally, you could also use different USB PIDs in main application and bootloader.

Best wishes,  Ivan.