baskerville / plato

Document reader
Other
1.26k stars 105 forks source link

Commits df549f and c8c036 may not be correct for all Libra 2 #241

Closed thataboy closed 2 years ago

thataboy commented 2 years ago

After merging these commits (Correct battery code path for Kobo Libra 2, Correct frontlight system path for Kobo Libra 2, resp.) Plato panics on start up for me with unable to create battery; no such file or directory.

ls -la /sys/class/power_supply/

drwxr-xr-x    2 root     root             0 Jun  5 10:34 .
drwxr-xr-x   39 root     root             0 Jun  5 10:34 ..
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 acpwr -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-0032/ricoh619-battery/power_supply/acpwr
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 mc13892_bat -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-0032/ricoh619-battery/power_supply/mc13892_bat
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 mc13892_charger -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-0032/ricoh619-battery/power_supply/mc13892_charger
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 usbpwr -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-0032/ricoh619-battery/power_supply/usbpwr

So mc13892_bat (BATTERY_INTERFACE_A) was the correct value

ls -la /sys/class/backlight/

drwxr-xr-x    2 root     root             0 Jun  5 10:34 .
drwxr-xr-x   39 root     root             0 Jun  5 10:34 ..
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 lm3630a_led -> ../../devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0036/backlight/lm3630a_led
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 lm3630a_leda -> ../../devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0036/backlight/lm3630a_leda
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 lm3630a_ledb -> ../../devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0036/backlight/lm3630a_ledb
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 mxc_msp430.0 -> ../../devices/platform/ntx_bl/backlight/mxc_msp430.0

lm3630a_led (FRONTLIGHT_ORANGE_B) was the correct value. /sys/class/leds/aw99703-bl_FL1/ does not exists

ls -la /sys/class/leds/

drwxr-xr-x    2 root     root             0 Jun  5 10:34 .
drwxr-xr-x   39 root     root             0 Jun  5 10:34 ..
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 GLED -> ../../devices/platform/leds/leds/GLED
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 mmc0:: -> ../../devices/platform/soc/2100000.aips-bus/2194000.usdhc/leds/mmc0::
lrwxrwxrwx    1 root     root             0 Jun  5 10:34 mmc1:: -> ../../devices/platform/soc/2100000.aips-bus/2198000.usdhc/leds/mmc1::

Perhaps @ticky has a different version or revision of Libra 2? I have the USA / Walmart affiliate version. Here's my sysinfo

Model name  Libra 2
Hardware    Mark 9
Code name   io
Model number    388
Firmare version 4.33.19608
Storage (Free / Total)  28.0 G / 28.5 G
Memory (Free / Total)   335 M / 496 M
Load Average    39.0% 17.0% 9.7%
CPU mx6sll
PCB E70K10
DisplayPanel    7" Right EPD
DisplayCtrl MX6SLL+SY7636
DisplayBusWidth 16Bits
DisplayResolution   1680x1264
FrontLight  TABLE0+
FrontLight_LEDrv    LM3630
FL_PWM  LM3630
TouchCtrl   ekth6
TouchType   C-Type
Battery PR-284983N-1500mA
IFlash  Micro SD
RamSize 512MB
LightSensor No
HallSensor  TLE4913
RSensor KX122
Wifi    RTL8723DS
ticky commented 2 years ago

Fascinating! I'll get you details from mine. Mine is brand new as of last week, direct from the Canadian Kobo store, so I wouldn't be surprised if it's the latest revision if any.

ticky commented 2 years ago

For what it's worth, with my patches I checked the front light worked, with colour temperature control.

uname -a

Linux kobo 4.1.15-00769-g20c06d7161f #62 SMP PREEMPT Fri Apr 8 11:58:44 CST 2022 armv7l GNU/Linux
ls -la /sys/class/power_supply/

drwxr-xr-x    2 root     root             0 Jun  2 21:00 .
drwxr-xr-x   39 root     root             0 Jun  2 20:59 ..
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 ac -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-004b/bd71827-power/power_supply/ac
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 battery -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-004b/bd71827-power/power_supply/battery
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 usb -> ../../devices/platform/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-004b/bd71827-power/power_supply/usb
ls -la /sys/class/backlight/

