Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => RT5350F => Topic started by: vinczo on December 06, 2018, 07:01:30 PM

Title: [SOLVED] OpenWrt 15.05 -> OpenWrt 18.06 : impossible to read from spi slave
Post by: vinczo on December 06, 2018, 07:01:30 PM
Hi,

I'm trying to read the content (a MAC addr) from an spi eeproom.

=========================================================================================

With OpenWrt 15.05, it worked fine.
I added the SPI device in the DTS as follows:
[...]
        palmbus@10000000 {
                spi@b00 {
                        status = "okay";

                        m25p80@0 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "s25fl064k";
                                reg = <0 0>;
                                linux,modalias = "m25p80", "s25fl064k";
                                spi-max-frequency = <10000000>;

                                partition@0 {
                                        label = "u-boot";
                                        reg = <0x0 0x30000>;
                                        read-only;
                                };

                                partition@30000 {
                                        label = "u-boot-env";
                                        reg = <0x30000 0x10000>;
                                        read-only;
                                };

                                factory: partition@40000 {
                                        label = "factory";
                                        reg = <0x40000 0x10000>;
                                        read-only;
                                };

                                partition@50000 {
                                        label = "firmware";
                                        reg = <0x50000 0x7b0000>;
                                };
                        };

                        mac@1 {
                            compatible = "at25";
                            spi-max-frequency = <1000000>;
                            reg = <1>;

                            at25,byte-len = <0x100>;
                            at25,addr-mode = <1>;
                            at25,page-size = <16>;
                        };
[...]


The SPI device would appear as follows :
root@OpenWrt:~# ls /sys/bus/spi/devices/spi32766.1/
driver/     eeprom      modalias    subsystem/  uevent

I could read from the SPI eeprom with the following command:
hexdump -C -s 250 -n 6 /sys/bus/spi/devices/spi32766.1/eeprom

=========================================================================================

However, since OpenWrt 18.06 it seems that the SPI device is not even recognized.
The DTS has changed a bit : instead of having one spi block for both spi_cs0 and spi_cs1, they are divided into two blocks. So the output of my DTS looks like this:
&spi0 {
status = "okay";

m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;

partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};

partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};

factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};

partition@50000 {
label = "firmware";
reg = <0x50000 0x7b0000>;
};
};
};

&spi1 {
status = "okay";

    mac@0 {
        compatible = "at25";
        spi-max-frequency = <1000000>;
        reg = <0>;

        at25,byte-len = <0x100>;
        at25,addr-mode = <1>;
        at25,page-size = <16>;
    };
};


I can see the spi device in the path but no eeprom file to read from :
root@OpenWrt:/# ls /sys/bus/spi/devices/spi1.0/
modalias    of_node     statistics  subsystem   uevent


Why is it that I can't read the SPI device with OpenWrt 18.06 ?

Thanks for your help
Vince

Title: Re: OpenWrt 15.05 -> OpenWrt 18.06 : impossible to read from spi slave
Post by: vinczo on December 06, 2018, 07:11:19 PM
After hours of search and debug. It just appeared to me after posting to the forum.

You have to add support to at25 in make menuconfig.