From ed2bf3e8b072cd0c4f849ee69018a59cb132d6b5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 27 Jul 2022 23:48:05 -0400 Subject: [PATCH] bootentry: Move set_bootup_code() signatures to misc.h Signed-off-by: Kevin O'Connor --- src/bootentry.c | 6 ++---- src/generic/armcm_canboot.c | 5 +---- src/generic/misc.h | 4 ++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bootentry.c b/src/bootentry.c index b715852..3ed5ef3 100644 --- a/src/bootentry.c +++ b/src/bootentry.c @@ -13,8 +13,6 @@ #include "ctr.h" // DECL_CTR #include "sched.h" // udelay -#define REQUEST_SIG 0x5984E3FA6CA1589B // Random request sig - // Generated by buildcommands.py DECL_CTR("DECL_BUTTON " __stringify(CONFIG_BUTTON_PIN)); extern int32_t button_gpio, button_high, button_pullup; @@ -38,7 +36,7 @@ check_double_reset(void) return; // set request signature and delay for two seconds. This enters the bootloader if // the reset button is double clicked - set_bootup_code(REQUEST_SIG); + set_bootup_code(REQUEST_CANBOOT); udelay(500000); set_bootup_code(0); // No reset, read the key back out to clear it @@ -52,7 +50,7 @@ bootentry_check(void) // - The request signature is set in memory (request from app) // - No application code is present uint64_t bootup_code = get_bootup_code(); - if (bootup_code == REQUEST_SIG || !application_check_valid() + if (bootup_code == REQUEST_CANBOOT || !application_check_valid() || check_button_pressed()) { // Start bootloader main loop set_bootup_code(0); diff --git a/src/generic/armcm_canboot.c b/src/generic/armcm_canboot.c index 46a0fb6..331c1b4 100644 --- a/src/generic/armcm_canboot.c +++ b/src/generic/armcm_canboot.c @@ -9,6 +9,7 @@ #include "autoconf.h" // CONFIG_MCU #include "board/internal.h" // SysTick #include "board/irq.h" // irq_disable +#include "board/misc.h" // get_bootup_code #include "command.h" // DECL_CONSTANT_STR // Export MCU type @@ -54,8 +55,6 @@ application_check_valid(void) return *app != 0 && *app != 0xffffffff; } -#define REQUEST_START_APP 0x7b06ec45a9a8243d - // Jump to the main application (exiting the bootloader) void application_jump(void) @@ -103,8 +102,6 @@ reset_handler_stage_two(void) ; } -#define CANBOOT_SIGNATURE 0x21746f6f426e6143 // CanBoot! - // Initial code entry point - invoked by the processor after a reset asm(".section .text.ResetHandler\n" ".balign 8\n" diff --git a/src/generic/misc.h b/src/generic/misc.h index 2cedb56..6441136 100644 --- a/src/generic/misc.h +++ b/src/generic/misc.h @@ -8,6 +8,10 @@ struct command_encoder; void console_sendf(const struct command_encoder *ce, va_list args); void *console_receive_buffer(void); +#define CANBOOT_SIGNATURE 0x21746f6f426e6143 // CanBoot! +#define REQUEST_CANBOOT 0x5984E3FA6CA1589B +#define REQUEST_START_APP 0x7b06ec45a9a8243d + uint64_t get_bootup_code(void); void set_bootup_code(uint64_t code); void application_read_flash(uint32_t address, uint32_t *dest);