About the datetime and soft power off for BBB

Hello,

Two questions need your kind support.
I am using Debian9 OS with BeagleBoneBlack Rev C.
1, Everytime after reboot the system datetime would reset to the original manufacture date. Is there any solution to keep datetime without networking and battery?
2, How to config the power or linux so that when push the power button during running, it would trigger the linux shutdown instead of cut off the power directly in order to protect the system?

Thanks much in advance.

@springzhang,

1: Correct, you will need a battery backed RTC.

Here is a cheap one I’ve had success with:

https://www.digikey.com/products/en?keywords=1528-1871-ND

(it does need a battery CR1220 )

Here is the overlay file I wrote for it:

2: Well the “power” button on the BBB is wired as a “POWER_KEY” so linux will proceed down a proper shutdown path. (your application running might not like that)… If you hold the button for 8 seconds, that works the same as yanking the plug. To better protect your system, take a look at the “overlayroot” option, that is now installed by default on the latest beagleboard.org images. It does take a little bit of ram, but the main os is left in a Read Only state to better protect the root file system…

Regards,

Can you provide more detail instruction for “overlayroot” usage since I do not use the official image but make image as your below instructions?

Thanks.

@springzhang

For overlayroot, install this package:

sudo apt update
sudo apt install overlayroot

Then make sure to regenerate the initrd.

sudo update-initramfs -uk `uname -r`

(if you didn’t have an initrd, swap the “u” for a “c” above)

Then in /boot/uEnv.txt append this variable to your existing cmdline settings.

cmdline=(existing settings) overlayroot=tmpfs

Then reboot, and your base root file system will be Read Only…

Regards,

Currently,When I press the “power” button(the red circle mark) normally (not holding 8 secs), the system would not proceed down a shutdown path but nothing happens. I hope after press this button it can trigger linux shutdown. How can I config linux or do some development work here?Can you give some detail instructions?
Thanks much!

If this script is available please run it and provide it’s output:

sudo /opt/scripts/tools/version.sh

Otherwise, please provide the output of:

uname -r

dpkg --list | grep libsystemd

Regards,

root@arm:/usr/bin# /opt/scripts/tools/version.sh
git:/opt/scripts/:[702a85c3ea80bf39c36f539e40dbd0e877b173dc]
]eprom:[A335BNLTBBG135Q
model:[TI_AM335x_BeagleBone_Green]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.09-dirty]:[location: dd MBR]
kernel:[4.19.19-bone-rt-r21]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20190123.0-0rcnee0~stretch+20190123]
WARNING:pkg:[bb-wl18xx-firmware]:[NOT_INSTALLED]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c netdev gpio pwm eqep bluetooth admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 quiet lpj=1990656 root=UUID=cf9a32c1-ca83-4c8d-aec2-adc9d50334a9 ro rootfstype=ext4 rootwait]
dmesg | grep pinctrl-single
[ 0.630989] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper

root@arm:/usr/bin# uname -r
4.19.19-bone-rt-r21
root@arm:/usr/bin# dpkg --list | grep libsystemd
ii libsystemd0:armhf 232-25+deb9u8 armhf systemd utility library

Well there is part of the problem, you got one of the GHI BeagleBone Blacks that got flashed the wrong eeprom, it’s a really simple fix:

1: GND TP4 (between ethernet and barrel plug)

2: Then run this command as root:

dd if=/opt/scripts/device/bone/bbb-eeprom.dump of=/sys/devices/platform/ocp/44e0b000.i2c/i2c-0/0-0050/eeprom

3: Reboot

idk know if that’ll solve the shutdown issue, RT some times make things odd, so i’ll test that kernel tomorrow…

Regards,

It also helps if the module is enabed:

debian@beaglebone:~$ dmesg | grep tps
[    3.241130] tps6521x_pwrbutton tps65217-pwrbutton: DMA mask not set
[    3.248397] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/tps65217-pwrbutton/input/input0
[    3.259856] tps65217 0-0024: TPS65217 ID 0xe version 1.2

Fixed:

Regards,