mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
canboot: improve bootloader request method
Use a cross platform request signature to enter the bootloader. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
3541dd1f2f
commit
9b4c95ee9a
@ -31,6 +31,8 @@
|
|||||||
#define WAIT_BLINK_TIME 1000000
|
#define WAIT_BLINK_TIME 1000000
|
||||||
#define XFER_BLINK_TIME 10000
|
#define XFER_BLINK_TIME 10000
|
||||||
|
|
||||||
|
#define REQUEST_SIG 0x5984E3FA6CA1589B // Random request sig
|
||||||
|
|
||||||
static uint8_t page_buffer[CONFIG_FLASH_PAGE_SIZE];
|
static uint8_t page_buffer[CONFIG_FLASH_PAGE_SIZE];
|
||||||
static uint8_t cmd_buf[CMD_BUF_SIZE];
|
static uint8_t cmd_buf[CMD_BUF_SIZE];
|
||||||
static uint8_t cmd_pos = 0;
|
static uint8_t cmd_pos = 0;
|
||||||
@ -264,18 +266,23 @@ enter_bootloader(void)
|
|||||||
void
|
void
|
||||||
canboot_main(void)
|
canboot_main(void)
|
||||||
{
|
{
|
||||||
uint16_t mkey = read_magic_key();
|
uint32_t req_addr = *(uint32_t *)CONFIG_FLASH_START;
|
||||||
// Enter the bootloader if the magic key has been set or if
|
volatile uint64_t* boot_request_sig = (volatile uint64_t *)req_addr;
|
||||||
// no application has been flashed
|
|
||||||
if (mkey == CONFIG_MAGIC_KEY || !check_application_code())
|
|
||||||
enter_bootloader();
|
|
||||||
|
|
||||||
// set magic key and delay for one second. This enters the bootloader if
|
// 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;
|
||||||
|
enter_bootloader();
|
||||||
|
}
|
||||||
|
|
||||||
|
// set request signature and delay for two seconds. This enters the bootloader if
|
||||||
// the reset button is double clicked
|
// the reset button is double clicked
|
||||||
set_magic_key();
|
*boot_request_sig = REQUEST_SIG;
|
||||||
udelay(1500000);
|
udelay(2000000);
|
||||||
|
*boot_request_sig = 0;
|
||||||
// No reset, read the key back out to clear it
|
// No reset, read the key back out to clear it
|
||||||
read_magic_key();
|
|
||||||
|
|
||||||
// jump to app
|
// jump to app
|
||||||
jump_to_application();
|
jump_to_application();
|
||||||
|
@ -57,13 +57,18 @@ SECTIONS
|
|||||||
_bss_end = .;
|
_bss_end = .;
|
||||||
} > ram
|
} > ram
|
||||||
|
|
||||||
_stack_start = CONFIG_RAM_START + CONFIG_RAM_SIZE - CONFIG_STACK_SIZE ;
|
_stack_start = CONFIG_RAM_START + CONFIG_RAM_SIZE - CONFIG_STACK_SIZE - 8;
|
||||||
.stack _stack_start (NOLOAD) :
|
.stack _stack_start (NOLOAD) :
|
||||||
{
|
{
|
||||||
. = . + CONFIG_STACK_SIZE;
|
. = . + CONFIG_STACK_SIZE;
|
||||||
_stack_end = .;
|
_stack_end = .;
|
||||||
} > ram
|
} > ram
|
||||||
|
|
||||||
|
.reserved (NOLOAD) :
|
||||||
|
{
|
||||||
|
. = . + 8;
|
||||||
|
} > ram
|
||||||
|
|
||||||
/DISCARD/ : {
|
/DISCARD/ : {
|
||||||
// The .init/.fini sections are used by __libc_init_array(), but
|
// The .init/.fini sections are used by __libc_init_array(), but
|
||||||
// that isn't needed so no need to include them in the binary.
|
// that isn't needed so no need to include them in the binary.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user