nRF5340 how to Direct test mode in NCS2.0

Hello

NCS2.0.2, nRF5340+nRF21540,  vscode

hwo to do Direct test mode with MT8852B? (PS: i konw how to test nRF52840)

i open the demo from:

C:\ncs\v2.0.2\nrf\samples\bluetooth\direct_test_mode

and add code to open 21540 to 20dB like this,

	gpio_pin_configure_dt(&sp_pdn_21540, GPIO_OUTPUT_ACTIVE);
	gpio_pin_set_dt(&sp_pdn_21540,1);		// high
		gpio_pin_configure_dt(&sp_csn_21540, GPIO_OUTPUT_ACTIVE);
		gpio_pin_set_dt(&sp_csn_21540,1);	// high
	gpio_pin_configure_dt(&sp_rxen_21540, GPIO_OUTPUT_ACTIVE);
	gpio_pin_set_dt(&sp_rxen_21540,1);		// high  enabled
		gpio_pin_configure_dt(&sp_mode_21540, GPIO_OUTPUT_ACTIVE);
		gpio_pin_set_dt(&sp_mode_21540,0);	// low  TX_Gain=POUTA(20dB)
	gpio_pin_configure_dt(&sp_antsel_21540, GPIO_OUTPUT_ACTIVE);
	gpio_pin_set_dt(&sp_antsel_21540,0);	// low ANT1
		gpio_pin_configure_dt(&sp_txen_21540, GPIO_OUTPUT_ACTIVE);
		gpio_pin_set_dt(&sp_txen_21540,1);	// high  enabled


	printk("Starting Direct Test Mode example\n");

nRF5340 is two core, is should choose cpuapp or cpunet? if choose cpuapp, the net core no hex.

   

build cpuapp or cpuapp_ns

  dtm.c:2118:24: error: 'RADIO_IRQn' undeclared

   

update SDK to NCS2.3.0 build error:

