Hi Experts,
I have also posted this to zephyr dev mailing list and thought to add it here as well as it is related to OpenAMP.
I tried it in v3.4.x version of Zephyr before the final v3.4.0 release.
I am able to get the OpenAMP Bare-metal sample application work for core-to-core messaging using the STM32CubeIDE. We are using Zephyr in our project that interfaces with Bare-metal. The OpenAMP master runs on Bare-metal and it uses resource table. So I am working to enable the samples/subsys/openamp_rsc_table. I am able to build this sample for another STM32 board as
west -v build -p always -b stm32mp157c_dk2 samples/subsys/ipc/openamp_rsc_table
I have added the overlay and conf required to my project files and trying to build the sample and get the below linker error. As my target is also M4 on STM32H755 SoC, I believe I am missing some change to allow the metal_io_read() to be resolved to a proper library function. Some has suggested using set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic") per https://github.com/alexa/avs-device-sdk/issues/1404 I have tried to add it to the lib/openamp CMakeLists.txt but didn't help. Since this sample builds fine for stm32mp157c_dk2 , some build flag missing for my STM32H755 SoC??? Any help on this will be appreciated.
Log here
[362/372] Linking CXX executable zephyr\zephyr_pre0.elf FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/xxxx/build/zephyr/zephyr_pre0.map cmd.exe /C "cd . && C:\xxxx\zephyr-sdk-0.16.1\arm-zephyr-eabi\bin\arm-zephyr-eabi-g++.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -fuse-ld=bfd -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=C:/xxxxx/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/lib/posix/liblib__posix.a zephyr/subsys/fs/libsubsys__fs.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/sd/libsubsys__sd.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/net/ip/libsubsys__net__ip.a zephyr/subsys/net/lib/config/libsubsys__net__lib__config.a zephyr/drivers/disk/libdrivers__disk.a zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/ipm/libdrivers__ipm.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/reset/libdrivers__reset.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a modules/stm32/stm32cube/lib..__modules__hal__stm32__stm32cube.a modules/libmetal/libmetal/lib/libmetal.a modules/littlefs/libmodules__littlefs.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a modules/mbedtls/libmodules__mbedtls.a modules/open-amp/open-amp/lib/libopen_amp.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L"c:/users/murali.karicheri/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp" -LC:/xxxxx/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie && cmd.exe /C "cd /D C:\xxxx\build\zephyr && "C:\Program Files\CMake\bin\cmake.exe" -E echo "" c:/xxxxx/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/open-amp/open-amp/lib/libopen_amp.a(remoteproc_virtio.c.obj): in function `metal_io_read': C:xxxxx/build/modules/libmetal/libmetal/lib/include/metal/io.h:252: undefined reference to `__atomic_load_8' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'C:\xxxx\build'
murali.karicheri@sandc.com wrote:
Hi Experts, I have also posted this to zephyr dev mailing list and thought to add it here as well as it is related to OpenAMP. I tried it in v3.4.x version of Zephyr before the final v3.4.0 release. I am able to get the OpenAMP Bare-metal sample application work for core-to-core messaging using the STM32CubeIDE. We are using Zephyr in our project that interfaces with Bare-metal. The OpenAMP master runs on Bare-metal and it uses resource table. So I am working to enable the samples/subsys/openamp_rsc_table. I am able to build this sample for another STM32 board as west -v build -p always -b stm32mp157c_dk2 samples/subsys/ipc/openamp_rsc_table I have added the overlay and conf required to my project files and trying to build the sample and get the below linker error. As my target is also M4 on STM32H755 SoC, I believe I am missing some change to allow the metal_io_read() to be resolved to a proper library function. Some has suggested using set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic") per https://github.com/alexa/avs-device-sdk/issues/1404 I have tried to add it to the lib/openamp CMakeLists.txt but didn't help. Since this sample builds fine for stm32mp157c_dk2 , some build flag missing for my STM32H755 SoC??? Any help on this will be appreciated. Log here [362/372] Linking CXX executable zephyr\zephyr_pre0.elf FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/xxxx/build/zephyr/zephyr_pre0.map cmd.exe /C "cd . && C:\xxxx\zephyr-sdk-0.16.1\arm-zephyr-eabi\bin\arm-zephyr-eabi-g++.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -fuse-ld=bfd -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=C:/xxxxx/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/lib/posix/liblib__posix.a zephyr/subsys/fs/libsubsys__fs.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/sd/libsubsys__sd.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/net/ip/libsubsys__net__ip.a zephyr/subsys/net/lib/config/libsubsys__net__lib__config.a zephyr/drivers/disk/libdrivers__disk.a zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/ipm/libdrivers__ipm.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/reset/libdrivers__reset.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a modules/stm32/stm32cube/lib..__modules__hal__stm32__stm32cube.a modules/libmetal/libmetal/lib/libmetal.a modules/littlefs/libmodules__littlefs.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a modules/mbedtls/libmodules__mbedtls.a modules/open-amp/open-amp/lib/libopen_amp.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L"c:/users/murali.karicheri/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp" -LC:/xxxxx/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie && cmd.exe /C "cd /D C:\xxxx\build\zephyr && "C:\Program Files\CMake\bin\cmake.exe" -E echo "" c:/xxxxx/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/open-amp/open-amp/lib/libopen_amp.a(remoteproc_virtio.c.obj): in function `metal_io_read': C:xxxxx/build/modules/libmetal/libmetal/lib/include/metal/io.h:252: undefined reference to `__atomic_load_8' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'C:\xxxx\build'
The solution was provided by sergeyblagodarnyy at his github repo and I modified it to work with Zephyr as shown here in my comment https://github.com/Faramax/open-amp/commit/e9c0e2825135930ad5173d4237cf9c0b7...
ST Restricted
-----Original Message----- From: Murali Karicheri via Openamp-rp <openamp- rp@lists.openampproject.org> Sent: Tuesday, September 19, 2023 4:17 PM To: openamp-rp@lists.openampproject.org Subject: [Openamp-rp] Re: zephyr: samples/subsys/openamp_rsc_table on an STMH7 based board - libopen_amp.a(remoteproc_virtio.c.obj): in function `metal_io_read': build/modules/libmetal/libmetal/lib/include/metal/io.h:252: undefined reference to `__atomic_load_8'
murali.karicheri@sandc.com wrote:
Hi Experts, I have also posted this to zephyr dev mailing list and thought to add it here
as well as it is related to OpenAMP.
I tried it in v3.4.x version of Zephyr before the final v3.4.0 release. I am able to get the OpenAMP Bare-metal sample application work for core-to-core messaging using the STM32CubeIDE. We are using Zephyr in our project that interfaces with Bare-metal. The OpenAMP master runs on Bare-metal and it uses resource table. So I am working to enable the samples/subsys/openamp_rsc_table. I am able to build this sample for another STM32 board as west -v build -p always -b stm32mp157c_dk2 samples/subsys/ipc/openamp_rsc_table I have added the overlay and conf required to my project files and trying to build the sample and get the below linker error. As my target is also M4 on STM32H755 SoC, I believe I am missing some change to allow the metal_io_read() to be resolved to a proper library function. Some has suggested using set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic") per https://github.com/alexa/avs-device-sdk/issues/1404 I have tried to add it to the lib/openamp CMakeLists.txt but didn't help. Since
this sample builds fine for stm32mp157c_dk2 , some build flag missing for my STM32H755 SoC??? Any help on this will be appreciated.
Log here [362/372] Linking CXX executable zephyr\zephyr_pre0.elf FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/xxxx/build/zephyr/zephyr_pre0.map cmd.exe /C "cd . && C:\xxxx\zephyr-sdk-0.16.1\arm-zephyr-eabi\bin\arm-
zephyr-eabi-g++.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -fuse- ld=bfd -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,- Map=C:/xxxxx/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch3 2__cortex_m.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/lib/posix/liblib__posix.a zephyr/subsys/fs/libsubsys__fs.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/sd/libsubsys__sd.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/net/ip/libsubsys__net__ip.a zephyr/subsys/net/lib/config/libsubsys__net__lib__config.a zephyr/drivers/disk/libdrivers__disk.a zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/ipm/libdrivers__ipm.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/reset/libdrivers__reset.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a modules/stm32/stm32cube/lib..__modules__hal__stm32__stm32cube.a modules/libmetal/libmetal/lib/libmetal.a modules/littlefs/libmodules__littlefs.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a modules/mbedtls/libmodules__mbedtls.a modules/open-amp/open- amp/lib/libopen_amp.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a - L"c:/users/murali.karicheri/zephyr-sdk-0.16.1/arm-zephyr- eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp" - LC:/xxxxx/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a modules/mbedtls/libmbedTLSBase.a modules/mbedtls/libmbedTLSCrypto.a modules/mbedtls/libmbedTLSX509.a -mcpu=cortex-m4 -mthumb - mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,- -sort-common=descending -Wl,--sort-section=alignment -Wl,- u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N - Wl,--orphan-handling=warn -Wl,-no-pie && cmd.exe /C "cd /D C:\xxxx\build\zephyr && "C:\Program Files\CMake\bin\cmake.exe" -E echo ""
c:/xxxxx/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-
eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/open- amp/open-amp/lib/libopen_amp.a(remoteproc_virtio.c.obj): in function `metal_io_read':
C:xxxxx/build/modules/libmetal/libmetal/lib/include/metal/io.h:252:
undefined reference to `__atomic_load_8'
collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'C:\Program
Files\CMake\bin\cmake.EXE' --build 'C:\xxxx\build'
The solution was provided by sergeyblagodarnyy at his github repo and I modified it to work with Zephyr as shown here in my comment https://github.com/Faramax/open- amp/commit/e9c0e2825135930ad5173d4237cf9c0b76a31eed
To keep a trace in case the link becomes unavailable in the future, the proposed solution is:
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a36325689..801ee27e4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -65,5 +65,7 @@ else (WITH_ZEPHYR) endif (WITH_STATIC_LIB) endif (WITH_ZEPHYR)
+target_compile_definitions(${_lib} PRIVATE __STDC_NO_ATOMICS__) + install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/openamp" DESTINATION include) install (DIRECTORY "${PROJECT_BINARY_DIR}/include/generated/openamp" DESTINATION include)
To be integrated in open-amp it should probably be part of a new cmake config in https://github.com/OpenAMP/open-amp/tree/main/cmake/platforms
For zephyr, seems that the good place to declare it is https://elixir.bootlin.com/zephyr/latest/source/soc/arm/st_stm32/stm32h7/CMa... In addition " if(CMAKE_COMPILER_IS_GNUCXX)" condition could be used to differentiate C and C++.
Thanks, Arnaud
-- Openamp-rp mailing list -- openamp-rp@lists.openampproject.org To unsubscribe send an email to openamp-rp- leave@lists.openampproject.org
openamp-rp@lists.openampproject.org