tonarino / panel-firmware

Firmware for the volume control hardware, targeting an STM32F4 board
MIT License
74 stars 10 forks source link

Make the firmware remotely updatable #18

Closed bschwind closed 3 years ago

bschwind commented 3 years ago

@skywhale please review

Here's the basic summary of the changes:

The reason for this little dance instead of just jumping directly into the bootloader is that we would otherwise have to reset all device peripherals back to their default state, including USB devices, timers, etc.

It's much easier to simply reset and jump to the bootloader before we configure any hardware devices.

References:

Screen Shot 2021-05-21 at 3 11 46 PM Screen Shot 2021-05-17 at 3 07 15 PM
bschwind commented 3 years ago

@skywhale could I get one more look at this? I changed the USB code a bit to initialize the USB device right before the loop so it's less likely to miss any USB communication from the host, and I also added some code to reset the bus before starting up.

Occasionally after uploading firmware via DFU, the tonari serial device would not show up on the host. This forced reset condition seems to fix it. I have jumped to the bootloader, uploaded new firmware, and reset dozens of times without failure on my laptop. I'll test it on linux as well.