bl works 🎉

This commit is contained in:
Matthew Kennedy 2020-12-12 15:11:48 -08:00
parent 0b4521693b
commit b57a7ff4c0
1 changed files with 14 additions and 2 deletions

View File

@ -48,9 +48,10 @@ void EraseAppPages()
uintptr_t blSize = (uintptr_t)(appFlashAddr - 0x08000000); uintptr_t blSize = (uintptr_t)(appFlashAddr - 0x08000000);
size_t pageIdx = blSize / 1024; size_t pageIdx = blSize / 1024;
size_t appSizeKb = __appflash_size__ / 1024; // size_t appSizeKb = __appflash_size__ / 1024;
size_t appSizeKb = 25;
for (size_t i = 0; i <= appSizeKb; i++) for (size_t i = 0; i < appSizeKb; i++)
{ {
Flash::ErasePage(pageIdx); Flash::ErasePage(pageIdx);
pageIdx++; pageIdx++;
@ -169,6 +170,8 @@ void RunBootloaderLoop()
break; break;
case 0x03: // opcode 3 is "boot app" case 0x03: // opcode 3 is "boot app"
sendAck();
// Clear the flag // Clear the flag
bootloaderBusy = false; bootloaderBusy = false;
// Kill this thread // Kill this thread
@ -180,11 +183,20 @@ void RunBootloaderLoop()
} }
} }
static const CANConfig canConfig500 =
{
CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
CAN_BTR_SJW(0) | CAN_BTR_BRP(5) | CAN_BTR_TS1(12) | CAN_BTR_TS2(1),
};
THD_WORKING_AREA(waBootloaderThread, 512); THD_WORKING_AREA(waBootloaderThread, 512);
THD_FUNCTION(BootloaderThread, arg) THD_FUNCTION(BootloaderThread, arg)
{ {
(void)arg; (void)arg;
// turn on CAN
canStart(&CAND1, &canConfig500);
WaitForBootloaderCmd(); WaitForBootloaderCmd();
// We've rx'd a BL command, don't load the app! // We've rx'd a BL command, don't load the app!