dresden-elektronik / raspbee2-rtc

RTC kernel module builder for RaspBee II
BSD 3-Clause "New" or "Revised" License
21 stars 2 forks source link

Displaying the RTC time #3

Closed jondpenton closed 3 years ago

jondpenton commented 4 years ago

I have done a fresh install of raspbian and followed the installation instructions, but am having some trouble displaying the RTC time.

pi@raspberrypi:~ $ sudo hwclock --systohc --verbose
hwclock from util-linux 2.33.1
System Time: 1588524293.711060
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1588523574 seconds after 1969
Last calibration done at 1588523574 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
RTC type: 'rtc-pcf85063'
Using delay: 0.000000 seconds
missed it - 1588524293.725680 is too far past 1588524293.000000 (0.725680 > 0.001000)
1588524294.000000 is close enough to 1588524294.000000 (0.000000 < 0.002000)
Set RTC to 1588524294 (1588524293 + 1; refsystime = 1588524293.000000)
Setting Hardware Clock to 16:44:54 = 1588524294 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Not adjusting drift factor because the --update-drift option was not used.
New /etc/adjtime data:
0.000000 1588524293 0.000000
1588524293
UTC

pi@raspberrypi:~ $ sudo hwclock --verbose
hwclock from util-linux 2.33.1
System Time: 1588524360.136342
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1588524293 seconds after 1969
Last calibration done at 1588524293 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(3, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
...synchronization failed

I took a look at the service file, and ran the ExecStart command as root:

root@raspberrypi:/home/pi# echo pcf85063 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
bash: echo: write error: Invalid argument

I am running buster on the 3B:

pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

I would appreciate any help with solving this.

ChrisHae commented 4 years ago

Please try the command sudo hwclock --verbose while deCONZ is running. There is a FW problem that restarts the ConBeeII when deCONZ is not running. A FW update is on its way.

jondpenton commented 4 years ago

The device I'm using is the RaspBee II, but I went ahead and tried your suggestion anyway:

pi@raspberrypi:~ $ sudo hwclock --verbose
hwclock from util-linux 2.33.1
System Time: 1588853827.686280
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1588853823 seconds after 1969
Last calibration done at 1588853823 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(3, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
...synchronization failed

Here are some screenshots taken from the settings page of the Phoscon App and Wireless Light Control: Screenshot from 2020-05-07 08-23-52 Screenshot from 2020-05-07 08-24-31

It seems to me that both web interfaces are saying they can't find the device.

ChrisHae commented 4 years ago

Sorry I meant RaspBeeII. Could it be that the FW is not installed correctly? What does sudo GCFFlasher_internal -d /dev/ttyS0 -r say? Perhaps you have to flash it again.

jondpenton commented 4 years ago

It looks like GCFFlasher_internal didn't get installed during setup. I installed GCFFlasher from http://deconz.dresden-elektronik.de/raspbian/gcfflasher/gcfflasher-latest.deb and ran your command:

pi@raspberrypi:~/Downloads $ sudo GCFFlasher -d /dev/ttyS0 -r
rmmod: ERROR: Module ftdi_sio is not currently loaded
rmmod: ERROR: Module usbserial is not currently loaded
GCFFlasher V2_11 (c) dresden elektronik ingenieurtechnik gmbh 2017/12/10
invalid device parameter /dev/ttyS0

pi@raspberrypi:~/Downloads $ sudo GCFFlasher_internal -d /dev/ttyS0 -r
sudo: GCFFlasher_internal: command not found
jondpenton commented 4 years ago

I installed the beta version of deCONZ and ran the following commands:

pi@raspberrypi:~ $ sudo GCFFlasher_internal -d /dev/ttyS0 -r                          
GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh                         
Reboot device /dev/ttyS0 (RaspBee)                                                    
action: reset device RaspBee                          

pi@raspberrypi:~ $ sudo hwclock --verbose                                             
hwclock from util-linux 2.33.1                                                        
System Time: 1588858749.943439                                                        
Trying to open: /dev/rtc0                                                             
Using the rtc interface to the clock.                                                 
Last drift adjustment done at 1588857723 seconds after 1969                           
Last calibration done at 1588857723 seconds after 1969                                
Hardware clock is on UTC time                                                         
Assuming hardware clock is kept in UTC time.                                          
Waiting for clock tick...                                                             
ioctl(3, RTC_UIE_ON, 0): Invalid argument                                             
Waiting in loop for time from /dev/rtc0 to change                                     
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument    
...synchronization failed                                                             

pi@raspberrypi:~ $ sudo hwclock --systohc                                             
pi@raspberrypi:~ $ sudo hwclock --verbose                                             
hwclock from util-linux 2.33.1                                                        
System Time: 1588858757.137820                                                        
Trying to open: /dev/rtc0                                                             
Using the rtc interface to the clock.                                                 
Last drift adjustment done at 1588858753 seconds after 1969                           
Last calibration done at 1588858753 seconds after 1969                                
Hardware clock is on UTC time                                                         
Assuming hardware clock is kept in UTC time.                                          
Waiting for clock tick...                                                             
ioctl(3, RTC_UIE_ON, 0): Invalid argument                                             
Waiting in loop for time from /dev/rtc0 to change                                     
hwclock: Timed out waiting for time change.                                           
...synchronization failed                                                             

pi@raspberrypi:~/Downloads $ sudo GCFFlasher_internal -f deCONZ_Rpi_0x26350500.bin.GCF
GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh                         
Reboot device RaspBee (RaspBee)                                                       
action: reset device RaspBee                                                          
Bootloader version 0x00030003, app crc: 0xD4E57E35                                    

pi@raspberrypi:~/Downloads $ sudo hwclock --verbose                                   
hwclock from util-linux 2.33.1                                                        
System Time: 1588858878.393336                                                        
Trying to open: /dev/rtc0                                                             
Using the rtc interface to the clock.                                                 
Last drift adjustment done at 1588858753 seconds after 1969                           
Last calibration done at 1588858753 seconds after 1969                                
Hardware clock is on UTC time                                                         
Assuming hardware clock is kept in UTC time.                                          
Waiting for clock tick...                                                             
ioctl(3, RTC_UIE_ON, 0): Invalid argument                                             
Waiting in loop for time from /dev/rtc0 to change                                     
hwclock: Timed out waiting for time change.                                           
...synchronization failed                                                             

pi@raspberrypi:~/Downloads $ sudo hwclock --systohc                                   
pi@raspberrypi:~/Downloads $ sudo hwclock --verbose                                   
hwclock from util-linux 2.33.1                                                        
System Time: 1588858887.098117                                                        
Trying to open: /dev/rtc0                                                             
Using the rtc interface to the clock.                                                 
Last drift adjustment done at 1588858885 seconds after 1969                           
Last calibration done at 1588858885 seconds after 1969                                
Hardware clock is on UTC time                                                         
Assuming hardware clock is kept in UTC time.                                          
Waiting for clock tick...                                                             
ioctl(3, RTC_UIE_ON, 0): Invalid argument                                             
Waiting in loop for time from /dev/rtc0 to change                                     
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument    
...synchronization failed                                                             
ChrisHae commented 4 years ago

I think this is not the correct fw file for RaspBeeII. I can't say why the correct files aren't on our server yet but I have send you the correct file to your email address.

gothrek22 commented 4 years ago

Hi, it seems that this issue is more common. Would it be possible to update the README.md to include a fix for it? @ChrisHae

I've started with a new rpi 4b plus a new RaspBee II and I'm getting the same issue.

EDIT: Weird, after fetching the rtc file from the kernel repo manually and rebuilding 3 times, 3 restarts, suddenly it's working.

Dreiviertelblut commented 4 years ago

Running RaspbeeII on Buster, RaspberryPi 2B. Exactly the same problem. Deconz/Phoscon running fine, but no RTC working:

pi@Himbeere:~ $ sudo hwclock --verbose hwclock from util-linux 2.33.1 System Time: 1589957062.228692 Trying to open: /dev/rtc0 Using the rtc interface to the clock. Last drift adjustment done at 1589957040 seconds after 1969 Last calibration done at 1589957040 seconds after 1969 Hardware clock is on UTC time Assuming hardware clock is kept in UTC time. Waiting for clock tick... ioctl(3, RTC_UIE_ON, 0): Invalid argument Waiting in loop for time from /dev/rtc0 to change hwclock: Timed out waiting for time change. ...synchronization failed

pi@Himbeere:~ $ sudo journalctl -o cat -fau rtc-pcf85063 Started Enable RTC-PCF85063. rtc-pcf85063.service: Succeeded.

Something is obviously wrong, with what is described in the plugin docs and/or software implementation! Please check. Thnx.

@ChrisHae, @manup: Warning in make install? install rtc module... make -C /lib/modules/4.19.97-v7+/build M=/home/pi/raspbee2-rtc-master INSTALL_MOD_PATH= modules_install || (echo "could not install rtc module file (did you run make?)"; exit 1) make[1]: Entering directory '/usr/src/linux-headers-4.19.97-v7+' INSTALL /home/pi/raspbee2-rtc-master/rtc-pcf85063.ko DEPMOD 4.19.97-v7+ Warning: modules_install: missing 'System.map' file. Skipping depmod. make[1]: Leaving directory '/usr/src/linux-headers-4.19.97-v7+'

Edit: The 11-minute-mode sets the hwclock every 11 minute, but the clock just don't start to tick by itself.

ChrisHae commented 4 years ago

We have found the problem and implemented a fix in a new firmware. Its only a matter of time when it is released. I think only a few days, perhaps this week. I will tell when it is available for download.

mtandrup commented 4 years ago

Just bought a Raspbee II and am having this exact issue.

Looking forward to new firmware.

EDIT: After having Deconz up and running, the commands worked like they should.

ChrisHae commented 4 years ago

New FW is available. It removes that RTC bug so The RTC should work right after a reboot and when deCONZ is not running.

It also introduce a new experimental source routing mechanism wich should improve network stability: http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700_many2one.bin.GCF

If you experiance some problems with your network then there is also a version without source routing: http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700.bin.GCF

Dreiviertelblut commented 4 years ago

OK. So what's wrong with the firmware update?

Still got the old version on Raspbee II after update:

Stopped deconz.

wget http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700.bin.GCF

sudo GCFFlasher_internal -f deCONZ_RaspBeeII_0x26610700.bin.GCF

pi@Himbeere:~ $ wget http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700.bin.GCF --2020-06-11 12:40:13-- http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700.bin.GCF Resolving deconz.dresden-elektronik.de (deconz.dresden-elektronik.de)... 84.19.195.242 Connecting to deconz.dresden-elektronik.de (deconz.dresden-elektronik.de)|84.19.195.242|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 160860 (157K) [application/x-graphing-calculator] Saving to: ‘deCONZ_RaspBeeII_0x26610700.bin.GCF’

deCONZ_RaspBeeII_0x26610700.bin.GCF 100%[=====================================================================================>] 157.09K --.-KB/s in 0.1s

2020-06-11 12:40:14 (1.23 MB/s) - ‘deCONZ_RaspBeeII_0x26610700.bin.GCF’ saved [160860/160860]

pi@Himbeere:~ $ sudo GCFFlasher_internal -f deCONZ_RaspBeeII_0x26610700.bin.GCF GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh Reboot device RaspBee (RaspBee) deCONZ firmware version 26520700 Bootloader version 0x00030003, app crc:

ChrisHae commented 4 years ago

I just tried it with the same GCFFlasher version as yours. And it works:

sudo GCFFlasher_internal -f deCONZ_RaspBeeII_0x26610700.bin.GCF GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh Reboot device RaspBee (RaspBee) deCONZ firmware version 26610700 Bootloader version 0x00030003, app crc: 0xA0FA91C8 flashing 160846 bytes: |================|

perhaps just try it again, or download file again. Seems crc is missing.

Dreiviertelblut commented 4 years ago

Same as before. This time with crc.

pi@Himbeere:~ $ sudo GCFFlasher_internal -f deCONZ_RaspBeeII_0x26610700.bin.GCF GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh Reboot device RaspBee (RaspBee) deCONZ firmware version 26520700 Bootloader version 0x00030003, app crc: 0xD4E57E35

grafik

ChrisHae commented 4 years ago

Can you try flash another one? http://deconz.dresden-elektronik.de/deconz-firmware/deCONZ_RaspBeeII_0x26610700_many2one.bin.GCF or an older FW...

Or try GCFFlasher with these parameter -t 30 (retry until timeout 30sec) or -x 3 (debug log level 0, 1, 3)

Dreiviertelblut commented 4 years ago

pi@Himbeere:~ $ sudo GCFFlasher_internal -f deCONZ_RaspBeeII_0x26610700.bin.GCF -t 30 GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh Reboot device RaspBee (RaspBee) deCONZ firmware version 26520700 Bootloader version 0x00030003, app crc: 0xD4E57E35 flashing 160846 bytes: |================|

If I look to your previous try, you've had already the new firmware installed and just flashed it once more with the same version?

grafik

BTW: Why is there still the old date of the previous Gateway version there? V 2.05.77 should have a more recent date, shouldn't it?

ChrisHae commented 4 years ago

Yes, I have tried it serveral times to flash the FW. For me it worked also without the parameter. But glad this helped you. The date indicates the version of the phoscon app. The number before the date is the version of the deCONZ software.

Dreiviertelblut commented 4 years ago

Ok, thnx.

BTW: After firmware upgrade, all my configured devices, meaning lights (one OSRAM outlet just for testing purpose installed) and 3 Xiaomi sensors (Multisensor + Watersensor) had not been updated anymore in Phoscon/deconz.

ebaauw commented 4 years ago

I'm having the same issue, see https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2864. Upgrading the RaspBee II to 0x26610700 worked fine, but doesn't resolve the RTC clock not working.

cwildfoerster commented 4 years ago

Lights/Switches to not connect after update to 26610700. Needed to relearn them once. Connecting again even after reboot.

ChrisHae commented 4 years ago

I am not aware of such an error related to the new FW. Can you still control your connected lights or do you have non connected lights right now? Can you confirm that deCONZ is connected (e.g. in the GUI). Or can you provide the output of: sudo GCFFlasher_internal -r

cwildfoerster commented 4 years ago
GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh
Reboot device RaspBee (RaspBee)
deCONZ firmware version 26610700
Bootloader version 0x00030003, app crc: 0x769F0F78

They were in the deconz overview, but only with the "old" states. Everything was just grey, only the tradfri remote was somehow connecting/drawing a line. After re-adding every light, sensor and switch, every entity was connecting again. As i was running deconz without debugging the whole time, i do not have any logs... now everything works as before, rebooting, no problem.

ChrisHae commented 4 years ago

Did you used 0x26610700_many2one.bin.GCF or the normal 0x26610700.bin.GCF ? the many2one introduced a new routing meachnism and it's a bit experimental. The stability of networks should be improved but perhaps it caused that issue. But When it is now running and no other issues I would keep that version.

Dreiviertelblut commented 4 years ago

update with deCONZ_RaspBeeII_0x26610700.bin.GCF showed the same behaviour (see above), so assumption that this is related to the many2one version is not correct.

cwildfoerster commented 4 years ago

Did you used 0x26610700_many2one.bin.GCF or the normal 0x26610700.bin.GCF ? the many2one introduced a new routing meachnism and it's a bit experimental. The stability of networks should be improved but perhaps it caused that issue. But When it is now running and no other issues I would keep that version.

I tried both versions, let them run for about 30 minutes but nothing was connecting, currently using the normal routing firmware. What has been changes in the routing mechanism? Can't find any info about it.

ChrisHae commented 4 years ago

The routing was introduced to reduce problems with ikea devices. Discussed here: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/1261

Briefly: Routes become parts of zigbee packets.

If further problems with the new firmware exists that are not related to the RTC: please open an issue in the decont rest plugin repository: https://github.com/dresden-elektronik/deconz-rest-plugin/issues

kucharovic commented 4 years ago

I have exactly the same problem (RPi4 8GB). i2cdetect -y 1 shows all addresses are used, but after a while (few hours) it shows correctly only 0x51. I've double-checked SDA for short circuits and it looks fine. Raspberry is in plastic box, so there is no touch between any pin and metal.

Then I tried to update firmware. It somehow fails, but without any error message.

pi@raspberrypi:~ $ GCFFlasher_internal -d /dev/ttyAMA0 -f deCONZ_RaspBeeII_0x26610700_many2one.bin.GCF -x 3
GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh
05:58:32:220 using firmware file: deCONZ_RaspBeeII_0x26610700_many2one.bin.GCF 

05:58:32:307 ls dev: /dev/ttyAMA0 (0x0000/0x0000) sn: 
05:58:32:307 check symlink /dev/ttyAMA0 (/dev/ttyAMA0)
05:58:32:307 dev /dev/ttyAMA0 (/dev/ttyAMA0)
05:58:32:307 ls dev: /dev/ttyS0 (0x0000/0x0000) sn: 
Reboot device /dev/ttyAMA0 (RaspBee)
05:58:32:308 query bootloader v1 ID after 0 ms
05:58:33:810 query bootloader v1 ID after 1501 ms
05:58:34:310 query deCONZ firmware version
05:58:34:318 SLIP RX frame length: 9
deCONZ firmware version 26520700
05:58:34:327 set watchdog ttl status: 0x00
05:58:36:429 query bootloader v1 ID after 0 ms
05:58:38:854 query bootloader v1 ID after 2425 ms
05:58:40:356 query bootloader v3 ID after 3927 ms
05:58:40:356 TX c081027dffc0
05:58:40:373 RX 28 bytes ASCII ??? after 3944 ms
05:58:40:373 RX c0818203000300357ee5d48bfcc0c0818203000300357ee5d48bfcc0 after 3944 ms
05:58:40:373 SLIP RX frame length: 10
05:58:40:373 check magic: 0x81 cmd: 0x82 after 3944 ms
Bootloader version 0x00030003, app crc: 0xD4E57E35
05:58:40:374 GCF_ResetDeviceDone
05:58:40:376 bootloader v3 update firmware request size: 163744, addr: 0x00005000, type: 31, crc-32: 0xAAAAAAAA
05:58:40:376 TX c08103a07f0200005000001faaaaaaaa44fbc0
05:58:40:384 SLIP RX frame length: 10
pi@raspberrypi:~ $
pi@raspberrypi:~ $ GCFFlasher_internal -d /dev/ttyAMA0 -r
GCFFlasher V3_13 (c) dresden elektronik ingenieurtechnik gmbh
Reboot device /dev/ttyAMA0 (RaspBee)
deCONZ firmware version 26520700
Bootloader version 0x00030003, app crc: 0xD4E57E35
ChrisHae commented 4 years ago

Try GCFFlasher with parameter -t 30 This should help if flashing fails.

kucharovic commented 4 years ago

Thanks a lot. I'm finally updated firmware to version 26610700. After update, I didn't notice incorrect output from i2cdetect. Now I tried installed Ubuntu Server 20. There is still error ioctl(4, RTC_UIE_ON, 0): Invalid argument but it seems OK:

ubuntu@ubuntu:~$ sudo hwclock --verbose
hwclock from util-linux 2.34
System Time: 1594374623.781759
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1594374601 seconds after 1969
Last calibration done at 1594374601 seconds after 1969
Hardware clock is on UTC time
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: 2020/07/10 09:50:25
Hw clock time : 2020/07/10 09:50:25 = 1594374625 seconds since 1969
Time since last adjustment is 24 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2020-07-10 09:50:24.279508+00:00
ubuntu@ubuntu:~$ 
ubuntu@ubuntu:~$ timedatectl
               Local time: Fri 2020-07-10 09:51:14 UTC
           Universal time: Fri 2020-07-10 09:51:14 UTC
                 RTC time: Fri 2020-07-10 09:51:14    
                Time zone: Etc/UTC (UTC, +0000)       
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no