little fixes to make everything actually work
diff --git a/bbb_cape/src/cape/bootloader.c b/bbb_cape/src/cape/bootloader.c
index 39f3080..5194832 100644
--- a/bbb_cape/src/cape/bootloader.c
+++ b/bbb_cape/src/cape/bootloader.c
@@ -74,8 +74,8 @@
while (!(SYSCFG->CMPCR & SYSCFG_CMPCR_READY)) {} // wait for it to be ready
if (GPIOC->IDR & (1 << 2)) {
- bootloader_start();
- } else {
jump_to_main();
+ } else {
+ bootloader_start();
}
}
diff --git a/bbb_cape/src/cape/bootloader_impl.c b/bbb_cape/src/cape/bootloader_impl.c
index 15d28b1..2cd287d 100644
--- a/bbb_cape/src/cape/bootloader_impl.c
+++ b/bbb_cape/src/cape/bootloader_impl.c
@@ -6,6 +6,7 @@
#include "cape/uart_common.h"
#include "cape/crc.h"
#include "cape/util.h"
+#include "cape/led.h"
// The protocol is pretty simple. Basically, when the bootloader is started, it
// expects repeated "packets" of data to write. It starts at MAIN_FLASH_START,
@@ -37,6 +38,11 @@
}
__attribute__((noreturn)) void bootloader_start(void) {
+ led_set(LED_ERR, 1);
+ led_set(LED_DB, 1);
+ led_set(LED_Z, 1);
+ led_set(LED_HB, 0);
+
crc_init();
// Unlock the flash so we can program it.
@@ -80,6 +86,7 @@
error = 1;
}
} else { // successfully received a byte
+ led_set(LED_HB, bytes_received & 1);
if (error == 0) {
buffer[bytes_received++] = (uint8_t)received;
if (bytes_received == sizeof(buffer)) {
diff --git a/bbb_cape/src/cape/fill_packet.c b/bbb_cape/src/cape/fill_packet.c
index 012b7e3..29ea095 100644
--- a/bbb_cape/src/cape/fill_packet.c
+++ b/bbb_cape/src/cape/fill_packet.c
@@ -25,9 +25,6 @@
static uint8_t buffer2[DATA_STRUCT_SEND_SIZE] __attribute__((aligned(4)));
static uint32_t flash_checksum;
-// These aren't really integers; they're (4-byte) variables whose addresses mark
-// various locations.
-extern uint8_t __etext, __data_start__, __data_end__;
static inline void do_fill_packet(struct DataStruct *packet) {
static uint64_t timestamp = 0;
@@ -82,9 +79,9 @@
encoder_init();
digital_init();
- uint8_t *flash_end = &__etext + (&__data_start__ - &__data_end__) + 8;
- flash_checksum = crc_calculate((void *)MAIN_FLASH_START,
- (size_t)(flash_end - MAIN_FLASH_START) / 4);
+ flash_checksum =
+ crc_calculate((void *)MAIN_FLASH_START,
+ (size_t)(MAIN_FLASH_END - MAIN_FLASH_START) / 4);
led_set(LED_ERR, 0);
gyro_init();