The Raspberry Pi doesn’t have any ‘Real Time Clock’ (RTC) module, which keeps actual time.
Here is instruction how to use it with FreeBSD 11 on the Raspberry Pi.
Running FreeBSD 11
FreeBSD 11 isn’t released yet, but we can use latest snapshot available here: ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/arm/armv6/ISO-IMAGES/11.0
Let’s connect DS1307 to our Raspberry Pi and check that it works.
My utility detects DS1307 on address 0x68 but DS1307(4) manual page says that default address for it is 0xD0.
This is because my utilities use ‘standard’ 7-bit I2C addresses, but FreeBSD uses 8-bit I2C addresses: (7-bit device address << 1), leaving the room for the read/write bit.
0xD0 = 0x68 << 1
To use DS1307 in FreeBSD 11 we need to update FDT for our Raspberry Pi.
To do this we need first to get and extract source code.
This is because updating FDT is a necessary but insufficient condition to get working RTC module in the FreeBSD 11.
We should to add device ds1307 to the kernel file /usr/src/sys/arm/conf/RPI-B:
To compile new kernel we needs something more that the /usr/src/sys tree.
We needs Makefile in the /usr/src directory at least.
The simplest way to have this file is get all source code.
We can add /usr/src path to the svn(1) without removing /usr/src/sys path from it.
After that we can compile and install our new kernel:
After reboot we can check the result.
We got our DS1307 device.
Let’s look to our new device:
To be sure that this device really works we need to turn off ntpd(8), check time, turn off our Raspberry Pi for the some days, and then turn it on and check the time.
As we see it works!
NTPD and DS1307
If we turn on ntpd(8) with connected DS1307, after some short period of time our system will go to panic:
This is known issue. The workaround is: