Pmbootstrap: Implement charging mode

Created on 4 Jan 2018  路  10Comments  路  Source: postmarketOS/pmbootstrap

I've started with the packaging of the charging-sdl which can be tested in the branch:
https://github.com/postmarketOS/pmbootstrap/tree/feature/charging-sdl

Building the package

pmbootstrap checksum charging-sdl
pmbootstrap build charging-sdl --arch armhf

Installation on the device

pmbootstrap install --add charging-sdl
or copy it into the device:
scp $work/packages/armhf/charging-sdl-0.1-r0.apk [email protected]:/home/user/
ssh [email protected]
apk add ./charging-sdl-0.1-r0.apk

Testing

export DFBARGS="system=fbdev,no-cursor,disable-module=linux_input"
charging-sdl -pcf /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf

Todo

  • [x] Package charging-sdl with proper version tag
  • [x] Include charging-sdl into the initramfs-extra
  • [x] Identify a common way to detect the charging mode on each device
  • qualcomm lk adds androidboot.mode=charger to the kernel cmdline when it's supposed to go to charger mode (see lk code) (thanks to @z3ntu)
  • some Samsung devices have lpm_boot=1 in the kernel cmdline for charge mode

| device | normal | charge mode |
|----------------|--------------------------|---------------------------------------------------|
| samsung-i9070 | lpm_boot=0 | lpm_boot=1 |
| samsung-klte | androidboot.baseband=msm | androidboot.baseband=lpm androidboot.mode=charger |
| samsung-maguro | - | androidboot.mode=charger |
| huawei-y530 | - | androidboot.huawei_type=oem_rtc |
| sony-seagull | startup=0x00000001 warmboot=0x00000000 | startup=0x00010004 warmboot=0x77665501 |

architecture enhancement initramfs packaging

All 10 comments

@drebrez We either make a list of known cmdline params, or add a new deviceinfo variable. I would go with the former, because I assume it's more or less consistent between devices made by the same manufacturer.

Include charging-sdl into the initramfs or initramfs-extra

I'd prefer initramfs-extra, so we don't need to put SDL into the initramfs.

@ata2001 I agree to go with a list of known cmdline, if that doesn't work out, it shouldn't be that hard to switch later to a different solution. I suggest starting by collecting this list for as much as possible devices that we already have, so we can have a better look of the differences.
@ollieparanoid yes, the initramfs-extra is definitively the better place, I've updated the todo list.

Right now the charging-sdl is configured to display the battery for 5 seconds and close itself.
How do we want to show it in charging mode?
I was thinking that we can start charging-sdl (if not already running) when we press the power button and let it close automatically, but that raises the question about how to handle the power button on all devices

@drebrez https://github.com/postmarketOS/charging-sdl/commit/461036a579946a76f1574258983fdd7b0850bf02 just got merged by the way, that means, you don't even need to turn the screen off on some of the devices (although I'm not sure how is the CPU/battery usage of the SDL loop).

For handling power button events, triggerhappy might be a viable option.

I've checked some of my devices and here are the various cmdline:

(edit: table moved to first post)

If somebody else can also verify on some devices what are the differences in the cmdline, it would be great

I documented mine some time ago. The difference isn't really obvious: https://wiki.postmarketos.org/wiki/Sony_Xperia_T3_(sony-seagull)#Boot_command_line

It seems like the samsung-i9100 always has the same command line, no matter if in charging mode or not. I've tried to boot it about 5 times now:

console=ttySAC2,115200 consoleblank=0 androidboot.hardware=smdk4210 loglevel=4 console=ram androidboot.serialno=00099991717777e sec_debug.enable=0 sec_debug.enable_user=0
c1_watchdog.sec_pet=5 sec_log=0x100000@0x4d900000 s3cfb.bootloaderfb=0x5ec00000 ld9040.get_lcdtype=0x0 consoleblank=0 lpj=3981312 vmalloc=144m

I guess we really need a button in osk-sdl to exit to charging mode.

@ollieparanoid I've downloaded the lineage os kernel for the samsung-i9100, extracted the initramfs and the internal boot.cpio.
Inside the init executable I've found this line /sys/class/power_supply/battery/batt_lp_charging, maybe they check that right at the beginning to decide if they have to go in charge mode or not.
Can you check what's the value inside that file? With and without the usb connected?

Other interesting things I've found searching for the charg word inside the boot.cpio:

  • Add ability to boot from charger mode (link)
  • Search in the various .rc files for settings to reduce performance and improve charing. e.g.:
on charger
# CPU Frequency Governor
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor powersave
# EHCI runtime enable for LPA
    write /sys/devices/platform/s5p-ehci/power/control auto 

I've also noticed that one of my devices doesn't automatically shutdown the phone when the usb gets removed.
How do we want to handle that case? Should we open a new issue to track these improvements?

Thanks for all the input, I've created multiple issues from it in the charging-sdl repository. About being able to boot from the charging mode: That is a nice feature, and I'd like to see this in charging-sdl as well. But I think our code would need to be entirely different, see https://github.com/postmarketOS/charging-sdl/issues/19.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartijnBraam picture MartijnBraam  路  6Comments

craftyguy picture craftyguy  路  6Comments

zenety picture zenety  路  5Comments

ollieparanoid picture ollieparanoid  路  5Comments

fynngodau picture fynngodau  路  3Comments