Skip to content

Fix incorrect maximum RAM and flash size in NRF board.jsons - #765

Merged
liamcottle merged 2 commits into
meshcore-dev:devfrom
oltaco:fix-incorrect-ram-flash-maximums
Mar 7, 2026
Merged

Fix incorrect maximum RAM and flash size in NRF board.jsons#765
liamcottle merged 2 commits into
meshcore-dev:devfrom
oltaco:fix-incorrect-ram-flash-maximums

Conversation

@oltaco

@oltaco oltaco commented Sep 9, 2025

Copy link
Copy Markdown
Member

Every NRF52 board json file has maximum_ram_size set incorrectly, and a couple of them have maximum_size (flash size) set incorrectly. It's not super important, as it's only used by the platformio size-checker to create the output for the build log and to stop you uploading a firmware above what you have set in maximum_size.

This PR solves that, and brings the RAK board.json in tree so that we can fix it too.

Note that neither maximum_ram_size/maximum_size settings will stop the firmware actually getting built. The linker will throw an error and stop if you exceed the limits set in the linker scripts, but those limits are not the same as what is set in the board.json files.

nrf52840_s140_v*.ld defines maximum RAM as LENGTH = 0x20040000 - 0x20006000 in nrf52840_s140_v*.ld, minus another 2kb for the stack as seen in nrf_common.ld:

__StackSize = 1024*2;

/* Set stack top to end of RAM, and stack limit move down by size of stack_dummy section */
PROVIDE(__StackTop   = ORIGIN(RAM) + LENGTH(RAM));
PROVIDE(__StackLimit = __StackTop - __StackSize);
PROVIDE(__stack      = __StackTop);

This leaves us with 235520 bytes of RAM allowed by the linker.

You can confirm this by forcing a RAM usage increase with a big array, and once RAM usage gets past 235520 bytes the linker will choke: arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 537128960 bytes

@recrof
recrof requested a review from fdlamotte January 11, 2026 23:19
@weebl2000

Copy link
Copy Markdown
Contributor

@oltaco is this PR still needed? I'm having a look at older PRs and see if they're still relevant.

weebl2000 added a commit to weebl2000/meshcore that referenced this pull request Mar 4, 2026
@weebl2000

Copy link
Copy Markdown
Contributor

@oltaco please see oltaco#5

liamcottle added a commit that referenced this pull request Mar 7, 2026
Fix incorrect ram flash maximums (supersedes #765)
@liamcottle
liamcottle merged commit 801ed6b into meshcore-dev:dev Mar 7, 2026
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

Successfully merging this pull request may close these issues.

3 participants