RPi 2(RTC module): from unruly Stepchild to Wunderkind

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • RPi 2(RTC module): from unruly Stepchild to Wunderkind

      Adding a RTC module to these makes a hell of a difference. Anyone who does not spend a few bucks for one on e-Bay is nuts.

      ebay.com/itm/New-DIY-DS3231-Pr…aspberry-Pi-/371312488218

      I was experiencing many errors with an rpi 2 I bought a few days ago. Some things that were at issue.

      ntpdate is not needed if you use ntp server. Also, when ntpdate is installed the ntp server will not start correctly:
      apt-get purge ntpdate

      Now in the web gui change the Time Zone to yours and click on save.

      There is another issue with the ntp server. The default config in the mkconf file does not work correctly. I recommend manually editing the /etc/ntp.conf file to get the ntp server working correctly:
      /etc/ntp.conf

      remove these lines:
      server 127.127.1.0 # Local clock
      fudge 127.127.1.0 stratum 12
      server pool.ntp.org iburst

      And replace with these:
      server 0.no.pool.ntp.org iburst
      server 1.no.pool.ntp.org iburst
      server 2.no.pool.ntp.org iburst
      server 3.no.pool.ntp.org iburst

      After making these changes for the ntp server do not disable/enable in the web gui anymore. It will overwrite the ntp.conf file.
      Restart the time server with this command. Your time should be correct in a minute or so:
      service ntp restart

      Wait a minute and then check if your time is accurate with this command:
      date

      The post was edited 7 times, last by tekkb ().

    • Here are some of the links I used to get the RTC module working. I will try to elaborate more later and create a guide.

      skpang.co.uk/blog/archives/575
      learn.adafruit.com/adafruits-r…pio-setup/configuring-i2c
      thepihut.com/blogs/raspberry-p…lock-to-your-raspberry-pi
      http://www.amazon.com/review/R2FJNAWLO6Y813/ref=cm_cr_dp_cmt?ie=UTF8&ASIN=B00HF4NUSS&channel=detail-glance&nodeID=541966&store=pc#wasThisHelpful

      Before the RTC module was installed and working the graphs did not work. RRDCACHED was flooding the logs with errors. Samba was not even working correctly. The module fixed this and more.
    • Make the following changes:

      /etc/modules

      Source Code

      1. # /etc/modules: kernel modules to load at boot time.
      2. #
      3. # This file contains the names of kernel modules that should be loaded
      4. # at boot time, one per line. Lines beginning with "#" are ignored.
      5. # Parameters can be specified after the module name.
      6. snd-bcm2835
      7. i2c-bcm2708
      8. i2c-dev
      9. rtc-ds1307
      10. ipv6
      Display All


      /etc/modprobe.d/raspi-blacklist.conf

      Source Code

      1. # blacklist spi and i2c by default (many users don't need them)
      2. # blacklist spi-bcm2708
      3. # blacklist i2c-bcm2708


      update-rc.d -f hwclock.sh remove
      cd /etc/init.d
      mv hwclock.sh hwclock.old
      touch hwclock.sh
      chmod 755 hwclock.sh
      nano hwclock.sh

      copy and paste the code box into the hwclock.sh while editing with nano

      Shell-Script

      1. #!/bin/sh
      2. # hwclock.sh Set and adjust the CMOS clock.
      3. #
      4. # Version: @(#)hwclock.sh 2.00 14-Dec-1998 miquels@cistron.nl
      5. #
      6. # Patches:
      7. # 2000-01-30 Henrique M. Holschuh <hmh@rcm.org.br>
      8. # - Minor cosmetic changes in an attempt to help new
      9. # users notice something IS changing their clocks
      10. # during startup/shutdown.
      11. # - Added comments to alert users of hwclock issues
      12. # and discourage tampering without proper doc reading.
      13. # 2012-02-16 Roger Leigh <rleigh@debian.org>
      14. # - Use the UTC/LOCAL setting in /etc/adjtime rather than
      15. # the UTC setting in /etc/default/rcS. Additionally
      16. # source /etc/default/hwclock to permit configuration.
      17. # WARNING: Please read /usr/share/doc/util-linux/README.Debian.hwclock
      18. # before changing this file. You risk serious clock
      19. # misbehaviour otherwise.
      20. init_rtc_device()
      21. {
      22. [ -e /dev/rtc0 ] && return 0;
      23. # load i2c and RTC kernel modules
      24. modprobe i2c-dev
      25. modprobe rtc-ds1307
      26. # iterate over every i2c bus to support Pi v1 and Pi v2
      27. # (different I2C busses on GPIO header!)
      28. for bus in $(ls -d /sys/bus/i2c/devices/i2c-*);
      29. do
      30. echo ds1307 0x68 >> $bus/new_device;
      31. #check if RTC found and if not delete device and try again
      32. if [ -e /dev/rtc0 ]; then
      33. log_action_msg "RTC found on bus `cat $bus/name`";
      34. break; # found the RTC so break out of loop
      35. else
      36. echo 0x68 >> $bus/delete_device
      37. fi
      38. done
      39. }
      40. init_rtc_device
      41. ### BEGIN INIT INFO
      42. # Provides: hwclock
      43. # Required-Start: mountdevsubfs
      44. # Required-Stop: $local_fs
      45. # Default-Start: S
      46. # X-Start-Before: checkroot
      47. # Default-Stop: 0 6
      48. ### END INIT INFO
      49. # These defaults are user-overridable in /etc/default/hwclock
      50. BADYEAR=no
      51. HWCLOCKACCESS=yes
      52. HWCLOCKPARS=
      53. HCTOSYS_DEVICE=rtc0
      54. # We only want to use the system timezone or else we'll get
      55. # potential inconsistency at startup.
      56. unset TZ
      57. hwclocksh()
      58. {
      59. [ ! -x /sbin/hwclock ] && return 0
      60. [ ! -r /etc/default/rcS ] || . /etc/default/rcS
      61. [ ! -r /etc/default/hwclock ] || . /etc/default/hwclock
      62. . /lib/lsb/init-functions
      63. verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; }
      64. case "$BADYEAR" in
      65. no|"") BADYEAR="" ;;
      66. yes) BADYEAR="--badyear" ;;
      67. *) log_action_msg "unknown BADYEAR setting: \"$BADYEAR\""; return 1 ;;
      68. esac
      69. case "$1" in
      70. start)
      71. # If the admin deleted the hwclock config, create a blank
      72. # template with the defaults.
      73. if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
      74. printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime
      75. fi
      76. # Commented out because Raspberry Pi doesn't have udev detectable RTC
      77. #if [ -d /run/udev ] || [ -d /dev/.udev ]; then
      78. #return 0
      79. #fi
      80. if [ "$HWCLOCKACCESS" != no ]; then
      81. log_action_msg "Setting the system clock"
      82. # Just for reporting.
      83. if head -n 3 /etc/adjtime | tail -n 1 | grep -q '^UTC$' ; then
      84. UTC="--utc"
      85. else
      86. UTC=
      87. fi
      88. # Copies Hardware Clock time to System Clock using the correct
      89. # timezone for hardware clocks in local time, and sets kernel
      90. # timezone. DO NOT REMOVE.
      91. if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --hctosys $HWCLOCKPARS $BADYEAR; then
      92. # Announce the local time.
      93. verbose_log_action_msg "System Clock set to: `date $UTC`"
      94. else
      95. log_warning_msg "Unable to set System Clock to: `date $UTC`"
      96. fi
      97. else
      98. verbose_log_action_msg "Not setting System Clock"
      99. fi
      100. ;;
      101. stop|restart|reload|force-reload)
      102. #
      103. # Updates the Hardware Clock with the System Clock time.
      104. # This will *override* any changes made to the Hardware Clock.
      105. #
      106. # WARNING: If you disable this, any changes to the system
      107. # clock will not be carried across reboots.
      108. #
      109. if [ "$HWCLOCKACCESS" != no ]; then
      110. log_action_msg "Saving the system clock"
      111. if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $HWCLOCKPARS $BADYEAR; then
      112. verbose_log_action_msg "Hardware Clock updated to `date`"
      113. fi
      114. else
      115. verbose_log_action_msg "Not saving System Clock"
      116. fi
      117. ;;
      118. show)
      119. if [ "$HWCLOCKACCESS" != no ]; then
      120. /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $HWCLOCKPARS $BADYEAR
      121. fi
      122. ;;
      123. *)
      124. log_success_msg "Usage: hwclock.sh {start|stop|reload|force-reload|show}"
      125. log_success_msg " start sets kernel (system) clock from hardware (RTC) clock"
      126. log_success_msg " stop and reload set hardware (RTC) clock from kernel (system) clock"
      127. return 1
      128. ;;
      129. esac
      130. }
      131. hwclocksh "$@"
      Display All


      Then:
      update-rc.d hwclock.sh defaults

      ** Don't worry about the warning message. This init script does not use the defaults run levels. It will use the appropriate ones given by the script though. **

      The post was edited 7 times, last by tekkb ().

    • Install i2c tools:
      apt-get install i2c-tools

      Enable SPI & I2c with the following in command line:
      raspi-config
      arrow down to "8 Advanced Option" and press Enter
      arrow down to "A6 SPI" and press Enter
      Choose Yes and press Enter for "Would you like the SPI interface to be enabled?"
      Press Enter on OK for "The SPI Interface is enabled"
      Choose Yes and press Enter for "Would you like the SPI kernel module loaded by default?"
      Press Enter on OK

      Back at main menu again choose "8 Advanced Options" and press Enter
      Arrow down to "A7 I2C" and press Enter
      Choose Yes and press Enter for "Would you like the ARM I2C Interface to be enabled?"
      Press OK
      Choose Yes and Press Enter for "Would you like the I2C kernel module loaded by default?"
      Press OK for "The I2C kernel module will be loaded by default"
      Back at main menu press TAB til "Finish" is highlighted and press Enter to exit.

      Now shutdown your pi and put the module on it. There is picture here so you can see what pins to put it on:
      thepihut.com/blogs/raspberry-p…lock-to-your-raspberry-pi


      Start your pi and see if this command works:
      i2cdetect -y 1

      if you have a rev. 1 pi use:
      i2cdetect -y 0

      When it is working on the rpi 2 you will see this:
      cdn.shopify.com/s/files/1/0176…e.png?7032407749952668269

      Actually it should say UU where the 68 shows in the picture if you followed this correctly and the clock should be activated. :)

      After verifying the new hardware clock is working you need to disable the fake-hwclock package. You can look at the kernel entries in your syslog in the web gui. The kernel entries when you first boot will only show correct date/time if the hardware clock is working. Sometimes it helps to clear the log and do a reboot so you are only looking back through a couple pages to find the kernel entries. When the hardware clock is first activated I think it took like 5-10 minutes for the ntp server to set the correct time on it.

      Do it with this command:
      update-rc.d -f fake-hwclock remove

      The post was edited 6 times, last by tekkb ().

    • How to get graphs working again once the RTC (Real Time Clock) is working:

      rm -r /var/lib/rrdcached/db/localhost
      rm /var/lib/rrdcached/journal/*
      service collectd restart
      service rrdcached restart

      It will take a while for data to populate for the graphs. But if you are antsy you can click on refresh to see that they have begun to work again.

      Now your logs & graphs will look pretty... :)

      The post was edited 3 times, last by tekkb ().

    • More info. that people may find helpful. The first 4 days or so I was having issues with corruption on my Micro SD and I was getting message like this:

      "Kernel Panic: VFS : Unable to mount root fs on unknown-block (179,2) "

      The rpi 2 was not finding the root partition to boot it due to corruption in the root partition. Somtimes I could fix with fsck and sometimes not. I checked the cmdline.text and it had the correct partition name. One of two things helped and maybe Aaron can give some insight.

      When I got it finally working correctly here are the 2 things I did differen. These were done post all the NTP server and RTC steps:

      1) After steps above I did these to make sure I had latest upgrades/drivers
      apt-get update
      apt-get upgrade
      apt-get rpi-update (Aaron mentioned this can be risky but went well for me)

      2) Then I handled deleting of the rrdcache partition slightly different before I expaned the root partion to take all the space on the Micro SD card.

      In OMV's web gui:
      unmount rrdcache filesystem
      delete rrdcache filesystem

      Then in command line:
      fdisk -l (to list the partitions which gives the /dev/mmcblk0 )
      fdisk /dev/mmcblk0
      p
      d
      3 (should be mmcblk0p3)
      w
      shutdown -r now

      After reboot you can use raspi-config to expand the root filesystem.
      It seems the kernel has to release the old partition table. This will not be done til reboot. (I believe there is command to do this too)
      I think if you expand root filesystem before you are using the new partition table you will corrupt filesystem.
      So rebooting to new partition table may be key to prevent this.


      Anyway, one of the 2 things above prevented the corruption in the root filesystem and no more kernel panic/unable to mount root fs messages.


      Hope this helps... :)

      The post was edited 4 times, last by tekkb ().

    • Yep. Most people won't need to resize the OS partition like you are doing. And once I get a chance to release new image, none of this will be necessary.
      omv 4.0.11 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • And you picked on me for having so many arm boards... :D You should see how fast the odroid-c1 is with a faster cpu and gigabit ethernet...
      omv 4.0.11 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • ofcourse try it several times....

      here are some infos:

      Brainfuck Source Code

      1. ​root@raspberrypi:~# samba --version
      2. -bash: samba: command not found
      3. root@raspberrypi:~# find / -executable -name samba
      4. /run/samba
      5. /etc/samba
      6. /etc/dhcp/dhclient-enter-hooks.d/samba
      7. /etc/dhcp3/dhclient-enter-hooks.d/samba
      8. /etc/cron.daily/samba
      9. /etc/init.d/samba
      10. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/etc/samba
      11. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/var/spool/samba
      12. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/var/lib/samba
      13. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/var/log/samba
      14. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/var/cache/samba
      15. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/usr/lib/samba
      16. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/usr/share/samba
      17. /media/ec9a4e2e-d53c-4bed-bb61-1d97a044595f/omvbackup/usr/share/doc/samba
      18. /var/spool/samba
      19. /var/log/samba
      20. /var/cache/samba
      21. /var/lib/samba
      22. /usr/share/doc/samba
      23. /usr/share/samba
      24. /usr/share/openmediavault/mkconf/samba
      25. /usr/lib/samba
      26. root@raspberrypi:~# smbstatus
      27. WARNING: The "null passwords" option is deprecated
      28. WARNING: The "null passwords" option is deprecated
      29. Samba version 3.6.6
      30. PID Username Group Machine
      31. -------------------------------------------------------------------
      32. Service pid machine Connected at
      33. -------------------------------------------------------
      34. /var/run/samba/locking.tdb not initialised
      35. This is normal if an SMB client has never connected to your server.
      36. root@raspberrypi:~# service samba status
      37. nmbd is running.
      38. smbd is not running ... failed!
      Display All
      omv 2.2 on lenovo thinkpad R61 :thumbup: