RTC on RPi2

To add a module to FDT model you would add to the boards kernconf.

-For example- an RTC module on RPi2 via Maxim DS3231 supported via ds3231.c

/src/sys/arm/conf/RPI2
Code:
device ds3231

Then under the rpi2.dts you must add an entry for the module to the existing device tree source. Here is what needs be added.

/src/sys/boot/fdt/dts/arm/rpi2.dts
Code:
--- rpi2.dts.original   2016-10-30 13:28:25.152947000 -0400
+++ rpi2.dts   2016-11-01 19:55:01.064610000 -0400
@@ -322,7 +322,12 @@
                     mac-address = [00 00 00 00 00 00];
                 };
             };
-
+       };
+       bsc1{
+           rtc {
+               compatible="maxim,ds3231";
+               reg=<0x68>;
+           };
         };
     };
Save this as patch-rpi2.dts-file then apply on your source.

Then you cross compile like normal instructions. From there I am still learning.
 
Last edited:
I opted for crochet to cross build. Its so darn easy.

pkg install u-boot-rpi2
./crochet.sh -b RaspberryPi2
 
Looking good device is now recognized.
Code:
iichb0: <BCM2708/2835 BSC controller> mem 0x205000-0x20501f on simplebus0
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
ds32310: <Maxim DS3231 RTC> at addr 0x1a0 on iicbus0
 
root@rpi2:~ # sysctl dev.ds3231
dev.ds3231.0.32khz_enable: 1
dev.ds3231.0.sqw_mode: interrupt
dev.ds3231.0.sqw_freq: 8192
dev.ds3231.0.bbsqw: 0
dev.ds3231.0.temp_conv: 0
dev.ds3231.0.temperature: 27.0C
dev.ds3231.0.%parent: iicbus1
dev.ds3231.0.%pnpinfo: name=rtc compat=maxim,ds3231
dev.ds3231.0.%location: addr=0xd0
dev.ds3231.0.%driver: ds3231
dev.ds3231.0.%desc: Maxim DS3231 RTC
dev.ds3231.%parent:
 
Crochet took 4 hours on first run. After that changes to the rpi2.dtb it only took 4 minutes to generate a new image by re-running crochet. Perfect for trying many code settings.
 
Back
Top