Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kobo: Unable to *read back* a previously set RTC alarm on a Touch C #10996

Closed
formula-spectre opened this issue Oct 11, 2023 · 59 comments · Fixed by #11010
Closed

Kobo: Unable to *read back* a previously set RTC alarm on a Touch C #10996

formula-spectre opened this issue Oct 11, 2023 · 59 comments · Fixed by #11010
Labels
can't fix an issue that, by definition, cannot be fixed firmware help-wanted We'd like help with this issue Kobo need more info
Milestone

Comments

@formula-spectre
Copy link

Does your feature request involve difficulty completing a task? Please describe.
no, it does not

Describe the solution you'd like
i would like to set the autoshutdown timer in hours, not days; on my standard kobo I have standby in 15 minutes, and poweroff in 2 hours, and I would like to replicate that with koreader

Describe alternatives you've considered
I.. haven't tried anything else, guilty as charged

Additional context
I don't think there is more needed? I have a kobo n905c

@NiLuJe
Copy link
Member

NiLuJe commented Oct 11, 2023

@formula-spectre
Copy link
Author

do i change autoshutdown_timeout_seconds, rebuild koreader and then upload it to my kobo? or can I do that "on the fly" on the kobo itself? because you mentioned that

There's already been a fair amount of bike-shedding as to why this isn't doable from the UI, so, let's not go there .

@NiLuJe
Copy link
Member

NiLuJe commented Oct 11, 2023

If by "rebuild", you meant restart, then, yeah.

Can't do it from within KOReader's text editor, because the settings will be overwritten on exit.

That leaves USBMS, or whatever else you might want to do, as long as it's done while KOReader isn't running.

@formula-spectre
Copy link
Author

a quick udevil mount /dev/sdb and settings.reader.lua later I did it, thank you very much! I have one more question: what's the difference between autostandby and autosuspend? I mean, the difference between suspend and standby, aren't they the same?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 11, 2023

Standby keeps the lights on and the input wakeup sources active; suspend actually goes into full suspend to ram.

You probably shouldn't be using standby on such an old device, it won't serve much purpose, and it hasn't been optimized for, so it's likely to suffer a large wakeup latency penalty.

@Frenzie
Copy link
Member

Frenzie commented Oct 11, 2023

Isn't the AutoStandby plugin disabled on anything other than PB?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 11, 2023

Yes, but AutoSuspend provides an opt-in standby timer elsewhere ;).

EDIT: Which is what I thought was implied here, since once shouldn't even be aware of the standalone AutoStandby plugin on Kobo.

@formula-spectre
Copy link
Author

UPDATE:
i tried to modify settings.reader.lua, but it appears that koreader hasn't picked up the changes,even though I've shut down and powered on the kobo many times. did I do wrong? I mounted via USBMS, edited the file (it was in .app iirc) and put 7200

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

Check debug logs for AutoSuspend: stuff, and grep autoshutdown_timeout_seconds /mnt/onboard/.adds/koreader/settings.reader.lua

@formula-spectre
Copy link
Author

formula-spectre commented Oct 12, 2023

grep autoshutdown_timeout_seconds /mnt/onboard/.adds/koreader/settings.reader.lua

7200, which is two hours
as for logs, do I search for crash.log or something else?

@zwim
Copy link
Contributor

zwim commented Oct 12, 2023

The most simple solution is shown in #9182
Enable verbose debug and you can enter for example if you want 3 hours ':=3/24'

@Frenzie
Copy link
Member

Frenzie commented Oct 12, 2023

Thanks @zwim that's what I was thinking of in https://www.mobileread.com/forums/showthread.php?t=356479 but I was missing a key component.

@formula-spectre
Copy link
Author

@zwim can you explain the math behind 3/24 resulting in 3 hours? I can't wrap my head around it

@zwim
Copy link
Contributor

zwim commented Oct 12, 2023

Numberpicker just picks a number. If this number stands for a day you can force with the colon not to check limits.
With one hour as the 24th part of a day 3/24 is three hours.

@formula-spectre
Copy link
Author

