Hi,
i am working with the following setup:
- nrf5340
- SDK 2.6.3
- Direct Test Mode example with serial communication
I see that DTM example has changed from 2.1.4 to 2.6.3, so that the communication with the netcore goes through the appcore (child image, remote_shell).
I wanted to avoid copying all the DTM example into my repo, so I managed to access its code by a CMakeLists.txt file that looks like this:
# CMakeLists.txt cmake_minimum_required(VERSION 3.20.0) # This to immediately characterize ZEPHYR_BASE find_package(Zephyr COMPONENTS extensions basic_settings) zephyr_get(USER_VAR) # Define the absolute path to the directory containing the DTM sample in the installed SDK cmake_path(SET DTM_PATH NORMALIZE "${ZEPHYR_BASE}/../nrf/samples/bluetooth/direct_test_mode/") message(STATUS "DTM_PATH=${DTM_PATH}") # To compile the Direct Test Mode example directly from the SDK without copying, it is necessary to specify: # 1. The configuration files for netcore and appcore (CONF_FILE) # 2. The device tree overlay files for netcore and appcore(DTC_OVERLAY_FILE) # 3. The KConfig file only for the netcore (KCONFIG_ROOT) set(CONF_FILE ${DTM_PATH}prj.conf; ${DTM_PATH}boards/nrf5340dk_nrf5340_cpunet.conf CACHE INTERNAL "Configuration files for netcore") set(DTC_OVERLAY_FILE ${DTM_PATH}boards/nrf5340dk_nrf5340_cpunet.overlay; ${DTM_PATH}conf/remote_shell_nrf53.overlay remote_shell_cpunet.overlay # Local file to change the TX and RX pin of UART CACHE INTERNAL "Devicetree overlays for netcore") set(KCONFIG_ROOT "${DTM_PATH}KConfig") set(remote_shell_CONF_FILE ${DTM_PATH}child_image/remote_shell/prj.conf CACHE INTERNAL "Configuration files for appcore") set(remote_shell_DTC_OVERLAY_FILE ${DTM_PATH}child_image/remote_shell/boards/nrf5340dk_nrf5340_cpuapp.overlay; ${CMAKE_CURRENT_SOURCE_DIR}/remote_shell_cpuapp.overlay # Local file to change the TX and RX pin of UART CACHE INTERNAL "Devicetree overlay for appcore") find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(dtm) # Import the SDK's sample as your source add_subdirectory(${ZEPHYR_NRF_MODULE_DIR}/samples/bluetooth/direct_test_mode app)
My project directory looks like this:
remote_shell_cpu*.overlay files are the one used to changed the tx and rx pin of the uart (they both includes remote_shell_pinctrl.dtsi)
In this configuration, i can build the DTM example and i can test it on my custom board.
Question 1: is this a good approach ? is there another better, maybe by using the sysbuild ?
I would like to know if it is possible with the describe configuration (no copy of the example), inject some code into the child image of the DTM example, that is the app core.
I dont want to redefine the main function of the code running on the app_core (remote_shell). I was thinking to create a small thread where i can perform just a couple of configuration/initialization that we need on our custom board. Like, creating the file app_core_thread.c as follows:
#include <zephyr/kernel.h>
static void my_thread_fn(void *p1, void *p2, void *p3) {
(void) p1;
(void) p2;
(void) p3;
//Perfom customization
// let the task be deleted
}
K_THREAD_DEFINE(my_thread_id, 256, my_thread_fn, NULL, NULL, NULL, 10, 0, 0);
I tried several approaches but none of them worked.
Question 2: is there a way to inject code in an child image (in this case, the remote shell of DTM example) based on the configuration described above (no hard copy of the example in my repo) ?
Thanks in advance for your support.
Kind regards
Riccardo Gaiati