[SOLVED] NanoPi NEO3 device tree overlay

I am trying to get a ds18b20 1-wire temperature sensor working on my NEO3.
After I add the following line to “/boot/armbianEnv.txt” :-

overlays=w1-gpio

and reboot, I cannot SSH into the NEO3. The Network interface is down.

Watching the debug console, everything is going fine until:-

[   10.711832] OF: /onewire@0: could not get #gpio-cells for /ethernet@ff540000
[   10.712508] w1-gpio onewire@0: gpio_request_nable_pin) failed
[   10.717827] dwmmc_rockchip ff500000.mmc: error -110 requesting status
[  OK  ] Finished DietPi-PreBoot.
[  OK  ] Reached target Network (Pre).
[   10.771070] mmcblk0: recovery failed!
[   10.771551] blk_update_request: I/O error, dev mmcblk0, sector 1106512 op 0x0:(READ) flags 0x8070
         Starting Raise network interfaces...
[   10.785656] dwmmc_rockchip ff500000.mmc: error -110 requesting status
[   10.786339] mmcblk0: recovery failed!
[   10.786839] bk_update_request: I/O error, dev mmcblk0, sector 774352 op 0x0:([   10.800951] dwmms
[   10.801575] mmcblk0: recovery failed!
[   10.802160] blk_update_request: I/O error, dev mmcblk0, sector 1231280 opg 4 prio class 0
[   10.817067] dwmmc_rockchip ff500000.mmc: error -110 requesting status
[   10.817697] mmcblk0: recovery failed!
[   10.818292] blk_update_request: I/O error, dev mmcblk0, sector 1106512 opx0 phys_seg 1 prio clas0
[   10.832020] dwmmc_rockchip ff500000.mmc: error -110 requesting status
[   10.832653] mmcblk0: recovery failed!

There is more of the same, then output stops.

Remove the overlays line and everything boots fine.

Any ideas?

Also, what is the parameter for the “param_w1_pin=”
I am using GPIO Header Pin 7, which is GPIO2_A2

I have updated the “fdtfile=” line in “/boot/armbianEnv.txt” to:-

fdtfile=rockchip/rk3328-nanopi-neo3-rev02.dtb

after doing this, pwmchip0 has turned up under /sys/class/pwm/
I think this can control the fan. I’ll check this out when I get a 2-pin JST ZHN connector.

Any help appreciated.

Regards,
John

Hi John,

I’m looking for similar solution for NEO3 however currently got some other projects to finalize. You may check and try this one:
https://github.com/friendlyarm/WiringNP
It looks quite old (6 years) but some updates were made last year. Not sure is GPIO on NEO3 same as on NEO2 but it might be a good starting point.

Let us know results - would be nice to know it is working :slight_smile:

Mike

The NEO3 device tree is not available anymore with recent kernel, so with last DietPi update we switched back to a compatible NanoPi R2 one. But that may affect GPIO support: https://forum.armbian.com/topic/20133-nanopi-neo3-dtb-gone-since-linux-dtb-current-rockchip64-22021

Generally, instead of WiringPi, I’d try to use libgpiod for controlling GPIO nowadays:

apt install gpiod

I have solved my problem of the w1-gpio overlay not working.
I think the w1-gpio pin assigned in the supplied overlay is messing up access of the SD card.

I found some helpful information from this post:
https://forum.pine64.org/showthread.php?tid=6987&pid=100639#pid100639

I copied the overlay code, modified it to use GPIO2_A2 (pin 7 on the 26pin header), compiled it and copied the new dtbo file to “/boot/dtb/rockchip/overlay/” . Added the “overlays=w1-gpio” line to “/boot/armbianEnv.txt” and rebooted.
Success. I was able to read the ds18b20.

The steps I took:
Overlay file: rockchip-w1-gpio.dts

/dts-v1/;
/plugin/;

/ {
compatible = "rockchip,rk3328";

    fragment@0 {
            target-path = "/";
            __overlay__ {

                    w1: onewire@0 {
                            compatible = "w1-gpio";
                            pinctrl-names = "default";
                            gpios = <&gpio2 2 0>;
                            status = "okay";
                    };
            };
    };

};

You will probably need to install the device-tree-compiler.

sudo apt install device-tree-compiler

Compile the overlay:

dtc -I dts -O dtb -o rockchip-w1-gpio.dtbo  rockchip-w1-gpio.dts

Copy the compiled overlay:

sudo cp rockchip-w1-gpio.dtbo /boot/dtb/rockchip/overlay/

This will overwrite the existing “rockchip-w1-gpio.dtbo” file. If you wish to keep the original, move it to another directory or rename it.

Add the “overlays=w1-gpio” line (without quotes) to “/boot/armbianEnv.txt” and reboot.

Check that all went well by :

ls /sys/bus/w1/devices/

You should see a directory starting with “28-” . This is your ds18b20.

Read the temperature:

cat /sys/bus/w1/devices/28-xxxxxxxxxxxx/temperature

(substitute the 28-xxxxxxxxxxxx with your directory name.)

However. I came to realise that the newly created overlay will be overwritten on the next kernal update. There must be a way around this.

Further research I came across this page:
https://docs.armbian.com/User-Guide_Armbian_overlays/

This explained about a “/boot/overlay-user/” directory that is for user provided overlays.

Create the “/boot/overlay-user/” directory:

sudo mkdir /boot/overlay-user

Copy (or move) the “rockchip-w1-gpio.dbto” file from “/boot/rockchip/overlay/” to “/boot/overlay-user/” directory.

You will then need to edit “/boot/armbianEnv.txt” and add “user_overlays=rockchip-w1-gpio” (without quotes).
Comment out or remove the “overlays=w1-gpio” line, save and reboot.

You should be able to read the ds18b20 temperature as above.

I probably should have persevered to find out the correct syntax for “param_w1_pin=” but then I wouldn’t have learnt about device tree overlays etc. ( I think it might be “param_w1_pin=PC2” (GPIO2_A2))

I have upgraded to the latest DietPi and every thing is OK, although the “pwmchip0” directory has disappeared but I think I can create a device tree overlay that will bring it back. (See, the lessons are paying off.)

I have been using “python-periphery” for turning LEDs on and off but will look into libgpiod.
python-periphery:
https://github.com/vsergeev/python-periphery

pip3 install python-periphery

Regards,
John

Wow that is great. I’ll forward this to Armbian to have their overlay updated, or added as specific for the NanoPi NEO3.