@zwim I tried your method, still nothing, it does not power off.
note: to me power off is seeing the screen either with inverted color (I noticed this behavior, but it might be that i'm using dark mode) with Powered off on the top right corner. which is not happening.
which log should I check? where are they located?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

There's only one log, the slightly unfortunately named crash.log ;).

You'll need to enable verbose debug logging first, though (and restart KOReader).

c.f., the issue template for all the gory details about logging.

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

Unrelated, but

seeing the screen either with inverted color (I noticed this behavior, but it might be that i'm using dark mode) with Powered off on the top right corner. which is not happening.

sounds extremely unclear. Unless the Touch C has yet another wonky quirk, night mode is honored no matter what. Keep in mind we do "fix" images while in night mode so that they don't look like negatives, which is perfectly normal.

@formula-spectre
Copy link
Author

attached to this is crash.log
i made sure to have verbose logging on!
crash.log

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

Okay, the RTC on your device is dead (or at the very least its "setting a wakeup alarm" bits are), and you have a suspend timer lower than the shutdown timer, so it fails to wakeup during suspend to trigger shutdown ;).

Given that device, it's also possible that RTC alarms just never worked, period. You'd have to double-check with a sane Touch C to confirm. Which would involve going back in time, so, good luck ;o).

@formula-spectre
Copy link
Author

@NiLuJe

Unrelated, but

seeing the screen either with inverted color (I noticed this behavior, but it might be that i'm using dark mode) with Powered off on the top right corner. which is not happening.

sounds extremely unclear. Unless the Touch C has yet another wonky quirk, night mode is honored no matter what. Keep in mind we do "fix" images while in night mode so that they don't look like negatives, which is perfectly normal.

idk sometimes when I turned the kobo off with koreader the image of the book i'm reading has inverted color, idk why

@formula-spectre
Copy link
Author

formula-spectre commented Oct 12, 2023

Okay, the RTC on your device is dead (or at the very least its "setting a wakeup alarm" bits are), and you have a suspend timer lower than the shutdown timer, so it fails to wakeup during suspend to trigger shutdown ;).

Given that device, it's also possible that RTC alarms just never worked, period. You'd have to double-check with a sane Touch C to confirm. Which would involve going back in time, so, good luck ;o).

uhh is it bad? why the standard kobo interface autosuspend fine then? can it be repaired?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

Either it's aware of some quirks of the rtc chip we're not, or it just never suspends or shuts down properly (either are a possibility ;)).

@formula-spectre
Copy link
Author

is there a way I can troubleshoot this further?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

If you can find a way to set an rtc alarm in a way that actually sticks, sure.

@NiLuJe
Copy link
Member

NiLuJe commented Oct 12, 2023

You can also enable developer mode in Nickel, with the power management related bits enabled in the dev menu logging knobs, then check the syslog.

As well as stracing Nickel to see if it does something funky with the rtc (or nothing at all).

@NiLuJe
Copy link
Member

NiLuJe commented Oct 13, 2023

color inverted:

Is the book in question an ePub or a PDF?

do i still apply the patch?

Which one?

If that was with #10996 (comment), then, first, I'd like to see the logs from it; and, yes, do double-check that #10996 (comment) still works.

@NiLuJe
Copy link
Member

NiLuJe commented Oct 13, 2023

color inverted:

Is the book in question an ePub or a PDF?

Also, does this always happen? Does it happen when going to suspend? Does it happen if you trigger a shutdown manually (via the Exit menu)?

@formula-spectre
Copy link
Author

color inverted:

Is the book in question an ePub or a PDF?

epub

do i still apply the patch?

Which one?

If that was with #10996 (comment), then, first, I'd like to see the logs from it; and, yes, do double-check that #10996 (comment) still works.

before patching, I'm gonna share the crash.log (I hope it's the right one and not the old one, but it should be constantly dumping right? checked and it has today's date)
crash.log

@formula-spectre
Copy link
Author

color inverted:

Is the book in question an ePub or a PDF?

Also, does this always happen? Does it happen when going to suspend? Does it happen if you trigger a shutdown manually (via the Exit menu)?

it happens at seemingly random, both in sleep mode, power off mode, and sometimes even in "awake" mode; i'm gonna try to get out of a pattern of it and see if it's really random or it's triggered by something
may the omnissiah help me

@formula-spectre
Copy link
Author

formula-spectre commented Oct 13, 2023

color inverted:

Is the book in question an ePub or a PDF?

Also, does this always happen? Does it happen when going to suspend? Does it happen if you trigger a shutdown manually (via the Exit menu)?

here is a log when this happened; i just turned on the kobo from standby mode
crash.log
forgot to mention: to restore it to non inverted colors I switched off and on night mode

@NiLuJe
Copy link
Member

NiLuJe commented Oct 13, 2023

it's the right one

Yup, that was the right one, and it confirms that the new approach ought to be more correct ;o).

a pattern

That's enough of a pattern to tell me that it's a kernel issue ;). It vaguely rings a bell, so it must have been affecting a few other devices at some point.

