H7 turn off USB before reset (#2999)

* turn off USB before reset

* comment

* add link
This commit is contained in:
Matthew Kennedy 2021-07-20 16:39:26 -07:00 committed by GitHub
parent 9ebaa0f926
commit c3699f8353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -313,6 +313,13 @@ stm32_hardware_pwm* getNextPwmDevice() {
#endif
void jump_to_bootloader() {
#ifdef STM32H7XX
// H7 needs a forcible reset of the USB peripheral(s) in order for the bootloader to work properly.
// If you don't do this, the bootloader will execute, but USB doesn't work (nobody knows why)
// See https://community.st.com/s/question/0D53W00000vQEWsSAO/stm32h743-dfu-entry-doesnt-work-unless-boot0-held-high-at-poweron
RCC->AHB1ENR &= ~(RCC_AHB1ENR_USB1OTGHSEN | RCC_AHB1ENR_USB2OTGFSEN);
#endif
// leave DFU breadcrumb which assembly startup code would check, see [rusefi][DFU] section in assembly code
*((unsigned long *)0x2001FFF0) = 0xDEADBEEF; // End of RAM
// and now reboot