Skip to content

Commit 8737d13

Browse files
maxnetXECDesign
authored andcommitted
Initial support for booting from MSD
- search for drive that contains recovery.rfs to determine NOOBS drive - export $PARTUUIDx environment variable to partition setup scripts - put method_reformatDrive() code back
1 parent 5136f34 commit 8737d13

18 files changed

+425
-112
lines changed

buildroot/.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ BR2_PACKAGE_UTIL_LINUX_BINARIES=y
18731873
# BR2_PACKAGE_UTIL_LINUX_MINIX is not set
18741874
# BR2_PACKAGE_UTIL_LINUX_NSENTER is not set
18751875
# BR2_PACKAGE_UTIL_LINUX_MORE is not set
1876-
# BR2_PACKAGE_UTIL_LINUX_MOUNT is not set
1876+
BR2_PACKAGE_UTIL_LINUX_MOUNT=y
18771877
# BR2_PACKAGE_UTIL_LINUX_MOUNTPOINT is not set
18781878
# BR2_PACKAGE_UTIL_LINUX_NEWGRP is not set
18791879
# BR2_PACKAGE_UTIL_LINUX_NOLOGIN is not set

buildroot/kernelconfig-recovery.armv6

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ CONFIG_HID_SUNPLUS=y
104104
CONFIG_USB=y
105105
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
106106
CONFIG_USB_DWCOTG=y
107+
CONFIG_SCSI=y
108+
CONFIG_BLK_DEV_SD=y
109+
CONFIG_USB_STORAGE=y
107110
CONFIG_MMC=y
108111
CONFIG_MMC_BLOCK_MINORS=32
109112
CONFIG_MMC_BCM2835=y

buildroot/kernelconfig-recovery.armv7

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ CONFIG_HID_SUNPLUS=y
110110
CONFIG_USB=y
111111
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
112112
CONFIG_USB_DWCOTG=y
113+
CONFIG_SCSI=y
114+
CONFIG_BLK_DEV_SD=y
115+
CONFIG_USB_STORAGE=y
113116
CONFIG_MMC=y
114117
CONFIG_MMC_BLOCK_MINORS=32
115118
CONFIG_MMC_BCM2835=y

recovery/bootselectiondialog.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
#include <QDesktopWidget>
2323
#include <QScreen>
2424
#include <QWSServer>
25+
#include <QRegExp>
2526
#include <QDebug>
2627

27-
BootSelectionDialog::BootSelectionDialog(const QString &defaultPartition, QWidget *parent) :
28+
BootSelectionDialog::BootSelectionDialog(const QString &drive, const QString &defaultPartition, QWidget *parent) :
2829
QDialog(parent),
2930
_countdown(11),
3031
ui(new Ui::BootSelectionDialog)
@@ -39,14 +40,14 @@ BootSelectionDialog::BootSelectionDialog(const QString &defaultPartition, QWidge
3940
dir.mkdir("/settings");
4041

4142
if (QProcess::execute("mount -o remount,ro /settings") != 0
42-
&& QProcess::execute("mount -t ext4 -o ro " SETTINGS_PARTITION " /settings") != 0)
43+
&& QProcess::execute("mount -t ext4 -o ro "+partdev(drive, SETTINGS_PARTNR)+" /settings") != 0)
4344
{
4445
QMessageBox::critical(this, tr("Cannot display boot menu"), tr("Error mounting settings partition"));
4546
return;
4647
}
4748