drwxr-xr-x    2 root     root             0 Jun  2 21:00 .
drwxr-xr-x   39 root     root             0 Jun  2 20:59 ..
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 mxc_msp430.0 -> ../../devices/platform/ntx_bl/backlight/mxc_msp430.0
ls -la /sys/class/leds/
drwxr-xr-x    2 root     root             0 Jun  2 21:00 .
drwxr-xr-x   39 root     root             0 Jun  2 20:59 ..
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 GLED -> ../../devices/platform/leds/leds/GLED
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 aw99703-bl_FL1 -> ../../devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0036/leds/aw99703-bl_FL1
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 aw99703-bl_FL2 -> ../../devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0036/leds/aw99703-bl_FL2
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 mmc0:: -> ../../devices/platform/soc/2100000.aips-bus/2194000.usdhc/leds/mmc0::
lrwxrwxrwx    1 root     root             0 Jun  2 21:00 mmc1:: -> ../../devices/platform/soc/2100000.aips-bus/2198000.usdhc/leds/mmc1::
Model name          Libra 2
Hardware            Mark 9
Code name           io
Model number        388
Firmware version    4.32.19501

CPU                 mx6sll
PCB                 E70K10
DisplayPanel        7" Right EPD
DisplayCtrl         MX6SLL+SY7636
DisplayBusWidth     16Bits
DisplayResoution    1680x1264
FrontLight          TABLE0+
FrontLight_LEDrv    LM3630
FL_PWM              AW99703x2
TouchCtrl           ekth6
TouchType           C-Type
Battery             PR-284983N-1500mA
IFlash              Micro SD
RamSize             512MB
LightSensor         No
HallSensor          TLE4913
RSensor             KX122
Wifi                RTL8723DS

Merging #185 and possibly adopting a similar solution for the front-light might be worth the trouble, given these differences are within a single model.

I notice you have a newer firmware revision, but mine is reporting that I'm up to date. I would be surprised if that revision update had major changes to the device tree, but I suppose it's possible!

Full output of /bin/ntx_hwconfig -s /dev/mmcblk0, in case that helps:

HW CONFIG v3.5 @1024 secno, size=74 bytes :
[0] PCB='E70K10'
[1] KeyPad='PGUP+PGDN'
[2] AudioCodec='No'
[3] AudioAmp='No'
[4] Wifi='RTL8723DS'
[5] BT='RTL8723DS'
[6] Mobile='No'
[7] TouchCtrl='ekth6'
[8] TouchType='C-Type'
[9] DisplayCtrl='MX6SLL+SY7636'
[10] DisplayPanel='7" Right EPD'
[11] RSensor='KX122'
[12] MicroP='No'
[13] Customer='9'
[14] Battery='PR-284983N-1500mA'
[15] Led='W'
[16] RamSize='512MB'
[17] IFlash='Micro SD'
[18] ExternalMem='No'
[19] RootFsType='Ext4'
[20] SysPartType='TYPE3'
[21] ProgressXHiByte=0x01
[22] ProgressXLoByte=0x68
[23] ProgressYHiByte=0x02
[24] ProgressYLoByte=0xE4
[25] ProgressCnts=0x00
[26] ContentType=0x00
[27] CPU='mx6sll'
[28] UIStyle='Customer UI'
[29] RAMType='LPDDR2'
[30] UIConfig='Normal'
[31] DisplayResolution='1680x1264'
[32] FrontLight='TABLE0+'
[33] CPUFreq='NC'
[34] HallSensor='TLE4913'
[35] DisplayBusWidth='16Bits'
[36] FrontLight_Flags=BootON:OFF,TABLE1X:OFF,EN_INV:ON,(null):OFF,(null):OFF,(null):OFF,(null):OFF,(null):OFF
[37] PCB_Flags=NO_KeyMatrix:ON,FPC_Touch:OFF,LOGO_LED:OFF,RD_MODE:OFF,EPD_LV:OFF,EPDVDD_STDALONE:OFF,HP_DETECT:OFF,ISD_1V8:OFF
[38] FrontLight_LEDrv='LM3630'
[39] VCOM_10mV_HiByte=0xFF
[40] VCOM_10mV_LoByte=0x6A
[41] PCB_REV=0x00
[42] PCB_LVL='E'
[43] HOME_LED_PWM='No'
[44] PMIC='BD71828'
[45] FL_PWM='AW99703x2'
[46] RTC='BD71828'
[47] BootOpt=ESD:OFF
[48] Touch2Ctrl='No'
[49] Touch2Type='No'
[50] GPS='No'
[51] FM='No'
[52] RSensor2='No'
[53] LightSensor='No'
[54] TPFWIDByte0=0x00
[55] TPFWIDByte1=0x00
[56] TPFWIDByte2=0x00
[57] TPFWIDByte3=0x00
[58] TPFWIDByte4=0x00
[59] TPFWIDByte5=0x00
[60] TPFWIDByte6=0x00
[61] TPFWIDByte7=0x00
[62] GPU='NC'
[63] PCB_Flags2=eMMC@SD1:ON,WiFi@SD2:OFF,eMMC@SD2:OFF,USB_TYPEC:ON,Cilix:OFF,(null):OFF,(null):OFF,(null):OFF
[64] EPD_Flags=NO_VDD_CTRL:OFF,LP_PANEL:OFF,ACEP:OFF,CFA:OFF,XON:OFF,(null):OFF,(null):OFF,(null):OFF
[65] LAN='No'
[66] MobileIF='NC'
[67] PIR='No'
[68] PanelLaminationSrc='NC'
[69] FL_CHNS=0x04
[70] TTS='No'
[71] Test_Flags=0:OFF,1:OFF,2:OFF,3:OFF,4:OFF,5:OFF,6:OFF,7:OFF
[72] EPD_CFA_REV='Gen1'
[73] PanelModel='NC'
baskerville commented 2 years ago

The FL_PWM keys differ.

@thataboy Can you also post the output of /bin/ntx_hwconfig -s /dev/mmcblk0?

thataboy commented 2 years ago

per req

HW CONFIG v3.5 @1024 secno, size=74 bytes : 
[0] PCB='E70K10'
[1] KeyPad='PGUP+PGDN'
[2] AudioCodec='No'
[3] AudioAmp='No'
[4] Wifi='RTL8723DS'
[5] BT='RTL8723DS'
[6] Mobile='No'
[7] TouchCtrl='ekth6'
[8] TouchType='C-Type'
[9] DisplayCtrl='MX6SLL+SY7636'
[10] DisplayPanel='7" Right EPD'
[11] RSensor='KX122'
[12] MicroP='No'
[13] Customer='9'
[14] Battery='PR-284983N-1500mA'
[15] Led='W'
[16] RamSize='512MB'
[17] IFlash='Micro SD'
[18] ExternalMem='No'
[19] RootFsType='Ext4'
[20] SysPartType='TYPE3'
[21] ProgressXHiByte=0x01
[22] ProgressXLoByte=0x68
[23] ProgressYHiByte=0x02
[24] ProgressYLoByte=0xE4
[25] ProgressCnts=0x00
[26] ContentType=0x00
[27] CPU='mx6sll'
[28] UIStyle='Customer UI'
[29] RAMType='LPDDR2'
[30] UIConfig='Normal'
[31] DisplayResolution='1680x1264'
[32] FrontLight='TABLE0+'
[33] CPUFreq='NC'
[34] HallSensor='TLE4913'
[35] DisplayBusWidth='16Bits'
[36] FrontLight_Flags=BootON:OFF,TABLE1X:OFF,EN_INV:ON,(null):OFF,(null):OFF,(null):OFF,(null):OFF,(null):OFF
[37] PCB_Flags=NO_KeyMatrix:ON,FPC_Touch:OFF,LOGO_LED:OFF,RD_MODE:OFF,EPD_LV:OFF,EPDVDD_STDALONE:OFF,HP_DETECT:OFF,ISD_1V8:OFF
[38] FrontLight_LEDrv='LM3630'
[39] VCOM_10mV_HiByte=0xFF
[40] VCOM_10mV_LoByte=0x69
[41] PCB_REV=0x00
[42] PCB_LVL='A'
[43] HOME_LED_PWM='No'
[44] PMIC='RC5T619'
[45] FL_PWM='LM3630'
[46] RTC='RC5T619'
[47] BootOpt=ESD:OFF
[48] Touch2Ctrl='No'
[49] Touch2Type='No'
[50] GPS='No'
[51] FM='No'
[52] RSensor2='No'
[53] LightSensor='No'
[54] TPFWIDByte0=0x00
[55] TPFWIDByte1=0x00
[56] TPFWIDByte2=0x00
[57] TPFWIDByte3=0x00
[58] TPFWIDByte4=0x00
[59] TPFWIDByte5=0x00
[60] TPFWIDByte6=0x00
[61] TPFWIDByte7=0x00
[62] GPU='NC'
[63] PCB_Flags2=eMMC@SD1:ON,WiFi@SD2:OFF,eMMC@SD2:OFF,USB_TYPEC:ON,Cilix:OFF,(null):OFF,(null):OFF,(null):OFF
[64] EPD_Flags=NO_VDD_CTRL:OFF,LP_PANEL:OFF,ACEP:OFF,CFA:OFF,XON:OFF,(null):OFF,(null):OFF,(null):OFF
[65] LAN='No'
[66] MobileIF='NC'
[67] PIR='No'
[68] PanelLaminationSrc='NC'
[69] FL_CHNS=0x04
[70] TTS='No'
[71] Test_Flags=0:OFF,1:OFF,2:OFF,3:OFF,4:OFF,5:OFF,6:OFF,7:OFF
[72] EPD_CFA_REV='Gen1'
[73] PanelModel='NC'
baskerville commented 2 years ago

