1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-06-05 17:20:21 -07:00

DFU logic moved to BSP

This commit is contained in:
Peter Antypas 2020-10-13 15:59:43 -07:00
parent bcd603edfe
commit bc1793a861
3 changed files with 8 additions and 18 deletions

View File

@ -141,11 +141,7 @@ void CommandProcessor::processCommand(const char *buff)
void CommandProcessor::jumpToBootloader() void CommandProcessor::jumpToBootloader()
{ {
GPS::instance().disable(); bsp_enter_dfu();
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
HAL_Delay(1000);
bsp_reboot();
} }

View File

@ -545,20 +545,14 @@ bool bsp_is_tx_disabled()
void bsp_enter_dfu() void bsp_enter_dfu()
{ {
/** // Turn off the GNSS immediately to prevent its UART from transmitting and hijacking the bootloader upon reset
* The RC delay circuit feeding BOOT0 from this GPIO will latch the voltage high bsp_gnss_off();
* long enough for the next reset to invoke the ROM bootloader. This is the cleanest
* way to go about it. The alternative requires that we shut down all peripherals and
* disable every interrupt including Systick.
*/
/** // This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
* BUG: This can never work with this board, because the GNSS UART is constantly sending data, so the bootloader *(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
* will enable DFU protocol on that USART instead of the main one :(
*/
HAL_GPIO_WritePin(DFU_EN_PORT, DFU_EN_PIN, GPIO_PIN_SET); // Give the GNSS enough time to hibernate, then reset
HAL_Delay(250); HAL_Delay(1000);
bsp_reboot(); bsp_reboot();
} }

View File

@ -110,13 +110,13 @@ int main(void)
{ {
#if 1 #if 1
if ( *(uint32_t*)DFU_FLAG_ADDRESS == DFU_FLAG_MAGIC ) if ( *(uint32_t*)DFU_FLAG_ADDRESS == DFU_FLAG_MAGIC )
//if ( true )
{ {
*(uint32_t*)DFU_FLAG_ADDRESS = 0; *(uint32_t*)DFU_FLAG_ADDRESS = 0;
jump_to_bootloader(); jump_to_bootloader();
} }
#endif #endif
// This is for debugging imprecise bus faults
//*(uint8_t *)0xe000ed08 |= 2; //*(uint8_t *)0xe000ed08 |= 2;
bsp_hw_init(); bsp_hw_init();