summaryrefslogtreecommitdiff
path: root/sw/Core
diff options
context:
space:
mode:
Diffstat (limited to 'sw/Core')
-rwxr-xr-xsw/Core/Src/config.h5
-rwxr-xr-xsw/Core/Src/plinky.c27
-rwxr-xr-xsw/Core/Src/webusb.h1
3 files changed, 30 insertions, 3 deletions
diff --git a/sw/Core/Src/config.h b/sw/Core/Src/config.h
index 387382c..7cb83ab 100755
--- a/sw/Core/Src/config.h
+++ b/sw/Core/Src/config.h
@@ -59,3 +59,8 @@
// 0.A7 - Bootloader work to make it work on MacOSX
#define VERSION2 "v0.A7"
+// the bootloader is manually copied to the file golden_bootloader.bin
+// makebin.py uses it to make a UF2 file containing the bootloader + latest firmware together
+// it also checksums the firmware and prints out the value. it should match this value
+
+#define GOLDEN_CHECKSUM 0xb5a7228c \ No newline at end of file
diff --git a/sw/Core/Src/plinky.c b/sw/Core/Src/plinky.c
index cdcec60..14ffafe 100755
--- a/sw/Core/Src/plinky.c
+++ b/sw/Core/Src/plinky.c
@@ -2557,6 +2557,7 @@ short *getrxbuf(void);
#define REVERB_BUF 0x10000000
#define DELAY_BUF 0x20008000
+
void check_bootloader_flash(void) {
int count=0;
uint32_t *rb32=(uint32_t*)REVERB_BUF;
@@ -2569,8 +2570,23 @@ void check_bootloader_flash(void) {
if (count!=64/4 || magic!=0xa738ea75) {
return;
}
- clear();
char buf[32];
+ // checksum!
+ uint32_t checksum = 0;
+ for (int i=0;i<65536/4;++i) {
+ checksum = checksum * 23 + ((uint32_t*)DELAY_BUF)[i];
+ }
+ if (checksum != GOLDEN_CHECKSUM) {
+ DebugLog("bootloader checksum failed %08x != %08x\r\n", checksum, GOLDEN_CHECKSUM);
+ clear();
+ drawstr(0,0,F_8,"bad bootloader crc");
+ snprintf(buf, sizeof(buf), "%08x vs %08x", checksum, GOLDEN_CHECKSUM);
+ drawstr(0,8,F_8,buf);
+ oled_flip(vrambuf);
+ HAL_Delay(10000);
+ return;
+ }
+ clear();
snprintf(buf, sizeof(buf), "%08x %d", magic, count);
drawstr(0, 0, F_16, buf);
snprintf(buf, sizeof(buf), "%08x %08x", app_base[0], app_base[1]);
@@ -2606,7 +2622,11 @@ void check_bootloader_flash(void) {
}
DebugLog("FLASHING BOOTLOADER! DO NOT RESET\r\n");
clear();
- drawstr(0,0,F_16_BOLD,"FLASHING\nBOOTLOADER");
+ drawstr(0,0,F_12_BOLD,"FLASHING\nBOOTLOADER");
+ char verbuf[5]={};
+ memcpy(verbuf,(DELAY_BUF+65536-4),4);
+ drawstr(0,24,F_8,verbuf);
+
oled_flip(vrambuf);
HAL_FLASH_Unlock();
FLASH_EraseInitTypeDef EraseInitStruct;
@@ -2640,7 +2660,8 @@ void check_bootloader_flash(void) {
HAL_FLASH_Lock();
DebugLog("BOOTLOADER has been flashed!\r\n");
clear();
- drawstr(0,0,F_16_BOLD,"BOOTLOADER\nFLASHED OK!");
+ drawstr(0,0,F_12_BOLD,"BOOTLOADER\nFLASHED OK!");
+ drawstr(0,24,F_8,verbuf);
oled_flip(vrambuf);
HAL_Delay(3000);
diff --git a/sw/Core/Src/webusb.h b/sw/Core/Src/webusb.h
index 3405de5..495acd7 100755
--- a/sw/Core/Src/webusb.h
+++ b/sw/Core/Src/webusb.h
@@ -51,6 +51,7 @@ typedef struct WebUSBHeader { // 10 byte header
u16 len;
} WebUSBHeader;
const static u8 wu_magic[4] = { 0xf3,0x0f,0xab,0xca }; // we expect magic to be these
+const static u8 wu_magic_ext[4] = { 0xf4,0x1f,0xcb,0xdb }; // we expect magic to be these
#define WEB_USB_TIMEOUT 500
enum { // state machine ticks thru these in order, more or less
WU_MAGIC0,