nRF SDK Device Tree Editor problems

I am trying to make a custom board device tree for evaluation of some new parts and am struggling.  I have attached the Schematic as reference sine this is only for part discovery there is nothing proprietary.  I seem to be having issues on adding my sensors (BMP585 & ADXL367) as children to spi0.  I am also curious why nRF SDk for VS Code DeviceTree Visual Editor puts all pinctrl data in the .dts file instead of using the .dtsi file?

/dts-v1/;
#include <nordic/nrf52832_qfaa.dtsi>
#include "PCB7410_10_006-pinctrl.dtsi"

/ {
	model = "PCB7410-10-006";
	compatible = "InstantCare,PCB7410-10-006";

	chosen {
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
	};

	leds {
		compatible = "gpio-leds";
		grn: grn {
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			label = "GRN";
		};

		red: red {
			gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
			label = "RED";
		};
	};

	buttons {
		compatible = "gpio-keys";
		sw2 {
			label = "SW2";
			gpios = <&gpio0 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
		};
	};

	sounders {
		compatible = "gpio-leds";
		SN1: SN1 {
			gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
			label = "SN1";
		};
		SN2: SN2 {
			gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
			label = "SN2";
		};
		SN3: SN3 {
			gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
			label = "SN3";
		};
	};
};

&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 DT_SIZE_K(48)>;
		};

		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0x0000c000 DT_SIZE_K(220)>;
		};

		slot1_partition: partition@43000 {
			label = "image-1";
			reg = <0x00043000 DT_SIZE_K(220)>;
		};

		storage_partition: partition@7a000 {
			label = "storage";
			reg = <0x0007a000 DT_SIZE_K(24)>;
		};
	};
};

&gpio0 {
	status = "okay";
};

&uart0 {
	status = "okay";
	pinctrl-0 = <&uart0_default>;
	pinctrl-1 = <&uart0_sleep>;
	pinctrl-names = "default", "sleep";
	current-speed = <115200>;
};

&spi0 {
	status = "okay";
	pinctrl-0 = <&spi0_default>;
	pinctrl-1 = <&spi0_sleep>;
	pinctrl-names = "default", "sleep";
	adxl367@0 {
		compatible = "adi,adxl367";
		reg = <0x0>;
		spi-max-frequency = <8000000>;
		cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; // Is this how to do CS?
		int1-gpios = <&gpio0 12 0>; // Is this the INT pin?
	};

	bmp585@1 {
		compatible = "bosch,bmp585";
		reg = <0x1>;
		spi-max-frequency = <8000000>;
		cs-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; // Is this how to do CS?
		int1-gpios = <&gpio0 11 0>; // Is this INT pin?
	};
};


&pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 26)>, <NRF_PSEL(UART_RX, 0, 27)>;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 26)>;
		};
	};

	spi0_default: spi0_default {
		group1 {
			psels = <NRF_PSEL(SPIM_MISO, 0, 17)>,
			        <NRF_PSEL(SPIM_MOSI, 0, 16)>,
			        <NRF_PSEL(SPIM_SCK, 0, 15)>;
		};
	};

	spi0_sleep: spi0_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_MISO, 0, 17)>;
		};
	};
};
SCH_7410_10_006.pdf

  • Hi,

     

    I am also curious why nRF SDk for VS Code DeviceTree Visual Editor puts all pinctrl data in the .dts file instead of using the .dtsi file?

    Technically your original definition should be in a .dtsi file, and any overriding of such, should be in a overlay. Both will however work.

     

    I seem to be having issues on adding my sensors (BMP585 & ADXL367) as children to spi0. 

    cs-gpios is an array that shall belong to the root node, ie spi0 in this case:

    &spi0 {
    	status = "okay";
    	pinctrl-0 = <&spi0_default>;
    	pinctrl-1 = <&spi0_sleep>;
    	pinctrl-names = "default", "sleep"
    	cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>, <&gpio0 14 GPIO_ACTIVE_LOW>;
    	adxl367@0 {
    		compatible = "adi,adxl367";
    		reg = <0x0>;
    		spi-max-frequency = <8000000>;
    		int1-gpios = <&gpio0 12 0>;
    	};
    
    	bmp585@1 {
    		compatible = "bosch,bmp585";
    		reg = <0x1>;
    		spi-max-frequency = <8000000>;
    		int1-gpios = <&gpio0 11 0>;
    	};
    };

     

    Please note that you are referencing a sensor that is not present in zephyr/ncs. The "closest" you get here is the bmp581 sensor. I would recommend that you ask the manufacturer about the differences and possibly if they have a zephyr rtos based driver for you.

     

    Kind regards,

    Håkon

  • Thank you for the suggestion.  I have reached out to Bosch about the BMP585 driver.  I am still confused though how the cs-gpios are just an array in the root spi0 node.  How do they then get associated to the correct respective sub-nodes?  Can you point me to some example code that uses a shared SPI Bus like this?

  • Hi,

     

    cs-gpios is an array, and the "reg" variable, and the sensor@index will look up the corresponding index in cs-gpios array.

     

    index 0 is in bold and index 1 is underlined:

    cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>, <&gpio0 14 GPIO_ACTIVE_LOW>;
    adxl367@0 {
    compatible = "adi,adxl367";
    reg = <0x0>;

    ...
    };

    bmp585@1 {
    compatible = "bosch,bmp585";
    reg = <0x1>;
    ...
    };

    Austinag said:
    Can you point me to some example code that uses a shared SPI Bus like this?

    The code itself will use device tree defines/macros:

    https://docs.zephyrproject.org/latest/build/dts/api-usage.html

     

    For the adxl367, the referencing is here:

    https://github.com/nrfconnect/sdk-zephyr/blob/ncs-v3.1.1/drivers/sensor/adi/adxl367/adxl367.c#L1185-L1188

     

    Kind regards,

    Håkon

Related