Is there a way to make the external DS3231 the wakeup device? Just like in this RaspPi thread, I want to set the alarm and use the INT pin on the clock chip to activate something.
The RaspPi dtoverlay command seems to use a different format and I’m at a loss how to translate this.
I’ve already made the INT pin work using Adafruit’s python libraries for the DS3231, but I’d like to use the linux tools if possible - then I can also use the clock to set the system time. Of course if the device tree is using the clock, the python libraries can’t get to it.
That’s not quite what I am asking. I want to set the alarm in the DS3231, shut down the BBB, completely, then have the Alarm / INT pin on the DS3231 initiate a series of events that eventually powers on the BBB. Doing this, I can achieve a true zero power sleep state. Nothing will draw power except the coin cell on the DS3231.
I can set the alarm in the DS3231 using python libraries, is it possible to set that alarm using the device drivers? I have a bunch of relay and delay circuits that area all working, this is the last link in the chain. I will use the python if necessary but would prefer to use the kernel drivers.
I need the BBB to power up for a couple hours every two weeks and last for a year on a stack of D cells; the normal sleep state draws too much power, I want to shut it off.
The reddit page I linked describes the exact same problem and solution for RaspPi. Is there a similar solution for BBB?
The power chip TPS65217 needs PWR_BUT P9.9 pulled low (<0.4V) for more than 50ms, but less than 8sec.
It appears the DS3231 can hold its INT/SQW pin low for 1 second
Hi.
I leave this post here just to share my experience with a DS3231 module and a Beaglebone Blue, hopping that it will help folks trying to do the same.
To automatically set system time of my BBBlue by external DS3231 I followed the following steps (most of them already posted here).
Output of “i2cdetect -y -r 1” after connecting the module to the BBBlue (it is the only module connected to the i2c bus available in the board i2c connector):
debian@beaglebone:~$ i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – 57 – – – – – – – –
60: – – – – – – – – 68 – – – – – – –
70: – – – – – – – –
Address 0x68 is for DS3231 and address 0x57 is for an EEPROM AT24C32 (4k x 8-bit) also present in the DS3231 module.
To confirm connectivity to the DS3231 I executed these commands:
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r -f /dev/rtc1
and got something like this:
2000-01-01 03:20:00.821573+00:00
My DS3231 board was brand new, so the DS3231 clock had never been set. To set it, I just copied system time (system time was already correctly set to that day’s date) to the DS3231 with the commands:
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device # Not needed if already executed
hwclock -w -f /dev/rtc1
To confirm that writing the DS3231 was successful, just execute
hwclock -r -f /dev/rtc1
and verify if the time returned is correct (in my case it was correct).
2) To make sure system time gets updated with DS3231 automatically at every reboot, I included the following line at the end of file /boot/uEnv.txt :
dtb_overlay=/lib/firmware/BB-I2C1-RTC-DS3231.dtbo
Please note that there are no spaces near the equal sign (thank you RobertCNelson to point this out). And also note that the file /lib/firmware/BB-I2C1-RTC-DS3231.dtbo already existed in my BBBlue.
After this, if I shutdown the BBBlue and restart it, the output of command “dmesg | grep rtc” is something like this:
debian@beaglebone:~$ dmesg | grep rtc
[ 1.204788] omap_rtc 44e3e000.rtc: already running
[ 1.205467] omap_rtc 44e3e000.rtc: registered as rtc1
[ 1.401269] rtc-ds1307 1-0068: registered as rtc0
[ 1.411806] rtc-ds1307 1-0068: setting system clock to 2024-02-20 19:52:47 UTC (1708458767)
[ 38.563534] PM: bootloader does not support rtc-only!
debian@beaglebone:~$
In that output of command “dmesg | grep rtc”, what I find a bit misleading is the mention to ”rtc-ds1307“, since the chip in my module is really the DS3231 and not the DS1307 (which is another RTC chip). In spite of this, that output shows that the setup is ok, and now the system time is always updated with the DS3231 automatically at every reboot.
Just to clarify which version of BBBlue I’m using, here is the output of the “sudo /opt/scripts/tools/version.sh” command:
debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[4d3a0aff57aae78a0db890f72ce505f61f1a93ce]
eeprom:[A335BNLTBLA21712EL004624]
model:[TI_AM335x_BeagleBone_Blue]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblue.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-I2C1-RTC-DS3231]
kernel:[4.19.94-ti-r43]
nodejs:[v10.24.0]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
uboot_overlay_options:[dtb_overlay=/lib/firmware/BB-I2C1-RTC-DS3231.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-wl18xx-firmware]:[1.20211222.2-0~buster+20211222]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 8.891694] remoteproc remoteproc0: 4a334000.pru is available
[ 8.910290] remoteproc remoteproc1: 4a338000.pru is available
[ 39.316289] remoteproc remoteproc2: wkup_m3 is available
[ 39.324081] remoteproc remoteproc2: powering up wkup_m3
[ 39.324107] remoteproc remoteproc2: Booting fw image am335x-pm-firmware.elf, size 217168
[ 39.324362] remoteproc remoteproc2: remote processor wkup_m3 is now up
dmesg | grep pru
[ 8.891694] remoteproc remoteproc0: 4a334000.pru is available
[ 8.908378] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[ 8.910290] remoteproc remoteproc1: 4a338000.pru is available
[ 8.910454] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[ 0.913099] pinctrl-single 44e10800.pinmux: 142 pins, size 568
[ 1.118117] pinctrl-single 44e10800.pinmux: pin PIN102 already requested by 48300180.eqep; cannot claim for ocp:P9_30_pinmux
[ 1.129515] pinctrl-single 44e10800.pinmux: pin-102 (ocp:P9_30_pinmux) status -22
[ 1.137100] pinctrl-single 44e10800.pinmux: could not request pin 102 (PIN102) from group pinmux_P9_30_spi_pin on device pinctrl-single
dmesg | grep gpio-of-helper
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
debian@beaglebone:~$
I hope this is the right place to post this, and that this is helpful to someone using a BBBlue.
Cheers.