From b57a7ff4c0c350ba4f09685449177e66442ac9f7 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sat, 12 Dec 2020 15:11:48 -0800 Subject: [PATCH] =?UTF-8?q?bl=20works=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- firmware/bootloader/bootloader.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/firmware/bootloader/bootloader.cpp b/firmware/bootloader/bootloader.cpp index 0855e82..9645293 100644 --- a/firmware/bootloader/bootloader.cpp +++ b/firmware/bootloader/bootloader.cpp @@ -48,9 +48,10 @@ void EraseAppPages() uintptr_t blSize = (uintptr_t)(appFlashAddr - 0x08000000); 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); pageIdx++; @@ -169,6 +170,8 @@ void RunBootloaderLoop() break; case 0x03: // opcode 3 is "boot app" + sendAck(); + // Clear the flag bootloaderBusy = false; // 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_FUNCTION(BootloaderThread, arg) { (void)arg; + // turn on CAN + canStart(&CAND1, &canConfig500); + WaitForBootloaderCmd(); // We've rx'd a BL command, don't load the app!