Will DietPi work on the NanoPi R2S Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Will DietPi work on the NanoPi R2S

Post by MichaIng »

About the RAM, try first to flash the updated bootloader: https://forum.armbian.com/topic/13962-n ... 2m-memory/

Code: Select all

. /usr/lib/u-boot/platform_install.sh
write_uboot_platform $DIR /dev/mmcblk0
reboot # to apply changes
Looks like we need to update the image.

About PWM, try to load the kernel module:

Code: Select all

modprobe pwm-fan
ls -l /sys/devices/platform/pwm-fan
And also, there are some related tunables already, check:

Code: Select all

ls -l /sys/devices/virtual/thermal/cdev0/
cat /sys/devices/virtual/thermal/cdev0_trip_point
cat /sys/devices/virtual/thermal/cdev0_weight
cat /sys/devices/virtual/thermal/trip_point_[012]_temp
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

Thanks for the attention to this, @MichaIng!

I will give that a try later today or tomorrow and report back.
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

@MichaIng,

After this:

Code: Select all

. /usr/lib/u-boot/platform_install.sh
write_uboot_platform $DIR /dev/mmcblk0
reboot # to apply changes
I get:

Code: Select all

root@DietPi:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            978          53         845           1          79         854
Swap:             0           0           0
I also loaded the kernel module with # modprobe pwm-fan. Which apparently has been loaded:

Code: Select all

root@DietPi:~# lsmod | grep pwm
pwm_fan                20480  0
But there is no such file or directory:

Code: Select all

root@DietPi:~# ls -l /sys/devices/platform/pwm-fan
ls: cannot access '/sys/devices/platform/pwm-fan': No such file or directory
root@DietPi:~# ls -l /sys/devices/platform/
Fixed MDIO bus.0/      ff060000.rng/          ff300000.gpu/          ff580000.usb/          power/                 usb@ff600000/
arm-pmu/               ff100000.syscon/       ff350000.video-codec/  ff5c0000.usb/          psci/                  vcc-phy-regulator/
board/                 ff130000.serial/       ff350800.iommu/        ff5d0000.usb/          reg-dummy/             vcc-rtl8153-regulator/
bus/                   ff150000.i2c/          ff450000.syscon/       ff790000.dfi/          sdmmc-regulator/       vcc-sys/
cpufreq-dt/            ff160000.i2c/          ff460000.syscon/       gpio-keys/             sdmmcio-regulator/     
ddr_timing/            ff1a0000.watchdog/     ff470000.usb3-phy/     gpio-leds/             serial8250/            
display-subsystem/     ff250000.tsadc/        ff500000.mmc/          host-vbus-regulator/   timer/                 
dmc/                   ff260000.efuse/        ff540000.ethernet/     pinctrl/               uevent   
As per your other suggestion, this is what I find under /sys/devices/virtual/thermal/:

Code: Select all

root@DietPi:~# ls -l /sys/devices/virtual/thermal/
cooling_device0/ thermal_zone0/   

Code: Select all

root@DietPi:~# ls -l /sys/devices/virtual/thermal/cdev0/
ls: cannot access '/sys/devices/virtual/thermal/cdev0/': No such file or directory
root@DietPi:~# ls -l /sys/devices/virtual/thermal/cooling_device0/
total 0
-rw-r--r-- 1 root root 4096 Feb  5 11:24 cur_state
-r--r--r-- 1 root root 4096 Feb  5 11:24 max_state
drwxr-xr-x 2 root root    0 Feb  5 11:24 power
drwxr-xr-x 2 root root    0 Feb  5 11:24 stats
lrwxrwxrwx 1 root root    0 Feb  5 11:24 subsystem -> ../../../../class/thermal
-r--r--r-- 1 root root 4096 Feb  5 11:24 type
-rw-r--r-- 1 root root 4096 Feb  5 11:22 uevent

Code: Select all

root@DietPi:~# ls -l /sys/devices/virtual/thermal/thermal_zone0/
available_policies  hwmon0/             k_pu                slope               trip_point_0_temp   trip_point_2_hyst   
cdev0/              integral_cutoff     mode                subsystem/          trip_point_0_type   trip_point_2_temp   
cdev0_trip_point    k_d                 offset              sustainable_power   trip_point_1_hyst   trip_point_2_type   
cdev0_weight        k_i                 policy              temp                trip_point_1_temp   type                
emul_temp           k_po                power/              trip_point_0_hyst   trip_point_1_type   uevent              
root@DietPi:~# ls -l /sys/devices/virtual/thermal/thermal_zone0/
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Will DietPi work on the NanoPi R2S

