Version 1 (modified by 7 years ago) ( diff ) | ,
---|
The Reboot Command - History
The reboot
command in Linux is a 'soft' reboot which means that the processor is restarted but not actually powered down and powered back on.
Invariably there are situations which sometimes can cause a typical 'soft restart' via the Linux reboot
command to hang or not properly restart. There are a variety of reasons for this occurring including:
- Peripherals left in an unexpected state which don't have a reset line to them
- Capacitive load issues where certain peripheral combinations can cause the primary power supply to drain slowly resulting in need for a minimum 'power off' time to clear
- SoC errata
Because of these situations with a soft reboot, Gateworks has provided reliable ways to reboot the single board computer.
Reboot Command
In order to have a high reliability Gateworks has designed most of its products with a GSC and a on-board primary power supply which the GSC has the ability to disable. This design provides the following capabilities:
- Capability of powering the board off, and on again at a specific time (GSC Sleep mode)
- Providing a sane alternative to soft reset which power-cycles the board (with a user specified 'off' time)
Our latest BSP's have been updated to so that the reboot command will perform a 1 second GSC sleep essentially creating a 'hard' or 'machine' restart:
- Yocto 1.8
- Kernel (flsc-3.14 kernel) - commit 061ef9
- Yocto 1.8 OS commit 22f181
- Android L5 (3.14.28 kernel) - commit 7cb45f3
- OpenWrt 16.02 (4.4 kernel) -commit 3d57ef0
Manual Reboot via GSC Sleep
Older BSP's with the GSC driver (OpenWrt 14.08, Yocto 1.7, Android 4.4.3 (KitKat)) that have an earlier version of the GSC driver can use use the drivers powerdown
sysfs hook to request a 1 second powerdown and therefore perform a safe restart as:
- Stop any applications or services which may be writing files that you care about
sync
the filesystems- Write the number of seconds to power the board down for to the gsc powerdown sysfs hook (recommend 2 seconds as this garuntees '1 to 2 seconds')
sync && echo 2 > /sys/bus/i2c/devices/i2c-0/0-0020/powerdown
- Note : If performing this reset without a coin cell battery, a maximum of 4 seconds should be used for resetting the board. Anything longer may put the board to 'sleep' and not allow it to wake up without pressing the pushbutton or unplugging and plugging in the main power supply.
Older Manual Method
If for some reason you are using a BSP that does not have the GSC kernel drivers you can do this manually with i2cget
/i2cset
:
#!/bin/sh # # usage: gsc_sleep [seconds] # # default 2 second sleep ensures between 1 and 2 seconds pass before powerup SECS=${1:-2} # syncs the filesystem echo "Syncing filesystems" sync # perform i2c transactions in loop to retry on i2c timeouts echo "Powering down for $SECS seconds" while [ 1 ]; do # set R6-R9 with 32bit number of seconds to wake i2cset -f -y 0 0x20 6 $((SECS % 256)) || continue SECS=$((SECS >> 8)) i2cset -f -y 0 0x20 7 $((SECS % 256)) || continue SECS=$((SECS >> 8)) i2cset -f -y 0 0x20 8 $((SECS % 256)) || continue SECS=$((SECS >> 8)) i2cset -f -y 0 0x20 9 $((SECS % 256)) || continue # latch sleep time - taking care to not disturb other bits R1=$(i2cget -f -y 0 0x20 1) || continue R1=$((R1 | 0x04)) # set R1.2 LATCH_SLEEP i2cset -f -y 0 0x20 1 $R1 || continue # set R1.0 SLEEP_ENABLE and R1.1 ACTIVATE_SLEEP - taking care not to disturb other bits R1=$(i2cget -f -y 0 0x20 1) || continue R1=$((R1 | 0x03)) # set R1.0 and R1.1 i2cset -f -y 0 0x20 1 $R1 || continue done
See the complete GSC reference here