MPU Fault when calling function part of static library linked using cmake TARGET_OBJECTS

Hello,
I have a third party lib which uses cmake as build system I want to link as a static lib to my main Zephyr application.

I created a dummy example you will find attached to this description.

The FW compiles properly, however when calling the dummy function get_sn(), I got an MPU fault and do not understand why.

Here how I link part of the thirt party lib (called mylib):

ADD_SUBDIRECTORY(mylibutils)
add_library(mylib STATIC $<TARGET_OBJECTS:mylibutils> libfile.cpp)
add_dependencies(mylib mylibutils)

Do you have any explanations/solutions why I ended with a MPU fault ?

I used a nrf52DK_52832.

Thank you.

*** Booting Zephyr OS build zephyr-v3.3.0 ***
Hello World! Hello from library!
[00:00:00.271,514] <err> os: ***** MPU FAULT *****
[00:00:00.276,947] <err> os:   Instruction Access Violation
[00:00:00.283,203] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x00000000
[00:00:00.291,839] <err> os: r3/a4:  0x00000001 r12/ip:  0x00000000 r14/lr:  0x000003fb
[00:00:00.300,476] <err> os:  xpsr:  0x01000000
[00:00:00.305,694] <err> os: Faulting instruction address (r15/pc): 0xfffffb70
[00:00:00.313,568] <err> os: >>> ZEPHYR FATAL ERROR 20: Unknown error on CPU 0
[00:00:00.321,411] <err> os: Current thread: 0x20000180 (unknown)
[00:00:00.328,155] <err> os: Halting system

Parents Reply
  • Hi,
    Yes I already saw that.
    But since my lib uses cmake as a build system and uses cmake option to configure it, I do not want to use cmake external_lib.

    It is strange that TARGET_OBJECTS lead to a fault whereas link the mylibutils/src/mylibutils.cpp directly does not.
    This is this behavior I do not understand and I am looking for an explanation.

    Please try the example I posted earlier.
    Thank you.

Children
Related