Post by MichaIng »

Sorry for the late reply. So the memory issue is solved with the new bootloader flashed, that is great! I'll update our image.

The the fan control, can you show the content of some of the tunables:

Code: Select all

cat /sys/devices/virtual/thermal/cooling_device0/cur_state
cat /sys/devices/virtual/thermal/cooling_device0/max_state
ls -l /sys/devices/virtual/thermal/thermal_zone0/ # So we can see which one is writable and which one only to read from
cat /sys/devices/virtual/thermal/thermal_zone0/available_policies
cat /sys/devices/virtual/thermal/thermal_zone0/policy
cat /sys/devices/virtual/thermal/thermal_zone0/cdev0_trip_point
cat /sys/devices/virtual/thermal/thermal_zone0/cdev0_weight
cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_temp
cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_type
cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_hyst
ls -l /sys/devices/virtual/thermal/thermal_zone0/cdev0/ # Again a sub directory, currently looks doubled to me, let's see whats inside
This policy and available policies actually look quite promising, the trip points for fine tuning. I just wonder what the "cdev0" (=coolingDevice0?) again is, with own trip point, weight (=fan speed?) and again a subdirectory is. Probably the trip points in the parent dir define how attached cooling devices shall behave and the cdev0 is mostly for reading back which trip point and related speed this particular cooling device currently has. Let's see.
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

@MichaIng,

No need for apologies. I am happy to wait for the new image and only hope to help with this amazing project!

Code: Select all

root@DietPi:~# cat /sys/devices/virtual/thermal/cooling_device0/cur_state
0

root@DietPi:~# cat /sys/devices/virtual/thermal/cooling_device0/max_state
6

root@DietPi:~# ls -l /sys/devices/virtual/thermal/thermal_zone0/
total 0
-r--r--r-- 1 root root 4096 Feb 11 15:35 available_policies
lrwxrwxrwx 1 root root    0 Feb 11 15:35 cdev0 -> ../cooling_device0
-r--r--r-- 1 root root 4096 Feb 11 15:35 cdev0_trip_point
-rw-r--r-- 1 root root 4096 Feb 11 15:35 cdev0_weight
--w------- 1 root root 4096 Feb 11 15:35 emul_temp
drwxr-xr-x 3 root root    0 Jan 21  2016 hwmon0
-rw-r--r-- 1 root root 4096 Feb 11 15:35 integral_cutoff
-rw-r--r-- 1 root root 4096 Feb 11 15:35 k_d
-rw-r--r-- 1 root root 4096 Feb 11 15:35 k_i
-rw-r--r-- 1 root root 4096 Feb 11 15:35 k_po
-rw-r--r-- 1 root root 4096 Feb 11 15:35 k_pu
-rw-r--r-- 1 root root 4096 Feb 11 15:35 mode
-rw-r--r-- 1 root root 4096 Feb 11 15:35 offset
-rw-r--r-- 1 root root 4096 Feb 11 15:35 policy
drwxr-xr-x 2 root root    0 Feb 11 15:35 power
-rw-r--r-- 1 root root 4096 Feb 11 15:35 slope
lrwxrwxrwx 1 root root    0 Jan 21  2016 subsystem -> ../../../../class/thermal
-rw-r--r-- 1 root root 4096 Feb 11 15:35 sustainable_power
-r--r--r-- 1 root root 4096 Feb 11 15:21 temp
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_0_hyst
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_0_temp
-r--r--r-- 1 root root 4096 Feb 11 15:35 trip_point_0_type
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_1_hyst
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_1_temp
-r--r--r-- 1 root root 4096 Feb 11 15:35 trip_point_1_type
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_2_hyst
-rw-r--r-- 1 root root 4096 Feb 11 15:35 trip_point_2_temp
-r--r--r-- 1 root root 4096 Feb 11 15:35 trip_point_2_type
-r--r--r-- 1 root root 4096 Feb 11 15:35 type
-rw-r--r-- 1 root root 4096 Jan 21  2016 uevent

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/available_policies
user_space step_wise bang_bang fair_share 

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/policy
step_wise

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/cdev0_trip_point
1

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/cdev0_weight
4096

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_temp
70000
85000
95000

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_type
passive
passive
critical

