Closed zhang-wenchao closed 4 weeks ago
This problem is very strange, torture me for a day. It looks like the problem is on the RP2040 board. I'm not sure, because it crash with static links? Perhaps Zephyr has other problems.
Request investigation, Ask for investigation, I recovered on my nrf52840_mdk, the same problem.
west build -p always -b nrf52840_mdk
west flash
I also have an ESP32C3, there is no problem, normal. I think the problem may appear on ARM compilation or DAPLink or OpenOCD. Perhaps this is a dual-core problem.
Where can this problem be a problem? Request to improve priority.
frdm_k64f I also have a FRDM-K64F, which is also this error, which looks like all ARMs will be like this.
Breakpoint 1, main () at /home/life/Develop/test/rp/src/main.c:6
6 test();
(gdb) stepi
test () at /home/life/Develop/test/rp/lib/test.c:2
2 {
(gdb) stepi
0x00000412 in test () at /home/life/Develop/test/rp/lib/test.c:2
2 {
(gdb) stepi
0xfffffe70 in ?? ()
(gdb) stepi
z_arm_usage_fault () at /home/life/Develop/platform/zephyr-project/zephyr/arch/arm/core/cortex_m/fault_s.S:80
80 mrs r0, MSP
(gdb)
Did you try using https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/application_development/external_lib ? Because this is tested and works
This makes me difficult to understand, because it is just a empty test function. Arm can't, risc-v ok.
*** Booting Zephyr OS build v3.7.0-4639-g861fdae65dfc ***
Hello World!
mylib says: Hello World!
on nrf5340dk (arm cortex m33) so works fine
I have positioned some questions,
zephyr_get_compile_options_for_lang_as_string( C options)
Use options:
add_library(lib STATIC
test.c
)
target_compile_options(lib PRIVATE -fno-strict-aliasing -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=/home/life/Develop/platform/zephyr-project/sdk/zephyr-sdk-0.16.8/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/life/Develop/platform/zephyr-project/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wformat -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/life/Develop/test/rp=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/life/Develop/platform/zephyr-project/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/life/Develop/platform/zephyr-project=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=picolibc.specs -std=c99)
It's ok, The reason is that the compilation option is not applied to add_subdirectory (lib)
@nashif I don't know who can help me. Excuse me.
I temporarily solved this problem.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(app)
zephyr_get_compile_options_for_lang_as_string(C options)
# get_cmake_property(_variableNames VARIABLES)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
target_sources(app PRIVATE src/main.c
)
add_subdirectory(crypto)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(app PRIVATE crypto)
add_library(lib STATIC
test.c
)
message(STATUS "Zephyr Log: ${options}")
string(REGEX REPLACE "\\$<SEMICOLON>\\$<TARGET_PROPERTY:compiler,imacros>\\$<SEMICOLON>[^$]+/autoconf\\.h" "" options "${options}")
separate_arguments(options_list UNIX_COMMAND "${options}")
message(STATUS "Options list: ${options_list}")
target_compile_options(crypto PRIVATE ${options_list})
Use cmake add_subdirectory(lib)
scene is very many, I think it is necessary to create an example.
Environment:
Info:
Minimal reproducible example:
pj.conf
CMakeLists.txt
src/main.c
lib/test.c
lib/test.h
lib/CMakeLists.txt
Log: