Argon One Up - Native Battery Integration

Battery Percent on Argon ONE UP (Ubuntu)

I received the unit yesterday and started testing it. Argon provides a script to manage the battery, but it does not integrate natively with the operating system. The problem is that the script does not register any battery on the power_supply subsystem, so the system cannot recognize the battery as standard.

According to the block diagram, the Argon ONE UP uses a Cellwise CW2217 chip connected over I2C (on RPI1, bus i2c-1, address 0x64), so creating a driver for it is not very difficult.

I created the driver and uploaded it to GitHub cw2217-battery. After installing it, the system can display the battery percentage on Ubuntu or Debian.

:hammer_and_wrench: Build & Install the Module

Install the dependencies.

sudo apt update
sudo apt install git build-essential linux-headers-$(uname -r)

Build the driver module

git clone https://github.com/diegojfer/cw2217-battery.git
cd cw2217-battery

make

After building, you should have the build/cw2217_battery.ko kernel module. You can then install the module manually.

# Install module
sudo mkdir -p /lib/modules/$(uname -r)/extra
sudo cp build/cw2217_battery.ko /lib/modules/$(uname -r)/extra/

# Recreate dependency graph
sudo depmod -a

# Load module
sudo modprobe cw2217_battery

# Load automatically on boot
echo cw2217_battery | sudo tee /etc/modules-load.d/cw2217_battery.conf

:deciduous_tree: DeviceTree Overlay

By default, the bootloader does not expose the CW2217 IC to the kernel (it only enables the I2C bus). Therefore, you need to either add a Device Tree entry or create the device manually.

Register Manually

If you choose to register it manually, you will have to recreate the device every time the system reboots.

# Create device
echo cw2217 0x64 | sudo tee /sys/bus/i2c/devices/i2c-1/new_device

# If you want to remove device
echo 0x64 | sudo tee /sys/bus/i2c/devices/i2c-1/delete_device

Register on Bootloader

To register an overlay, you need to know where the bootloader loads overlay files from. Normally, on Ubuntu on Raspberry Pi, this is /boot/firmware/current/overlays.

// FILE: cw2217-overlay.dts

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2711", "brcm,bcm2712", "brcm,bcm2835";

    fragment@0 {
        target = <&i2c1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";

            cw2217: battery@64 {
                reg = <0x64>;
                compatible = "cellwise,cw2217";
            };
        };
    };
};
# Compile DeviceTree Overlay
dtc -@ -I dts -O dtb -o cw2217.dtbo cw2217-overlay.dts

# Copy DeviceTree Overlay
sudo mv cw2217.dtbo /boot/firmware/current/overlays/cw2217.dtbo

After compiling and copying the Device Tree overlay, you must enable it. To do this, add the following line under the [all] section in config.txt.

dtoverlay=cw2217

:warning: Known Issues

  • Kernel updates: After updating the kernel, you must rebuild and
    reinstall the module because it is an external driver. Consider
    using DKMS to automate this.

  • No DeviceTree overlay: If you create the I2C device manually
    (new_device), you will need to recreate it after every reboot.
    Using a proper overlay avoids this.

:star: Example

3 Likes

Hi, I have an error when running make:

ilkka@argonone:~/cw2217-battery$ make
mkdir -p /home/ilkka/cw2217-battery/build
make -C /lib/modules/6.17.0-1008-raspi/build M=/home/ilkka/cw2217-battery MO=/home/ilkka/cw2217-battery/build modules
make[1]: Entering directory ‘/usr/src/linux-headers-6.17.0-1008-raspi’
make[2]: Entering directory ‘/home/ilkka/cw2217-battery/build’
GEN Makefile
warning: the compiler differs from the one used to build the kernel
The kernel was built by: aarch64-linux-gnu-gcc (Ubuntu 15.2.0-4ubuntu4) 15.2.0
You are using: gcc (Ubuntu 15.2.0-4ubuntu4) 15.2.0
MODPOST Module.symvers
ERROR: modpost: GPL-incompatible module cw2217-battery.ko uses GPL-only symbol ‘power_supply_get_drvdata’
ERROR: modpost: GPL-incompatible module cw2217-battery.ko uses GPL-only symbol ‘power_supply_unregister’
ERROR: modpost: GPL-incompatible module cw2217-battery.ko uses GPL-only symbol ‘power_supply_register’
ERROR: modpost: GPL-incompatible module cw2217-battery.ko uses GPL-only symbol ‘power_supply_changed’
make[4]: *** [/usr/src/linux-headers-6.17.0-1008-raspi/scripts/Makefile.modpost:147: Module.symvers] Error 1
make[3]: *** [/usr/src/linux-headers-6.17.0-1008-raspi/Makefile:1966: modpost] Error 2
make[2]: *** [/usr/src/linux-headers-6.17.0-1008-raspi/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory ‘/home/ilkka/cw2217-battery/build’
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-6.17.0-1008-raspi’
make: *** [Makefile:9: all] Error 2

I am not sure if this is the right thing to do, but my quick fix was to change the last line in the module source to MODULE_LICENSE(“GPL”);

I just updated the library to use GPL License!

Hi, thanks, it worked now.

Just that there was cw2217-battery.ko file instead of cw2217_battery.ko after the make. I renamed the file and the rest of the instructions were OK.

The battery indicator works now and it is great! Thanks a lot.

Hello, and thank you so much for this! However, I followed the instructions, and it all seemed to work exactly as indicated, except that now the battery level just always reads 0% (it does seem to know whether it’s charging or not though). I know code but am completely unfamiliar with Linux driver development. Can you share maybe some tips on where to start diagnosing the issue? Thank you!!

Thanks diegofer, Great Work

Take note that hyhen (cw2217-battery)is used in Make process, and underscore (cw2217_battery) is for the rest of the process. This caused errors.

Thanks to the contribution from rbm78bln, DKMS is now implemented, so the driver should continue working after kernel updates.

I don’t know why but I can’t edit my main message to update installation instructions.

Is there any moderator that can update the main message? If not, you can check the updated version of the tutorial on GitHub Gist.

For troubleshooting you can use lsmod | grep cw2217b and dmesg -w to check if kernel module has been loaded correctly.

1 Like

Hi, I cannot get the cw2217b.dtbo moved to /boot/firmware/current/overlays, because this folder is read only.

Hmm, that’s strange… Ubuntu normally mounts the boot firmware as read-write…

But if that’s the case, you can try remounting the filesystem as read-write.

# Remount as read-write.
sudo mount -o remount,rw /boot/firmware

# Switch back to read-only.
sudo mount -o remount,ro /boot/firmware

I also added a troubleshooting section to the tutorial. Since I can’t edit my main message, check the latest version of the guide on the ArgonOneUP-CW2217.md · GitHub.

Thank you. I got it in there as root.

But now I cannot create the device, because it already exists. Not sure why.

I reflashed Ubuntu (25.10) and everything works (battery percentage and all) until I let Ubuntu do updates.

As you can tell, I am pretty new to Linux (Steam Deck User…) and I did not do anything else, it seems like the Gnome update is the culprit. I also tried to remove Gnome before the update and use KDE instead, with same results.

Any boby manage to get it working on Kali Linux?

Thanks for this contribution, Diego.

This is not working for me. The battery display always says 100% on Ubuntu 25.10.

Hmm - plugged it in, and now I’m seen 19% and charging. More experimentation needed..