root@DietPi:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*_hyst
2000
2000
2000

root@DietPi:~# ls -l /sys/devices/virtual/thermal/thermal_zone0/cdev0
lrwxrwxrwx 1 root root 0 Feb 11 15:35 /sys/devices/virtual/thermal/thermal_zone0/cdev0 -> ../cooling_device0

root@DietPi:~# ls -l /sys/devices/virtual/thermal/thermal_zone0/cdev0/
total 0
-rw-r--r-- 1 root root 4096 Feb 11 15:34 cur_state
-r--r--r-- 1 root root 4096 Feb 11 15:35 max_state
drwxr-xr-x 2 root root    0 Feb 11 15:37 power
drwxr-xr-x 2 root root    0 Feb 11 15:37 stats
lrwxrwxrwx 1 root root    0 Feb 11 15:37 subsystem -> ../../../../class/thermal
-r--r--r-- 1 root root 4096 Feb 11 15:37 type
-rw-r--r-- 1 root root 4096 Feb  5 11:37 uevent
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Will DietPi work on the NanoPi R2S

Post by MichaIng »

Readings about the interface: https://www.kernel.org/doc/html/latest/ ... s-api.html

You have one registered cooling device, associated with trip point 1, which is 85 degree Celsius. That device is currently in state 0 while it can be in states up to 6, so your temperature currently is below 85°C.
I'm pretty sure that cooling device is the CPU, which starts to throttle down in six steps when 85°C is reached:

Code: Select all

cd /sys/class/thermal/thermal_zone0 # shorter patch to the thermal tunables
cat cdev0/type # should show "processor"
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # check freq
echo 6 > cdev0/cur_state # set max state
cat cdev0/cur_state # verify
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # check freq
echo 0 > cdev0/cur_state # reset state
cat cdev0/cur_state # verify
echo 95000 > emul_temp # emulate 95°C
cat temp # should show 95°C
cat cdev0/cur_state # should be high again
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # should be at minimum again
echo 0 > emul_temp # stop temperature emulation
Ah maybe instead of scaling_cur_freq, cpuinfo_cur_freq needs to be checked to see throttled frequencies, as the first might be what the governor wants the CPU to run, based on load only, while the second might show what firmware or such force for thermal or voltage throttling.

However, while it's all interesting to read and learn about the Linux thermal tunables, we actually want the fan being recognised as cooling device, reacting on a trip point we define. And I'm currently not sure how to achieve that.

Probably lm-sensors and its fan control daemon work:

Code: Select all

apt install lm-sensors fancontrol
sensors-detect
sensors
# If the above shows the fan and an RPM value, the following can be used to configure it:
pwmconfig
# To have the related fan control daemon active
systemctl enable --now fancontrol
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

@MichaIng,

Thanks for your reply!

I have tried to flash the image once more and flashed the updated bootloader by executing this:

Code: Select all

. /usr/lib/u-boot/platform_install.sh
write_uboot_platform $DIR /dev/mmcblk0
reboot # to apply changes
Once I try to execute the following block:

Code: Select all

cd /sys/class/thermal/thermal_zone0 # shorter patch to the thermal tunables
cat cdev0/type # should show "processor"
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # check freq
echo 6 > cdev0/cur_state # set max state
cat cdev0/cur_state # verify
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # check freq
echo 0 > cdev0/cur_state # reset state
cat cdev0/cur_state # verify
echo 95000 > emul_temp # emulate 95°C
cat temp # should show 95°C
cat cdev0/cur_state # should be high again
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq # should be at minimum again
echo 0 > emul_temp # stop temperature emulation
It breaks the ssh connection when I attempt to execute the following line:

Code: Select all

echo 95000 > emul_temp
Long story short, I reflashed DietPi into the device and updated the bootloader. Then I executed apt install lm-sensors fancontrol.

Code: Select all

root@DietPi:~# sensors-detect
# sensors-detect revision $Revision$
# DMI data unavailable, please consider installing dmidecode 2.7
# or later for better results.
# Kernel: 5.10.12-rockchip64 aarch64
# Processor:  (//)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): y
modprobe: FATAL: Module cpuid not found in directory /lib/modules/5.10.12-rockchip64
Failed to load module cpuid.
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 17h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Intel digital thermal sensor...                             No
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): y
Sorry, no supported PCI bus adapters found.

