2 2
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
(edited)

I have 3 Orange Pi (Lite, 1Plus and 3), Lite and 1+ I only record armbian at SDCards and it works perfectly. But OPi3, I record all of armbian versions for it and nothing works, the led RED turn on, green led (card reader) blink very fast and RED prevails. But I installed a version of Ubuntu of OPi official site, and it works, but is a very bugged version. I tried use spacebar in the begin, but nothing happens. Someone knows what I have to do? Thank you.

 

Edit 1: I tried to record in 3 SD Cards (Class 10)!

Edited by vinicius

Share this post


Link to post
Share on other sites
On 9/30/2019 at 5:28 PM, martinayotte said:

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

Isn't it that way, that they HAVE, but also have to find bootloader on uSD? I remember there were instructions on forum to clear xx first kB on uSD to prevent booting from SD after installing system on eMMC. Don't remember numbers. But this case one should copy these xx kB to a file, then clear it to switch to eMMC, doing reverse (copy from file to SD) for revert to uSD booting?

Share this post


Link to post
Share on other sites

Martin, do You remember, how "we" divide people?

- those that DO backups,

- those that WILL DO backups :)

 

So it would be better to first save what You want to clear.

 

Regards ;p

Share this post


Link to post
Share on other sites
15 hours ago, laurentppol said:

So it would be better to first save what You want to clear.

There is no need to save those u-boot sectors since the original copy is already located in /usr/lib/linux-u-boot-dev-orangepi3_20.08.0-trunk_arm64/ for example.

Share this post


Link to post
Share on other sites

An for me, Armbian works, "root@orangepi3:/var/motion# uname -a
Linux orangepi3 5.4.43-sunxi64 #20.05.2 SMP Tue Jun 2 17:20:17 CEST 2020 aarch64 GNU/Linux"

Image: "-rw-r--r--  1 laurent laurent 1484783616 05-22 14:58 Armbian_20.02.1_Orangepi3_buster_current_5.4.20.img"

 

Maybe You used later (broken?) image?

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...
2 2