LPC SPI Firmware and Driver Prototype

OK so I checked the lsmod list, no dice. I found what looks like the driver in a folder called misc, reform2-lpc.ko, but I can’t load it. I get an invalid module error from insmod. Maybe that’s the wrong one?

I tried also with the other method I found, modprobe, but that gives an exec format error.

Oh whoops, I’ll look into it. Thank you for the error report!

I cannot reproduce your problem. The module is not in a folder called misc but here:

 ./lib/modules/5.19.0-reform2-arm64/updates/dkms/reform2_lpc.ko

It is also not named reform2-lpc.ko but reform2_lpc.ko (underscore instead of dash). Maybe you have some leftovers from a manual installation?

Can you try to apt update and apt install reform2-lpc-dkms to get the latest version of the package?

I also just built reform-system-image locally and flashed the result on my SD-Card. The module gets loaded automatically upon boot:

$ lsmod | grep lpc
reform2_lpc      16384  0

I have updated my system and gotten the latest update to the reform-tools, and the lpc module seems to be correctly loaded. However, both Sway and KDE report the battery as 0%. Plugging in the power does not change that.

The oled screen shows the correct values.

❯ dpkg -l | grep reform-tools
ii  reform-tools                                  1.11                               all          MNT Reform System Tools
❯ dpkg -l | grep lpc
ii  reform2-lpc-dkms                              1.11                               all          dkms driver sources for reform2 lpc
❯ lsmod | grep lpc
reform2_lpc            16384  0

I just installed the firmware a minute ago and it’s working for me in Sway. Your log shows that you have the packages and modules, but you did flash the firmware too, right?

I must say i did not update the new firmware, after I did that, i get a proper reading on the battery level in sway.

It seems that the information is now independent from the information from what the OLED is showing. That is still showing ??? because I’ve just reset the LPC but sway is showing a correct number.

I experienced that too, my guess is it’s the same reason the system controller battery percentage (when it does display one) is not identical to the Waybar/KDE/Gnome battery percentage described by nanocodebug earlier in the thread.

Updating the lpc firmware (or resetting the lpc) clears the full/empty battery charge info. It will take a charge cycle for it to be correct again on the lpc display.

Your desktop environment can be applying its own full/empty charge state logic to the battery indicator as well. I don’t think it will be possible to get these to sync perfectly, but they should generally be within a few percent of each other if everything is working properly.

Really weird…I just ran upgrade again and now I have it, loaded automatically. I wonder why I didn’t get the update sooner! So it worked immediately since everything else was in place.

Has anyone else gotten into a state where the battery percentage is no longer being reported? I forget what triggered it for me (I think I did Circle + R to reset the system controller) but now KDE shows a brightness control where the battery taskbar icon used to be and Sway doesn’t show battery percentage. The tooltip on the KDE brightness control says “No Batteries Available.”

Did you have the kernel module installed manually before and then installed the reform2-lpc-dkms package via the new reform-tools package? Recently on IRC there was a similar situation which solved itself magically: 2022-09-29.log

No, but I did notice that the reform2_lpc module no longer gets loaded, even though reform-tools and reform2-lpc-dkms packages are still installed.

Update: reinstalling reform2-lpc-dkms and rebooting got the module loaded again and battery status is being reported as it was before.

1 Like

FYI I just did a full upgrade after a while away from Reform and the battery status was gone again. Ran sudo apt reinstall reform2-lpc-dkms and cleared that right up.

3 Likes

I was running the 20210925 version of the LPC firmware and with the upgrade to the v6.0 kernel, I lost the battery status info in gnome. Reinstalling the reform2-lpc-dkms didn’t help. I flashed the latest version of the LPC firmware just now and that restored the battery status info in gnome. The LPC firmware version is now reported as 20220621.

1 Like

With the protected battery boards and my new trackball 2.0 arriving I finally found the time to flash the LPC firmware required for the battery status display.

I was able to confirm the problem that sometimes after kernel upgrades, the battery status would vanish. This is a problem with the packaging and I posted the fix here:

I configured wayland like this:

    "battery": {
        "bat": "8xlifepo4",
        "format": "BAT {capacity}% <span font='Font Awesome'>{icon}</span>",
        "format-icons": ["", "", "", "", ""],
        "format-charging": "BAT {capacity}% <span font='Font Awesome'>{icon}</span> ",
        "format-full": "BAT 100% ",
        "interval": 30,
        "states": {
            "warning": 10,
            "critical": 5
        },
        "tooltip": false,
        "on-click": "gnome-power-statistics"
    },

This will show a “flash” symbol when power is plugged in and also give a visual indication of the battery charge. If the battery is too low, it will first turn red and then start blinking using this CSS:

#battery.warning:not(.charging) {
    color: #FF0000;
}

#battery.critical:not(.charging) {
    animation: blink_effect 0.5s steps(2) infinite;
}

