Custom nRF5340 Board in NCS

Last year i asked about a custom nRF5340 board when using NCS V1.7.0 and the comment was to just copy the entire nRF5340DK into my custom board folder and modify the names to match my board.

With V1.9.1 and VSC with the option to "Create a New Board" has there been any optimization in this method.

Is it still suggested to just create a folder and copy the DK board files or can i create a board through VSC for the nRF5340?

BTW.  I have tried using VSC with the nRF5340 and have been unsuccessful

Parents
  • Hey Wes, 

    Unfortunately, I will have to get back to you next week.

    I have tried using VSC with the nRF5340 and have been unsuccessful

    What issues are you running into? Is bt_ready() not returning like in this case, or are you not able to build a project with a custom board? 

    Regards,

    Elfving

  • i cannot get it to build.  So what i did was create a new board and selsct the nRF5340_cpuapp_ns as the base.  I then copied what i thought i would need from the nRF5340_cpuapp_common.dts into my test5340.dts.  when i compile i get the following error about a DTS error with sram0_sherd

    west build --build-dir c:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution\build c:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution --pristine --board test5340_ns -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="c:/Users/Wes/Documents/Nordic/MyProjects;c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution;c:/Users/Wes/Documents/Nordic/MyProjects/Blog_LowPower;c:/Users/Wes/ncs/v1.9.1/nrf/applications/asset_tracker_v2" -DCONF_FILE:STRING="c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution/prj.conf"
    
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution
    -- Found Python3: C:/Users/Wes/ncs/v1.9.1/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Cache files will be written to: C:/Users/Wes/ncs/v1.9.99-dev1/zephyr/.cache
    -- Zephyr version: 3.0.99 (C:/Users/Wes/ncs/v1.9.99-dev1/zephyr)
    -- Found west (found suitable version "0.12.0", minimum required is "0.7.1")
    CMake Warning at C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\cmake\modules\boards.cmake:85 (message):
      BOARD_ROOT element without a 'boards' subdirectory:
    
      c:/Users/Wes/Documents/Nordic/MyProjects
    
      Hints:
    
        - if your board directory is '/foo/bar/boards/<ARCH>/my_board' then add '/foo/bar' to BOARD_ROOT, not the entire board directory
        - if in doubt, use absolute paths
    Call Stack (most recent call first):
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\cmake\modules\zephyr_default.cmake:121 (include)
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:45 (include)
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:70 (include_boilerplate)
      c:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution\build\CMakeLists.txt:4 (find_package)
    
    
    -- Board: test5340_ns
    -- Found dtc: C:/Users/Wes/ncs/v1.9.1/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: gnuarmemb (c:/Users/Wes/ncs/v1.9.1/toolchain/opt)
    -- Found BOARD.dts: C:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution/boards/arm/test5340_ns/test5340_ns.dts
    devicetree error: /soc/peripheral@40000000/ipc0: undefined node label 'sram0_shared'
    CMake Error at C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\cmake\modules\dts.cmake:212 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\cmake\modules\zephyr_default.cmake:121 (include)
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:45 (include)
      C:\Users\Wes\ncs\v1.9.99-dev1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:70 (include_boilerplate)
      c:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution\build\CMakeLists.txt:4 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'c:\Users\Wes\ncs\v1.9.1\toolchain\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\Users\Wes\ncs\v1.9.1\toolchain\opt\bin\python.exe' '-Bc:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution\build' '-Sc:\Users\Wes\Documents\Nordic\MyProjects\fund_less2_exer2_solution' -GNinja -DBOARD=test5340_ns -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=c:/Users/Wes/Documents/Nordic/MyProjects;c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution;c:/Users/Wes/Documents/Nordic/MyProjects/Blog_LowPower;c:/Users/Wes/ncs/v1.9.1/nrf/applications/asset_tracker_v2' -DCONF_FILE:STRING=c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution/prj.conf
    The terminal process terminated with exit code: 1.

  • > Found Python3: C:/Users/Wes/ncs/v1.9.1/toolchain/opt/bin/python.exe

    > Cache files will be written to: C:/Users/Wes/ncs/v1.9.99-dev1/zephyr/.cache

    First of all, it seems to me that you are running the Master branch SDK along with the NCS 1.9.1 toolchain. Is this on purpose?

    > BOARD_ROOT element without a 'boards' subdirectory

    This also gives the impression that you might have saved the board to another directory, or modified the BOARD_ROOT.

    Are you able to build a basic hello world sample with a new default 5340 board? (ie. nothing added besides what comes with its creation in VSC).

    Regards,

    Elfving

  • Sorry for the delay I was working on other things.  

    So I was working on Main with NCS 1.9.1 toolchain for LE Audio.

    but i changed my environment to just use NCS 1.9.1 and Toolchain 1.9.1

    my custom board directory is created outside of NCS folder

    I was using zephyr/samples/basic/button and created a custom nRF5340_cpuapp_ns board.

    if i make no modifications to the custom generated DTS file it will not compile because there are DT nodes with Aliases that are used in main.c

    if i look at the nRF5340_cpuapp_common.dts and copy elements of that dts into the custom board that have the button nodes and aliases, i get many more error of the type

    C:\Users\Wes\ncs\v1.9.1\zephyr\include\toolchain\gcc.h:61:36: error: static assertion failed: ""
    61 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)

    also i get this

    CMake Warning at C:\Users\Wes\ncs\v1.9.1\zephyr\cmake\app\boilerplate.cmake:241 (message):
    BOARD_ROOT element without a 'boards' subdirectory:

    c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution

    Hints:

    - if your board directory is '/foo/bar/boards/<ARCH>/my_board' then add '/foo/bar' to BOARD_ROOT, not the entire board directory
    - if in doubt, use absolute paths

    Do i need to modify the boilerplate to look for custom boards in the other directory?

    looking for advice to create a custom board

  • So I moved to NCS V2.0.0

    I started by creating a new board and locating the board directory outside of NCS.  I then added some elements of the nrf5340_cpuapp_common_ns.dts to my Custom5340_cpuapp_ns.dts.  I have attached my custom dts for reference.  Here is the error I get.

    Found host-tools: zephyr 0.14.1 (C:/Users/Wes/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found dtc: C:/Users/Wes/ncs/toolchains/v2.0.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/Users/Wes/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/Users/Wes/Documents/Nordic/MyProjects/boards/arm/custom5340_cpuapp_ns/custom5340_cpuapp_ns.dts
    -- Found devicetree overlay: c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/nrf5340dk_nrf5340_cpuapp_ns.overlay
    devicetree error: /ipc/ipc0: undefined node label 'sram0_shared'
    CMake Error at C:\Users\Wes\ncs\v2.0.0\zephyr\cmake\modules\dts.cmake:213 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      C:\Users\Wes\ncs\v2.0.0\zephyr\cmake\modules\zephyr_default.cmake:121 (include)
      C:\Users\Wes\ncs\v2.0.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:51 (include)
      C:\Users\Wes\ncs\v2.0.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:76 (include_boilerplate)
      c:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed\build_test\CMakeLists.txt:4 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'c:\Users\Wes\ncs\toolchains\v2.0.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\Users\Wes\ncs\toolchains\v2.0.0\opt\bin\python.exe' '-Bc:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed\build_test' '-Sc:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed' -GNinja -DBOARD=custom5340_cpuapp_ns -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=c:/Users/Wes/Documents/Nordic/MyProjects;c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution;c:/Users/Wes/ncs/v2.0.0/zephyr/samples/bluetooth/peripheral_hr' -DCONF_FILE:STRING=c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/prj.conf -DDTC_OVERLAY_FILE:STRING=c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/nrf5340dk_nrf5340_cpuapp_ns.overlay
    The terminal process terminated with exit code: 1.

    my DTS:

    /dts-v1/;
    #include <nordic/nrf5340_cpuappns_qkaa.dtsi>
    
    / {
    	model = "Custom5340_cpuapp_ns";
    	compatible = "wescherry,custom5340-cpuapp-ns";
    
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_ns_partition;
    	};
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
    			label = "Green LED 0";
    		};
    		led1: led_1 {
    			gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
    			label = "Green LED 1";
    		};
    		led2: led_2 {
    			gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
    			label = "Green LED 2";
    		};
    		led3: led_3 {
    			gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
    			label = "Green LED 3";
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = <&gpio0 23 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 1";
    		};
    		button1: button_1 {
    			gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 2";
    		};
    		button2: button_2 {
    			gpios = <&gpio0 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 3";
    		};
    		button3: button_3 {
    			gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 4";
    		};
    	};
    	aliases {
    		led0 = &led0;
    		led1 = &led1;
    		led2 = &led2;
    		led3 = &led3;
    		pwm-led0 = &pwm_led0;
    		sw0 = &button0;
    		sw1 = &button1;
    		sw2 = &button2;
    		sw3 = &button3;
    		bootloader-led0 = &led0;
    	};
    
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x0 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    			reg = <0x10000 0x40000>;
    		};
    		slot0_ns_partition: partition@50000 {
    			label = "image-0-nonsecure";
    			reg = <0x50000 0x30000>;
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    			reg = <0x80000 0x40000>;
    		};
    		slot1_ns_partition: partition@c0000 {
    			label = "image-1-nonsecure";
    			reg = <0xc0000 0x30000>;
    		};
    		scratch_partition: partition@f0000 {
    			label = "image-scratch";
    			reg = <0xf0000 0xa000>;
    		};
    		storage_partition: partition@fa000 {
    			label = "storage";
    			reg = <0xfa000 0x6000>;
    		};
    	};
    };
    
    

