Deep sleep & wake through GPIO and RTC

Kernel: Linux beaglebone 4.4.48-ti-r88 #1 SMP Sun Feb 12 01:06:00 UTC 2017 armv7l GNU/Linux
OS: Debian 8.1

In order to get a low-power board, I get sensors data every 10min and I need to sleep meanwhile.
I have an external RTC DS3231 with a SQW pin in order to setAlarm. I can plug it to a gpio and it changes its value when I want.

What I would like is:

  1. After the sampling, put the board in the highest low-power mode as possible (only the RTC running?)
  2. Let the RTC wakup from suspension changing the gpio pin value

I tried:

root@beaglebone:/# echo standby > /sys/power/state

The rtc set the gpio value from 1 to 0 but it doesn’t wakeup. I think because I don’t have the wakup option in /sys/class/gpio/gpio44/power. Right? How could I enable it?

Is there a way to close the 3.3/5V output to the sensor when the device is sleeping and reopen it after wakeup?

It this guideline still good for my beaglebone green wireless? It tells to set

echo uart0_rxd.gpio1_10=0x27,rising > standby_gpio_pad_conf

but If I would set gpio P8_12?
Something like:

echo something.gpio44=0x??, falling > standby_gpio_pad_conf

???

Some tutorials speak about a GPIO0 use for wakeup. Which is in our BB?

Is this the right way?

Thank you for the support :smiley:

If you want the lowest possible power usage from the beaglebone, and using something like, or akin to sleeping the system. You will need an external processor( low power MCU ) involved.

It would work something like this:

  • The beaglebone is completely powered down
  • the External MCU would toggle power, and reset lines on the beaglebone.
  • The beaglebone after boot through systemd would run a OneShot service.
  • This services calls a script that runs through a sequence of things it must do for a single time period. Lastly, the board powers down.
  • The MCU, has a timer loop than will toggle toggle the power and reset lines on the beaglebone every X time period.

While your at it, add psuedo watch dog functionality to your MCU, which basically you’ve already done by following the above proceedures. Add an I2C RTC to the board you made for this automated wake up system described above. As the onboard beaglebone RTC functions, but only while it has power.

So I’m a bit unclear what yo uwant a real time clock for. If it’s to keep proper time stamps on the beaglebone while logging, You do not need one. Part of your systemd startup service / script could call ntpdate to update the time from a atomic clock. IF the system has access to the internet.

If no internet, or you would like to keep time from the control MCU, Then one would probably need an external RTC. Which would complicate things a good bit, but is possible.

We’re looking for something less external mcu-based in order to exploit all the AM335x capabilities. I would prefer consume a bit more without making the project too complex with programming an external mcu :slight_smile:

I’m wondering if the BB offers a inner way to sleep/awake or at least the possibility to use the GPIO and the external rtc with the interrupt.
I’m trying rtcwake with ‘standby’ mode and it’s working quite good, but the best (imho) wat would be the ‘mem’ mode if it’s possible to wake it up with the rtc (rtc0 or rtc1).

I’m using an external RTC because I will have possible situations without the access to Internet, like you guessed.

If you leave out the need for an external MCU, the system will not be
robust, nor efficient.

I'm not saying what you want is not possible, I'm honestly not sure if this
is possible on this platform or not. More or less like it's possible and
most if not all X86 style systems. What I am saying is that if you rely
solely on the beaglebone, you're asking for trouble. For several reasons,
but for starters, there is no functional watchdog hardware module on the
beaglebone. Passed that, if the processor on the beaglebone has to be
active, but even in low power mode. The PMIC has to be active as well.
Comparatively, this will use a lot of power. Compared to something that was
specifically designed to use micro, or nano amps.

Those are just two reasons. There are many more reasons if you think about
it hard.

