I'm having trouble with a Pi-Zero rebooting after a varying number of hours. It's not crashing, it's rebooting, so there must be a reason for its madness.

I see this in syslog minutes or hours before a reboot:

rtc rtc0: __rtc_set_alarm: err=-22

I'm not trying to set an alarm or to use the rtc to wakeup or reboot the system. But SOMETHING is telling the system to reboot because I always find this in syslog:

shutdown[28715]: shutting down for system reboot

with varying process ID's, none of which I can ever track down because I only learn about them after the system reboots. I never see those PID's while the system is running, so they must only be present for an instant.

I checked how the rtc is setup (I can read the hwclock ok) but something is clearly wrong because I see this very strange path:

/sys/class/rtc/rtc0/device/rtc/<endless copies of rtc0/subsystem/>

I may be causing this because I have this line in /etc/init.d/rc.local:

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

I thought I needed it for every boot, but maybe not. How do I fix it ? I tried to remove the repeating path, but it won't let me. Could it be causing the reboots ?

Update: I found a similar problem with two gpio's that I defined using /sys/class/gpio. Something is causing endless nesting of /sys/class definitions for rtc and gpio. I'm only running the statement once that defines them, and if I reboot without that statment, the entire repeating chain is gone, which is good. Otherwise, each /sys/class/rtc or gpio subdirectory repeats everything so there's a huge maze of definitions.

I'm running Raspian 4.9.40+ #1022 (prior to System-D, apparently sys-v init), and a DS-3231 clock chip, which is a DS-1307 compatible device.

Thank you in advance.

  • I don't know what "Raspian 4.9.40" is! cat /etc/os-release will show what you have. DS-3231 IS NOT a DS-1307. – Milliways Feb 1 at 22:38
  • uname -a gives 4.9.40+ #1022 Sun Jul 30 11:11:04 BST 2017 armv61 GNU/Linux, cat /etc/os-release gives Raspian GNU/Linux 7 (wheezy), like debian. The spec for the DS-3231 real time clock chip says it is software-compatible with the DS-1307, the differences being a larger EEPROM and thermal compensation for the clock in the DS-3231. But the key question is much more general... why is there a seemingly endless directory tree for the device ? I don't see any circular symlinks. – NewtownGuy Feb 2 at 18:13

You are running a doubly obsolete operating system Raspbian-Wheezy but have somehow installed a reasonably up-to-date kernel 4.9.40, presumably by running rpi-update - despite the warnings.

These are an unsupported combination. As you surmise Wheezy is SysV based, but the 4.9 kernels REQUIRE Device Tree and use this to load and initiate modules.

Adding the following line to /boot/config.txt MAY work.

dtoverlay=i2c-rtc,ds3231 

You should really do a fresh installation of Raspbian.

  • Thank you. That worked, without having to echo xxx to the device at boot, although syslog still thinks the chip is a ds-1307. For comic relief, this all started because my machine kept rebooting for no obvious reason. It turns out that my Pi was exposed to the Internet, it was hacked into, and hackers rebooted it ! I have details on what the hackers loaded into my machine if anyone is interested. It may help detect such attacks or be useful in a virus scanner. – NewtownGuy Feb 3 at 17:33
  • @NewtownGuy It is likely dmesg shows something like rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0 rtc-ds1307 is the driver, used by many similar RTC chips. – Milliways Feb 3 at 23:36

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.