# Orange Pi Zero: No aw_thermal device



## Miguel (Mar 9, 2020)

Hi all
this is a GENERIC SD card image instalation downloaded from official site, customized as follows for Orange Pi Zero
`dd if=FreeBSD-12.1-STABLE-arm-armv7-GENERICSD-20200220-r358121.img of=/dev/mmcsd0 bs=1M conv=sync
dd if=/usr/local/share/u-boot/u-boot-orangepi-zero/u-boot-sunxi-with-spl.bin of=/dev/mmcsd0 bs=1024 seek=8 conv=sync`
I am worried about the temperature, when the CPU reaches high process rates since the system hangs
The system boots normally but I can't find the aw_thermal device.
May this device be added?
Is there any way to control the temperature at high process rates?
Regards


----------



## JohnnySorocil (Mar 13, 2020)

Miguel said:


> I am worried about the temperature, when the CPU reaches high process rates since the system hangs



I have same board and experienced same issue. Fix for that is to connect it to USB charger (or yellow USB port on PC). Mine board was drawing too much current with connected 3G modem and USB WLAN.
Now board is connected to USB charger (probably 2A) and works as 3G router for days 
Still waiting for delivery of heatsink, but it works as is.



Miguel said:


> The system boots normally but I can't find the aw_thermal device.
> May this device be added?



Yup, you need to use device tree overlay to enable it. I am not currently besides my Orange Pi Zero, so I can't tell you (nor upload) exact device tree file names. I think that I have used (and patched) Armbian files but not sure. I am planning to write small tutorial how I did it for weeks, but, well, "life" happens.


----------



## Miguel (Mar 14, 2020)

Thank you for your comments, I'm waiting for delivery of heatsink too
About thermal device, it seems the module is loaded since if I try to do it manually the system responds with the following error message.
`# kldload aw_thermal
kldload: can't load aw_thermal: module already loaded or in kernel`
I don't know if something else would have to be added to make it operational


----------



## JohnnySorocil (Mar 15, 2020)

Miguel said:


> `# kldload aw_thermal
> kldload: can't load aw_thermal: module already loaded or in kernel`
> I don't know if something else would have to be added to make it operational



You still need device tree which describes to that kernel module where actual device is implemented:

```
root@naranca:~ # kldload aw_thermal
kldload: can't load aw_thermal: module already loaded or in kernel
root@naranca:~ # ofwdump -a | grep thermal
    Node 0x528: thermal_sensor@1c25000
root@naranca:~ # sysctl -a | grep thermal
dev.aw_thermal.0.cpu: 71C
dev.aw_thermal.0.%parent: simplebus0
dev.aw_thermal.0.%pnpinfo: name=thermal_sensor@1c25000 compat=allwinner,sun8i-h3-ths
dev.aw_thermal.0.%location:
dev.aw_thermal.0.%driver: aw_thermal
dev.aw_thermal.0.%desc: Allwinner Thermal Sensor Controller
dev.aw_thermal.%parent:

root@naranca:~ # grep overlay /boot/loader.conf
fdt_overlays="sun8i-h3-sid.dtbo,sun8i-h3-ths.dtbo,sun8i-h3-i2c0.dtbo,sun8i-h3-i2c1.dtbo,sun8i-h3-usbhost0.dtbo,sun8i-h3-usbhost1.dtbo,sun8i-h3-usbhost2.dtbo,sun8i-h3-usbhost3.dtbo,sun8i-h3-pwm1.dtbo,sun8i-h3-analog-codec.dtbo"
```

In attachment (rename it to .tar) are .dtbo and .dts files. Just put sun8i*ths*.dtbo file in /boot/dtb/overlays/ add relevant fdt_overlays part in loader.conf and reboot.


----------



## Miguel (Mar 15, 2020)

Something I'm not doing right because I still can't find the device
My model is Orange Pi Zero H2 +

This is what I have done:
`cp sun8i-h3-ths.dtbo /boot/dtb/overlays`

This is my final /boot/loader.conf

