How to compiling the static library of the flpr core into the main program of the flpr core?

Hi,

I am debugging a program running on the FLPR core on the nRF54L15 development board. I need to call a static library (. a file) on the FLPR core. I use the project created by the nRF Connect SDK to generate a static library, and then call it in the main function of the project.

This is the code for generating a static library (.a file) in the CMakeLists.txt file:

target_sources(app PRIVATE 
    src/flpr_lib_src/flpr_lib_src.c

)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR}/lib)
set(SOURCES
    src/flpr_lib_src/flpr_lib_src.c

)
add_library(flpr STATIC ${SOURCES})

And this is the CMakeLists.txt code when I compile the static library (.a file) into hex:

FILE(GLOB app_sources 
    src/*.c
)
target_sources(app PRIVATE ${app_sources})
target_link_libraries(app PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/libflpr.a
)

Compiling .a file and hex file using NCS2.9.1 integrated with VSCode. The compilation configuration is as follows:

SDK: nRF Connect SDK v2.9.1

Toolchain: nRF Connect SDK Toolchain v2.9.1

Board target: nrf54l15dk/nrf54l15/cpuflpr    Nordic Soc

System build(sysbuild): No sysbuild

When compiling the static library(.a file) into hex, the following errors was reported:

"error: ../lib/libflpr.a(flpr_lib_src.c.obj) use 16-byte stack aligned but the output use 4-byte stack aligned"


Recently, when compiling static libraries, I added a compilation option in CMakeLists.txt:: target_compile_options(flpr PRIVATE -mpreferred-stack-boundary=2) to try to change the byte alignment of the static library. However, the following error was reported:“error: '-mpreferred-stack-boundary=2' must be between 3 and 8”. It means that using this method, I can only create static libraries that are aligned with at least 8 bytes.

How should this problem be solved? How can I compile a static library into 4-byte alignment?

If you know how to solve it, please reply to me.

Thank you.

Related