Repository navigation
Closed
Description
tested at NT98566 (XM ipg-N8S )
root@nt98566-imx415:~# nt1
ain_avg_out=262, trim=236, temp=63 °C
trim - calibration value at eFuse (do not know way to read it but
https://github.com/OpenIPC/linux/blob/novatek-nt9856x/drivers/iio/adc/nvt_adc.c
used
#define DEFAULT_THERMAL_LEVEL 259
#define DEFAULT_THERMAL_528_LEVEL 231
values
)
#!/bin/sh
# nvt_adc_devmem.sh - Read Novatek NA51089/NT98566 CPU temperature via devmem
# No kernel module required. Enables ADC clock, configures ADC, reads thermal sensor.
# Tested on NT98566 (NA51089). trim_value = 236 for this chip.
# --- Step 1: Enable ADC clock (bit 13 in CG_CLK_EN_REG1) ---
VAL=$(devmem 0xf0020074) # CG_CLK_EN_REG1: read current value
VAL_DEC=$(printf "%d" "$VAL") # convert hex to decimal
NEW=$(( VAL_DEC | 0x2000 )) # set bit 13 (ADC clock enable)
devmem 0xf0020074 32 $(printf "0x%08X" "$NEW") # CG_CLK_EN_REG1: write back with bit 13 set
# --- Step 2: Enable ADC interrupts (bits 0-6) ---
devmem 0xf0260008 32 0x0000007F # ADC_INTCTRL: enable ain0-3 + aintr0-2
# --- Step 3: Configure ADC: ain0-3_mode=1, clkdiv=1, adc_en=1 ---
devmem 0xf0260000 32 0x5080100F # ADC_CTRL: channels on, clkdiv=1, ADC enabled
# --- Step 4: Wait for first conversion ---
sleep 1
# --- Step 5: Read thermal sensor register ---
RAW=$(devmem 0xf0260040) # THERMAL_SENSOR_CONFIGURE: read raw value
RAW_DEC=$(printf "%d" "$RAW") # convert hex to decimal
AIN_AVG=$(( (RAW_DEC >> 16) & 0x1FF )) # extract ain_avg_out (bits 24:16, 9 bits)
# --- Step 6: Convert to Celsius (NA51089 formula) ---
TRIM=236 # eFuse trim value for this chip (calibrated)
TEMP=$(( (AIN_AVG - TRIM) * 13 / 10 + 30 )) # temp = (ain_avg_out - trim) * 13 / 10 + 30
# --- Output ---
echo "ain_avg_out=$AIN_AVG, trim=$TRIM, temp=${TEMP} °C"
pure driver may compile as kernel module
CONFIG_IIO=m
CONFIG_NVT_ADC=m
CONFIG_THERMAL=m
insmod industrialio.ko
insmod thermal_sys.ko
insmod nvt_adc.ko
cat /sys/class/thermal/thermal_zone0/temp
Metadata
Metadata
Assignees
Labels
No labels
Activity
widgetii commentedon Nov 10, 2026
Thanks. That register path is the right one, and #276 builds it into
ipctool --temp/ipcinfo --tempfor NA51089. It differs from your script in two ways:0xF0660000. The read sequence is in the SDK's binaryotp_protected.o_shipped, and ipctool now runs it itself, read-only. Your kernel may already show the value:echo trim > /proc/nvt_otp_op/otp_trim; dmesg | tail -8prints it as[6] data = 0x.... Our lab NT98566 has0xe4= 228.nvt_adcuses* 13 / 10only for NA51055. On NA51089 it's(code - trim) * 1319 / 1000 + 30.It also only adds
ain3_mode | adc_ento whatever is already inADC_CTRL, rather than writing0x5080100Fover it. It doesn't need the interrupt enables or the 1 s sleep, because the first average arrives in well under a millisecond.On the jumping
thermal_zone0values you posted earlier (66, 43, 45, 12, 20): I couldn't reproduce them. On our NT98566 the raw average stays within ±1 code over 1500 back-to-back reads, both with thenvt_adcregister settings and with these. If you still see the swings, please post a few raw reads from your board:Once #276 is merged, the rolling
latestrelease picks it up andipctool --tempwill use it. Please post what it reads on your IMX415 board alongside your script's number.sansarus commentedon Nov 10, 2026
nt1
ain_avg_out=263, trim=236, temp=65 °C
root@nt98566-imx415:
##root@nt98566-imx415:
root@nt98566-imx415:~# for i in 1 2 3 4 5 6 7 8 9 10; do devmem 0xf0260040; done
0x01070030
0x01080030
0x01070030
0x01070030
0x01070030
0x01070030
0x01080030
0x01080030
0x01080030
0x01080030
ipctool --temp
The ipctool installed as remote GitHub plugin
Temperature cannot be retrieved
my temp from 66 to 12 - with freezer.....just to see real temp changes
sansarus commentedon Nov 10, 2026
echo trim > /proc/nvt_otp_op/otp_trim; dmesg | tail -8
[0] data = 0x000012e4
[1] data = 0x000002a4
[2] data = NULL
[4] data = 0x00000383
[3] data = 0x0000005b
[5] data = NULL
[6] data = 0x000000eb
[7] data = 0x00000006
widgetii commentedon Nov 10, 2026
Thanks, that settles the calibration for your chip:
[6] = 0xebis the thermal trim, 235. That's one below the 236 you picked. Ours reads0xe4= 228, so it does differ from die to die.With NA51089's formula, the
ain_avg_out=262from your first post works out to:Your script gave 63, because it used 236 and the NA51055 slope of 1.3.
You don't need the proc file for this. ipctool now reads row 6 directly from the eFuse controller, the same value
otp_trimprints, soipctool --tempfrom the currentlatestrelease (#276) should land on that figure without any hardcoded trim. Please post its output next to adevmem 0xf0260040from your camera. Ifthermal_zone0still jumps around on your build, a few raw reads would show whether that's the board or the driver.NA51055 (NT9852x) and NA51084 (NT98528/529) are now covered too (#277).
novatek: read NA51089 die temperature from the registers (OpenIPC#276)