[[PageOutline]] = 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) - [https://github.com/Gateworks/linux-imx6/commit/061ef9dff9c45a0a7941d3a3378367499f8fb9b8 commit 061ef9] - Yocto 1.8 OS [https://github.com/Gateworks/meta-gateworks/commit/22f181ed32b32c746b9b3a4640e85da26ba94bf9 commit 22f181] - Android L5 (3.14.28 kernel) - [https://github.com/Gateworks/linux-imx6/commit/7cb45f3718c5e5e1b384608fc5b9070fa753621f commit 7cb45f3] - OpenWrt 16.02 (4.4 kernel) -[https://github.com/Gateworks/openwrt/commit/3d57ef0c66e6a8ffa71ff79deb70929c8c9603ce commit 3d57ef0] - Example - Note the line that states it is using a GSC powerdown - Note that the Reset cause shown in example below shows POR, because the GSC actually cycled the board power. If the Reset cause shows WDOG, then the CPU watchdog kicked in, which is not the desired result. {{{ root@OpenWrt:/# reboot root@OpenWrt:/# [ 273.301224] imx2-wdt 20bc000.wdog: Device shutdown: Expect reboot! [ 273.307825] reboot: Restarting system [ 273.311504] gsc 0-0020: GSC powerdown for 1 seconds U-Boot 2015.04-g040377a (Apr 11 2017 - 10:05:57) CPU: Freescale i.MX6DL rev1.1 at 792MHz CPU: Industrial temperature grade (-40C to 105C) at 57C Reset cause: POR }}} == poweroff / shutdown command == The poweroff command is another system command. Gateworks recommend using an indefinite GSC sleep (documented below) rather than the poweroff / shutdown command directly. However, in order to 'wake up' or turn the board back on, the board pushbutton will need to be pressed. == 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 [wiki:gsc#driver GSC driver] can use use the drivers {{{powerdown}}} sysfs hook to request a 1 second powerdown and therefore perform a safe restart as: 1. Stop any applications or services which may be writing files that you care about 2. {{{sync}}} the filesystems 3. 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') {{{#!bash 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}}}. Please copy and paste the following code and put it into a file on the Gateworks board called reboot.sh using something like the editor vi. Then, make the file executable with the chmod command, something like so: {{{ chmod 777 reboot.sh }}} Then run the command to reboot the board: {{{ ./reboot.sh }}} Reboot Code Below: {{{#!bash #!/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 [wiki:gsc here]