mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
armcm_boot: Add get/set_bootup_code() helper functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
34e14386ed
commit
23f3c0e1e2
@ -266,22 +266,20 @@ enter_bootloader(void)
|
||||
void
|
||||
canboot_main(void)
|
||||
{
|
||||
uint32_t req_addr = *(uint32_t *)CONFIG_FLASH_START;
|
||||
volatile uint64_t* boot_request_sig = (volatile uint64_t *)req_addr;
|
||||
|
||||
// Enter the bootloader in the following conditions:
|
||||
// - The request signature is set in memory (request from app)
|
||||
// - No application code is present
|
||||
if ((*boot_request_sig == REQUEST_SIG ) || !check_application_code()) {
|
||||
*boot_request_sig = 0;
|
||||
uint64_t bootup_code = get_bootup_code();
|
||||
if (bootup_code == REQUEST_SIG || !check_application_code()) {
|
||||
set_bootup_code(0);
|
||||
enter_bootloader();
|
||||
}
|
||||
|
||||
// set request signature and delay for two seconds. This enters the bootloader if
|
||||
// the reset button is double clicked
|
||||
*boot_request_sig = REQUEST_SIG;
|
||||
set_bootup_code(REQUEST_SIG);
|
||||
udelay(2000000);
|
||||
*boot_request_sig = 0;
|
||||
set_bootup_code(0);
|
||||
// No reset, read the key back out to clear it
|
||||
|
||||
// jump to app
|
||||
|
@ -18,6 +18,20 @@ extern uint32_t _stack_end;
|
||||
* Basic interrupt handlers
|
||||
****************************************************************/
|
||||
|
||||
uint64_t
|
||||
get_bootup_code(void)
|
||||
{
|
||||
uint64_t *req_code = (void*)&_stack_end;
|
||||
return *req_code;
|
||||
}
|
||||
|
||||
void
|
||||
set_bootup_code(uint64_t code)
|
||||
{
|
||||
uint64_t *req_code = (void*)&_stack_end;
|
||||
*req_code = code;
|
||||
}
|
||||
|
||||
void __noreturn __visible
|
||||
reset_handler_stage_two(void)
|
||||
{
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <stdint.h> // uint8_t
|
||||
#include "autoconf.h" // CONFIG_MACH_STM32F0
|
||||
|
||||
uint64_t get_bootup_code(void);
|
||||
void set_bootup_code(uint64_t code);
|
||||
void jump_to_application(void);
|
||||
|
||||
// Timer Functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user