[arm-allstar] DS3231 RTC install on my node/ repeater controller

Vendel hot96xl at yahoo.com
Wed Oct 17 14:41:25 EDT 2018



Hi Doug I tried the script you suggested with no success. I hate to post this lengthy script with it’s associated replies but here goes…

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[root at K2DSI ~]# sudo [root at K2DSI ~]# sudo #!/bin/bash
    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

#-----------------------------------------------------------
#_CATETEST__    echo -e ""
#_CATETEST__    echo -e ".. systemctl status rtc"
#_CATETEST__    systemctl status rtc
#_CATETEST__    echo -e ""
#_CATETEST__    echo -e ".. testing i2c activation in /boot/config.txt"
#_CATETEST__    grep "^device_tree_param=i2c_arm=on" /boot/config.txt
#_CATETEST__    echo -e ""
#_CATETEST__    echo -e ".. testing connection of i2c devices"
#_CATETEST__    i2cdetect -y 1
#_CATETEST__    echo -e ""
#_CATETEST__    echo -e ".. testing rtc hwclock"
#_CATETEST__    hwclockusage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-u user]
            [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-u user] file
            ...
[root at K2DSI ~]# #-----------------------------------------------------------
[root at K2DSI ~]# # Copyright (C) 2014-2016 GRUBERND http://grubernd.at
[root at K2DSI ~]# # released under a FreeBSD License
[root at K2DSI ~]# #-----------------------------------------------------------
[root at K2DSI ~]# # CATE installer module :: device RealTimeClock RPi
[root at K2DSI ~]# #
[root at K2DSI ~]# #       !!  needs to be run as root / sudo  !!
[root at K2DSI ~]# #
[root at K2DSI ~]# # works both for DS1307 and DS3231 chips.
[root at K2DSI ~]# # this script is also designed to run standalone for
[root at K2DSI ~]# # both Arch Linux ARM and Raspbian installs.
[root at K2DSI ~]# #-----------------------------------------------------------
[root at K2DSI ~]# #_CATECONF__    # RTC service requires no configuration
[root at K2DSI ~]#
[root at K2DSI ~]# 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

