Keeping time with a real-time clock

Having all clocks synchronized throughout a system is often an assumption that doesn't hold for embedded devices. Specialized devices may not need to know the time to perform their function. However, in security protocols, accurate time keeping is often important. For example, in TLS, the X.509 certificates that are used to prove the identity of web servers contain a validity range. There is a not before and not after time that specifies when that certificate is valid. Without an accurate time keeping system, a device can't enforce this date range allowing it to possibly accept expired or not yet valid certificates.

If you use your BBB in an offline environment, but still need accurate time, then you can insert a coin cell battery into the battery compartment of the CryptoCape. When the BBB is disconnected from power, the RTC will receive enough power from the battery to maintain accurate time.

The BBB already contains an RTC; however, it lacks a dedicated battery. It is possible to power the entire BBB from a battery using the battery access pads located near the DC barrel plug adapter; however, a greater capacity battery would be needed since the entire board is powered from these pads.

The RTC driver is loaded automatically, which you can verify by running:

dmesg | grep rtc

This should result in the following:

[    0.729101] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0
[    0.748605] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc1
[    0.748627] rtc-ds1307 1-0068: 56 bytes nvram
[    0.977426] [drm] Cannot find any crtc or sizes - going 1024x768
[    1.048851] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:01 UTC (946684801)

The previous example shows the BBB's RTC, omap_rtc, registered as rtc0 and the not-so-accurate-time of 2000-01-01 being set. The CryptoCape's RTC is rtc1 and the time value is not manipulated.

You will have to set the RTC time initially after installing the CryptoCape. First, you'll need an accurate system time. Refer to the project from Chapter 2, Circumventing Censorship with a Tor Bridge, on how this is done. Set the RTC from the system time with the following command:

hwclock -w -f /dev/rtc1

Cross-check the time to ensure it was set properly:

hwclock -r -f /dev/rtc1

This should produce something like the following:

Tue 13 May 2014 07:29:27 PM UTC  -0.198319 seconds

If you use the coin cell battery from SparkFun Electronics, it has a stated capacity of 47mAh. The DS3231m draws 2 micro Amps when on the battery. Ideally, this would result in 23,500 hours of run time on the battery or about 2.7 years. In actuality, you see much less run time from your battery, but even if the battery dies in half of the ideal time, you should still see plenty of battery life from your RTC.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.61