AP_Bootloader: add support for app start offset

This commit is contained in:
Siddharth Purohit 2020-08-24 01:32:56 +05:30 committed by Peter Barker
parent 1f16aa8360
commit 2edcd852eb
4 changed files with 9 additions and 9 deletions

View File

@ -51,9 +51,9 @@ int main(void)
{ {
board_info.board_type = APJ_BOARD_ID; board_info.board_type = APJ_BOARD_ID;
board_info.board_rev = 0; board_info.board_rev = 0;
board_info.fw_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + FLASH_RESERVE_END_KB))*1024; board_info.fw_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + FLASH_RESERVE_END_KB + APP_START_OFFSET_KB))*1024;
if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) { if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) {
board_info.fw_size = (1024 - FLASH_BOOTLOADER_LOAD_KB)*1024; board_info.fw_size = (1024 - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024;
} }
bool try_boot = false; bool try_boot = false;

View File

@ -203,7 +203,7 @@ do_jump(uint32_t stacktop, uint32_t entrypoint)
: : "r"(stacktop), "r"(entrypoint) :); : : "r"(stacktop), "r"(entrypoint) :);
} }
#define APP_START_ADDRESS (FLASH_LOAD_ADDRESS + FLASH_BOOTLOADER_LOAD_KB*1024U) #define APP_START_ADDRESS (FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024U)
void void
jump_to_app() jump_to_app()

View File

@ -569,8 +569,8 @@ bool can_check_firmware(void)
return false; return false;
} }
const uint8_t sig[8] = { 0x40, 0xa2, 0xe4, 0xf1, 0x64, 0x68, 0x91, 0x06 }; const uint8_t sig[8] = { 0x40, 0xa2, 0xe4, 0xf1, 0x64, 0x68, 0x91, 0x06 };
const uint8_t *flash = (const uint8_t *)(FLASH_LOAD_ADDRESS + FLASH_BOOTLOADER_LOAD_KB*1024); const uint8_t *flash = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
const uint32_t flash_size = (BOARD_FLASH_SIZE - FLASH_BOOTLOADER_LOAD_KB)*1024; const uint32_t flash_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024;
const app_descriptor *ad = (const app_descriptor *)memmem(flash, flash_size-sizeof(app_descriptor), sig, sizeof(sig)); const app_descriptor *ad = (const app_descriptor *)memmem(flash, flash_size-sizeof(app_descriptor), sig, sizeof(sig));
if (ad == nullptr) { if (ad == nullptr) {
// no application signature // no application signature

View File

@ -71,7 +71,7 @@ void cout(uint8_t *data, uint32_t len)
static uint32_t flash_base_page; static uint32_t flash_base_page;
static uint8_t num_pages; static uint8_t num_pages;
static const uint8_t *flash_base = (const uint8_t *)(0x08000000 + FLASH_BOOTLOADER_LOAD_KB*1024U); static const uint8_t *flash_base = (const uint8_t *)(0x08000000 + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024U);
/* /*
initialise flash_base_page and num_pages initialise flash_base_page and num_pages
@ -81,9 +81,9 @@ void flash_init(void)
uint32_t reserved = 0; uint32_t reserved = 0;
num_pages = stm32_flash_getnumpages(); num_pages = stm32_flash_getnumpages();
/* /*
advance flash_base_page to account for FLASH_BOOTLOADER_LOAD_KB advance flash_base_page to account for (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)
*/ */
while (reserved < FLASH_BOOTLOADER_LOAD_KB * 1024U && while (reserved < (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB) * 1024U &&
flash_base_page < num_pages) { flash_base_page < num_pages) {
reserved += stm32_flash_getpagesize(flash_base_page); reserved += stm32_flash_getpagesize(flash_base_page);
flash_base_page++; flash_base_page++;
@ -104,7 +104,7 @@ void flash_set_keep_unlocked(bool set)
} }
/* /*
read a word at offset relative to FLASH_BOOTLOADER_LOAD_KB read a word at offset relative to flash base
*/ */
uint32_t flash_func_read_word(uint32_t offset) uint32_t flash_func_read_word(uint32_t offset)
{ {