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

  • 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

Related