[bootloader] Added trampolines

This commit is contained in:
M4x1m3
2022-02-26 13:36:54 +01:00
parent d16808183b
commit f2c17121d2
6 changed files with 54 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ bootloader_src += $(addprefix bootloader/,\
slot.cpp \
interface.cpp \
jump_to_firmware.s \
trampoline.cpp \
)
bootloader_images = $(addprefix bootloader/, \

33
bootloader/trampoline.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include <string.h>
#include <ion/src/device/shared/drivers/flash.h>
#include <ion/src/device/n0110/drivers/power.h>
#include "trampoline.h"
namespace Bootloader {
void __attribute__((noinline)) suspend() {
Ion::Device::Power::internalFlashSuspend(true);
}
void* Trampolines[TRAMPOLINES_COUNT]
__attribute__((section(".trampolines_table")))
__attribute__((used))
= {
(void*) Bootloader::suspend, // Suspend
(void*) Ion::Device::Flash::EraseSector, // External erase
(void*) Ion::Device::Flash::WriteMemory, // External write
(void*) memcmp,
(void*) memcpy,
(void*) memmove,
(void*) memset,
(void*) strchr,
(void*) strcmp,
(void*) strlcat,
(void*) strlcpy,
(void*) strlen,
(void*) strncmp
};
}

12
bootloader/trampoline.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef BOOTLOADER_TRAMPOLINE_H
#define BOOTLOADER_TRAMPOLINE_H
namespace Bootloader {
#define TRAMPOLINES_COUNT 13
extern void* Trampolines[TRAMPOLINES_COUNT];
}
#endif

View File

@@ -7,7 +7,7 @@ $(BUILD_DIR)/test.external_flash.write.$(EXE): $(BUILD_DIR)/quiz/src/test_ion_ex
$(BUILD_DIR)/bootloader.$(EXE): $(call flavored_object_for,$(bootloader_src),usbxip)
$(BUILD_DIR)/bootloader.$(EXE): LDSCRIPT = ion/test/device/n0110/external_flash_tests.ld
$(BUILD_DIR)/bootloader.$(EXE): LDSCRIPT = ion/src/device/n0110/internal_flash.ld
.PHONY: %_flash
%_flash: $(BUILD_DIR)/%.dfu

View File

@@ -8,6 +8,7 @@ namespace Device {
namespace Power {
void standbyConfiguration();
void internalFlashSuspend(bool isLEDActive);
}
}

View File

@@ -6,6 +6,7 @@ MEMORY {
}
STACK_SIZE = 32K;
TRAMPOLINES_OFFSET = 0xE000;
SECTIONS {
.isr_vector_table ORIGIN(INTERNAL_FLASH) : {
@@ -69,6 +70,11 @@ SECTIONS {
_data_section_end_ram = .;
} >SRAM AT> INTERNAL_FLASH
.trampolines_table : {
. = ORIGIN(INTERNAL_FLASH) + TRAMPOLINES_OFFSET;
KEEP(*(.trampolines_table));
} > INTERNAL_FLASH
.bss : {
/* The bss section contains data for all uninitialized variables
* So like the .data section, it will go in RAM, but unlike the data section