My laptop runs Arch, and I can find battery information about the battery of the laptop inside /sys/class/power_supply/BAT0
. As far as I know, I have installed nothing to make this information available. I would love to have the same information available on my Jetson AGX Xavier, which is run by a battery, but has no idea about the max energy, percentages, etc. I suspect there needs to be more hardware which can collect this data. What does it look like, and can I implement it myself?

- 33
1 Answers
That is sysfs, a pseudo or synthetic filesystem used by the kernel to export things. It is to interact in a *nix way with the system, just like the older /proc
is to interact with the kernel and its modules.
$ mount | grep sysfs
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
You can read more here What is the difference between procfs and sysfs?
About the battery information, you will need a kernel module that can talk to a particular firmware. For example my Debian system has thinkpad_acpi
kernel module loaded to make things like this happen. I can't tell much about the writing. From what I've read some firmware may present itself through some bus device (for example SMBus/I2C, maybe as a keyboard or even a mouse) to communicate with the OS. In the past I've soldered LM75A
temperature sensors directly onto SMBus lines of memory DIMM's, and used I2C software and lm-sensors
to read them out after fiddeling with a kernel module and settings in /proc/bus/...
somewhere.
Btw. I like to point out the TLP project has tlp-stat --battery
which can conveniently report on /sys/class/power_supply/
and many other power-management related things.
But you will need a 'device driver' first. If you are comfortable with Kernel C coding, you could give it a try. You would be writing the firmware and building the hardware yourself anyway, so at least no mysteries there. I don't know the Jetson, but I'd think there are some other home-brew projects like this already out there in Linux land. Maybe for the Raspberry Pi?
I was reading some 2013 and 2017 posts on ACPI on ARM and wanted to add:
These ACPI/UEFI appearantly are x86/BIOS-world things and afaics based on abstraction standards which don't really apply to the SoC/ARM world per se. And there is the issue with how vendor firmware 'blobs' fit in with 'open source efforts'. But no, I have not seen ACPI for Raspberry although some 'ACPIA' (ACPI for ARM?) efforts seem to be there.
https://lwn.net/Articles/574439/ https://forums.raspberrypi.com/viewtopic.php?t=180001

- 106
ACPI
but AGX Xavier looks like an ARM part and I'm not aware of ARM's implementation. – Artem S. Tashkinov Jan 25 '22 at 17:42