• 0

5.15.25 breaks SPI on NanoPi Neo and does not create /dev/spidev0.0


mdrmdr
 Share

8 8

Question

Armbianmonitor:

 

I'm using a NanoPi Neo as Homegear gateway. This requires the SPI interface (/dev/spidev0.0).

 

Yesterday I ran apt-get upgrade, which bumped my kernel from 5.10.60 to 5.15.25.

No other changes have been done,

 

Since then no SPI devices are created anymore and the gateway fails!

 

I tried to downgrade the kernel already using armbian-config to 21.08 5.10.60-sunxi.

But that reported an error (do not remember the text; was very late) and left the Nano unbootable.

I could restore the 5.15.25 kernel by manually editing the zImage symbolic link in /boot.

 

Using param_spidev_spi_bus=1 instead of 0 does not help.

 

What can I do now to re-enable SPI? Downgrade the kernel manually? But 5.10.60 is not offered in the repos...

Link to post
Share on other sites

Recommended Posts

  • 0

Doing what is explained in this post make it to work but spidev isn't anymore controlled through /boot/armbianEnv.conf file but the DT.

 

I used the "quick and dirty" fix for now by using "rohm,dh2228fv" which is already in the spidev_dt_ids[] list and avoid me creating a new build with a patch to modify drivers/spi/spidev.c

 

So basically, I used armian-config to edit the Device Tree (System => Dtc),

Browse the DT over soc => spi@1c68000
And I added these lines :

spi@1c68000 {
	...
	spidev@0x00 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <100000000>;
		reg = <0x00>;
	};
}

 

And the same for the second SPI controller :
 

spi@1c69000 {
	...
	spidev@0x00 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <100000000>;
		reg = <0x00>;
	};
}

 

I also had to remove the spidev stuff from /boot/armbianEnv.conf (No spi-spidev overlay)

This way, I get two SPI devices and the SBC is working again with 5.15 kernel :
 

# ls /dev/ | grep spi
spidev0.0
spidev1.0

 

Link to post
Share on other sites

Donate and support the project!

  • 0

i have encountered the same problem as yours. i have downloaded the latest armbian from release page(my board is OrangePi Zero),flash it into sd card,and wrote this overlay:

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";
        fragment@0 {
                target-path = "/aliases";
                __overlay__ {
                        spi0 = "/soc/spi@1c68000";
                };
        };

        fragment@1 {
                target = <&spi0>;
                __overlay__ {
                        #address-cells = <0>;
                        #size-cells = <0>;
                        status = "okay";
                        spidev {
                                compatible = "spidev";
                                status = "okay";
                                reg = <0>;
                                spi-max-frequency = <1000000>;
                        };
                };
        };
};

after applying it using `sudo armbian-add-overlay spi0.dts`,it *seems* to be loaded correctly(i use a usb-serial wire to observe console log from on-board debugging serial,it shows "Applying user provided DT overlay spi1.dtbo" and no errors occurred),but when i logged in system,there were no /dev/spidev* show up.

also, i have noticed there are some spi error in kernel log:

[    1.928114] sun6i-spi 1c68000.spi: chipselect 0 already in use
[    1.928149] spi_master spi0: spi_device register error /soc/spi@1c68000/flash@0
[    1.928200] spi_master spi0: Failed to create SPI device for /soc/spi@1c68000/flash@0

when i change the spi0 to spi1 , the whole spi thing will not work,even if i have checked the `/proc/device-tree/soc/spi@1c690000/spidev/status` file is "okay"(and dmesg shows nothing related to spi). doesn't know what kinda thing happened.

sorry for my pool English,i'm not a native English speaker.

i wish these infomations will help the developer.

Link to post
Share on other sites

  • 0
10 hours ago, mdrmdr said:

Downgrade the kernel manually?


Yes, until we don't find time to fix switching and then when life permits check why SPI doesn't work. Sadly we are not in a position (far away) to check if all functions doesn't break on upgrade ...

Link to post
Share on other sites

  • 0
vor 1 Stunde schrieb Igor:

...Sadly we are not in a position...

 

No problem at all. I'm glad and thankful that you guys spend your time delivering all that good stuff :-)

 

Can you give me a hint how to install an arbitrary kernel version which is not directly offered in the repos?

I only can select between Legacy (5.4.88), Current (5.15.25) and Edge (5.16.13).

Since I know that 5.10.60 works, I'd like to install this one. And I always need image and headers, right?

Link to post
Share on other sites

  • 0
28 minutes ago, mdrmdr said:

Can you give me a hint how to install an arbitrary kernel version which is not directly offered in the repos?


workaround:
 

download file from https://imola.armbian.com/beta/pool/main/l/

install with

 

sudo dpkg -i FILE.deb

 

28 minutes ago, mdrmdr said:

And I always need image and headers, right?

 

and DTB package. Headers are optional - if you need to build modules.

Link to post
Share on other sites

  • 0
vor 10 Stunden schrieb Igor:

workaround: download file from https://imola.armbian.com/beta/pool/main/l/

 

Installed 5.10.98 and everything works again as expected.

 

Now I have to make sure not to accidentally upgrade again until proven that a new kernel version does not break SPI.

Did that for the time being with: apt-mark hold linux-dtb-current-sunxi linux-image-current-sunxi.

 

Thanks Igor for all the informations.

Link to post
Share on other sites

  • 0

Hello,

 

Also having the same issue. I am using Orange Pi PC.

 

Last working version:

Distributor ID:    Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:    buster

Kernel: 5.10.60-sunxi #21.08.2

 

Breaks on:

Distributor ID:    Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:    buster

Kernel: 5.15.25-sunxi #22.02.1

Link to post
Share on other sites

  • 0
On 3/11/2022 at 8:05 PM, Igor said:


Yes, until we don't find time to fix switching and then when life permits check why SPI doesn't work. Sadly we are not in a position (far away) to check if all functions doesn't break on upgrade ...

 

Do you have any hint on what to look at to try to fix that issue ?
I might invest some time on it (and hopefully also get some more knowledge about these things)

Link to post
Share on other sites

  • 0

I actually found a better fix for this by only modifying the spidev overlay (/boot/dts/allwinner/overlays/sun50i-h5-spi-spidev.dtbo in my case).
compatible = "spidev"; seems to not work anymore while compatible = "rohm,dh2228fv"; works.

 

I have a board with an Allwinner H5 SoC so I dig a bit more and found there is spi-sun4i.c and spi-sun6i.c drivers.
I found out that none of these drivers seems to be used (There are no spi-sun*i.ko in /lib/modules/5.15.32-sunxi64/kernel/drivers/spi ) while CONFIG_SPI_SUN4I and CONFIG_SPI_SUN6I are set to y, is this normal ?

I also found out of_device_id are defined there (See here and here ).
Should we add these IDs in the spidev_dt_ids[] list of spidev.c ?

Link to post
Share on other sites

  • 0
03.04.2022 в 01:56, Falcounet сказал:

So basically, I used armian-config to edit the Device Tree (System => Dtc),

Browse the DT over soc => spi@1c68000
And I added these lines :

spi@1c68000 {
	...
	spidev@0x00 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <100000000>;
		reg = <0x00>;
	};
}

 

And the same for the second SPI controller :
 

spi@1c69000 {
	...
	spidev@0x00 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <100000000>;
		reg = <0x00>;
	};
}

 

I also had to remove the spidev stuff from /boot/armbianEnv.conf (No spi-spidev overlay)

This way, I get two SPI devices and the SBC is working again with 5.15 kernel :
 

# ls /dev/ | grep spi
spidev0.0
spidev1.0

 

 

this one really works! thank you!

 

Link to post
Share on other sites

  • 0

So this means:

- Upgrade to 5.15

- Reboot

- Do above change with armbian-config to section "DT over soc => spi@1c68000"

- Remove "spi-spidev" from "overlays=" from "/boot/armbianEnv.txt"

- Reboot

- Should work

 

Right? And this procedure needs to applied whenever the kernel gets updated?

Link to post
Share on other sites

  • 0
5 hours ago, mdrmdr said:

So this means:

- Upgrade to 5.15

- Reboot

- Do above change with armbian-config to section "DT over soc => spi@1c68000"

- Remove "spi-spidev" from "overlays=" from "/boot/armbianEnv.txt"

- Reboot

- Should work

 

Right? And this procedure needs to applied whenever the kernel gets updated?

 

I think it's just a workaround for now.

Something seems to be broken with kernel 5.15 but I couldn't understand what.

 

It is still better to only modify the spidev overlay, I think. This way you could still control spidev using /boot/armbianEnv.txt

Link to post
Share on other sites

  • 0
11.03.2022 в 17:36, arclight сказал:
spidev {
                                compatible = "spidev"

This no longer works in version v5.15 and above.
All we can do for the user is to expand the warning to a more detailed one if the kernel receives such an outdated way of overlaying the device tree from the user.

 

@IgorIgor, should we delete the files of outdated overlays for the device tree from the corresponding patches?

 

 

11.03.2022 в 17:36, arclight сказал:

i have noticed there are some spi error in kernel log:

[    1.928114] sun6i-spi 1c68000.spi: chipselect 0 already in use

If this SPI channel is already in use, why are you trying to use it in another way?

Link to post
Share on other sites

  • 0
51 minutes ago, going said:

This no longer works in version v5.15 and above.

 

I have noticed ...

 

52 minutes ago, going said:

should we delete the files of outdated overlays for the device tree from the corresponding patches?


I assume there is nothing wrong with overlay? Why would we remove it? Recording a bug into Jira is all what we can do. Unless someone has so much time to dig in and understand why it broke down.

Link to post
Share on other sites

  • 0
2 минуты назад, Igor сказал:

I assume there is nothing wrong with overlay? Why would we remove it? Recording a bug into Jira is all what we can do. Unless someone has so much time to dig in and understand why it broke down.

https://lore.kernel.org/all/20210921192149.50740-1-broonie@kernel.org/

 

In other words, the core has become smarter. If it is correctly spelled out in the device tree, then the kernel does the mapping and the mapped driver is used.
For example in orangepi-pc2

&spi0 {
	status = "okay";
        spi-flash@0 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "jedec,spi-nor";
                reg = <0>; /* Chip select 0 */
                spi-max-frequency = <10000000>;
                status = "okay";
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
                        partition@0 {
                                label = "uboot";
                                reg = <0x0 0x100000>;
                        };
                        partition@100000 {
                                label = "env";
                                reg = <0x100000 0x100000>;
                        };
                };
        };
};

compatible = "jedec,spi-nor";

The kernel uses a mapped driver (spi-nor) and creates the corresponding device, not /dev/spidevX.X

Link to post
Share on other sites

  • 0
14.04.2022 в 15:55, Falcounet сказал:

I think it's just a workaround for now.

A little wrong. This is the official way to load this kernel module.

 

You can write complete nonsense, as I did for the test.

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 852dcbb2d..2c53e2b5a 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -682,6 +682,7 @@ static const struct spi_device_id spidev_spi_ids[] = {
 	{ .name = "m53cpld" },
 	{ .name = "spi-petra" },
 	{ .name = "spi-authenta" },
+	{ .name = "elephant" },
 	{},
 };
 MODULE_DEVICE_TABLE(spi, spidev_spi_ids);
@@ -696,6 +697,7 @@ static const struct of_device_id spidev_dt_ids[] = {
 	{ .compatible = "menlo,m53cpld" },
 	{ .compatible = "cisco,spi-petra" },
 	{ .compatible = "micron,spi-authenta" },
+	{ .compatible = "hello,elephant" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, spidev_dt_ids);

And call this module to load and initialize by replacing the compatible = "spidev"; string with compatible = "hello,elephant"; in the dts file.

 

14.04.2022 в 15:55, Falcounet сказал:

Something seems to be broken with kernel 5.15 but I couldn't understand what.

I have discovered this and will fix it in the 5.17 kernel soon.
And I need someone to test the fixes on real hardware.
Anyone interested?

 

 

 

Link to post
Share on other sites

  • 0

I would test it on my NanoPi Neo.

 

But I'd need instructions how to keep 5.10.98, thus installing 5.17 additionally and being able to switch back to 5.10.98 best case just by editing files or links in "/boot".

Link to post
Share on other sites

  • 0
11.03.2022 в 11:53, mdrmdr сказал:
Armbianmonitor:

 

I'm using a NanoPi Neo as Homegear gateway. This requires the SPI interface (/dev/spidev0.0).

 

Please publish information about your current working operating system:

cat /boot/armbianEnv.txt

lsb_release -rc

find /sys/ -name '*spi*'

df -h

Are the overlay files that you use files that are part of the dtb system package?

And simple curiosity. Which device do you connect via SPI?

 

9 часов назад, mdrmdr сказал:

But I'd need instructions

I will make all the packages and provide a download link. There will be instructions.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

8 8