(PS:cpoy new project C:\ncs\v2.3.0\nrf\samples\bluetooth\direct_test_mode,   don't chang any code)

build cpuapp or cpuapp_ns

dtm.c:2185:35: error: 'NRF_RADIO' undeclared

build cpunet

main.c:73: undefined reference to `__device_dts_ord_66'

   

Best regards

Parents
  • From Bluetooth: Direct Test Mode docs, this sample supports the following boards:

    nrf5340dk_nrf5340_cpunet or nrf21540dk_nrf52840.

    Regards,
    Sigurd Hellesvik

  • Hi,  thanks for reply,

    I have checked your link.

    is means:

    build \nrf\samples\bluetooth\direct_test_mode as nrf5340dk_nrf5340_cpunet, and download to net core,

    app core no hex or download emptyapp(such as helloworld)?

    if need set a pin to high for open peripheral power, it should write to app core or net core?

          

    Best regards

  • Hi,

    thanks,   i'v got it,

    \nrf\samples\bluetooth\direct_test_mode

    add two lines to prj.conf

    CONFIG_PARTITION_MANAGER_ENABLED=y
    CONFIG_NCS_SAMPLE_REMOTE_SHELL_CHILD_IMAGE=y
        
    add config to Kconfig file
    config NCS_SAMPLE_REMOTE_SHELL_CHILD_IMAGE  
    	bool "for REMOTE_SHELL_CHILD_IMAGE"
    	default y
    	help
    	   build remote_shell zephyr for app core.
    

    got hex:  "\direct_test_mode\build\remote_shell\zephyr\merged_CPUAPP.hex"

    add forwarder to  \child_image\remote_shell.overlay

    gpio_fwd: nrf-gpio-forwarder {
    	compatible = "nordic,nrf-gpio-forwarder";
    	nrf21540-gpio-if {
    	  gpios = <&gpio1 11 0>, <&gpio1 12 0>, <&gpio1 5 0>, <&gpio1 4 0>, <&gpio1 6 0>, <&gpio1 7 0>  , <&gpio0 0x14 0>, <&gpio0 0x16 0>    , <&gpio0 0x18 0>, <&gpio0 0x10 0>, <&gpio0 27 0>;
    	};
      };
      

    add forwarder to  \boards\nrf5340dk_nrf5340_cpunet.overlay

    &pinctrl {
    	uart1_default_alt: uart1_default_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 0x14)>,
    					<NRF_PSEL(UART_RX, 0, 0x16)>;
    		};
    	};
    	uart1_sleep_alt: uart1_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 0x14)>,
    					<NRF_PSEL(UART_RX, 0, 0x16)>;
    			low-power-enable;
    		};
    	};
    };
    
    
    &uart0 {
    	status = "okay";
    	current-speed = <19200>;
    	pinctrl-0 = <&uart1_default_alt>;
    	pinctrl-1 = <&uart1_sleep_alt>;
    };
    
    &radio {
    	status = "okay";
    	/* This is a number of antennas that are available on antenna matrix
    	 * designed by Nordic. For more information see README.rst.
    	 */
    	dfe-antenna-num = <12>;
    	/* This is a setting that enables antenna 12 (in antenna matrix designed
    	 * by Nordic) for PDU. For more information see README.rst.
    	 */
    	dfe-pdu-antenna = <0x0>;
    
    	/* These are GPIO pin numbers that are provided to
    	 * Radio peripheral. The pins will be acquired by Radio to
    	 * drive antenna switching.
    	 * Pin numbers are selected to drive switches on antenna matrix
    	 * desinged by Nordic. For more information see README.rst.
    	 */
    	dfegpio0-gpios = <&gpio0 4 0>;
    	dfegpio1-gpios = <&gpio0 5 0>;
    	dfegpio2-gpios = <&gpio0 6 0>;
    	dfegpio3-gpios = <&gpio0 7 0>;
    };
    nrf_radio_fem: nrf21540 {
    	compatible = "nordic,nrf21540-fem";
    	pdn-gpios   = <&gpio1 11 GPIO_ACTIVE_HIGH>;
    	csn-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
    	rx-en-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
    	mode-gpios  = <&gpio1 4 GPIO_ACTIVE_HIGH>;
    	antsel-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
    	tx-en-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
    	// uart
    	uart-tx-gpios = <&gpio0 0x14 GPIO_ACTIVE_HIGH>;
    	uart-rx-gpios = <&gpio0 0x16 GPIO_ACTIVE_HIGH>;
    	// power
    	power-1v8-gpios = <&gpio0 0x18 GPIO_ACTIVE_HIGH>;
    	power-sd-gpios = <&gpio0 0x10 GPIO_ACTIVE_HIGH>;
    	// led
    	ui-led-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
    };
    
      

    above forwarder contain (21540 pins, uart pins, power pins, led pins)

    i'm not sure if it's correct. build error:

                             

    Best regards

  • It is a dts syntax error.

    Do you want to create a new node, or edit an existing node?

    New node required "/ {":

    / {
        nrf_radio_fem: nrf21540 {
      
    };
    

    But if you want to modify an existing node, you must use "&":

    nrf_radio_fem: &nrf21450

    Also, when I search for this in the nRF Connect SDK, I find it to be nrf21540_fem.
    Not sure how which one you should use, but maybe worth looking into?

    Regards,
    Sigurd Hellesvik

  • Hi, thanks for reply

    if add \child_image\remote_shell.overlay, even a empty file, it will got build error:

    C:\ncs\v2.0.2\zephyr\include\zephyr\device.h:96:39: error: '__device_dts_ord_DT_CHOSEN_zephyr_shell_ipc_ORD' undeclared (first use in this function)
    96 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)

          direct_test_mode.rar

    see rar file

            

    Best regards

  • I get another error when I try to build the project you uploaded.

    Can you give instructions to how to build the project?
    Which nRF Connect version?
    Which board?

    Any extra build arguments?

    Regards,
    Sigurd Hellesvik

  • Hi

    Windows10 X64

    NCS2.0.2

    VsCode 1.77.3

    nRF Connect for VS Code     v2023.4.179

    board: nRF5340-DK+nRF21540-EK

    no extra build arguments,

       

    Best regards

Reply Children
  • yoyou said:

    When I build this project, with the configurations you mention, I get the following error:

    === child image empty_app_core - CPUAPP end ===
    
    CMake Error at /home/sihe/ncs/nrf/cmake/multi_image.cmake:193 (message):
      A domain may only have a single child image.Current domain image is:
      empty_app_core, `empty_app_core` is a domain parent image, so you may add
      `remote_shell` as a child inside `empty_app_core`
    Call Stack (most recent call first):
      /home/sihe/ncs/nrf/cmake/multi_image.cmake:150 (add_child_image_from_source)
      /home/sihe/ncs/nrf/samples/CMakeLists.txt:97 (add_child_image)

    Is the project supposed to build successfully out of the box?

    Regards,
    Sigurd Hellesvik

  • Hi

    if delete the file and folder of "\child_image\remote_shell.overlay",will build successed.

    bese on C:\ncs\v2.0.2\nrf\samples\bluetooth\direct_test_mode, i only want control follow pins in cpunet.

    Why is it so difficult.  can you provide useful examples? (ncs2.0.2 or ncs2.3.0)

         

    i'm testing DTM on board: nRF5340-DK+nRF21540-EK,

    in fact, my product is a headphone that needs to be powered on through these pins to work

           

    thanks

    Best regards

  • Let's take one step back:

    First, to build with the nRF-21540, we also must include "-DSHIELD=nrf21540_ek" to the build. See DTM docs.

    Also, in v2.2.0 and above of the nRF Connect SDK, we have a Kconfig to DB for the nRF21540 in DTM: MPSL_FEM_NRF21540_TX_GAIN_DB.

    If it is possible for you, upgrading to v2.2.0 is probably easier for setting DB.

    Regards,
    Sigurd Hellesvik

  • Hi

    chang to nRF Connect SDK 2.3.0

    copy bese on  C:\ncs\v2.3.0\nrf\samples\bluetooth\direct_test_mode

    if add -DSHIELD:STRING="nrf21540_ek", will build error!

    do DTM on 5340,it take me a lot of time.

    can you provide a complete project zip(contain build folder) bese on ncs2.3.0  direct_test_mode

    and control follow pins in cpunet?

    #ifdef FOR_TX
    	nrf_gpio_cfg_output(0x1e);
    	nrf_gpio_pin_set(0x1e);
    		nrf_gpio_cfg_output(0x15);
    		nrf_gpio_pin_set(0x15);
    	nrf_gpio_cfg_output(0x29);
    	nrf_gpio_pin_set(0x29);
    		nrf_gpio_cfg_output(0x19);
    		nrf_gpio_pin_clear(0x19);
    #else
    	nrf_gpio_cfg_output(0x18);
    	nrf_gpio_pin_clear(0x18);
    	nrf_gpio_cfg_output(0x10);
    	nrf_gpio_pin_set(0x10);
    #endif
    	nrf_gpio_cfg_output(0x2b);//21540  pdn
    	nrf_gpio_pin_set(0x2b);
    		nrf_gpio_cfg_output(0x2c);//csn
    		nrf_gpio_pin_set(0x2c);//high not ctrl spi
    	nrf_gpio_cfg_output(0x25);//rxen
    	nrf_gpio_pin_set(0x25);
    		nrf_gpio_cfg_output(0x24);//mode
    		nrf_gpio_pin_clear(0x24);
    	nrf_gpio_cfg_output(0x26);//antsel
    	nrf_gpio_pin_clear(0x26);
    		nrf_gpio_cfg_output(0x27);//txen
    		nrf_gpio_pin_set(0x27);

      

    Best regards

  • 7288.direct_test_mode.zip

    This sample builds for me with v2.3.0 without issue.

    Build log end:

    Regards,
    Sigurd Hellesvik

Related