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

Commit 28d662a

Browse files
committed
Provisional fix for #70 (requires testing). Also adds ability to create
missing MBR and warn users to reinstall NOOBS.
1 parent 492eb5a commit 28d662a

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

output

recovery/initdrivethread.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* Prepare SD card for first use thread
22
*
33
* Initial author: Floris Bos
4-
*
5-
* Initial author: Floris Bos
6-
* Maintained by Raspberry Pi
7-
*
8-
* See LICENSE.txt for license details
9-
*
4+
*
5+
* Initial author: Floris Bos
6+
* Maintained by Raspberry Pi
7+
*
8+
* See LICENSE.txt for license details
9+
*
1010
*/
1111

1212

@@ -183,7 +183,27 @@ bool InitDriveThread::method_resizePartitions()
183183

184184
if (!QFile::exists("/dev/mmcblk0p1"))
185185
{
186-
emit error(tr("SD card does not have a MBR. Cannot resize FAT partition."));
186+
//emit error(tr("SD card does not have a MBR. Cannot resize FAT partition."));
187+
// Warn user that their SD card does not have an MBR and ask
188+
// if they would like us to create one for them
189+
190+
// Create MBR containing single FAT partition
191+
QProcess proc;
192+
proc.setProcessChannelMode(proc.MergedChannels);
193+
proc.start("parted /dev/mmcblk0 --script -- mkpartfs primary fat32 0 -1");
194+
proc.waitForFinished(-1);
195+
if (proc.exitCode() != 0)
196+
{
197+
// Warn user if we failed to create an MBR on their card
198+
emit error(tr("Error creating MBR")+"\n"+proc.readAll());
199+
return false;
200+
}
201+
qDebug() << "Created missing MBR on SD card. parted output:" << proc.readAll();
202+
203+
// Advise user that their SD card has now been formatted
204+
// suitably for installing NOOBS and that they will have to
205+
// re-copy the files before rebooting
206+
emit error(tr("SD card has now been formatted ready for NOOBS installation. Please re-copy the NOOBS files onto the card and reboot"));
187207
return false;
188208
}
189209

@@ -271,7 +291,7 @@ bool InitDriveThread::method_resizePartitions()
271291
QThread::msleep(1500);
272292
}
273293

274-
QProcess::execute("/sbin/dosfslabel /dev/mmcblk0p1 RECOVERY");
294+
//QProcess::execute("/sbin/dosfslabel /dev/mmcblk0p1 RECOVERY");
275295

276296
emit statusUpdate(tr("Mounting FAT partition"));
277297
if (!mountSystemPartition())

0 commit comments

Comments
 (0)