Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Improved sunxi_tp_temp for H3

Featured Replies

Hello,

  My sunxi_tp_temp always reports the same value (429496576.0).

After digging around, it seems like it's not reading the correct registers.

According to the H3 datasheet(1), pp 255-258, the thermal sensor base is at 0x01C25000.

The data register is at 0x01C25080.

 

Using the mod_mmio.h and sunxi_tp_temp.c as a guide, I wrote a little utility to print the current SoC temp.

#include <stdio.h>
#include "mod_mmio.h"

// improved temperature print utility
// GPLv2

int main(int argc, char *argv[]) {
  float reading,celsius,farenheit;

  reading = (float)mmio_read(0x01c25080);
  //celsius = (reading - 2794.0) / -14.882; Allwinner H3 datasheet formula
  celsius = ((reading - 2794.0) / -14.882) - 51.0; // adjustment based on observation
  farenheit = celsius * 1.8 + 32;

#ifdef CEL_ONLY
  printf("%0.3f°C\n",celsius);
#elif defined FAR_ONLY
  printf("%0.3f°F\n",farenheit);
#else
  printf("%0.3f°C / %0.3f°F\n",celsius,farenheit,reading);
#endif

  if (argc > 1) printf("raw sensor data: %0.3f\n",reading);
  return 0;

}

You may have to change the value 51.0; I have no idea why the formula from the datasheet didn't work,

I just printed the results of their formula, compared it to the value obtained from

/sys/class/thermal/thermal_zone0/temp, and came up with this 'fudge factor'.

 

You can grab mod_mmio.h from here: https://github.com/igorpecovnik/lib/tree/master/scripts/sunxi-temp

 

I have left defines in for celsius only (#define CEL_ONLY),

farenheit only (#define FAR_ONLY),

and the default is to display both (to train my American mind to get used to SI units).

 

I named my executable pitemp: gcc -o pitemp pitemp.c

I copied it to /usr/local/bin, chowned it to root, and made it suid root so I don't have to type sudo everytime. (not recommended for security reasons).

 

Hope this helps someone.

 

(1): You can download the datasheet (pdf, ~7.5MB) from here:

http://linux-sunxi.org/H3

(scroll down halfway, it's under "Documentation")

sunxi_tp_temp was made to read temperature from A10/A20 touchscreen/touchpad controller temperature sensor with some corrections, since

  • there was no dedicated temperature sensor for CPU cores
  • sensor needed additional calibration

There is no need for this utility on H3 because it has properly integrated thermal sensor which can be read via sysfs

  • Author

sunxi_tp_temp was made to read temperature from A10/A20 touchscreen/touchpad controller temperature sensor with some corrections, since

  • there was no dedicated temperature sensor for CPU cores
  • sensor needed additional calibration

There is no need for this utility on H3 because it has properly integrated thermal sensor which can be read via sysfs

 

Ah, that explains it then. I suppose the integer value is close enough, and it would be trivial to write a script that reads the value and pipes into bc for conversion into Farenheit.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.