```
fdt_overlays="sun8i-h3-ths.dtbo"
# Configure USB OTG; see usb_template (4).
hw.usb.template=3
umodem_load="YES"
# Disable the beastie menu and color
beastie_disable="YES"
loader_color="NO"
```

This is the start record

/var/run/dmesg.boot (txt)


----------



## JohnnySorocil (Mar 15, 2020)

What it says before "---<<BOOT>>---" line? You can see it in UART console, before kernel is loaded.
Maybe try without spaces around "=" in loader.conf or 12.1-RELEASE?
That .dtbo file is what I have pulled from my router (OrangePi Zero, Allwinner H2+) this afternoon and it works.


----------



## Miguel (Mar 15, 2020)

JohnnySorocil said:


> What it says before "---<<BOOT>>---" line? You can see it in UART console, before kernel is loaded.


I connect through ssh and I don't see the previous messages in the console


JohnnySorocil said:


> Maybe try without spaces around "=" in loader.conf or 12.1-RELEASE?


spaces have been a "copy-paste" error, sorry... I just edited it to correct it


----------



## Miguel (Mar 15, 2020)

may I see the messages in the console before kernel start redirecting the output to a file?


----------



## JohnnySorocil (Mar 15, 2020)

Not sure about that, but probably the easiest way would be to connect UART and check console, you should see something like this:


```
Loading kernel...
/boot/kernel/kernel text=0x85cffc data=0xb1968+0x1f4698 syms=[0x4+0xa2ab0+0x4+0x10413c]
Loading configured modules...
/boot/kernel/umodem.ko text=0x1540 text=0xf00 data=0x1088+0xf7c syms=[0x4+0xe70+0x4+0xa74]
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x1734 text=0x29b0 data=0x1088+0x17b0 syms=[0x4+0x13e0+0x4+0xbac]
/boot/entropy size=0x1000

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...               
Using DTB provided by EFI at 0x47ef6000.
Loading DTB overlays: 'sun8i-h3-sid.dtbo,sun8i-h3-ths.dtbo,sun8i-h3-i2c0.dtbo,sun8i-h3-i2c1.dtbo,sun8i-h3-usbhost0.dtbo,sun8i-h3-usbhost1.dtbo,sun8i-h3-usbhost2.dtbo,sun8i-h3-usbhost3.dtbo,s
un8i-h3-pwm1.dtbo,sun8i-h3-analog-codec.dtbo'
/boot/dtb/overlays/sun8i-h3-sid.dtbo size=0x25c
/boot/dtb/overlays/sun8i-h3-ths.dtbo size=0x410
/boot/dtb/overlays/sun8i-h3-i2c0.dtbo size=0x1a6
/boot/dtb/overlays/sun8i-h3-i2c1.dtbo size=0x1a6
/boot/dtb/overlays/sun8i-h3-usbhost0.dtbo size=0x228
/boot/dtb/overlays/sun8i-h3-usbhost1.dtbo size=0x228
/boot/dtb/overlays/sun8i-h3-usbhost2.dtbo size=0x228
/boot/dtb/overlays/sun8i-h3-usbhost3.dtbo size=0x228
sun8i-h3-pwm1.dtbo: failed to load file
sun8i-h3-analog-codec.dtbo: failed to load file
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-sid.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-ths.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-i2c0.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-i2c1.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-usbhost0.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-usbhost1.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-usbhost2.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-usbhost3.dtbo'
EHCI failed to shut down host controller.
Kernel entry at 0x53000180...
Kernel args: (null)
modulep: 0xc0cc8000
relocation_offset 0
---<<BOOT>>---
Copyright (c) 1992-2019 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.1-RELEASE r354233 GENERIC arm
...
```

And there look if your device tree overlay is applied or not:

```
applying DTB overlay '/boot/dtb/overlays/sun8i-h3-ths.dtbo'
```