There's nothing we can do about it, given its random and "not our bug" nature, but you can work it around by disabling HW inversion.

Here's a user patch doing just that.

@formula-spectre
Copy link
Author

so do I apply the patch suggested here?
#10996 (comment)
and the user patch for the inverted colors?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 13, 2023

Yup, (revert the previous one before, of course)

@formula-spectre
Copy link
Author

formula-spectre commented Oct 14, 2023

I apply the user patch that you mention (I think, I plopped it in ~/.adds/koreader/patches), do I close this issue or further investigation or testing is needed?
UPDATE: the color inversion thing also appears in plato, so it's def a kernel issue lol

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

I'm just waiting on confirmation that the new rtc/suspend/shutdown patch works ;).

@formula-spectre
Copy link
Author

uhh do you want the current log?

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

That, too. But mainly an actual confirmation that it actually works? ;o).

@formula-spectre
Copy link
Author

formula-spectre commented Oct 14, 2023

i'm an idiot, the actual patch works, the device does goes in autopoweroff after the set time. the color inversion one is acting.. funny, I permanently have everything negative now. anyway here's the log.
i'm gonna remove the user patch and live with the problem
crash.log
(if you see a bunch of standby to wake to standby is when I realized the negative colors problem)
UPDATE: even though I'm sure about it, i'm testing again if it works, will report back with a new comment tagging you

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

Oh, you'll have to toggle nightmode off and on again for the userpatch not to screw things up, yeah.

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

Actually, you might even need to drop the userpatch, restart KOReader, disable nightmode; apply the userpatch, restart; and then it'll behave.

It swaps a flag that is assumed to be sort of immutable, so if the state changes while nightmode is enabled, shit happens ;).

@formula-spectre
Copy link
Author

formula-spectre commented Oct 14, 2023

Actually, you might even need to drop the userpatch, restart KOReader, disable nightmode; apply the userpatch, restart; and then it'll behave.

I roughly followed this procedure, but the user patch still screwed it up. I will try again with this exact procedure and report back though

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

(re: userpatch) Works as expected this way on my end, FWIW ;).

@formula-spectre
Copy link
Author

@NiLuJe confirmed, that patch makes the autopoweroff work fine, still testing the user patch for the color inversion thing

@NiLuJe
Copy link
Member

NiLuJe commented Oct 14, 2023

I've just updated the userpatch to fix the breakage, which only happened when starting KOReader with both the patch applied and nightmode enabled.

@formula-spectre
Copy link
Author

UPDATE: The patch for the autopoweroff is working fine, but the user patch is not; just started my kobo to read, and after starting koreader i was greeted with negative covers, no matter night mode being on or off

@NiLuJe
Copy link
Member

NiLuJe commented Oct 15, 2023

#worksforme with the fixed revision, so, smells like PEBCAK ;).

@formula-spectre
Copy link
Author

probably :/ i'll try to debug to debug some more. do I close the issue? since the main problem, the autopoweroff patch works for me

@NiLuJe
Copy link
Member

NiLuJe commented Oct 15, 2023

It'll get closed automatically once the PR is merged ;).

@formula-spectre
Copy link
Author

👍 thanks for the support!

NiLuJe added a commit to koreader/koreader-base that referenced this issue Oct 16, 2023
We've had a couple reports over the years of broken alarm reads on old NTX boards (in... every sense of the word; this only seems to affect old i.MX RTCs, true, but more specifically really old devices, with possibly dying batteries).

e.g., koreader/koreader#7994 & koreader/koreader#10996

While there *is* an ioctl that is supposed to help with this sort of stuff by reporting on the state of RTC's battery voltage, in my own testing on much less broken RTCs, it was extremely unreliable (especially when it matters most, i.e., right after a wakeup), so, that's kind of a no-go.

Thankfully, when this occurs, the returned alarm is *extremely* obviously bogus: `1`, as in, Epoch.

TL;DR: Just ignore such return values and assume the alarm did indeed fire properly, we already validate against both the task and the current time, double-checking the actual alarm is just a defensive and pedantic guard against... something... setting alarms behind our back, which should never really happen in the first place, least of all on the affected platform (Kobo) ;).

Also actually implement honoring WakeupMgr's character device selection, in case we ever need to actually use something other than rtc0 ;).
@Frenzie Frenzie added this to the 2023.10 milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't fix an issue that, by definition, cannot be fixed firmware help-wanted We'd like help with this issue Kobo need more info
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants