diff --git a/README.md b/README.md index e15985f3..aea63b44 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,15 @@ To force Recovery Mode to be entered on boot and to show the NOOBS interface, yo To force Recovery Mode being entered on boot, connect GPIO pin 3 on header P1 to GND (pin 25). If GPIO pin 3 remains unconnected then it will boot through to the installed OS as normal. +##### Modifying the GPIO Trigger +If you would like to use a different GPIO pin, for example if you have a push button or similar mechanism, to trigger the Recovery Mode append the `gpiotriggerenable` as described above and then perform the following steps: +1. Append `gpiochannel=[gpiopin]` to the argument list in the `recovery.cmdline` file which is found in the root NOOBS directory. `[gpiopin]` should be the GPIO pin number you wish to use, for example to use GPIO 15 you would append: `gpiochannel=15` +2. Reboot + +If you would like the GPIO pin to only trigger the Recovery Mode when the GPIO value becomes high instead of low (default) perform the following steps: +1. Append `gpiochannelvalue=[value]` to the argument list in the `recovery.cmdline` file which is found in the root NOOBS directory. `[value]` should be `1` if you want the trigger when the GPIO pin is high and `0` when the pin is low (default). For example to continue our example from above using GPIO 15, if we want to have it trigger when the pin is high you would append: `gpiochannelvalue=1` in addition to the `gpiochannel` argument already added. +2. Reboot + #### How to force Recovery Mode being entered on boot (overrides GPIO or keyboard input) Alternatively, if you are unable to use either the GPIO or keyboard to trigger entering Recovery Mode, you can: diff --git a/buildroot/package/recovery/init b/buildroot/package/recovery/init index 3c4cba0a..002a8e93 100755 --- a/buildroot/package/recovery/init +++ b/buildroot/package/recovery/init @@ -62,6 +62,8 @@ else DEFAULT_KBD= DEFAULT_DISPLAY= DEFAULT_PARTITION= + GPIO_CHANNEL= + GPIO_CHANNEL_VALUE= if grep -q runinstaller /proc/cmdline; then RUN_INSTALLER=-runinstaller @@ -88,9 +90,15 @@ else if [ "${p%%=*}" == "partition" ] ; then DEFAULT_PARTITION="-partition ${p#*=}" fi + if [ "${p%%=*}" == "gpiochannel" ] ; then + GPIO_CHANNEL="-gpiochannel ${p#*=}" + fi + if [ "${p%%=*}" == "gpiochannelvalue" ] ; then + GPIO_CHANNEL_VALUE="-gpiochannelvalue ${p#*=}" + fi done - /usr/bin/recovery $RUN_INSTALLER $GPIO_TRIGGER $KEYBOARD_NO_TRIGGER $FORCE_TRIGGER $DEFAULT_KBD $DEFAULT_LANG $DEFAULT_DISPLAY $DEFAULT_PARTITION -qws 2>/tmp/debug + /usr/bin/recovery $RUN_INSTALLER $GPIO_TRIGGER $KEYBOARD_NO_TRIGGER $FORCE_TRIGGER $DEFAULT_KBD $DEFAULT_LANG $DEFAULT_DISPLAY $DEFAULT_PARTITION $GPIO_CHANNEL $GPIO_CHANNEL_VALUE -qws 2>/tmp/debug fi diff --git a/recovery/main.cpp b/recovery/main.cpp index b42e1803..83ded44b 100644 --- a/recovery/main.cpp +++ b/recovery/main.cpp @@ -125,6 +125,7 @@ int main(int argc, char *argv[]) qDebug() << "Board revision is " << rev; int gpioChannel; + int gpioChannelValue = 0; if (rev == 2 || rev == 3) gpioChannel = 0; @@ -134,7 +135,6 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); RightButtonFilter rbf; LongPressHandler lph; - GpioInput gpio(gpioChannel); bool runinstaller = false; bool gpio_trigger = false; @@ -185,8 +185,22 @@ int main(int argc, char *argv[]) if (argc > i+1) defaultPartition = argv[i+1]; } + // Allow gpio channel to be specified in commandline + else if (strcmp(argv[i], "-gpiochannel") == 0) + { + if (argc > i+1) + gpioChannel = atoi(argv[i+1]); + } + // Allow gpio channel value i.e pull up or pull down to be specified in commandline + else if (strcmp(argv[i], "-gpiochannelvalue") == 0) + { + if (argc > i+1) + gpioChannelValue = atoi(argv[i+1]); + } } + GpioInput gpio(gpioChannel); + // Intercept right mouse clicks sent to the title bar a.installEventFilter(&rbf); @@ -252,7 +266,7 @@ int main(int argc, char *argv[]) // or no OS is installed (/settings/installed_os.json does not exist) bool bailout = !runinstaller && !force_trigger - && !(gpio_trigger && (gpio.value() == 0 )) + && !(gpio_trigger && (gpio.value() == gpioChannelValue)) && hasInstalledOS(drive); if (bailout && keyboard_trigger)