mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-27 01:48:17 +00:00
bootloader: subtle changes in bootloader.c and fastflash.c to make them more similar
This commit is contained in:
parent
f274d8cd73
commit
4603b0c800
@ -78,10 +78,15 @@ void show_unofficial_warning(const uint8_t *hash)
|
|||||||
|
|
||||||
void __attribute__((noreturn)) load_app(void)
|
void __attribute__((noreturn)) load_app(void)
|
||||||
{
|
{
|
||||||
// jump to app
|
// Relocate vector tables
|
||||||
SCB_VTOR = FLASH_APP_START; // & 0xFFFF;
|
SCB_VTOR = FLASH_APP_START; // & 0xFFFF;
|
||||||
|
|
||||||
|
// Set stack pointer
|
||||||
__asm__ volatile("msr msp, %0"::"g" (*(volatile uint32_t *)FLASH_APP_START));
|
__asm__ volatile("msr msp, %0"::"g" (*(volatile uint32_t *)FLASH_APP_START));
|
||||||
|
|
||||||
|
// Jump to address
|
||||||
(*(void (**)())(FLASH_APP_START + 4))();
|
(*(void (**)())(FLASH_APP_START + 4))();
|
||||||
|
|
||||||
// forever loop to indicate to the compiler that this function does not return.
|
// forever loop to indicate to the compiler that this function does not return.
|
||||||
// this avoids the stack protector injecting code that faults with the new stack.
|
// this avoids the stack protector injecting code that faults with the new stack.
|
||||||
for (;;);
|
for (;;);
|
||||||
|
@ -29,11 +29,14 @@ extern uint32_t __bootloader_loadaddr__[];
|
|||||||
extern uint32_t __bootloader_runaddr__[];
|
extern uint32_t __bootloader_runaddr__[];
|
||||||
extern uint8_t __bootloader_size__[];
|
extern uint8_t __bootloader_size__[];
|
||||||
|
|
||||||
void load_bootloader() {
|
void load_bootloader(void)
|
||||||
|
{
|
||||||
memcpy(__bootloader_runaddr__, __bootloader_loadaddr__, (size_t) __bootloader_size__);
|
memcpy(__bootloader_runaddr__, __bootloader_loadaddr__, (size_t) __bootloader_size__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_bootloader() {
|
// adapted from load_app() in bootloader.c
|
||||||
|
void __attribute__((noreturn)) run_bootloader(void)
|
||||||
|
{
|
||||||
// Relocate vector tables
|
// Relocate vector tables
|
||||||
SCB_VTOR = (uint32_t) __bootloader_runaddr__;
|
SCB_VTOR = (uint32_t) __bootloader_runaddr__;
|
||||||
|
|
||||||
@ -43,5 +46,7 @@ void run_bootloader() {
|
|||||||
// Jump to address
|
// Jump to address
|
||||||
((void (*)(void))(__bootloader_runaddr__[1]))();
|
((void (*)(void))(__bootloader_runaddr__[1]))();
|
||||||
|
|
||||||
while (true);
|
// forever loop to indicate to the compiler that this function does not return.
|
||||||
|
// this avoids the stack protector injecting code that faults with the new stack.
|
||||||
|
for (;;);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user