From ead82da4c30d6f7ca369a8b4dc7ddd5416190807 Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 4 Jun 2019 16:52:38 +0100 Subject: [PATCH 1/7] gpio channel and the gpio channel value can now be provided via the command line --- recovery/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/recovery/main.cpp b/recovery/main.cpp index b42e1803..ac9cddf7 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; @@ -185,6 +186,18 @@ 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 = std::stoi(argv[i+1]); + } + // Allow gpio channel value i.e pull up or pull low to be specified in commandline + else if (strcmp(argv[i], "-gpiochannelvalue") == 0) + { + if (argc > i+1) + gpioChannelValue = std::stoi(argv[i+1]); + } } // Intercept right mouse clicks sent to the title bar @@ -252,7 +265,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) From 1d9b6647ff8ab9f8f4d3a96cc0933c2cc9809a3c Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 4 Jun 2019 21:06:58 +0100 Subject: [PATCH 2/7] updated to not use C++ 11 features and corrected comment --- recovery/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recovery/main.cpp b/recovery/main.cpp index ac9cddf7..7f6330ba 100644 --- a/recovery/main.cpp +++ b/recovery/main.cpp @@ -190,13 +190,13 @@ int main(int argc, char *argv[]) else if (strcmp(argv[i], "-gpiochannel") == 0) { if (argc > i+1) - gpioChannel = std::stoi(argv[i+1]); + gpioChannel = atoi(argv[i+1]); } - // Allow gpio channel value i.e pull up or pull low to be specified in commandline + // 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 = std::stoi(argv[i+1]); + gpioChannelValue = atoi(argv[i+1]); } } From 88822e61c7eb310a8fcf009d2f9a608a5a25829f Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 11 Jun 2019 11:04:41 +0100 Subject: [PATCH 3/7] tweaked version number --- recovery/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recovery/config.h b/recovery/config.h index ad6a64e5..22ce19f1 100644 --- a/recovery/config.h +++ b/recovery/config.h @@ -2,7 +2,7 @@ #define CONFIG_H /* Version number displayed in the title bar */ -#define VERSION_NUMBER "3.0" +#define VERSION_NUMBER "3.1" /* Color of the background */ // #define BACKGROUND_COLOR Qt::white From c7751db8f4c4c16e7f77fc6ce335dfdbf0d0dd53 Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 11 Jun 2019 13:02:51 +0100 Subject: [PATCH 4/7] moved the gpiochannel init code until after all the arguments have been parsed --- recovery/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recovery/main.cpp b/recovery/main.cpp index 7f6330ba..83ded44b 100644 --- a/recovery/main.cpp +++ b/recovery/main.cpp @@ -135,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; @@ -200,6 +199,8 @@ int main(int argc, char *argv[]) } } + GpioInput gpio(gpioChannel); + // Intercept right mouse clicks sent to the title bar a.installEventFilter(&rbf); From a06599baf7ff012bb5d8b03f68fc0209dac37477 Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 11 Jun 2019 13:03:34 +0100 Subject: [PATCH 5/7] updated the recovery init code to pass the new arguements out of the recovery.cmdline file to the actual program --- buildroot/package/recovery/init | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 From 6a33a6e072490a76c9a187ba64f51092ffb7c2d6 Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 11 Jun 2019 19:23:23 +0100 Subject: [PATCH 6/7] reverted version number change as part of PR review --- recovery/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recovery/config.h b/recovery/config.h index 22ce19f1..ad6a64e5 100644 --- a/recovery/config.h +++ b/recovery/config.h @@ -2,7 +2,7 @@ #define CONFIG_H /* Version number displayed in the title bar */ -#define VERSION_NUMBER "3.1" +#define VERSION_NUMBER "3.0" /* Color of the background */ // #define BACKGROUND_COLOR Qt::white From c9d26c00ed7e7ae4ec43d99290f1dc05de896587 Mon Sep 17 00:00:00 2001 From: Michael James Date: Tue, 11 Jun 2019 19:40:34 +0100 Subject: [PATCH 7/7] extened the GPIO Trigger documentation to now include the additional customisations available --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) 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: