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

Commit 11ba0b5

Browse files
committed
Exchange supported_revisions for supported_models parameter
To determine if an OS image is supported by the hardware, check if the formal model name as provided to us by the firmware through device-tree contains a certain string. Example formal model names: Raspberry Pi Model B Rev 2 Raspberry Pi 2 Model B Rev 1.1 It is sufficient to specify part of the formal name in the supported_models parameter of os_list.json. E.g. supported_models: ['Pi Model'] supported_models: ['Pi 2'] supported_models: ['Pi Model','Pi 2'] The supported_models parameter can be omitted if all models are supported. Removes previous supported_revision / supported_hex_revision parameters.
1 parent bd093bd commit 11ba0b5

File tree

2 files changed

+11
-47
lines changed

2 files changed

+11
-47
lines changed

recovery/mainwindow.cpp

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ MainWindow::MainWindow(const QString &defaultDisplay, QSplashScreen *splash, QWi
158158
_qpd = NULL;
159159
QProcess::execute("mount -o ro -t vfat /dev/mmcblk0p1 /mnt");
160160

161+
_model = getFileContents("/proc/device-tree/model");
161162
QString cmdline = getFileContents("/proc/cmdline");
162163
if (cmdline.contains("showall"))
163164
{
@@ -399,60 +400,22 @@ bool MainWindow::isSupportedOs(const QString &name, const QVariantMap &values)
399400
return true;
400401
}
401402

402-
uint board_revision = readBoardRevision();
403-
if (values.find("supported_revisions") != values.end())
403+
if (values.contains("supported_models"))
404404
{
405-
/* Check the supported revisions list */
406-
QStringList revisions = values.value("supported_revisions").toString().remove(" ").split(",");
407-
for (int i=0; i < revisions.size(); i++)
408-
{
409-
bool ok;
410-
uint rev = revisions.at(i).toUInt(&ok, 10);
411-
if (ok)
412-
{
413-
if ((rev & 0xffff) == (board_revision & 0xffff))
414-
{
415-
return true;
416-
}
417-
}
418-
}
419-
return false;
420-
}
421-
else if (values.find("supported_hex_revisions") != values.end())
422-
{
423-
/* Check the supported revisions list */
424-
QStringList revisions = values.value("supported_hex_revisions").toString().remove(" ").split(",");
425-
for (int i=0; i < revisions.size(); i++)
405+
QStringList supportedModels = values.value("supported_models").toStringList();
406+
407+
foreach (QString m, supportedModels)
426408
{
427-
bool ok;
428-
uint rev = revisions.at(i).toUInt(&ok, 16);
429-
if (ok)
409+
/* Check if the full formal model name (e.g. "Raspberry Pi 2 Model B Rev 1.1")
410+
* contains the string we are told to look for (e.g. "Pi 2") */
411+
if (_model.contains(m, Qt::CaseInsensitive))
430412
{
431-
if ((rev & 0xffff) == (board_revision & 0xffff))
432-
{
433-
return true;
434-
}
413+
return true;
435414
}
436415
}
416+
437417
return false;
438418
}
439-
else
440-
{
441-
/* Check the feature_level flag */
442-
if (board_revision < 64) /* overflow otherwise */
443-
{
444-
quint64 featurelevel = values.value("feature_level", 58364).toULongLong();
445-
quint64 mask = (quint64)1 << board_revision;
446-
if ((featurelevel & mask) != mask)
447-
{
448-
return false;
449-
}
450-
}
451-
else
452-
{
453-
return false;
454-
}
455-
}
456419

457420
return true;
458421
}

recovery/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MainWindow : public QMainWindow
5353
QMessageBox *_displayModeBox;
5454
QTimer _networkStatusPollTimer;
5555
QTime _time;
56+
QString _model;
5657

5758
QMap<QString,QVariantMap> listImages();
5859
virtual void changeEvent(QEvent * event);

0 commit comments

Comments
 (0)