I had a problem before, when my .dtbo was rejected because it is incompatible. Uploaded .dtbo is patched and works for sure on 12.1-RELEASE. Maybe you can try to reproduce my steps and then try it with -STABLE/something. Because, it works on my bench™


----------



## Miguel (Mar 15, 2020)

JohnnySorocil said:


> I had a problem before, when my .dtbo was rejected because it is incompatible. Uploaded .dtbo is patched and works for sure on 12.1-RELEASE. Maybe you can try to reproduce my steps and then try it with -STABLE/something.


I suppose may be a good idea recompile the .dts file and get a new .dtbo
How did you do to compile your file?

```
dtc -I dts -O dtb -b0 -@ -o sun8i-h3-ths.dtbo sun8i-h3-ths.dts
```
Is correct?


----------



## JohnnySorocil (Mar 15, 2020)

Not sure if there is need to recompile it, I think mine was compiled on amd64, but yes, that is the command which I have used to convert .dts to .dtbo.


----------



## Miguel (Mar 15, 2020)

just in case I have recompiled it in amd64 but it doesn't work either


----------



## JohnnySorocil (Mar 16, 2020)

Logs on UART? sysctl doesn't show thermal device? Try it on 12.1-RELEASE?


----------



## Miguel (Mar 17, 2020)

I have tried a 12.1-RELEASE official image with identical results

```
# uname -a
FreeBSD generic 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  arm
```



JohnnySorocil said:


> Logs on UART?


I can't see pre-ssh connection messages; I don't know how to redirect console messages to a file to see what happens at startup


JohnnySorocil said:


> sysctl doesn't show thermal device?




```
sysctl -a | grep thermal
```
shows nothing


----------



## JohnnySorocil (Mar 17, 2020)

Well then, maybe it fails loading dtbo. That message I was able to see in UART console (with cheap $1 USB adapter connected to PC). Don't know how to redirect u-boot/something messages to a file.
What does ofwdump command (specified earlier in thread) shows for thermal device? If dtbo file is not loaded it will not show anything


----------



## Criosphinx (Mar 17, 2020)

A couple years ago the temperature sensor was working but then it didn't anymore:


			aw_thermal breakage on Allwinner H3 SoC
		


At that time I was still testing different systems (Armbian, NetBSD) on my Orange Pi One and since I have been using the GENERICSD images that are now available I didn't try to find a solution.

I see that there is a patch: https://github.com/freebsd/freebsd/pull/162/commits/ededc8caa2e9a543d556f46078ad5671d680fa54 but the overlay file is not part of the image.

When I try to compile it I get the error:
`dtc -I dts -O dtb -@ -o sun8i-h3-ts.dtbo sun8i-h3-ts.dtso
Error at sun8i-h3-ts.dtso:16:16: Expected numbers in array of cells
        interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
                      ^
Error at sun8i-h3-ts.dtso:16:16: Expected ; at end of property
        interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
                      ^
Failed to parse tree.`


----------



## Miguel (Mar 17, 2020)

Well, finally I was able to access the console through a USB adapter directly to the uart
It seems to be something wrong with the fat partition.
Although it loads .dtbo files, they seem to be incompatible
This is the console output at boot:

```
U-Boot SPL 2019.10 (Mar 01 2020 - 23:29:50 +0100)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2019.10 (Mar 01 2020 - 23:29:50 +0100) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi Zero
DRAM:  512 MiB
MMC:   mmc@1c0f000: 0, mmc@1c10000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   phy interface0
eth0: ethernet@1c30000
starting USB...
Bus usb@1c1a000: USB EHCI 1.00
Bus usb@1c1a400: USB OHCI 1.0
Bus usb@1c1b000: USB EHCI 1.00
Bus usb@1c1b400: USB OHCI 1.0
scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
26697 bytes read in 4 ms (6.4 MiB/s)
Found EFI removable media binary efi/boot/bootarm.efi
Scanning disk mmc@1c0f000.blk...
Card did not respond to voltage select!
Scanning disk mmc@1c10000.blk...
Disk mmc@1c10000.blk not ready
Found 4 disks
BootOrder not defined
EFI boot manager: Cannot load any image
623788 bytes read in 39 ms (15.3 MiB/s)
Consoles: EFI console
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/arm EFI loader, Revision 1.1

   Command line arguments: l
   EFI version: 2.80
   EFI Firmware: Das U-Boot (rev 8217.4096)
   Console: efi (0)
   Load Path: /efi\boot\bootarm.efi
   Load Device: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Trying ESP: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Setting currdev to disk0p1:
Trying: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,0x01,0,0x197c7,0xe80839)
Setting currdev to disk0p2:
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
-

Loading kernel...
/boot/kernel/kernel text=0x8b5334 data=0xa46c8 data=0x0+0x1f0000 syms=[0x4+0xa37f0+0x4+0x104d0c]
Loading configured modules...
/boot/kernel/umodem.ko text=0x1520 text=0xf30 data=0x234+0x4 syms=[0x4+0xe70+0x4+0xa74]
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x1714 text=0x2c60 data=0x3c4+0x838 syms=[0x4+0x13e0+0x4+0xbac]
/boot/entropy size=0x1000

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...            
Using DTB provided by EFI at 0x47ef6000.
Loading DTB overlays: 'sun8i-h3-sid.dtbo,sun8i-h3-ths.dtbo'
/boot/dtb/overlays/sun8i-h3-sid.dtbo size=0x210
/boot/dtb/overlays/sun8i-h3-ths.dtbo size=0x3e0
Kernel entry at 0x55000200...
Kernel args: (null)
DTB overlay '/boot/dtb/overlays/sun8i-h3-sid.dtbo' not compatible
DTB overlay '/boot/dtb/overlays/sun8i-h3-ths.dtbo' not compatible
EHCI failed to shut down host controller.
---<<BOOT>>---
```
I have tried several SD cards with the same result so I think the problem is not in the physical medium that I use


Criosphinx said:


> When I try to compile it I get the error:
> dtc -I dts -O dtb -@ -o sun8i-h3-ts.dtbo sun8i-h3-ts.dtso
> Error at sun8i-h3-ts.dtso:16:16: Expected numbers in array of cells
> interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
> ...


try to compile your latest official version with a specific Makefile in its correct location
/usr/src/sys/dts/arm/overlays on my laptop (amd64)
here you can see several .dtso including sun8i-h3-ths.dtso
you may compile them all at once by executing the following:
`# cd /usr/src/sys/dts/arm/overlays
# make`
You will find all .dtbo files in /tmp by default
anyway, loading these new files, the same error appears


----------



## Miguel (Mar 19, 2020)

To clarify ... the FAT partition crc error does not seem due to a physical problem with the SD card since I have tried several. The compatibility of .dtbo files is another different issue.


----------



## JohnnySorocil (Mar 20, 2020)

Did you try with ths*dtbo uploaded earlier in the thread on 12.1-RELEASE? That one works for sure on my Orange Pi Zero.


----------



## Miguel (Mar 21, 2020)

I just repeated a 12.1 RELEASE image SD card, to see console output, with this settings in loader.conf:
`fdt_overlays="sun8i-h3-sid.dtbo,sun8i-h3-ths.dtbo"`
first file is original in /boot/msdos/dtb/overlays (not compatible), second is yours (copied there but not loaded)
`...
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...              
Using DTB provided by EFI at 0x47ef6000.
Loading DTB overlays: 'sun8i-h3-sid.dtbo,sun8i-h3-ths.dtbo'
/boot/dtb/overlays/sun8i-h3-sid.dtbo size=0x18e
sun8i-h3-ths.dtbo: failed to load file
DTB overlay '/boot/dtb/overlays/sun8i-h3-sid.dtbo' not compatible
EHCI failed to shut down host controller.
Kernel entry at 0x53000180...
Kernel args: (null)
modulep: 0xc0cc5000
relocation_offset 0
---<<BOOT>>---
....`
(edited to paste the exact console output)


----------

