aleh / pocketchip-batt

A lighter replacement for pocketchip-batt and related scripts on PocketCHIP.
MIT License
24 stars 4 forks source link

make fails if using on non-PocketCHIP image #3

Open klundry opened 3 years ago

klundry commented 3 years ago

I am using the server image on my PocketCHIP and installing only the packages I need in order to save space but it fails because the PocketCHIP battery stuff is not there.

Failed to disable unit: Unit file pocketchip-warn15.timer does not exist.
Failed to stop pocketchip-warn15.service: Unit pocketchip-warn15.service not loaded.
load
Failed to disable unit: Unit file pocketchip-load.timer does not exist.
Failed to stop pocketchip-load.service: Unit pocketchip-load.service not loaded.
make: *** [Makefile:7: install] Error 5
klundry commented 3 years ago

Commented out the line disabling the existing services in the makefile and it installs successfully.

klundry commented 3 years ago

There also appears to be a problem with the pocketchip-one service. The log says "Could not open the display" "No protocol spceified". /usr/lib/pocketchip-batt/gauge also reports 127 and never changes.

Is pocketchip-one service depending on something that I don't have installed? I am running X just not the default PocketCHIP configuration.

aleh commented 3 years ago

@klundry Hey! Thanks for reporting this. What system are you on, Buster?

Commented out the line disabling the existing services in the makefile and it installs successfully.

Not sure those lines should be permanently removed, the old service should be stopped when present, however maybe I should ignore uninstallation errors. I am still on the older system though.

There also appears to be a problem with the pocketchip-one service. The log says "Could not open the display" "No protocol spceified". /usr/lib/pocketchip-batt/gauge also reports 127 and never changes.

Is pocketchip-one service depending on something that I don't have installed? I am running X just not the default PocketCHIP configuration.

"Could not open the display" is probably coming from check_backlight() function which tries to open the X display for backlight management, something that the old service was doing as well. It is trying to setuid(1000) assuming the standard config where this is the ID of the chip user, but maybe it should be a different number on your machine? Please let me know.

Not sure about why the gauge is failing. Could you please uncomment a tracing piece of code around line 166 and see if you get anything there?

klundry commented 3 years ago

I have upgraded to Buster and my chip UID is 1000.

I'm not sure what you want me to uncomment is this section here the right ballpark?

         int charging = 0, voltage = 0, gauge = 0;
165         if (battery_read(&charging, &voltage, &gauge) != 0)
166                 return;
167
168         // Not printing these params anymore as instead of replacing the battery.sh I've decided to replace 
169         // pocketchip-batt and extra output would just cause more logging by systemd.
170         /*~
171         // Let's print to stdout just in case this script is used instead of battery.sh .
172         printf("CHARG_IND=%d\n", charging);
173         printf("Battery voltage = %.0fmV\n", voltage);
174         */
aleh commented 3 years ago

Yes, lines 170-174, just to see if it reads something.

It would be hard for me to debug this as i am not on Buster.

On 12 Apr 2021, at 21:54, klundry @.***> wrote:

 I have upgraded to Buster and my chip UID is 1000.

I'm not sure what you want me to uncomment is this section here the right ballpark?

     int charging = 0, voltage = 0, gauge = 0;

165 if (battery_read(&charging, &voltage, &gauge) != 0) 166 return; 167 168 // Not printing these params anymore as instead of replacing the battery.sh I've decided to replace 169 // pocketchip-batt and extra output would just cause more logging by systemd. 170 /~ 171 // Let's print to stdout just in case this script is used instead of battery.sh . 172 printf("CHARG_IND=%d\n", charging); 173 printf("Battery voltage = %.0fmV\n", voltage); 174 / — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

klundry commented 3 years ago

Ok, the issue is becoming clearer but maybe I should open a separate issue for this. I'm getting compile errors and the battery gauge works until I reboot. Then /usr/lib/pocketchip-batt/gauge is gone but if I sudo make install again it will work until a reboot.

eliopoulos97 commented 2 years ago

Same issue on Bullseye, I'll try commenting out those lines but feel like I'll end up running into the same issue.

eliopoulos97 commented 2 years ago

I have made a bit of a discovery! I get 127 in gauge when I'm not plugged in, but when it's charging it actually reads the amount. What could this mean? What is the difference between how the gauge is computed when charging / not?