Well the USB stick you use to recover the situation could just have a startup script that renames the bootcode.bin file on the SD card back to it's original name.
For stage 3 I'm using the following script:BespokeTech wrote:Well the USB stick you use to recover the situation could just have a startup script that renames the bootcode.bin file on the SD card back to it's original name.
For a detailed write up on how the boot modes work....
https://www.raspberrypi.org/blog/pi-3-b ... rage-boot/
All of the boot code has to fit into 32kB so I don't think it is possible to do any fancy boot sequence ordering unfortunately.
Thinking about what I proposed, the script that checks for the presence of a USB stick with the "changeboot" file on it only needs to run once during the bootup of the SD image. So in summary the process would be.
1. Lose network connectivity to PI (Booted from SD card)
2. Insert USB stick containing a bootable image and also "changeboot" empty text file.
3. Power cycle the PI, the SD card will boot as normal and run the script to check for the presence of the USB stick. If it finds it then, rename the bootcode.bin file and reboot.
4. PI should then boot from the USB stick, and as I said above you could have a boot up script that renames the original bootcode.bin on the SD card.
Code: Select all
#!/bin/bash
if [ $(find /media/pi/ -name changeboot) ]; then
echo "Boot usb inserted"
mv /boot/bootcode.bin /boot/bootcode.bak
fi
Yes they will stay the same....For stage 4, it doesn't seem like Raspbian automounts the SD card so I'll have to have the script do it. The problem is finding the name of the boot partition. It is currently /dev/mmcblk0p1 as it has been every time I've looked in the past. Will it always be so?
Since this is all only for a rescue scenario, I think just having the script on the USB mount the SD card is simpler.BespokeTech wrote: ↑Mon May 13, 2019 11:40 amWith regards to auto mounting the SD card, have a look at this...
http://www.embeddedpi.com/documentation ... ng-sd-card
Code: Select all
#!/bin/bash
if [ $(find /media/pi/ -name changeboot) ]; then
echo "Boot usb inserted"
sudo mv /boot/bootcode.bin /boot/bootcode.bak
fi
Code: Select all
@reboot sleep 15 && sudo sh /usr/local/bin/usbbootcheck.sh
Code: Select all
#! /bin/bash
mount /dev/mmcblk0p1 /mnt/sdcard
mv /mnt/sdcard/bootcode.bak /mnt/sdcard/bootcode.bin
Code: Select all
@reboot sleep 15 && sudo sh /usr/local/bin/restorebootcode.sh