.. installing I2C RTC for Arch Linsudo: [root at K2DSI: command not found
[root at K2DSI ~]# #
[root at K2DSI ~]# #       !!  needs to be run as root / sudo  !!
[root at K2DSI ~]# #
[root at K2DSI ~]# # works both for DS1307 and DS3231 chips.
[root at K2DSI ~]# # this script is also designed to run standalone for
[root at K2DSI ~]# # both Arch Linux ARM and Raspbian installs.
[root at K2DSI ~]# #-----------------------------------------------------------
[root at K2DSI ~]# #_CATECONF__    # RTC service requires no configuration
[root at K2DSI ~]#
[root at K2DSI ~]# 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

.. installing I2C RTC for Arch Linux ARM

warning: i2c-tools-3.1.1-2 is up to date -- skipping
 there is nothing to do
[root at K2DSI ~]#
[root at K2DSI ~]# 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
which: no apt-get in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
[root at K2DSI ~]#
[root at K2DSI ~]# echo -e ""

[root at K2DSI ~]# echo -e ".. activating I2C devicetree in /boot/config.txt"
.. activating I2C devicetree in /boot/config.txt
[root at K2DSI ~]#
[root at K2DSI ~]# sed --in-place 's/^#device_tree_param=i2c_arm=on/device_tree_param=i2c_arm=on/' "/boot/config.txt"
[root at K2DSI ~]#
[root at K2DSI ~]# #-----------------------------------------------------------
[root at K2DSI ~]# echo -e ""

[root at K2DSI ~]# echo -e ".. adding i2c and rtc modules to the conf"
.. adding i2c and rtc modules to the conf
[root at K2DSI ~]#
[root at K2DSI ~]# cp "$modules_file" /tmp/rtc.tmp
cp: overwrite '/tmp/rtc.tmp'? c.tmp'? [root at K2DSI ~]# ---------------
bash: ---------------: command not found
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. systemctl status rtc"
[root at K2DSI ~]# #_CATETEST__    systemctl status rtc
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing i2c activation in /boot/config.txt"
[root at K2DSI ~]# #_CATETEST__    grep "^device_tree_param=i2c_arm=on" /boot/config.txt
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing connection of i2c devices"
[root at K2DSI ~]# #_CATETEST__    i2cdetect -y 1
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing rtc hwclock"
[root at K2DSI ~]# #_CATETEST__    hwclock
[root at K2DSI ~]# --------------
bash: --------------: command not found
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. systemctl status rtc"
[root at K2DSI ~]# #_CATETEST__    systemctl status rtc
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing i2c activation in /boot/config.txt"
[root at K2DSI ~]# #_CATETEST__    grep "^device_tree_param=i2c_arm=on" /boot/config.txt
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing connection of i2c devices"
[root at K2DSI ~]# #_CATETEST__    i2cdetect -y 1
[root at K2DSI ~]# #_CATETEST__    echo -e ""
[root at K2DSI ~]# #_CATETEST__    echo -e ".. testing rtc hwclock"
[root at K2DSI ~]# #_CATETEST__    hwclockusage: sudo -h | -K | -k | -V
[root at K2DSI ~]# usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
bash: usage:: command not found
[root at K2DSI ~]# usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
bash: usage:: command not found
[root at K2DSI ~]#             [command]
bash: [command]: command not found
[root at K2DSI ~]# usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-u user]
bash: usage:: command not found
[root at K2DSI ~]#             [VAR=value] [-i|-s] [<command>]
bash: command: No such file or directory
bash: [VAR=value]: command not found
[root at K2DSI ~]# usage: sudo -e [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-u user] file
bash: usage:: command not found
[root at K2DSI ~]#             ...
bash: ...: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #-----------------------------------------------------------
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # Copyright (C) 2014-2016 GRUBERND http://grubernd.at
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # released under a FreeBSD License
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #-----------------------------------------------------------
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # CATE installer module :: device RealTimeClock RPi
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #       !!  needs to be run as root / sudo  !!
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # works both for DS1307 and DS3231 chips.
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # this script is also designed to run standalone for
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# # both Arch Linux ARM and Raspbian installs.
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #-----------------------------------------------------------
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATECONF__    # RTC service requires no configuration
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# if [[ "$(which pacman)" != "" ]]; then
bash: syntax error near unexpected token `then'
[root at K2DSI ~]# >     echo -e ""
bash: -e: command not found
[root at K2DSI ~]# >     echo -e ".. installing I2C RTC for Arch Linux ARM"
bash: -e: command not found
[root at K2DSI ~]# >     echo -e ""
bash: -e: command not found
[root at K2DSI ~]# >     modules_file="/etc/modules-load.d/raspberrypi.conf"
bash: modules_file=/etc/modules-load.d/raspberrypi.conf: No such file or directory
[root at K2DSI ~]# >     pacman -S --needed --noconfirm i2c-tools
bash: -S: command not found
[root at K2DSI ~]# > fi
[root at K2DSI ~]#
[root at K2DSI ~]# .. installing I2C RTC for Arch Linux ARM
bash: ..: command not found
[root at K2DSI ~]#
[root at K2DSI ~]# warning: i2c-tools-3.1.1-2 is up to date -- skipping
bash: warning:: command not found
[root at K2DSI ~]#  there is nothing to do
bash: there: command not found
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# if [[ "$(which apt-get)" != "" ]]; then
bash: syntax error near unexpected token `then'
[root at K2DSI ~]# >     echo -e ""
bash: -e: command not found
[root at K2DSI ~]# >     echo -e ".. installing I2C RTC for Raspbian"
bash: -e: command not found
[root at K2DSI ~]# >     echo -e ""
bash: -e: command not found
[root at K2DSI ~]# >     modules_file="/etc/modules"
bash: modules_file=/etc/modules: No such file or directory
[root at K2DSI ~]# >     apt-get install --yes i2c-tools
install: unrecognized option '--yes'
Try 'install --help' for more information.
[root at K2DSI ~]# > fi
[root at K2DSI ~]# which: no apt-get in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
bash: syntax error near unexpected token `('
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]#
[root at K2DSI ~]# [root at K2DSI ~]# echo -e ".. activating I2C devicetree in /boot/config.txt"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# .. activating I2C devicetree in /boot/config.txt
bash: ..: command not found
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# sed --in-place 's/^#device_tree_param=i2c_arm=on/device_tree_param=i2c_arm=on/' "/boot/config.txt"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #-----------------------------------------------------------
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]#
[root at K2DSI ~]# [root at K2DSI ~]# echo -e ".. adding i2c and rtc modules to the conf"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# .. adding i2c and rtc modules to the conf
bash: ..: command not found
[root at K2DSI ~]# [root at K2DSI ~]#
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# cp "$modules_file" /tmp/rtc.tmp
bash: [root at K2DSI: command not found
[root at K2DSI ~]# cp: overwrite '/tmp/rtc.tmp'? [root at K2DSI ~]# ---------------
bash: cp:: command not found
[root at K2DSI ~]# bash: ---------------: command not found
bash: bash:: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ".. systemctl status rtc"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    systemctl status rtc
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ".. testing i2c activation in /boot/config.txt"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    grep "^device_tree_param=i2c_arm=on" /boot/config.txt
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ".. testing connection of i2c devices"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    i2cdetect -y 1
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ""
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    echo -e ".. testing rtc hwclock"
bash: [root at K2DSI: command not found
[root at K2DSI ~]# [root at K2DSI ~]# #_CATETEST__    hwclock
bash: [root at K2DSI: command not found
[root at K2DSI ~]#


Hopefully you or someone else can make heads or tails out of this and send me a solution. Please don’t assume I know a lot about Linux. (I am old enough to remember playing around with CPM though.) 😉

Again sorry about the long post, Vendel/ K2DSI.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


More information about the ARM-allstar mailing list