Reply
  • So I moved to NCS V2.0.0

    I started by creating a new board and locating the board directory outside of NCS.  I then added some elements of the nrf5340_cpuapp_common_ns.dts to my Custom5340_cpuapp_ns.dts.  I have attached my custom dts for reference.  Here is the error I get.

    Found host-tools: zephyr 0.14.1 (C:/Users/Wes/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found dtc: C:/Users/Wes/ncs/toolchains/v2.0.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/Users/Wes/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/Users/Wes/Documents/Nordic/MyProjects/boards/arm/custom5340_cpuapp_ns/custom5340_cpuapp_ns.dts
    -- Found devicetree overlay: c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/nrf5340dk_nrf5340_cpuapp_ns.overlay
    devicetree error: /ipc/ipc0: undefined node label 'sram0_shared'
    CMake Error at C:\Users\Wes\ncs\v2.0.0\zephyr\cmake\modules\dts.cmake:213 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      C:\Users\Wes\ncs\v2.0.0\zephyr\cmake\modules\zephyr_default.cmake:121 (include)
      C:\Users\Wes\ncs\v2.0.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:51 (include)
      C:\Users\Wes\ncs\v2.0.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:76 (include_boilerplate)
      c:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed\build_test\CMakeLists.txt:4 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'c:\Users\Wes\ncs\toolchains\v2.0.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\Users\Wes\ncs\toolchains\v2.0.0\opt\bin\python.exe' '-Bc:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed\build_test' '-Sc:\Users\Wes\Documents\Nordic\MyProjects\SterlingMed' -GNinja -DBOARD=custom5340_cpuapp_ns -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=c:/Users/Wes/Documents/Nordic/MyProjects;c:/Users/Wes/Documents/Nordic/MyProjects/fund_less2_exer2_solution;c:/Users/Wes/ncs/v2.0.0/zephyr/samples/bluetooth/peripheral_hr' -DCONF_FILE:STRING=c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/prj.conf -DDTC_OVERLAY_FILE:STRING=c:/Users/Wes/Documents/Nordic/MyProjects/SterlingMed/nrf5340dk_nrf5340_cpuapp_ns.overlay
    The terminal process terminated with exit code: 1.

    my DTS:

    /dts-v1/;
    #include <nordic/nrf5340_cpuappns_qkaa.dtsi>
    
    / {
    	model = "Custom5340_cpuapp_ns";
    	compatible = "wescherry,custom5340-cpuapp-ns";
    
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_ns_partition;
    	};
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
    			label = "Green LED 0";
    		};
    		led1: led_1 {
    			gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
    			label = "Green LED 1";
    		};
    		led2: led_2 {
    			gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
    			label = "Green LED 2";
    		};
    		led3: led_3 {
    			gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
    			label = "Green LED 3";
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = <&gpio0 23 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 1";
    		};
    		button1: button_1 {
    			gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 2";
    		};
    		button2: button_2 {
    			gpios = <&gpio0 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 3";
    		};
    		button3: button_3 {
    			gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Push button 4";
    		};
    	};
    	aliases {
    		led0 = &led0;
    		led1 = &led1;
    		led2 = &led2;
    		led3 = &led3;
    		pwm-led0 = &pwm_led0;
    		sw0 = &button0;
    		sw1 = &button1;
    		sw2 = &button2;
    		sw3 = &button3;
    		bootloader-led0 = &led0;
    	};
    
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x0 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    			reg = <0x10000 0x40000>;
    		};
    		slot0_ns_partition: partition@50000 {
    			label = "image-0-nonsecure";
    			reg = <0x50000 0x30000>;
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    			reg = <0x80000 0x40000>;
    		};
    		slot1_ns_partition: partition@c0000 {
    			label = "image-1-nonsecure";
    			reg = <0xc0000 0x30000>;
    		};
    		scratch_partition: partition@f0000 {
    			label = "image-scratch";
    			reg = <0xf0000 0xa000>;
    		};
    		storage_partition: partition@fa000 {
    			label = "storage";
    			reg = <0xfa000 0x6000>;
    		};
    	};
    };
    
    

Children
  • I've got the same compilation error. I add some lines to define sram0_shared and now it complies: 

    / {
    	model = "XX";
    	compatible = "XX,XX-v1-0-0";
    
        chosen {
            zephyr,sram = &sram0;
            zephyr,flash = &flash0;
            zephyr,code-partition = &slot0_partition;
            zephyr,ipc_shm = &sram0_shared; 
        };
    	
        reserved-memory {
            #address-cells = <1>;
            #size-cells = <1>;
            ranges;
    
    
            //sram0_ns: image_ns@20000000 {
                /* Non-Secure image memory */
            //};
            sram0_shared: memory@20070000 {
                /* SRAM allocated to shared memory */
                reg = <0x20070000 0x10000>;
            };
        };
    };

    Hope that's helped.

Related