Hi, I am trying to run the RPMSG-Lite on bare metal M4. The two rpmsg examples in the MCUXpresso SDK are built with freeRTOS. Extracting the code is not the problem, but the build process is, because all the cmake settings and includes are set for FreeRTOS and not bare-metal.
Only example I could find using bare metal was this one, but it uses a different (older) template of cmake files and older rpmsg version, so it is hard to translate. From the RPMsg-Lite Users’s Guide it is explained that rpmsg_env_bm.c should be used instead of rpmsg_env_freertos.c. But the things are a bit complicated that that. Going from the boards\evkmimx8mm\multicore_examples\rpmsg_lite_str_echo_rtos example, the rpmsg folder under middleware\multicore, has a few cmake files to be included as modules inside CMakeLists.txt:
middleware_multicore_rpmsg_lite_imx8mm_m4_freertos_MIMX8MM6
middleware_multicore_rpmsg_lite_freertos_MIMX8MM6
middleware_multicore_rpmsg_lite_MIMX8MM6
The last few lines of the last cmake file:
if(CONFIG_USE_middleware_multicore_rpmsg_lite_freertos_MIMX8MM6)
include(middleware_multicore_rpmsg_lite_freertos_MIMX8MM6)
endif()
if(CONFIG_USE_middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
include(middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
endif()
if(NOT (CONFIG_USE_middleware_multicore_rpmsg_lite_freertos_MIMX8MM6 OR CONFIG_USE_middleware_multicore_rpmsg_lite_bm_MIMX8MM6))
message(WARNING "Since middleware_multicore_rpmsg_lite_freertos_MIMX8MM6/middleware_multicore_rpmsg_lite_bm_MIMX8MM6 is not included at first or config in config.cmake file, use middleware_multicore_rpmsg_lite_bm_MIMX8MM6 by default.")
include(middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
endif()
Imply that there should also be an middleware_multicore_rpmsg_lite_bm_MIMX8MM6 file. It does not exist though. I tried creating one analogous to the freertos file (also changing the config.cmake accordingly), but I am still stuck at an build error:
c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/main.elf.dir/C_/workspace/Verdin/multicore/rpmsg_lite/lib/rpmsg_lite/rpmsg_queue.c.obj: in function `rpmsg_queue_rx_cb':
C:\workspace\Verdin\multicore\rpmsg_lite\lib\rpmsg_lite/rpmsg_queue.c:47: undefined reference to `env_put_queue'
c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/main.elf.dir/C_/workspace/Verdin/multicore/rpmsg_lite/lib/rpmsg_lite/rpmsg_queue.c.obj: in function `rpmsg_queue_create':
C:\workspace\Verdin\multicore\rpmsg_lite\lib\rpmsg_lite/rpmsg_queue.c:77: undefined reference to `env_create_queue'
c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/main.elf.dir/C_/workspace/Verdin/multicore/rpmsg_lite/lib/rpmsg_lite/rpmsg_queue.c.obj: in function `rpmsg_queue_recv_nocopy':
C:\workspace\Verdin\multicore\rpmsg_lite\lib\rpmsg_lite/rpmsg_queue.c:179: undefined reference to `env_get_queue'
Those are all function that are contained inside of rpmsg_env.h file, that should be included. To make it less complicated, the 3 modified cmake module files I’m adding to my CmakeLists file would look like this:
###middleware_multicore_rpmsg_lite_imx8mm_m4_bm_MIMX8MM6####
include_guard()
message("middleware_multicore_bm_lite_bm component is included.")
target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/porting/environment/rpmsg_env_bm.c
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/rpmsg_queue.c
)
target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/include/environment/bm
)
######middleware_multicore_rpmsg_lite_MIMX8MM6######
include_guard()
message("middleware_multicore_rpmsg_lite component is included.")
target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/common/llist.c
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/rpmsg_lite.c
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/rpmsg_ns.c
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/virtio/virtqueue.c
)
target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/include
)
#OR Logic component
if(CONFIG_USE_middleware_multicore_rpmsg_lite_freertos_MIMX8MM6)
include(middleware_multicore_rpmsg_lite_freertos_MIMX8MM6)
endif()
if(CONFIG_USE_middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
include(middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
endif()
if(NOT (CONFIG_USE_middleware_multicore_rpmsg_lite_freertos_MIMX8MM6 OR CONFIG_USE_middleware_multicore_rpmsg_lite_bm_MIMX8MM6))
message(WARNING "Since middleware_multicore_rpmsg_lite_freertos_MIMX8MM6/middleware_multicore_rpmsg_lite_bm_MIMX8MM6 is not included at first or config in config.cmake file, use middleware_multicore_rpmsg_lite_bm_MIMX8MM6 by default.")
include(middleware_multicore_rpmsg_lite_bm_MIMX8MM6)
endif()
######middleware_multicore_rpmsg_lite_bm_MIMX8MM6###############
include_guard()
message("middleware_multicore_bm_lite_bm component is included.")
target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/porting/environment/rpmsg_env_bm.c
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/rpmsg_lite/rpmsg_queue.c
)
target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rpmsg_lite/lib/include/environment/bm
)
If you take a look at the example code, this is almost the same as the freertos system apart from two module imports:
include(middleware_freertos-kernel_MIMX8MM6)
include(middleware_freertos-kernel_heap_4_MIMX8MM6)
I guess I shouldn’t import them since I’m not using freertos.
There is a lot of additional info, please ask for details if something is left unclear.
Thanks in advance!