The AM335x platform already includes a Cortex M3 for exactly this purpose – a low power MCU that can be used to wake the system on certain interrupts (http://processors.wiki.ti.com/index.php/AM335x_Power_Management_Standby_User's_Guide#Linux_Implementation)

I don’t yet have the wakeup working on a 4.4.x kernel, but will post an update when I figure it out.

Davide – have you have any luck since posting this question?

Hi flyingfred0!
Not really; I haven’t investigated more about this problem…I’m using rtcwake at the moment but I would be glad if you find a powerful standby mode way.

Just to add some info ,

With overlay I can wake up beaglebone BB-BONE-LCD4-01-00A1.dts, which have wakeup gpio at p9_24(gpio0[15]]). Just connect ground pin to P9_01 and p9_24 to a button, and use this button for wakeup.

# cat /sys/kernel/debug/wakeup_sources
 name		active_count	event_count	wakeup_count	expire_count	active_since	total_time	max_time	last_change	prevent_suspend_time
 gpio-keys   	5		5		0		0		0		1		0		47848		0
 musb-hdrc.0 	0		0		0		0		0		0		0		0		0
 mmc0        	0		0		0		0		0		0		0		0		0
 tps65217-pwrbutton	0		0		0		0		0		0		0		0		0
 alarmtimer.2.auto	0		0		0		0		0		0		0		0		0
 44e3e000.rtc	1		1		0		0		0		0		0		34752		0
 TI-am335x-tsc.0.auto	0		0		0		0		0		0		0		0		0
 musb-hdrc.1 	0		0		0		0		0		0		0		0		0
 mmc1        	0		0		0		0		0		0		0		0		0
 44e09000.serial	0		0		0		0		0		0		0		0		0
 autosleep   	0		0		0		0		0		0		0		0		0
 deleted     	0		0		0		0		0		0		0		0		0
 
 
 # echo mem > /sys/power/state 
 [   47.059958] PM: suspend entry (deep)
 [   47.158257] Filesystems sync: 0.094 seconds
 [   47.175454] Freezing user space processes ... (elapsed 0.002 seconds) done.
 [   47.184801] OOM killer disabled.
 [   47.188093] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
 [   47.197217] printk: Suspending console(s) (use no_console_suspend to debug)
 [   47.332209] cpsw 4a100000.ethernet eth0: Link is Down
 [   47.373672] Disabling non-boot CPUs ...
 [   47.373720] pm33xx pm33xx: PM: Successfully put all powerdomains to target state
 [   47.373720] PM: Wakeup source GPIO0
 [   47.397910] cpsw 4a100000.ethernet: initializing cpsw version 1.12 (0)
 [   47.463341] SMSC LAN8710/LAN8720 4a101000.mdio:00: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
 [   47.650640] pwm-backlight backlight: supply power not found, using dummy regulator
 [   47.707488] OOM killer enabled.
 [   47.710977] Restarting tasks ... done.
 [   47.767606] PM: suspend exit

Also bbb wakes up with uart0 also

# echo mem > /sys/power/state
[  520.625785] PM: suspend entry (deep)
[  520.637523] Filesystems sync: 0.007 seconds
[  520.655530] Freezing user space processes ... (elapsed 0.006 seconds) done.
[  520.671929] OOM killer disabled.
[  520.675230] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[  520.684295] printk: Suspending console(s) (use no_console_suspend to debug)
[  520.818735] cpsw 4a100000.ethernet eth0: Link is Down
[  520.848960] Disabling non-boot CPUs ...
[  520.849011] pm33xx pm33xx: PM: Successfully put all powerdomains to target state
[  520.849011] PM: Wakeup source UART
[  520.872174] cpsw 4a100000.ethernet: initializing cpsw version 1.12 (0)
[  520.938319] SMSC LAN8710/LAN8720 4a101000.mdio:00: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[  521.125463] pwm-backlight backlight: supply power not found, using dummy regulator
[  521.182190] OOM killer enabled.
[  521.185674] Restarting tasks ... done.
[  521.237086] PM: suspend exit

All of above done with mainline buildroot beaglebone

Linux buildroot 5.10.30 #1 SMP PREEMPT Sun Jun 16 21:35:37 IST 2024 armv7l GNU/Linux

1 Like

That is interesting, did not realize it would do that. Did you have to do anything special other than load the LCD4 overlay?

No, with this kernel version I didn’t faced any issue in s2r.
Works out of the box.

1 Like