Memory Layout and Configuration Guide#
This document explains the memory layout, configuration entry points, and tuning methods for the K230/K230D RT-Smart platform, based on the SDK source Kconfig files, linker scripts, and board-level implementations.
Overall Memory Model#
In the current SDK, DDR is divided into two main regions:
RT-Smart system region — kernel + user-space page pool + dynamic heap
MMZ region — large media-related memory blocks
The core configuration options are found under Board Configuration → Memory Layout:
CONFIG_MEM_RTSMART_BASE— RT-Smart start base address (default0x0)CONFIG_RTSMART_OPENSIB_MEMORY_SIZE— OpenSBI reserved region size (default0x20000)CONFIG_MEM_RTSMART_SIZE— RT-Smart total memory sizeCONFIG_MEM_RTSMART_HEAP_SIZE— RT-Smart heap sizeCONFIG_MEM_MMZ_BASE— MMZ base addressCONFIG_MEM_MMZ_SIZE— MMZ sizeCONFIG_MEM_TOTAL_SIZE— Total DDR size (used in static mode)
Source references:
boards/Kconfigboards/Kconfig.memory_staticboards/Kconfig.memory_autosrc/rtsmart/rtsmart/kernel/bsp/maix3/board/board.csrc/rtsmart/rtsmart/kernel/bsp/maix3/board/board.hsrc/rtsmart/rtsmart/kernel/bsp/maix3/link.lds.in
Two Configuration Modes#
Static Configuration Mode#
When CONFIG_AUTO_DETECT_DDR_SIZE=n, a fixed set of values from Kconfig.memory_static is used:
MEM_TOTAL_SIZEMEM_RTSMART_SIZEMEM_RTSMART_HEAP_SIZEMEM_MMZ_BASEMEM_MMZ_SIZE
These values are compiled directly into the linker script and runtime initialization.
Best suited for:
Boards with fixed DDR (e.g. SiP with fixed capacity)
Cases where precise control over each region size is required
Automatic DDR Detection Mode#
When CONFIG_AUTO_DETECT_DDR_SIZE=y, tier-based values from Kconfig.memory_auto are used:
512 MB tier:
*_5121024 MB tier:
*_10242048 MB tier:
*_2048
Runtime flow (see board.c):
Obtain DDR capacity via
k230_atag_get_ddr_size()If that fails, fall back to
0x20000000(512 MB)Select the matching tier’s RT-Smart size, heap size, MMZ base address, and MMZ size
In auto mode,
board.hredirectsCONFIG_MEM_*macros toget_*()function return values, enabling dynamic selection based on the actual DDR size.
Key Address Formulas#
The following formulas are derived from board.c and link.lds.in:
System start address
Total usable system region (aligned to KB, with 1 KB reserved)
RAM_END (4 KB reserved at the end)
Heap region
RT_HW_HEAP_BEGIN = &__bss_endRT_HW_HEAP_END = RT_HW_HEAP_BEGIN + CONFIG_MEM_RTSMART_HEAP_SIZE
MMZ region
MEM_MMZ_BASE = CONFIG_MEM_MMZ_BASEMEM_MMZ_SIZE = CONFIG_MEM_MMZ_SIZE - 4096(seeboard.h)
Default Tiers (Auto Mode)#
From boards/Kconfig.memory_auto:
512 MB tier
MEM_RTSMART_SIZE_512 = 0x10000000(256 MB)MEM_RTSMART_HEAP_SIZE_512 = 0x02000000(32 MB)MEM_MMZ_BASE_512 = 0x10000000MEM_MMZ_SIZE_512 = 0x10000000(256 MB)
1024 MB tier
MEM_RTSMART_SIZE_1024 = 0x20000000(512 MB)MEM_RTSMART_HEAP_SIZE_1024 = 0x04000000(64 MB)MEM_MMZ_BASE_1024 = 0x20000000MEM_MMZ_SIZE_1024 = 0x20000000(512 MB)
2048 MB tier
MEM_RTSMART_SIZE_2048 = 0x20000000(512 MB)MEM_RTSMART_HEAP_SIZE_2048 = 0x04000000(64 MB)MEM_MMZ_BASE_2048 = 0x20000000MEM_MMZ_SIZE_2048 = 0x60000000(1536 MB)
Configuration Entry Point#
Run the following in the SDK root directory:
make menuconfig
Navigate to:
Board Configuration
-> Memory Layout
From there you can:
Enable/disable
Auto Detect DRAM SizeConfigure per-tier parameters (512/1024/2048) in auto mode
Configure
MEM_TOTAL_SIZE,MEM_RTSMART_SIZE,MEM_RTSMART_HEAP_SIZE,MEM_MMZ_BASE,MEM_MMZ_SIZEin static mode
Configuration Guidelines and Constraints#
Follow these rules:
Total size constraint
MEM_RTSMART_SIZE + MEM_MMZ_SIZEmust not exceedMEM_TOTAL_SIZE
Contiguous layout (recommended)
Set
MEM_MMZ_BASE = MEM_RTSMART_SIZE(assuming the defaultMEM_RTSMART_BASE=0)
Heap size constraint
MEM_RTSMART_HEAP_SIZEmust be smaller than the actual usable system region (after subtracting the kernel image, BSS, and page management overhead)
Media-heavy workloads
Increase
MEM_MMZ_SIZEEnsure the RT-Smart heap still meets application requirements
Application-heavy workloads
Increase
MEM_RTSMART_HEAP_SIZEAvoid shrinking MMZ to the point where media module allocations fail
Validation After Changes#
Rebuild the image:
time make log
Check
.configto verify the target values (e.g.CONFIG_MEM_RTSMART_SIZE,CONFIG_MEM_MMZ_SIZE) are applied correctly.Run typical workloads on the board (media, AI, network) and observe whether any out-of-memory or allocation failure errors appear.
K230D Example (Static Configuration)#
From configs/k230d_rtos_evb_defconfig:
CONFIG_MEM_RTSMART_SIZE=0x4400000CONFIG_MEM_RTSMART_HEAP_SIZE=0x1000000CONFIG_MEM_MMZ_BASE=0x4400000CONFIG_MEM_MMZ_SIZE=0x3C00000
This is a typical contiguous “system region + MMZ region” split.
FAQ#
In auto DDR detection mode, why does the actual behavior differ from expectations?#
Check:
Is
CONFIG_AUTO_DETECT_DDR_SIZE=y?Does the corresponding tier option exist (512/1024/2048)?
Can the board correctly retrieve the ATAG DDR size? (If not, it falls back to the 512 MB tier.)
Memory configuration changed, compiles fine, but crashes at runtime?#
Check:
Is
MEM_RTSMART_HEAP_SIZEtoo large, encroaching on the page pool space?Do
MEM_MMZ_BASE/MEM_MMZ_SIZEoverflow or overlap with the system region?Does the board’s actual DDR capacity match the configuration?