Next adapter: rk3x-i2c (i2c-0)
Do you want to scan it? (YES/no/selectively): 

Next adapter: rk3x-i2c (i2c-1)
Do you want to scan it? (YES/no/selectively): 
Client found at address 0x18
Handled by driver `rk808' (built-in), chip type `rk805'
    (note: this is probably NOT a sensor chip!)

Sorry, no sensors were detected.
Either your system has no sensors, or they are not supported, or
they are connected to an I2C or SMBus adapter that is not
supported. If you find out what chips are on your board, check
https://hwmon.wiki.kernel.org/device_support_status for driver status.
root@DietPi:~# sensors
soc_thermal-virtual-0
Adapter: Virtual device
temp1:        +37.3°C  (crit = +95.0°C)

root@DietPi:~# pwmconfig 
# pwmconfig revision $Revision$ ($Date$)
This program will search your sensors for pulse width modulation (pwm)
controls, and test each one to see if it controls a fan on
your motherboard. Note that many motherboards do not have pwm
circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.
The program will attempt to restore each fan to full speed
after testing. However, it is ** very important ** that you
physically verify that the fans have been to full speed
after the program has completed.

/usr/sbin/pwmconfig: There are no pwm-capable sensor modules installed
root@DietPi:~# systemctl enable --now fancontrol
Synchronizing state of fancontrol.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable fancontrol
root@DietPi:~# 

PWM is still not working.

Cheers,
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Will DietPi work on the NanoPi R2S

Post by MichaIng »

Ay, either echo 95000 > emul_temp causes some forced system state change due to /sys/devices/virtual/thermal/thermal_zone0/trip_point_2_type == critical, or emulating a temperature is not permitted/broken. Would have been interesting if the other tunables behave as expected, but it isn't relevant when the the fan is not detected as PWM device :(.

A bit confusing that sensors-detect says "Sorry, no sensors were detected.", but the CPU temperature sensor is actually detected.

I'm out of ideas then for now, how to get it working with this kernel. Probably something to forward to Armbian.

Btw, I updated the image yesterday, so not need to re-flash the kernel for RAM size fix anymore :).
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

@MichaIng,

Thanks for updating the image.

Below is a printout from the flashing updated image, running MINIMAL setup and configs (disabling IPv6 and setting a STATIC IP for the WAN interface using IPv4). Rebooting. Updating DietPi wth # apt upgrade. Rebooting.

Code: Select all

 ─────────────────────────────────────────────────────
 DietPi v6.34.3 : 15:33 - Mon 02/15/21
 ─────────────────────────────────────────────────────
 - Device model : NanoPi R2S (aarch64)
 - CPU temp : 43'C : 109'F (Optimal temperature)
 - LAN IP : 192.168.50.252 (eth0)
 - MOTD : Pi-hole users, please run "pihole -up" to fix security issues in dnsmasq:
          https://pi-hole.net/2021/01/19/pi-hole-ftl-v5-5-released-update-today/
 ─────────────────────────────────────────────────────

 DietPi Team     : MichaIng (lead), Daniel Knight (founder), Joulinar (support)
 Image           : DietPi Core Team (pre-image: Armbian)
 Web             : https://dietpi.com | https://twitter.com/DietPi_
 Donate          : https://dietpi.com/#donate
 DietPi Hosting  : Powered by https://myvirtualserver.com

 dietpi-launcher : All the DietPi programs in one place.
 dietpi-config   : Feature rich configuration tool for your device.
 dietpi-software : Select optimized software for installation.
 htop            : Resource monitor.
 cpu             : Shows CPU information and stats.

root@DietPi:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            978         108         789           2          80         797
Swap:          1069           0        1069
root@DietPi:~# 
Thank you for all your help so far.
gtludwig
Posts: 18
Joined: Tue Nov 17, 2020 11:28 am

Re: Will DietPi work on the NanoPi R2S

Post by gtludwig »

@MichaIng,

Did you ever manage to have another look at this issue?

I have updated DietPi in all my SBCs (Odroid HC2, Raspberry Pi 4 and NanoPi R2S). The RPi sits in an Argon One M.2 case. A leaflet that with the unit says to execute the following script to activate the fan control:

Code: Select all

curl https://download.argon40.com/argon1.sh | bash
I did try this with no luck. I'm happy to try ideas!

Thanks,
Post Reply