How to disable sleep on USB suspend
Published:  16 November 2016

From Legato version 16.07, the mangOH board goes to sleep when the host suspends the USB connection. This is by design - but can be annoying if you're powering your board from the external power supply or simply don't want the board to go to sleep when your USB host does.

Here's how to disable this feature.

Edit by hand

The basic way to disable the autosleep feature is to manually edit the appropriate startup script - /etc/init.d/enable_autosleep.sh using the vi editor.

  1. Open a console or ssh connection to your mangOH board and log in.
  2. edit /etc/init.d/enable_autosleep.sh using vi

    vi /etc/init.d/enable_autosleep.sh
  3. scroll down through the file (using the up and down arrow keys) until the following is in the middle of the screen:

            # Enable the autosleep feature
    if [ -f /sys/power/autosleep ]
    then
        echo mem > /sys/power/autosleep
        true
    fi
    ;;
  4. move the cursor to the start of the line

    echo mem > /sys/power/autosleep
  5. press the i key (change to Insert mode)

  6. edit the file so that it looks like the following:

            # Enable the autosleep feature
    if [ -f /sys/power/autosleep ]
    then
    # stop autosleep
    #    echo mem > /sys/power/autosleep
        echo "Disable Autosleep"
        echo off > /sys/power/autosleep
        true
    fi
    ;;
  7. Press the ESC key to get out of Insert mode

  8. Press :w to save the file

  9. Press :q to quit vi

Next time you reboot your mangOH board, the auto sleep on USB suspend functionality will be disabled.

Use an automated script

Manually editing this file becomes a bit tedious after a while, so there is a script available that automates the changes to /etc/init.d/enable_autosleep.sh.

To install

  1. download DisableUsbSleep.sh.gz

  2. unpack the script (using gunzip on Linux or 7zip on Windows)

  3. copy the DisableUsbSleep.sh script to your mangOH board (scp on Linux, WinSCP on Windows)

  4. open a console or ssh connection to your mangOH board and log in.

  5. run the script

    ./DisableUsbSleep.sh

    This will modify /etc/init.d/enable_autosleep.sh to disable the auto-sleep feature.

Next time you reboot your mangOH board, the auto sleep on USB suspend functionality will be disabled.

To uninstall

Edit /etc/init.d/enable_autosleep.sh and follow the instructions in the comment lines starting with

## modified by DisableUsbSleep.sh (c)Renfell Engineering P/L 2016