Custom bootloader and application sharing USB CDC device?
I'm building an appliance that has both a custom bootloader for serial-based firmware update as well as an application that interfaces to a PC using serial.
The processor is STM32L432KBU6 (128K flash). I don't think the budget permits the cost of the KCU6 (256K flash).
Originally, I designed it using a CP2104 USB to UART bridge with the ST part operating a UART only. As an experiment in BOM reduction, I tried using the STM32 USB CDC device, and I got it to work. There is a caveat, however:
Every time the system resets, the USB device resets as well and has to go through re-initialization (which means re-enumeration), thus breaking the connection with the PC app.
Rather than resetting the processor to pass control to a bootloader for firmware download, I considered using a flasher app that runs from some alternate address (Flash or SDRAM), so that control can be passed to it via the usual jump mechanism. But how would this process "take over" the CDC device without a hiccup?
I need to clarify here that the firmware image is going to be so large that I can't fit 2 of them side by side on Flash, so the bootloader/flasher will have to do a live download / erase / write.
Thanks in advance,
Peter
