diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e475741..aad359a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.3] - 2023-10-26 + +### Fixed +- Launcher: Fix missing RAM relocation emulation on NanoX, NanoSP and Stax + ## [0.3.2] - 2023-09-28 ### Fixed diff --git a/src/launcher.c b/src/launcher.c index 5a328ea4..8e114d7b 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -17,6 +17,8 @@ #include "svc.h" #define LOAD_ADDR ((void *)0x40000000) +#define LINK_RAM_ADDR (0xda7a0000) +#define LOAD_RAM_ADDR (0x50000000) #define MAX_APP 16 #define MAIN_APP_NAME "main" @@ -299,6 +301,11 @@ static void *load_app(char *name) data_addr = get_lower_page_aligned_addr(app->elf.stack_addr); data_size = get_upper_page_aligned_size( app->elf.stack_size + app->elf.stack_addr - (unsigned long)data_addr); + if (app->elf.stack_addr == LINK_RAM_ADDR) { + // Emulate RAM relocation + data_addr = (void *)LOAD_RAM_ADDR; + data_size = get_upper_page_aligned_size(app->elf.stack_size); + } /* load code * map an extra page in case the _install_params are mapped in the beginning @@ -547,7 +554,11 @@ static int run_app(char *name, unsigned long *parameters) /* thumb mode */ f = (void *)((unsigned long)p | 1); stack_end = app->elf.stack_addr; - stack_start = app->elf.stack_addr + app->elf.stack_size; + if (app->elf.stack_addr == LINK_RAM_ADDR) { + // Emulate RAM relocation + stack_end = LOAD_RAM_ADDR; + } + stack_start = stack_end + app->elf.stack_size; asm volatile("mov r0, %2\n" "mov r9, %1\n"