Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Updated the GPIO Trigger functionality to allow custom GPIO ports #545

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion buildroot/package/recovery/init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
12 changes: 6 additions & 6 deletions recovery/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#define CONFIG_H

/* Version number displayed in the title bar */
#define VERSION_NUMBER "3.0"
#define VERSION_NUMBER "4.0"

/* Color of the background */
// #define BACKGROUND_COLOR Qt::white
#define BACKGROUND_COLOR QColor(0xde, 0xde, 0xde)
#define BACKGROUND_COLOR QColor(0xff, 0x9e, 0x17)

/* Highlight color of installed OS */
#define INSTALLED_OS_BACKGROUND_COLOR QColor(0xef,0xff,0xef)
#define INSTALLED_OS_BACKGROUND_COLOR QColor(0xff,0x9e,0x17)

/* Places background.png resource file in center of screen */
#define CENTER_BACKGROUND_IMAGE
Expand All @@ -18,11 +18,11 @@
#define ENABLE_LANGUAGE_CHOOSER

/* Website launched when launching Arora */
#define HOMEPAGE "http://www.raspberrypi.org/help/"
#define HOMEPAGE "https://www.hrsid.com"

/* Location to download the list of available distributions from
* Multiple lists can be specified by space separating the URLs */
#define DEFAULT_REPO_SERVER "http://downloads.raspberrypi.org/os_list_v3.json"
#define DEFAULT_REPO_SERVER "https://repository.hrs.cloud/os_list_v3.json"

/* Size of recovery FAT partition in MB when using reformat drive initialization method. */
#define RESCUE_PARTITION_SIZE 63
Expand All @@ -43,7 +43,7 @@
#define SETTINGS_PARTITION_SIZE (32 * 2048 - PARTITION_GAP)

/* If the image name matches this exactly, mark it as recommended */
#define RECOMMENDED_IMAGE "Raspbian Full"
#define RECOMMENDED_IMAGE "HRS MSite"

/* RiscOS magic */
#define RISCOS_OFFSET_KEY "riscos_offset"
Expand Down
Binary file added recovery/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed recovery/icons/raspberry_icon.png
Binary file not shown.
22 changes: 18 additions & 4 deletions recovery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -202,8 +216,8 @@ int main(int argc, char *argv[])
settingsdir.mkdir("/settings");

// Set wallpaper and icon, if we have resource files for that
if (QFile::exists(":/icons/raspberry_icon.png"))
a.setWindowIcon(QIcon(":/icons/raspberry_icon.png"));
if (QFile::exists(":/icons/icon.png"))
a.setWindowIcon(QIcon(":/icons/icon.png"));

#ifdef Q_WS_QWS
QWSServer::setBackground(BACKGROUND_COLOR);
Expand Down Expand Up @@ -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)
Expand Down
Binary file modified recovery/wallpaper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sdcontent/defaults/slides/A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.