Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher: Fix missing RAM relocation emulation on NanoX, NanoSP and Stax #429

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion src/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Loading