Skip to content

Commit 43e5126

Browse files
committed
wscript: cap kernel RAM on emery and gabbro to match real hw
Signed-off-by: Joshua Jun <joshuajun@proton.me>
1 parent 5892560 commit 43e5126

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/fw/wscript

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _generate_memory_layout(bld):
114114
ldscript_template = bld.path.find_node('stm32f7xx_flash_fw.ld.template')
115115
elif bld.is_silk():
116116
ldscript_template = bld.path.find_node('stm32f412_flash_fw.ld.template')
117-
elif bld.env.BOARD == 'snowy_emery':
117+
elif bld.env.BOARD in ('snowy_emery', 'spalding_gabbro'):
118118
ldscript_template = bld.path.find_node('stm32f439_snowy_emery_flash_fw.ld.template')
119119
elif bld.is_snowy_compatible():
120120
ldscript_template = bld.path.find_node('stm32f439_flash_fw.ld.template')
@@ -336,6 +336,12 @@ def _generate_memory_layout(bld):
336336
worker_ram_size = 12 * 1024 # The worker always gets 12k of RAM.
337337
worker_ram = (ram_end - app_ram_size - worker_ram_size, worker_ram_size)
338338
kernel_ram_size = total_ram[1] - app_ram_size - worker_ram_size
339+
# On snowy_emery the excess RAM results in a kernel heap far larger than real
340+
# hardware (~131K vs ~106K), which is further capped by the heap allocator's
341+
# 15-bit segment size field to 131068 bytes. Reduce kernel RAM to match real
342+
# hardware heap pressure and avoid masking memory-related bugs in QEMU.
343+
if bld.env.BOARD in ('snowy_emery', 'spalding_gabbro'):
344+
kernel_ram_size = min(kernel_ram_size, 172 * 1024)
339345
kernel_ram = (total_ram[0], kernel_ram_size)
340346

341347
# As a basic sanity check, make sure we're giving the kernel at least 64k.

0 commit comments

Comments
 (0)