-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Battery calibration issues after running Linux #6
Comments
Also of note is that the system time/date is set to some point in 2035, although this is likely a separate issue |
The time/date issue is normal. Linux keeps track of time using the hardware real-time clock directly, while Horizon instead stores an offset separately and never changes the hardware clock. By running Linux with NTP enabled, you change the hardware clock, and then Horizon gets the wrong time on the next boot. However, after Horizon syncs the clock again via the network, its offset will now be 0 (effectively), and from that point on Linux and Horizon should have synchronized clocks and the problem should not occur again. There may be some minor offsets as both Linux and Horizon correct clock drift independently, but periodic network sync in both OSes should keep things in check. |
Documentation of the fuel gauge: Linux has code to modify the remaining battery percentage at boot at: You can try and add a printk here to make sure that the registers are not written. Then as per spec, the battery pourcentage is fully driven by fuel gauge, and read only by linux. |
That's a detail worth noting actually, I can confirm that my battery was at 100% with the cable still connected on a few occasions whilst using Linux. Perhaps this calibration has gone wrong somehow? |
So the kernel never gets to max17042_init_worker() because the battery driver is loaded before the charger due to built-in load order
https://github.com/fail0verflow/switch-linux/blob/switch/drivers/power/supply/max17042_battery.c#L1081 Next, STATUS_POR_BIT is never set in the regmap. I couldn't figure out a way to enable it, but we can force this if statement to true: Finally, we have this line that has a couple of checks enable_por_init isn't set by anything, but I added code to enable it via the devicetree. However, config_data has no code to initialise the struct and never has data. max17042_load_new_capacity_params requires bits from config_data and forcing the if causes the kernel to crash. |
It seems fuel gauge reports correct value. When I power cycle Switch using BQ24193 BATFET, it fixes "sudden shutdown" but battery percentage remains in the same value. Also, battery voltage doesn't look bad. It reports 3.7v. I suspect this issue is a configuration issue on power system rather than fuel gauge issue. |
I spotted the difference of MAX77620 register status between HOS and Linux. HOS wants MAX77620_REG_CNFGGLBL1 has 0x92 but Linux sets it to 0xFF. When I set MAX77620_REG_CNFGGLBL1 to 0x92, it fixes the "desync" problem |
CTCaer/hekate@9672650 (2 commits because I forgot the driver changes..) |
Sorry, my previous patch for Linux disables LCD screen. Here is another dirty workaround. https://gitlab.com/perillamint/switch-linux/commit/ce5c0d82c6555db14d3a872974aaf09ba0bc2a5a This patch will prevent max77620-gpio driver is messing up CNFGGLBL1 reg in dirty way. Root cause of this is, max77620-gpio driver thinks CNFGGLBL1 register is GPIO IRQ masking register and I don't know how to fix this properly because I don't have access to max77620 datasheet. |
Actuially, Nvidia tried to fix this issue by adding support for IRQ masking unsupported devices, which seems didn't got into mainline kernel |
FYI, here is my write-up about discovering root cause of problem: https://blog.quendi.moe/2018/07/03/en-debugging-nintendo-switch-linux-power-management-battery-desync-edition/ |
Here is another fix as a fusee binary by @crystalseedgba https://github.com/crystalseedgba/BatteryFix/blob/master/fusee/src/main.c This one fixes the PMIC register, while @perillamint 's avoid to write it. |
For starters, my apologies if this isn't the correct place to report this. Myself and others seem to be experiencing random shutdowns in games after running Linux when the battery gets to ~<50%. These shutdowns start happening on the home menu at ~<25%. At this point the switch won't turn on again without attaching a charger. Remaining on the home menu, turning the brightness all the way down, disabling sleep mode, setting the volume all the way down and enabling airplane mode appears to allow the switch to drain further. Although at ~<10% the shutdowns begin again.
Apparently pulling the battery and holding the power button for 15 seconds has addressed this for some people. Others have also suggested draining the battery to 0% and then charging it back up to 100% has worked, however very few have reported success after doing this, and those that did appear to have a different issue.
The text was updated successfully, but these errors were encountered: