1 1
ShedDweller

Orange pi 3 - Switch boot between EMMC/SD

Recommended Posts

I have a headless Orange pi 3 and wanted to be able to test a new install.

 

Is it possible to issue a specific reboot command that will switch to boot from one storage to the other storage?

 

I have armbian bionic installed and running on the EMMC.

and

A new bionic build installed on a new SD card.

 

So, if i'm tinkering with the new build on the SD card, can i reboot to the EMMC without removing the SD card, and then similarly reboot from the EMMC into the SD card build??

Share this post


Link to post
Share on other sites
28 minutes ago, ShedDweller said:

So, if i'm tinkering with the new build on the SD card, can i reboot to the EMMC without removing the SD card, and then similarly reboot from the EMMC into the SD card build??

With all Soc from Allwinner, the SDCard has priority over eMMC.

But you can still stop U-Boot on Debug serial port with <spacebar> to get into prompt, and then choose the device you wish to boot from using "setenv devnum <device_number>" followed by "run mmc_boot"

Share this post


Link to post
Share on other sites

It depends on the boot method and kernel you are using but a very simple way would be to have 2 boot.scr / boot.ini / extlinux.conf files (I have no Orange Pi boards and I cant remember the exact boot process for them)

 

The following is not a great way to go about it but I was stuck in a hotel most of the weekend setting up some odroid n2 devices and and needed a quick and dirty way to set them up to tripleboot and I didnt have a serial cable. I needed Armbian, Ubuntu & my own custom distro from the eMMC and to have the option of also booting Android from uSD. I used 3 separate partitions on the eMMC to store my distros but you could easily split between eMMC and uSD instead

 

I first created the 3 boot configs I needed then wrote a simple script to switch them. Thats it! You should be able to adapt it for your Orange Pi 3

 

Boot Config Armbian:

# N2 Image based on @balbes150 build
LABEL Armbian
  LINUX /Image-armbian
  INITRD /uInitrd-armbian
  FDT /odroid-n2-balbes-armbian.dtb
  APPEND root=LABEL=ArmbianFS rootflags=data=writeback rw console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

Boot Config Ubuntu:

# Hardkernel Ubuntu build
LABEL HKUbuntu
  LINUX /Image-hk
  INITRD /uInitrd-hk
  FDT /odroid-n2-hk.dtb
  APPEND root=LABEL=HardKernelFS rootflags=data=writeback rw console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

Boot Config Open-CoreStaq:

# Open-CoreStaq Internal build
LABEL CoreStaq
  LINUX /Image-csq
  INITRD /uInitrd-csq
  FDT /odroid-n2-csq.dtb
  APPEND root=LABEL=CoreStaqFS rootflags=data=writeback rw console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

bootmode.sh toggle script:

#!/bin/bash
BOOTSLOTS=`ls -l /boot/extlinux/*.boot | cut -d"/" -f 4 | sed 's/.boot//g' | nl | cut -c 6-99`

case "$1" in
	a)
		mount -o remount,rw /boot
		cat /boot/extlinux/ArmbianFS.boot > /boot/extlinux/extlinux.conf 
		sync && mount -o remount,ro /boot
		[[ $2 = "y" ]] && reboot
		;;
	h)
		mount -o remount,rw /boot
		cat /boot/extlinux/HardKernelFS.boot > /boot/extlinux/extlinux.conf
		sync && mount -o remount,ro /boot
		[[ $2 = "y" ]] && reboot
		;;
	o)
		mount -o remount,rw /boot
		cat /boot/extlinux/CoreStaqFS.boot > /boot/extlinux/extlinux.conf
		sync && mount -o remount,ro /boot
		[[ $2 = "y" ]] && reboot
		;;
	*)
		echo "bootmode.sh mode=(a|h|o) reboot=(y|n)"
		echo "   mode [a=Armbian, h=HK-Ubuntu, o=Open-CoreStaq]"
		echo "   reboot [y=Yes, anything_else=No]"
		echo "e.g."
		echo "bootmode.sh r y   #Set Armbian boot mode and immediatly reboot"
		echo "bootmode.sh s     #Set Open-CoreStaq boot mode to be active for the next boot"
		echo ""
		;;
esac

Edit: You can probably ignore / remove the "mount -o remount /boot" entries. They are only there because I have a separate fat32 boot partition that I like to keep un-corrupted so I mount ro for normal use

 

Edit2: As martinayotte states, as the OPi3 gives boot priority to the uSD then thats much simpler. Have your primary distro on eMMC and secondary on uSD. Insert uSD to boot uSD, remove uSD to boot eMMC

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
1 1