/*
|
* Copyright (c) 2019-2023 Mauna Kea Semiconductor Holdings.
|
* All rights reserved.
|
*
|
*/
|
|
#include "mk_wdt.h"
|
|
#include "_customboot_image.c"
|
|
#if ((SRAM_BASE + SRAM_SIZE) < _customboot_end_address)
|
#error no enough space to store customboot
|
#endif
|
|
extern const VECTOR_TABLE_Type __VECTOR_TABLE[48];
|
|
int main(void)
|
{
|
wdt_close(WDT_ID0);
|
|
// copy customboot to it's link address
|
memcpy((void *)_customboot_start_address, _customboot_image, sizeof(_customboot_image));
|
|
// copy vector table from customboot and put it to the right place
|
memcpy((void *)SRAM_BASE, (void *)_customboot_start_address, sizeof(__VECTOR_TABLE));
|
|
// setup new msp
|
__set_MSP(*(uint32_t *)_customboot_start_address);
|
|
// jump to customboot
|
typedef void (*p_entry_t)(void);
|
((p_entry_t) (*(uint32_t *)(_customboot_start_address + 4)))();
|
}
|