Spidev file not generated for slave

  • Hello, please obtain the spi kernel information and attach the complete device tree file

    Code: Select all

    cat /var/log/messages  | grep "spi" 
    
  • Here by sharing details

    Code: Select all

    [root@luckfox slprograms]# cat /var/log/messages  | grep "spi"
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.088934] spi-nand spi2.0: Winbond SPI NAND was found.
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.088961] spi-nand spi2.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.090173] 7 cmdlinepart partitions found on MTD device spi-nand0
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.090190] Creating 7 MTD partitions on "spi-nand0":
    
    ------Device tree file---------

    Code: Select all

    // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
    /*
     * Copyright (c) 2023 Luckfox Electronics Co., Ltd.
     */
    
    /dts-v1/;
    
    #include "rv1103.dtsi"
    #include "rv1106-evb.dtsi"
    #include "rv1103-luckfox-pico-ipc.dtsi"
    
    / {
    	model = "Luckfox Pico Mini";
    	compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1103";
    };
    
    /**********SFC**********/
    &sfc {
    	status = "okay";
    	flash@0 {
    		compatible = "spi-nand";
    		reg = <0>;
    		spi-max-frequency = <75000000>;
    		spi-rx-bus-width = <4>;
    		spi-tx-bus-width = <1>;
    	};
    };
    
    /**********SDMMC**********/
    &sdmmc {
    	max-frequency = <50000000>;
    	no-sdio;
    	no-mmc;
    	bus-width = <4>;
    	cap-mmc-highspeed;
    	cap-sd-highspeed;
    	disable-wp;
    	pinctrl-names = "default";
    	pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_det &sdmmc0_bus4>;
    	status = "okay";
    };
    
    /**********ETH**********/
    &gmac {
    	status = "disabled";
    };
    
    /**********USB**********/
    &usbdrd_dwc3 {
    	status = "okay";
    	dr_mode = "peripheral";
    };
    
    /**********SPI**********/
    /* SPI0_M0 */
    
    //&spi0 {
    //	status = "okay";
    //	spidev@0 {
    //		spi-max-frequency = <50000000>;
    //	};
    //};
    
    //&spi0 {
    //    status = "okay";
    //    spi_test@00 {
    //        compatible = "rockchip,spidev";
    //        reg = <0>;    
    //        spi-cpha;  
    //        spi-cpol;    
    //        spi-lsb-first; 
    //        spi-max-frequency = <1000000>;  
    //        status = "okay";
    //    };
    //};
    
    &spi0 {
        status = "okay";
        spi-slave; 
        slave {  
            compatible ="rockchip,spidev";
            reg = <0>;
            id = <0>;
        };
    };
    
    /**********I2C**********/
    /* I2C3_M1 */
    &i2c3 {
    	status = "disabled";
    	clock-frequency = <100000>;
    };
    
    /**********UART**********/
    /* UART3_M1 */
    &uart3 {
    	status = "disabled";
    };
    
    /* UART4_M1 */
    &uart4 {
    	status = "disabled";
    };
    
    /**********PWM**********/
    /* PWM1_M0 */
    &pwm1 {
    	status = "disabled";
    };
    
    
  • According to the logs, your device tree modifications have not been successfully applied, please check whether the recompiled boot.img is burned
  • Burning of the boot.img is probably correct but while compiling the kernel i am getting the following warning regarding SPI

    Code: Select all

    /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1106.dtsi:1059.21-1072.4: Warning (spi_bus_bridge): /spi@ff500000: incorrect #address-cells for SPI bus
      also defined at /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1103-luckfox-pico-ipc.dtsi:314.7-335.3
      also defined at /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dts:77.7-86.3
    arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dtb: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'
    
    I even tried adding property of address cell as shown below

    Code: Select all

    &spi0 {
       	 status = "okay";
    	#address-cells = <0>;
       	spi-slave; 
    	slave {  
            compatible ="rockchip,spidev";
            reg = <0>;
            id = <0>;
        };
    };
    
    But then i get a warning regarding the reg property as shown below

    Code: Select all

    /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1103-luckfox-pico-ipc.dtsi:322.3-13: Warning (reg_format): /spi@ff500000/spidev@0:reg: property has invalid length (4 bytes) (#address-cells == 0, #size-cells == 0)
    /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1103-luckfox-pico-ipc.dtsi:326.7-17: Warning (reg_format): /spi@ff500000/fbtft@0:reg: property has invalid length (4 bytes) (#address-cells == 0, #size-cells == 0)
    /home/samip/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dts:83.9-19: Warning (reg_format): /spi@ff500000/slave:reg: property has invalid length (4 bytes) (#address-cells == 0, #size-cells == 0)
    arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
    
    Please check and if any modification in the device tree required please assist on the same.
    Last edited by Samip_veer on 2025-05-15 7:32, edited 1 time in total.
  • The “#address-cells = <0>;” is not need to add, the attachment is the boot.img I compiled, after the test, you can successfully register /dev/spidev0.0, the reference is also the instructions in the wiki, and there is no problem with the actual measurement
  • Supplementary attachments
    Attachments
    boot.zip (2.93 MiB)
    Downloaded 138 times
  • Thank you for the boot.img file now the device is being generated
    Hereby attaching logs for the same

    Code: Select all

    [root@luckfox root]# cat /var/log/messages  | grep "spi"
    Jan  1 00:00:05 luckfox kern.warn kernel: [    0.088929] rockchip-spi ff500000.spi: no high_speed pinctrl state
    Jan  1 00:00:05 luckfox kern.err kernel: [    0.089415] spi_slave spi0: /spi@ff500000/spidev@0 is not called 'slave'
    Jan  1 00:00:05 luckfox kern.warn kernel: [    0.089448] spi_slave spi0: Failed to create SPI device for /spi@ff500000/spidev@0
    Jan  1 00:00:05 luckfox kern.err kernel: [    0.089470] spi_slave spi0: /spi@ff500000/fbtft@0 is not called 'slave'
    Jan  1 00:00:05 luckfox kern.warn kernel: [    0.089483] spi_slave spi0: Failed to create SPI device for /spi@ff500000/fbtft@0
    Jan  1 00:00:05 luckfox kern.info kernel: [    0.090014] rockchip-spi ff500000.spi: probed, poll=0, rsd=0
    Jan  1 00:00:05 luckfox kern.info kernel: [    0.091526] spi-nand spi2.0: Winbond SPI NAND was found.
    Jan  1 00:00:05 luckfox kern.info kernel: [    0.091556] spi-nand spi2.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
    Jan  1 00:00:05 luckfox kern.notice kernel: [    0.092915] 7 cmdlinepart partitions found on MTD device spi-nand0
    Jan  1 00:00:05 luckfox kern.notice kernel: [    0.092938] Creating 7 MTD partitions on "spi-nand0":
    
    Can you please also share boot.img for master device (luckfox-mini B) as device is generated but there is no output on oscilloscope here by sharing logs for master

    Code: Select all

    [root@luckfox root]# cat /var/log/messages  | grep "spi"
    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.087869] rockchip-spi ff500000.spi: no high_speed pinctrl state
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088858] rockchip-spi ff500000.spi: chipselect 0 already in use
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088890] spi_master spi0: spi_device register error /spi@ff500000/fbtft@0
    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.088909] spi_master spi0: Failed to create SPI device for /spi@ff500000/fbtft@0
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088930] rockchip-spi ff500000.spi: chipselect 0 already in use
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088944] spi_master spi0: spi_device register error /spi@ff500000/spi_test@00
    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.088956] spi_master spi0: Failed to create SPI device for /spi@ff500000/spi_test@00
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.088967] rockchip-spi ff500000.spi: probed, poll=0, rsd=0
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.090425] spi-nand spi2.0: Winbond SPI NAND was found.
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.090451] spi-nand spi2.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.091799] 7 cmdlinepart partitions found on MTD device spi-nand0
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.091821] Creating 7 MTD partitions on "spi-nand0":
    Jan  1 00:00:07 luckfox kern.err kernel: [    7.457669] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /spi@ff500000/status
    Jan  1 00:00:07 luckfox kern.err kernel: [    7.457718] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /spi@ff500000/pinctrl-0
    Jan  1 00:00:07 luckfox kern.err kernel: [    7.457734] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /spi@ff500000/spidev@0/status
    Jan  1 00:00:07 luckfox kern.err kernel: [    7.457749] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /spi@ff500000/spidev@0/spi-max-frequency
    
  • In SPI communication, a slave device cannot send out data without a clock input from the master. The SPI master configuration can be done using the luckfox-config command. (Note: Modifying the device tree may cause luckfox-config to stop functioning correctly, as it only supports configuration in master mode.)

    The boot.img I provided is only to help you verify the cause of the configuration failure. At this point, we can rule out flashing issues. If you need further investigation, you can provide your own boot.img for analysis.
  • My point is i am trying to do a establish a communication between (luckfox-pico-mini-B(slave)) to (luckfox-pico-mini-B(master)), I have configured both the devices and modified the device tree but not able to to establish communication there were following issues :-

    1) Slave side spidev0.0 device was not generated
    But thanks to your boot.img for slave i am able to generate the device

    2) Master side spidev0.0 device is generted but no output on oscilloscope
    I feel there is some problem in configuring the device tree it would be very helpful if you can generate a boot.img for (luckfox-pico-mini-B(spi_master)) and share it here.

    for your refrence i am sharing kernel info for the master device below

    Code: Select all

    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.087962] rockchip-spi ff500000.spi: no high_speed pinctrl state
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088957] rockchip-spi ff500000.spi: chipselect 0 already in use
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.088988] spi_master spi0: spi_device register error /spi@ff500000/fbtft@0
    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.089006] spi_master spi0: Failed to create SPI device for /spi@ff500000/fbtft@0
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.089026] rockchip-spi ff500000.spi: chipselect 0 already in use
    Jan  1 00:00:00 luckfox kern.err kernel: [    0.089039] spi_master spi0: spi_device register error /spi@ff500000/spi_test@00
    Jan  1 00:00:00 luckfox kern.warn kernel: [    0.089052] spi_master spi0: Failed to create SPI device for /spi@ff500000/spi_test@00
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.089063] rockchip-spi ff500000.spi: probed, poll=0, rsd=0
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.090520] spi-nand spi2.0: Winbond SPI NAND was found.
    Jan  1 00:00:00 luckfox kern.info kernel: [    0.090546] spi-nand spi2.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.091910] 7 cmdlinepart partitions found on MTD device spi-nand0
    Jan  1 00:00:00 luckfox kern.notice kernel: [    0.091930] Creating 7 MTD partitions on "spi-nand0":