Straightforward patch:

diff --git a/src/battery/kobo.rs b/src/battery/kobo.rs
index 24388e7..31d302a 100644
--- a/src/battery/kobo.rs
+++ b/src/battery/kobo.rs
@@ -31,10 +31,10 @@ pub struct KoboBattery {

 impl KoboBattery {
     pub fn new() -> Result<KoboBattery, Error> {
-        let base = if CURRENT_DEVICE.mark() < 8 {
-            Path::new(BATTERY_INTERFACE_A)
-        } else {
+        let base = if Path::new(BATTERY_INTERFACE_B).exists() {
             Path::new(BATTERY_INTERFACE_B)
+        } else {
+            Path::new(BATTERY_INTERFACE_A)
         };
         let capacity = File::open(base.join(BATTERY_CAPACITY))?;
         let status = File::open(base.join(BATTERY_STATUS))?;
diff --git a/src/frontlight/premixed.rs b/src/frontlight/premixed.rs
index bb73ff4..f186d39 100644
--- a/src/frontlight/premixed.rs
+++ b/src/frontlight/premixed.rs
@@ -1,15 +1,16 @@
+use std::path::Path;
 use std::io::Write;
 use std::fs::File;
 use std::fs::OpenOptions;
 use anyhow::Error;
-use crate::device::{CURRENT_DEVICE, Model};
+use crate::device::CURRENT_DEVICE;
 use super::{Frontlight, LightLevels};

 const FRONTLIGHT_WHITE: &str = "/sys/class/backlight/mxc_msp430.0/brightness";

 // Forma
 const FRONTLIGHT_ORANGE_A: &str = "/sys/class/backlight/tlc5947_bl/color";
-// Libra H₂O, Clara HD
+// Libra H₂O, Clara HD, Libra 2
 const FRONTLIGHT_ORANGE_B: &str = "/sys/class/backlight/lm3630a_led/color";
 // Sage, Libra 2
 const FRONTLIGHT_ORANGE_C: &str =  "/sys/class/leds/aw99703-bl_FL1/color";
@@ -24,12 +25,12 @@ pub struct PremixedFrontlight {
 impl PremixedFrontlight {
     pub fn new(intensity: f32, warmth: f32) -> Result<PremixedFrontlight, Error> {
         let white = OpenOptions::new().write(true).open(FRONTLIGHT_WHITE)?;
-        let model = CURRENT_DEVICE.model;
-        let orange_path = match model {
-            Model::Forma | Model::Forma32GB => FRONTLIGHT_ORANGE_A,
-            Model::LibraH2O | Model::ClaraHD => FRONTLIGHT_ORANGE_B,
-            Model::Sage | Model::Libra2 => FRONTLIGHT_ORANGE_C,
-            _ => FRONTLIGHT_ORANGE_A,
+        let orange_path = if Path::new(FRONTLIGHT_ORANGE_C).exists() {
+            FRONTLIGHT_ORANGE_C
+        } else if Path::new(FRONTLIGHT_ORANGE_B).exists() {
+            FRONTLIGHT_ORANGE_B
+        } else {
+            FRONTLIGHT_ORANGE_A
         };
         let orange = OpenOptions::new().write(true).open(orange_path)?;
         Ok(PremixedFrontlight { intensity, warmth, white, orange })
ticky commented 2 years ago

Looks reasonable! I'll build with this patch and test on my Libra 2.

ticky commented 2 years ago

Yep, that patch is working on my Libra 2 - here's my build in case it helps @thataboy test :) plato.zip

thataboy commented 2 years ago

yes, tested fine. I think @baskerville can push it to master