Pinebook RTC
Chris Hall (132) 3558 posts |
The Pinebook has a ‘real time clock’ based around a 30 bit counter. It is memory mapped at 0×01F00000 with the RTC YY-MM-DD register at offset 0×10. I want to read this register from BASIC but my attempts using OS_Memory (to map 0×01F00000 to 0xFB000000) and *Memory have failed. Can anyone help please? |
Jon Abbott (1421) 2651 posts |
Can you post the relevant code? |
Chris Hall (132) 3558 posts |
I have tried the following:
A simpler Hope this helps. |
Jon Abbott (1421) 2651 posts |
Should that not be:
|
Chris Hall (132) 3558 posts |
Cracked it:
|
Simon Willcocks (1499) 519 posts |
Isn’t it August? :) Congratulations! (What’s the chip type, just out of interest?) |
David Gee (1833) 268 posts |
Aren’t both the day and the month wrong? But at least the year is right… |
Chris Hall (132) 3558 posts |
I don’t think it is a chip. It is a 30 bit counter with crystal and backup power. I haven’t connected up to the internet so I think it is doing the ‘last shutdown date’. |
Simon Willcocks (1499) 519 posts |
There must be something to translate the counter into day/month/year, surely? |
Chris Hall (132) 3558 posts |
I think it may just be part of the SOC. The problem as presented to me was that a Pinebook would be operating in RISC OS with the right date. It would then be booted into Linux and would show the right date. It would then be booted into RISC OS and think the date was 2053 until and unless it was connected to the internet when it would pick up the right year. Usually RISC OS would be used without connecting to the internet. I think I have understood what was going on: I think the problem with the date is that RISC OS and Linux behave differently when faced with a ‘real time clock’ (on the Pinebook) that can only count up to 63 for the year. Linux dates its files (AIUI) with a datestamp which has a 1 Jan 1970 zero datum. It knows the Pinebook will be obsolete by 2033 and so treats the stored year as an offset from 1970 such that 2023=53. It therefore uses the ‘year’ value directly. RISC OS dates its files (and stores times internally) with a datestamp which has a 1 Jan 1900 zero datum. It therefore knows the century figure is stored in CMOS RAM, adds that to what it reads as the current year from the real time clock (making 2053, thanks to Linux) and checks it against the whole year figure in CMOS (which is 2023 from the last time set in RISC OS before the latest reboot) takes the later of the two, sets the date again and stores the current year back into CMOS (thus now 2053). Once it can ‘see’ the network it corrects itself (and the CMOS year is set back to 2023 again). Leave it unconnected to the internet and it will continue to think it is 2053. The following commands will read the stored CMOS year and subtract 30 if the year is between 2050 and 2063. My ‘solution’ is to put these in PreDesk. This seems a rather elegant solution and will last for seventeen years longer (not sure the Pinebook or its user will though). Any comments please?
|
Chris Hall (132) 3558 posts |
Well I suppose it is always best to test that something actually works before thinking you have solved a problem. At the Bristol user group we all had a go at solving the problem but had had beer and food first and retired hurt! The BASIC programme below, placed in !Boot.Choices.Boot.PreDesk on the Pinebook should get the year right after Linux has fudged the issue by setting the real time clock (which has only six bits to store the year) to the number of years since 1970 rather than to the right year just omitting the century (which RISC OS expects). Linux will sort itself out once connected to the internet (as RISC OS would do once a WiFi bridge has been set up). At present the use case is that RISC OS cannot see the internet and relies upon the real time clock in the Pinebook. The programme should work OK until 2029 which seems good enough as by 2033 Linux will be setting the real time clock to the year 63 (the highest value 6 bits can store) and will have to do something different as it reaches its own ‘Millenium Bug’ on the Pinebook.
|
Colin Ferris (399) 1818 posts |
Is there any sound with the Pinebook Pro? |
Rob Andrews (112) 164 posts |
Yes i am running the latest build that includes sound every thing is progressing well there are a few problems but they are working on them. |