Default boot partition specified in recovery.cmdline never gets used #151
Description
While investigating #150 I found that if you have more than one OS installed, and you haven't yet booted any of the OSes (i.e. the countdown-timer doesn't activate on the OS-boot menu) then if you power-off, and set a partition=<number>
in recovery.cmdline
as instructed to change the default boot partition, then when you boot up the Pi it doesn't select that partition as the default like you'd expect it to.
Did some digging, and eventually got to the bottom of the problem: https://github.com/raspberrypi/noobs/blob/master/recovery/bootselectiondialog.cpp#L94
and https://github.com/raspberrypi/noobs/blob/master/recovery/bootselectiondialog.cpp#L96 and https://github.com/raspberrypi/noobs/blob/master/recovery/mainwindow.cpp#L461
The problem is that as soon as NOOBS has finished installing all OSes, it sets "default_partition_to_boot" to 800 straight away, which means settings.value("default_partition_to_boot", defaultPartition).toInt()
will also always return 800 (if "default_partition_to_boot" hasn't been set to some other value yet by actually booting an OS), and thus the defaultPartition
value never actually gets picked up and used. The defaultPartition
value itself also gets initialised to 800 here https://github.com/raspberrypi/noobs/blob/master/recovery/main.cpp#L92
Also, https://github.com/raspberrypi/noobs/blob/master/recovery/main.cpp#L43 seems to be assuming that the presence of a /dev/mmcblk0p7 partition indicates that we have more than one OS installed (based on the assumption that each OS uses 2 partitions). Of course this isn't strictly true - we might have a single OS using 3 partitions, or we might have 2 OSes each only using a single partition (if they're each booting from an initrd).