@keyframes blink_effect {
        50% { color: #FF0000; }
        100% { color: #0000FF; }
}
5 Likes

You icon symbols are unreadable in the forum post, unfortunately.

I use something less fancy and more limited:

 "battery": {
        "bat": "8xlifepo4",
        "format": "BAT {capacity}%",
        "format-charging": "AT {capacity}%",
        "format-full": "BAT FULL",
        "interval": 30,
        "tooltip": false,
        "on-click": "gnome-power-statistics"
    },
1 Like

The icon symbols may not get rendered properly in your browser, but copypasting them results in the correct characters nonetheless.

1 Like

I know this is an old thread, but I noticed after upgrading my Reform2 system just recently that the battery level is no longer displayed in the waybar.

Some details:

PRETTY_NAME="Debian GNU/Linux trixie/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=trixie
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Linux reform 6.11.2-mnt-reform-arm64 #1 SMP Debian 6.11.2-1+reform20241009T184201Z (2024-10-09) aarch64 GNU/Linux

The kernel module is built and is loaded. I explicitly ran an apt reinstall reform2_lpc.

root@reform:~# lsmod |grep reform2
reform2_lpc            12288  0
root@reform:~# modinfo reform2_lpc
filename:       /lib/modules/6.11.2-mnt-reform-arm64/updates/dkms/reform2_lpc.ko.xz
license:        GPL
description:    Reform 2 LPC Driver
alias:          of:N*T*Cmntre,lpc11u24C*
alias:          of:N*T*Cmntre,lpc11u24
alias:          spi:lpc11u24
depends:        
name:           reform2_lpc
vermagic:       6.11.2-mnt-reform-arm64 SMP mod_unload modversions aarch64
sig_id:         PKCS#7
signer:         DKMS module signing key
sig_key:        4D:FB:9A:06:42:4E:E3:F7:27:B7:08:7C:56:57:2B:FE:2C:9E:D4:1A
sig_hashalgo:   sha256
signature:      97:AB:D6:96:B5:6A:04:5C:BE:ED:C6:D1:6F:CB:39:08:68:7A:E2:3D:
		D5:22:41:2C:6E:6D:A0:A9:52:E6:75:6D:64:F5:56:8B:6A:F4:22:14:
		1B:80:1D:83:D3:61:AB:9A:BA:D6:6E:EE:14:F1:97:68:77:1D:73:CF:
		96:95:36:7B:31:62:21:36:5A:B1:96:06:80:C5:49:4B:12:1F:97:D8:
		F4:15:78:22:C9:C5:2F:BC:19:29:12:9A:8C:D4:CF:69:3C:E3:AD:F5:
		83:E9:E8:C0:17:A3:8E:17:E5:EE:32:1B:1A:58:9E:87:FB:BE:96:CC:
		98:A9:CE:AD:4D:6B:E1:DC:0E:3B:65:64:44:3F:EB:B5:59:F2:09:92:
		BF:31:FC:74:05:3E:C8:CC:08:97:69:C6:0B:5C:22:D9:B0:C4:40:2C:
		67:6B:03:02:C5:0C:76:92:E3:9C:9C:5A:54:AB:3C:2A:94:19:FD:E5:
		E5:29:CD:F9:F5:8C:2B:8B:B9:EB:09:FF:F3:62:65:EE:6B:2A:BD:4B:
		2F:87:EE:B1:9D:8B:48:F6:A1:55:D6:E4:07:80:05:FF:9C:D1:F0:73:
		4E:45:F9:39:31:19:7D:E3:80:E5:FF:AE:87:00:06:1C:F7:20:03:65:
		62:61:5D:83:64:03:5A:E8:87:B2:CD:B6:55:41:AC:C0

And the waybar configuration is unchanged from previously (config truncated for brevity).

# ~/.config/waybar$ cat config
{
    // "layer": "top", // Waybar at top layer
    // "position": "bottom", // Waybar position (top|bottom|left|right)
    "height": 34, // Waybar height (to be removed for auto height)
    // "width": 1280, // Waybar width
    // Choose the order of the modules
    "modules-left": ["sway/workspaces", "sway/mode", "sway/window"],
    "modules-center": [],
    "modules-right": ["tray", "network", "custom/stat", "memory", "battery", "temperature", "pulseaudio", "clock"],
    "sway/window": {
    },
    "sway/mode": {
        "format": "<span>{}</span>"
    },
    "tray": {
        "icon-size": 32,
        "spacing": 16
    },
....
....
    },
    "battery": {
        "bat": "8xlifepo4",
        "interval": 30,
        "format": "BATT {}%"
    },

Has anybody observed anything similar? Is there a way to interrogate the system from the CLI to determine that the module is functioning?

“bat”: “8xlifepo4”

the battery was renamed in an update to the kernel module. the module is shared between the reform2 and pocket reform, each use different chemistry.

its now BAT0 so as to avoid naming the chemistry and number of batteries in the battery name.
replacing “8xlifepo4” with “BAT0” in your waybar config should fix it.

you can manually query the battery via upower (will need to be installed) or by checking the under “/sys/class/power_supply” - there should be a battery device under there with examinable properties

1 Like

Excellent! I will give it a try shortly and write back if there are any more issues. Many thanks :pray: