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

RTC not working on PijuiceZero with Raspberry Pi OS Lite 64 bit bookworm #1063

Open
mroelandts opened this issue Feb 16, 2024 · 4 comments
Open

Comments

@mroelandts
Copy link

Hello,

Device: Pi zero 2 + PiJuice zero
Firmware: V1.6
OS: 2023-12-11-raspios-bookworm-arm64-lite
Connected devices: Pijuice zero 1200mAh battery

I'm having some issues with the RTC on my latest setup.
According to the rtc documentation the i2c-rtc module should automatically load.
But even while forcing it by adding dtoverlay=i2c-rtc,ds1339 in /boot/config.txt does not enable it.
I do not get an ‘UU’ at address 68.

$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- 14 -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   

$ ll /dev | grep i2c
crw-rw---- 1 root i2c      89,   1 Nov 10 01:25 i2c-1
crw-rw---- 1 root i2c      89,   2 Nov 10 01:25 i2c-2

$ uname -m
aarch64

The EEPROM address is set to 50. (default)
image

The command lsmod | grep rtc also returns nothing, which makes me believe the module is not loaded.
Should I activate a different module for bookworm (64bit)?
I do have a working setup, but this one is running the bullseye build of raspberry OS Lite with dtoverlay=i2c-rtc,ds1339 inside the /boot/config.txt.
(cat /etc/debian_version -> 11.3 && uname -mm -> armv7l)

First I had some issues with the i2c module not activate: see PiJuice/issues/1062 but raspi-config fixed that.
Any help is much appreciated!
If more information is needed, please clarify.

@tvoverbeek
Copy link
Contributor

tvoverbeek commented Feb 19, 2024

I tried to reproduce your problem using a Pi zero 2 and the Pijuice HAT.
Installing raspios 64-bit lite with the imager results in the same version as yours. After an sudo apt update; sudo apt -y upgrade I get version 2024-01-25.
With both the imager version and the 2024-01-25 version the pijuice-base package installs fine.
I even get the UU for address 68 in i2cdetect.

Have you tried manually loading the rts_ds1307 module (sudo modprobe rtc_ds1307)?
lsmod should ahow both rtc_1307 and regmap_i2c

@mroelandts
Copy link
Author

What do you mean with "the 2024-01-25 version"? Are you taking about the raspberry os or the pijuice-base package?
For the OS I'm unable to locate a newer version than 2023-12-11-raspios.
And for pijuice-base, I can only see the apt version, which is 1.8.

Using the PiImager, once I select the zero 2 as device, I'm unable to select the bookworm 64 bit OS using the official images (Imager v1.8.5). Selecting a different device, allows me to select it. Weird, but that's a different issue...
I have created my sd card using the downloaded file from https://www.raspberrypi.com/software/operating-systems/ and balenaEtcher.

Manually loading the module has no effect on my existing system.

$ sudo modprobe rtc-ds1307 

$ lsmod
Module                  Size  Used by
rtc_ds1307             28672  0
regmap_i2c             16384  1 rtc_ds1307
brcmfmac              327680  0
vc4                   364544  2
snd_soc_hdmi_codec     20480  1
drm_display_helper     16384  1 vc4
cec                    53248  1 vc4
brcmutil               24576  1 brcmfmac
drm_dma_helper         20480  1 vc4
drm_kms_helper        212992  4 drm_dma_helper,vc4
cfg80211              950272  1 brcmfmac
snd_soc_core          282624  2 vc4,snd_soc_hdmi_codec
snd_compress           20480  1 snd_soc_core
binfmt_misc            20480  1
snd_pcm_dmaengine      20480  1 snd_soc_core
fb_sys_fops            16384  1 drm_kms_helper
syscopyarea            16384  1 drm_kms_helper
raspberrypi_hwmon      16384  0
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
bcm2835_isp            28672  0
bcm2835_codec          49152  0
bcm2835_v4l2           45056  0
snd_bcm2835            28672  0
v4l2_mem2mem           40960  1 bcm2835_codec
bcm2835_mmal_vchiq     36864  3 bcm2835_codec,bcm2835_v4l2,bcm2835_isp
videobuf2_vmalloc      16384  1 bcm2835_v4l2
rfkill                 32768  4 cfg80211
snd_pcm               143360  5 snd_bcm2835,snd_soc_hdmi_codec,snd_compress,snd_soc_core,snd_pcm_dmaengine
videobuf2_dma_contig    20480  2 bcm2835_codec,bcm2835_isp
videobuf2_memops       16384  2 videobuf2_vmalloc,videobuf2_dma_contig
videobuf2_v4l2         32768  4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,bcm2835_isp
videobuf2_common       69632  8 bcm2835_codec,videobuf2_vmalloc,videobuf2_dma_contig,videobuf2_v4l2,bcm2835_v4l2,v4l2_mem2mem,videobuf2_memops,bcm2835_isp
videodev              282624  6 bcm2835_codec,videobuf2_v4l2,bcm2835_v4l2,videobuf2_common,v4l2_mem2mem,bcm2835_isp
snd_timer              40960  1 snd_pcm
mc                     61440  6 videodev,bcm2835_codec,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem,bcm2835_isp
snd                   110592  6 snd_bcm2835,snd_soc_hdmi_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm
vc_sm_cma              32768  2 bcm2835_mmal_vchiq,bcm2835_isp
raspberrypi_gpiomem    16384  0
joydev                 28672  0
uio_pdrv_genirq        16384  0
uio                    24576  1 uio_pdrv_genirq
i2c_dev                20480  2
drm                   593920  5 drm_kms_helper,drm_dma_helper,vc4,drm_display_helper
fuse                  143360  1
drm_panel_orientation_quirks    28672  1 drm
dm_mod                143360  0
backlight              24576  1 drm
ip_tables              32768  0
x_tables               49152  1 ip_tables
ipv6                  561152  26
i2c_bcm2835            20480  1

$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- 14 -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

$ sudo hwclock -rv
hwclock from util-linux 2.38.1
System Time: 1708455574.125568
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
Trying to open: /dev/misc/rtc
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

I also created a new sd card with the 64 bit bullseye OS system.
I even used a different zero2 and different pijuice zero.
All resulted in the same behavior as above.

BUT using the 32bit bullseye && 32 bit bookworm OS did work! It did not auto load, but after editing the /boot/config.txt and rebooting again, I was able to use sudo hwclock -r.
Does the pijuice zero board not support a 64bit system? Or is it something in the pijuice-base (v1.8) package that does not support it?

Are you positive that you used the 64-bit lite OS to reproduce this issue?
I'm able to reproduce it multiple times using multiple zero2 and pijuice zero boards.
If not, I'm out of ideas :)

@tvoverbeek
Copy link
Contributor

@mroelandts You wrote:
What do you mean with "the 2024-01-25 version"? Are you taking about the raspberry os or the pijuice-base package?
After running sudo apt update and sudo apt -y upgrade the output of uname -a is:

tvo@pi02-test:~ $ uname -a
Linux pi02-test 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
tvo@pi02-test:~ $ 

Note: You can use the Raspberry Pi Imager to download the 64-bit bookworm-lite for the Pi02 by selecting "No filtering" as device.
The problem with the PiJuice Zero is that it is not a proper HAT. It does not have an EEPROM, so the configuration (Enabling I2C and loading the rtc driver and /dev/rtc) has to be done by hand.
I'll describe how I did it tomorrow.
The end result:

tvo@pi02-test:~ $ sudo hwclock -rv
hwclock from util-linux 2.38.1
System Time: 1708639599.513575
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(4, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2024/02/22 22:06:40
Hw clock time : 2024/02/22 22:06:40 = 1708639600 seconds since 1969
Time since last adjustment is 1708639600 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2024-02-22 23:06:39.507732+01:00
tvo@pi02-test:~ $ 

@tvoverbeek
Copy link
Contributor

@mroelandts Here the continuation of yesterday.
Same hardware configuration as you: Pi02W, PiJuice Zero with 1200mAh battery.
Installed Raspberry Pi Os Lite with the Imager (Customizing User, Password, Wifi, Localization and enable SSH)
After first run sudo apt update and sudo apt -y upgrade
Enabled I2C via raspi-config.
installed i2c-tools (for i2cdetect)
With PiJuicd Zero + battery connected, i2cdetect gives a response for addresses 14 and 68
Load the i2c-rtc device tree overlay dynamically: sudo dtoverlay i2c-rtc ds1307
Check that /dev/rtc exists: ls -l /dev/rtc*
Running i2cdetect now give 'UU' for address 68.
Also sudo hwclock -rv now works. (See previous post).
After a reboot the overlay is gone and you do not get the rtc
Adding the line dtoverlay=i2c-rtc,ds1307 to /boot/firmware/config,txt and an other reboot makes it permanent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants