[arm-allstar] Adding a real-time clock (i2c etc) to arch Linux all Star?

Tony Ross ynotssor at yahoo.com
Wed Oct 16 15:00:11 EDT 2019


The hamvoip.org mail list server munges the leading tabs into "?????? ", 
so some editing is required. I also attached the script, but apparently 
that's not allowed.

On 10/16/19 11:15 AM, "Tony Ross via ARM-allstar" wrote:
> On 10/2/19 1:55 PM, "Kvo via ARM-allstar" wrote:
>> I have attempted to ( quite unsuccessfully) add a hardware rtc (i2c) 
>> module to my raspberry pi running the Arch Linux image.
>> Can someone guide me to the correct steps?
>
> Since the GPIO pins are open on George's "Yellowbox", I decided to 
> install http://amazon.com/gp/product/B01M105UFC which uses a DS3231 
> clock chip. The included battery maintains time during power-off 
> states, very useful for when Internet isn't available for 
> "fakehwclock" synchronization at boot time, allowing a correct 
> timestamp in the log files.
>
> The following script worked perfectly for installation, and will most 
> likely also install your RTC:
>
>
> #!/usr/bin/env bash
> #-----------------------------------------------------------
> # Copyright (C) 2014-2016 GRUBERND http://grubernd.at
> # released under a FreeBSD License
> #-----------------------------------------------------------
> # CATE installer module :: device RealTimeClock RPi
> #
> #???????????? !!?? needs to be run as root / sudo?? !!
> #
> # works both for DS1307 and DS3231 chips.
> # this script is also designed to run standalone for
> # both Arch Linux ARM and Raspbian installs.
> #-----------------------------------------------------------
> #_CATECONF__?????? # RTC service requires no configuration
>
> if [[ "$(which pacman)" != "" ]]; then
> ?????? echo -e ""
> ?????? echo -e ".. installing I2C RTC for Arch Linux ARM"
> ?????? echo -e ""
> ?????? modules_file="/etc/modules-load.d/raspberrypi.conf"
> ?????? pacman -S --needed --noconfirm i2c-tools
> fi
>
> if [[ "$(which apt-get)" != "" ]]; then
> ?????? echo -e ""
> ?????? echo -e ".. installing I2C RTC for Raspbian"
> ?????? echo -e ""
> ?????? modules_file="/etc/modules"
> ?????? apt-get install --yes i2c-tools
> fi
>
> echo -e ""
> echo -e ".. activating I2C devicetree in /boot/config.txt"
>
> sed --in-place 
> 's/^#device_tree_param=i2c_arm=on/device_tree_param=i2c_arm=on/' 
> "/boot/config.txt"
>
> #-----------------------------------------------------------
> echo -e ""
> echo -e ".. adding i2c and rtc modules to the conf"
>
> cp "$modules_file" /tmp/rtc.tmp
> echo rtc-ds1307 >> /tmp/rtc.tmp
> echo i2c-dev?????? >> /tmp/rtc.tmp
> sort /tmp/rtc.tmp | uniq > "$modules_file"
>
> #-----------------------------------------------------------
> echo -e ""
> echo -e ".. creating init script for the RTC"
>
> mkdir -p /usr/lib/systemd/scripts/
> cat > /usr/lib/systemd/scripts/rtc << ENDRTCSCRIPT
> #!/bin/bash
> # create an i2c device DS1307 (works also for DS3231)
> # set systemclock from external i2c-rtc
> echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
> hwclock -s
> ENDRTCSCRIPT
>
> chmod 755 /usr/lib/systemd/scripts/rtc
>
> echo -e ""
> echo -e ".. creating service for the RTC"
>
> cat > /etc/systemd/system/rtc.service << ENDRTCSERVICE
> [Unit]
> Description=RTClock
> Before=network.target
>
> [Service]
> ExecStart=/usr/lib/systemd/scripts/rtc
> Type=oneshot
> [Install]
> WantedBy=multi-user.target
> ENDRTCSERVICE
>
> #-----------------------------------------------------------
> echo -e ""
> echo -e ".. enabling and starting RTC service"
>
> systemctl enable rtc
> systemctl start rtc
>
> #-----------------------------------------------------------
> ########## end script ##############
>
> _______________________________________________
>
> ARM-allstar mailing list
> ARM-allstar at hamvoip.org
> http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
>
> Visit the BBB and RPi2/3 web page - http://hamvoip.org
>



More information about the ARM-allstar mailing list