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

Sentinel value interaction with loadable flash addresses not clear #1

Open
mundaym opened this issue Aug 9, 2021 · 1 comment
Open

Comments

@mundaym
Copy link
Contributor

mundaym commented Aug 9, 2021

I am unsure why the sentinel value is subtracted from the flash app load address in kernel.c. It doesn't seem to be re-added anywhere so does this mean that the flash image is loaded at a different address to the one specified or is this just to compensate for a fixed offset encoded into the relocations? Might be worth a comment explaining what is happening:

uint32_t entry = program_flash_with_elf(elf_data, flash_addr - SENTINEL);

@luismarques
Copy link
Collaborator

The app linker script was adapted from the Tock project. It sets SRAM to address 0x0 and Flash to 0x80000000. The MSBit is used to distinguish between SRAM and Flash. You can relocate the app to another address but it must retain the MSB set. The function program_flash_with_elf has a flash_offset parameter. From the point of view of the ELF loading, it's just a regular offset that is applied to the existing value (i.e. address) of the ELF symbols. To convert between the absolute base address you want to relocate the Flash to (e.g. 0x80005000) and the offset you are applying (0x5000) you subtract 0x80000000, i.e. the SENTINEL. I'll make this clearer in the documentation and/or code comments. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants