Trying to emulate "get_throttled" functionality that vcgencmd provides on the RPi

I’m running AllSky on Le Potato with 2022-09-22-raspbian-bullseye-arm64-lite+aml-s905x-cc.

One of the functions that the UI provides is a visual status of CPU throttling which it gets by running ‘vcgencmd get_throttled’ and vcgencmd, while it is available, is not supported. I believe since it’s not a Broadcom chip.
I created a wrapper for vcgencmd which returns a static “all’s well” message, but would like to actually pull live throttling data (from somewhere) and return that in the format that vcgencmd does,

I’ve done some poking, and can find things like CPU temperature in /sys/class/*, but nothing about current (or past) throttling events.

If anyone has any tips where I can find that, it would be greatly appreciated.

Check the cur_state file in the cooling_device0 directory. If it has a non-zero value, it means the CPU is thermal throttled.

cat /sys/class/thermal/cooling_device0/cur_state # current thermal throttling
cat /sys/class/thermal/cooling_device0/stats/time_in_state_ms # counter for time in each state

Other relevant bits include the following:

/sys/class/thermal/thermal_zone0/temp # current temperature
/sys/class/thermal/thermal_zone0/trip_point_0_temp # temperature at which Linux throttles CPU

These are standard virtual files across the Linux world. Raspberry Pi’s vcgenmod is poison and they are forced to use it because they screwed up on the hardware power design in Pi 3 B/B+ and need to hack the firmware to compensate for a hardware bug that they refuse to fix.

Thank you. I appreciate your reply. This will be very helpful!

One more quick question, if I may.
Is there a similar interface to monitor board / CPU voltage and recognize past or present under-voltage events? I don’t want to intentionally under-voltage teh board just to see if I get anything out of dmesg or the /var/log files.
That’s the final piece needed to emulate the vcgencmd get_throttled that the AllSky UI monitors and displays.
Thank you!

There’s no voltage sensor. The board will just experience errors if undervolted below 4.5V. The upside is that this board will not experience errors unless the power supply cannot deliver > 1.5A at 4.5V. Raspberry Pi 3 and higher need >2A at 5.3V in order to stay stable.

Ok. Thank you again!