48-
/* Also mount /dev/mmcblk0p1 as it may contain icons we need */
49-
if (QProcess::execute("mount -t vfat -o ro /dev/mmcblk0p1 /mnt") != 0)
49+
/* Also mount recovery partition as it may contain icons we need */
50+
if (QProcess::execute("mount -t vfat -o ro "+partdev(drive, 1)+" /mnt") != 0)
5051
{
5152
/* Not fatal if this fails */
5253
}
@@ -105,12 +106,15 @@ BootSelectionDialog::BootSelectionDialog(const QString &defaultPartition, QWidge
105106
ui->list->installEventFilter(this);
106107

107108
// Select OS booted previously
108-
QByteArray partstr = "/dev/mmcblk0p"+QByteArray::number(partition);
109+
QString partnrStr = QString::number(partition);
110+
QRegExp partnrRx("([0-9]+)$");
109111
for (int i=0; i<ui->list->count(); i++)
110112
{
111113
QVariantMap m = ui->list->item(i)->data(Qt::UserRole).toMap();
112-
if (m.value("partitions").toList().first() == partstr)
114+
QString bootpart = m.value("partitions").toList().first().toString();
115+
if (partnrRx.indexIn(bootpart) != -1 && partnrRx.cap(1) == partnrStr)
113116
{
117+
qDebug() << "Previous OS at" << bootpart;
114118
ui->list->setCurrentRow(i);
115119
break;
116120
}
@@ -153,8 +157,13 @@ void BootSelectionDialog::accept()
153157
QSettings settings("/settings/noobs.conf", QSettings::IniFormat, this);
154158
QVariantMap m = item->data(Qt::UserRole).toMap();
155159
QByteArray partition = m.value("partitions").toList().first().toByteArray();
156-
partition.replace("/dev/mmcblk0p", "");
157-
int partitionNr = partition.toInt();
160+
QRegExp partnrRx("([0-9]+)$");
161+
if (partnrRx.indexIn(partition) == -1)
162+
{
163+
QMessageBox::critical(this, "noobs.conf corrupt", "Not a valid partition: "+partition);
164+
return;
165+
}
166+
int partitionNr = partnrRx.cap(1).toInt();
158167
int oldpartitionNr = settings.value("default_partition_to_boot", 0).toInt();
159168

160169
if (partitionNr != oldpartitionNr)

recovery/bootselectiondialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BootSelectionDialog : public QDialog
2424
Q_OBJECT
2525

2626
public:
27-
explicit BootSelectionDialog(const QString &defaultPartition, QWidget *parent = 0);
27+
explicit BootSelectionDialog(const QString &drive, const QString &defaultPartition, QWidget *parent = 0);
2828
~BootSelectionDialog();
2929
virtual void accept();
3030
void setDisplayMode();

recovery/config.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
* Multiple lists can be specified by space separating the URLs */
2525
#define DEFAULT_REPO_SERVER "http://downloads.raspberrypi.org/os_list_v3.json"
2626

27-
/* Size of recovery FAT partition in MB.
28-
* First partition starts at offset 1 MB (sector 2048)
29-
* If you want the second partition to start at offset 1024 MB, enter 1023 */
27+
/* Size of recovery FAT partition in MB when using reformat drive initialization method. */
3028
#define RESCUE_PARTITION_SIZE 63
3129

32-
/* Files that are currently on the FAT partition are normaaly saved to memory during
30+
/* Files that are currently on the FAT partition are normally saved to memory during
3331
* repartitioning.
3432
* If files they are larger than number of MB, try resizing the FAT partition instead */
3533
#define MAXIMUM_BOOTFILES_SIZE 64
@@ -41,14 +39,12 @@
4139
if that prevents having a 4 MiB gap between the next one */
4240
#define SHRINK_PARTITIONS_TO_MINIMIZE_GAPS
4341

44-
#define SETTINGS_PARTITION "/dev/mmcblk0p5"
42+
#define SETTINGS_PARTNR 5
4543
#define SETTINGS_PARTITION_SIZE (32 * 2048 - PARTITION_GAP)
4644

4745
/* If the image name matches this exactly, mark it as recommended */
4846
#define RECOMMENDED_IMAGE "Raspbian"
4947

50-
#define FAT_PARTITION_OF_IMAGE "/dev/mmcblk0p6"
51-
5248
/* RiscOS magic */
5349
#define RISCOS_OFFSET_KEY "riscos_offset"
5450
#define RISCOS_OFFSET (1760)

0 commit comments

Comments
 (0)