USB disconnect on STM32F4 breaks backup SRAM.
I'm working on firmware for a flight controller with the STM32F405. The board communicates with a computer using VCP over USB. I'm debugging a driver for the backup SRAM, to recover in case of a firmware crash. The crash handler is programmed to save a little bit of information to backup SRAM, and then to reboot. On reboot it checks for backup information, and adjusts accordingly. It works well, unless the USB is disconnected between power on and the crash, in which case it fails to write to backup SRAM.
I wouldn't think that the backup SRAM and the USB drivers should be sharing any resources. I also don't understand the USB driver well enough to know what part of the driver is called when the USB disconnects. In my searching it seems that it is somewhat tricky to detect when USB is disconnected.
Any suggestions on how to fix this or where to look are appreciated.
