1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-05-28 05:10:40 -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()
{
GPS::instance().disable();
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
HAL_Delay(1000);
bsp_reboot();
bsp_enter_dfu();
}

View File

@ -545,20 +545,14 @@ bool bsp_is_tx_disabled()
void bsp_enter_dfu()
{
/**
* The RC delay circuit feeding BOOT0 from this GPIO will latch the voltage high
* 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.
*/
// Turn off the GNSS immediately to prevent its UART from transmitting and hijacking the bootloader upon reset
bsp_gnss_off();
/**
* BUG: This can never work with this board, because the GNSS UART is constantly sending data, so the bootloader
* will enable DFU protocol on that USART instead of the main one :(
*/
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
HAL_GPIO_WritePin(DFU_EN_PORT, DFU_EN_PIN, GPIO_PIN_SET);
HAL_Delay(250);
// Give the GNSS enough time to hibernate, then reset
HAL_Delay(1000);
bsp_reboot();
}

View File

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