Building a DTS file

Hello,

I have a custom board which has an nrf5340 on it. We are using nRF Connect/Zephyr in this project. Currently the board has a pretty simple interface seen in my overlay file below

/ {
    zephyr,user {
        dac = <&mcp4728>;
        dac-resolution = <12>;
    };

    power_rail_3v3: power_rail_3v3 {
        compatible = "power-switch";
        gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
    };

    power_rail_24v: power_rail_24v {
        compatible = "power-switch";
        gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
    };

    debug_led_blue: debug_led_blue {
        compatible = "power-switch";
        gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
    };

    debug_led_green: debug_led_green {
        compatible = "power-switch";
        gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
    };
};

&gpio_fwd {
    status = "disabled";
};

&spi2 {
    status = "disabled";
};

&spi4 {
    status = "disabled";
};

&uart2 {
    status = "disabled";
};

&i2c2 {
    pinctrl-0 = <&i2c2_default>;
    pinctrl-1 = <&i2c2_sleep>;
    pinctrl-names = "default", "sleep";

    status = "okay";
    // See https://docs.zephyrproject.org/latest/build/dts/api/bindings/dac/microchip%2Cmcp4728.html
    mcp4728: dac@60 {
        compatible = "microchip,mcp4728";
        reg = <0x60>;  // I2C address of the MCP4728
        voltage_reference = <0>; // 0 - Vdd
        #io-channel-cells = <1>;
        power_down_mode = <0>; // 0 - normal mode
    };
};

&gpio1 {
    status = "okay";
};

&pinctrl {
    i2c2_default: i2c2_default {
        group1 {
            psels = <NRF_PSEL(TWIM_SCL, 1, 6)>,  // Example: P1.06 for SCL
                    <NRF_PSEL(TWIM_SDA, 1, 7)>;  // Example: P1.07 for SDA
        };
    };

    i2c2_sleep: i2c2_sleep {
        group1 {
            psels = <NRF_PSEL(TWIM_SCL, 1, 6)>,
                    <NRF_PSEL(TWIM_SDA, 1, 7)>;
            low-power-enable;
        };
    };
};


This works, however it relies on using the nrf5340dk_nrf5340_cpuapp board target (found in "<nRF Connect DIR>\zephyr\boards\arm\nrf5340dk_nrf5340"). I am working on building our own DTS file but it is not clear to me which files from Nordic I can/should re-use vs. the files I need to make myself. For instance looking in the build directory for the nrf3240dk (mentioned above) there are 21 .dtsi, .dts, .yaml, and other files. If there is documentation outlining how to do this then I would love to see it as I would rather not start from scratch. For instance, it seems like a lot of memory/flash planning is already done using "nrf5340_cpuapp_partition_conf.dtsi" and "nrf5340_shared_sram_planning_conf.dtsi"... however "nrf5340_cpuapp_common-pinctrl.dtsi" for example has nothing I would like to use since my pinctrl definitions will be completely different for my board.

I would appreciate more guidance here. Specifically, what configuration parameters are the same for all nrf5340 MCUs (or are there none) that I can and SHOULD copy from Nordic examples?

Thank you,
Louis

Parents Reply
  • Yes this is precisely what I was looking for thank you very much.

    In Exercise 2 of that tutorial they do not use the "create a new board" GUI in nRF Connect for VSCode. Since we are using an nRF5340 we would be following Exercise 2 in order to create a board, however I can see the nrf5340 in the "Create a new board" GUI and I'm wondering if I can just use this to create my board? Will this not properly generate the board files to be configured for the multi-core or Trusted Firmware-M as opposed to following Exercise 2 and copying the files from, say, the nrf5340dk and modifying them accordingly?

    Takk!
    -Louis

Children
No Data
Related