-
Notifications
You must be signed in to change notification settings - Fork 1.5k
kernel/build: Fix the protected build #18262
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
Conversation
|
@Barto22 please change the PR message to something like: kernel/build: fix the protected build |
|
Could someone explain why build for arm-12 failed? It seems that everything is ok and then fail. And could it be rerun manually or I need to push some commit to trigger it once again? |
Seems like some defconfigs need to be normalized: no changes added to commit (use "git add" and/or "git commit -a") @simbit18 do you see other reason? |
But this warning and note is not the reason of fail. It shows in other builds also and didn't fail them. |
|
Hi @Barto22 @acassis step |
Ok, I will take a look at this later and fix. |
9fa5a73 to
08c485e
Compare
- Added support for multiple linker scripts preprocessing in CMake - Changed kernel/CMakeLists.txt to use target_sources for nuttx_user - Added KEEP() directive in user-space.ld for .userspace section - Removed hardcoded -funwind-tables to fix binary size bloat - Updated memory regions: ksram/usram 4KB→16KB, xsram 104KB→80KB - Enabled CONFIG_ARCH_FPU, CONFIG_STM32_CCMEXCLUDE, adjusted heap size Fixes protected mode CMake build for stm32f4discovery:kostest configuration. Signed-off-by: Bartosz <[email protected]>
08c485e to
d4c0e6d
Compare
Summary
This patch adds CMake build support for NuttX protected mode (kernel/user space separation) on STM32F4Discovery and similar ARM boards. Previously, protected mode configurations like
stm32f4discovery:kostestcould only be built with the Make build system. The CMake build system failed due to several architectural issues:Key Changes:
Multiple Linker Script Support (CMakeLists.txt)
foreachloopsmemory.ld(memory regions) andkernel-space.ld/user-space.ld(section placements)get_filename_component()-TflagsUser Space Binary Build (boards/.../kernel/CMakeLists.txt)
nuttx_add_aux_library()totarget_sources(nuttx_user PRIVATE ...)nuttx_add_aux_library()was creating an empty target without source filestarget_sources()properly adds userspace initialization codeLinker Script Selection (boards/.../src/CMakeLists.txt)
CONFIG_BUILD_PROTECTEDmemory.ld+kernel-space.ldfor kernel,memory.ld+user-space.ldfor userld.script(existing behavior)-funwind-tablesflag that was adding ~4.7KB bloat per binaryCritical .userspace Section (boards/.../scripts/user-space.ld)
KEEP(*(.userspace))directive to prevent linker garbage collectionEXTERN()declarations for memory management functions.userspacesection containsstruct userspace_swith memory map and entry pointsKEEP(), CMake's static library linking discards unreferenced sectionsMemory Layout Updates (boards/.../scripts/memory.ld)
CONFIG_MM_KERNEL_HEAPSIZE=16384)Configuration Updates (boards/.../configs/kostest/)
Make.defsfor kostest configuration (defines dual linker scripts)defconfig: enabled FPU, increased idle stack, excluded CCM, set kernel heap sizeTechnical Details:
The root cause was that Make builds link userspace object files directly to the linker, while CMake links from static library archives. When sections aren't explicitly referenced, the linker's garbage collector removes them from archives. The
.userspacesection at address0x08020000is critical—the kernel reads it during boot to initialize user space memory regions, entry points, and heap structures.Impact
Positive Impacts:
Build Process:
cmake -B build -DBOARD_CONFIG=stm32f4discovery:kostest -GNinja && ninja -C build./tools/configure.sh stm32f4discovery:kostest && makeTesting
Test Environment:
stm32f4discovery:kostest(protected mode OS test suite)