Charging sdl was in my opinion a pretty neat tool that made postmarketOS feel more feature complete.
I think the existing implementation was somewhat overcomplicated, so why dont we bring it back as something a lot easier:
A shell script (or Go binary if someone fancies) which reads the battery voltage, charge, charging current etc and just displays them on the console, maybe with some cool ascii art or something :D
Rather than using triggerhappy, lets make use of the fact that the power button is configured as a wakeup source, have the script loop for a few second and then disable the backlight and put the system into s2idle (where the CPUs are up but userspace and IO is frozen).
This would be a lot simpler, work out of the box on any device with a framebuffer and battery stats and I think be much more suited to postmarketOS than charging-sdl was.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
This should be user cinfigurable via postmarketOS tweaks (the timeout as well as the ability to just disable the functionality entirely). We can do this by storing a configuration file in /boot which is read by the initramfs.
By Caleb Connolly on 2021-09-06T12:10:53
Administratorchanged title from Revive charging-sdl to Revive power-on charging mode display (charging-sdl)·
Imported
changed title from Revive charging-sdl to Revive power-on charging mode display (charging-sdl)
It is, but I want to change some things (investigate LVGL's task system, add support for power button without triggerhappy etc.) before releasing it, otherwise it has feature parity with charging-sdl and runs where directfb doesn't work :D
That's great! Would it be feasible to make use of s2idle and the fact that the powerbutton will always wake the device to implement the screen off stuff? This would also reduce power draw.
For reference, below is the code from mkinitfs that figured out if charging mode is active from the kernel command-lines. I think when adding it again, it should be done as mkinitfs extra hook, so we can add it only to the devices that need it.
Also maybe it makes sense to just integrate this into unl0kr? it would be nice to display the battery status inside of it (and I'd also like to see that for ondev2, which is based on unl0kr). Maybe it could be started in a charging mode that only displays the battery, and shutdown / boot to OS buttons. (@cherrypicker, thoughts on that?)
start_charging_mode(){# Check cmdline for charging modechargingmodes=" androidboot.mode=charger lpm_boot=1 androidboot.huawei_type=oem_rtc startup=0x00010004 lpcharge=1 androidboot.bootchg=true "# Support devices using KMS# shellcheck disable=SC2154if[-n"$deviceinfo_mesa_driver"];thenexport SDL_VIDEODRIVER="kmsdrm"fi# shellcheck disable=SC2086grep-Eq"$(echo$chargingmodes | tr' ''|')" /proc/cmdline ||return# ... run charging app here}
Also maybe it makes sense to just integrate this into unl0kr? it would be nice to display the battery status inside of it (and I'd also like to see that for ondev2, which is based on unl0kr). Maybe it could be started in a charging mode that only displays the battery, and shutdown / boot to OS buttons. (@cherrypicker, thoughts on that?)
That could be a nice feature in unl0kr, yes. I'm not quite sure how we'd set this up packaging-wise though. I suppose there can be cases where you don't want FDE or you want FDE but with osk-sdl but still want charging-sdl, right?
I would like it if you could clarify why you think it makes sense for unl0kr to handle this. Handling a charging mode doesn't seem very related to handling unlocking of an encrypted rootfs to me. Am I missing something?
Seeing the battery status during boot / unlocking seems helpful to me. I'm a little less clear if unl0kr should be the charging-sdl replacement but maybe @ollieparanoid didn't actually mean it like that?
I'm interpreting "Also maybe it makes sense to just integrate this into unl0kr?" as that he imagines unl0kr would amass charging-sdl's functionality at least.
Rather than using triggerhappy, lets make use of the fact that the power button is configured as a wakeup source, have the script loop for a few second and then disable the backlight and put the system into s2idle (where the CPUs are up but userspace and IO is frozen).
Great idea! Yeah the way charging-sdl did it seemed pretty inefficient.
i think we can collect some actual arguments why we should have this, beyond "it was neat",
specifically some might be non-obvious, so let's collect:
user expectations
users are expecting to be able to charge without booting (they call it "powering on", but we don't need to be confused by that):
#2329 "Oneplus-enchilda will automatically restart after shutting down while charging"
#2858 "samsung charging without automatical poweron?"
the battery charge might be too low or the battery too weak to support booting,
specifically on devices without fast-charge, where the charger alone might not sustain the system at load peaks.
so the user should have the option to charge before booting.
here the lack-of-feature actually becomes a bug:
#2594 "Phone boot-loops when battery is critically low"
do we have any guarantee that, when the device comes up in charging mode, all hardware is actually initialized and available just like in regular mode?
as far as i am aware, android will always reboot to get from charging mode to regular operation:
!6219 (merged) "crownlte: touchscreen not working when booted by plugging charger"
It would probably make a lot of sense to build charging-sdl like functionality into @cherrypicker's awesome BuffyBox code tree (which also has unl0kr for unlocking FDE installs, which replaced osk-sdl).