Boot Ubuntu from emmc/SSD

Hello,

my R2 is booting from the SD-card at the moment. Would be great to use the R2 without the SD-Card. I read that booting with Kernel 5.4 is possible via SD or emmc only. As my Ubuntu 20.4.03 is bigger than 8gb, i can’t use the emmc.

So my idea is, to copy the small BOOT-partition on the emmc, and copy the ROOT-partition on a SSD connected via SATA.

So i started to copy the ROOT-partition on the SSD and connected it to the R2. I still used the SD-card for the BOOT-partition (no emmc for now). There was no “uEnv.txt” in “bananapi/bpi-r2/linux/” so i created one and wrote:

root=/dev/sdb rw rootfstype=ext4 rootwait

in it. When i boot it, i get:

Partition Map for MMC device 1  --   Partition Type: DOS

Part	Start Sector	Num Sectors	UUID		Type
  1	204800    	524288    	54fd6008-01	0c
  2	729088    	32768000  	54fd6008-02	83
mmc1 is available
Interface:  MMC
  Device 1: Vendor: Man 000003 Snr b1569c01 Rev: 1.5 Prod: SC32G�
            Type: Removable Hard Disk
            Capacity: 30436.5 MB = 29.7 GB (62333952 x 512)
Filesystem: FAT16 "BPI-BOOT   "
Boot from SD
reading bananapi/bpi-r2/linux/uEnv.txt
** Unable to read file bananapi/bpi-r2/linux/uEnv.txt **
reading uEnv.txt
** Unable to read file uEnv.txt **
## Error: "uenvcmd" not defined
reading bananapi/bpi-r2/linux/uImage
8250159 bytes read in 1057 ms (7.4 MiB/s)
bootm flag=0, states=70f
## Booting kernel from Legacy Image at 84000000 ...
   Image Name:   Linux Kernel 5.4.0-main
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8250095 Bytes = 7.9 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

why can’t the R2 not read the uEnv.txt? I got the same error message when the file is empty or deleted. Is it necessary to define uenvcmd?

The R2 is booting up usually (fully from SD not SSD).

uboot is running in ram and do not know from which device it was booted, so it needs a way to get the right boot device to read uEnv.txt from

on r2 there was a flag in memory i used for this (idk if i have send it upstream), the other way is try sd first then emmc.

your log says that my script detects SD boot so it will try to load from sdcard. if you remove sdcard it should print emmc

checksd only looks if sdcard is available and guesses boot was from it and use this to load uenv.txt from

ok, now it make sense.

so it needs a way to get the right boot device to read uEnv.txt from

So how can do this? For now i would like to use the SD instead of emmc.

If you have bootchain till uboot on emmc and no sdcard inserted it should work

ok but how should the R2 find the uEnv.txt on the SD when the SD is not inserted?

i’m not using emmc on this point.

I moved the ubuntu-partition to the SSD. The Boot-partition is still on the SD. If this is working, i will try to copy the Boot-partition on the emmc.

you have to put bootheaders, uboot and the boot-partition to emmc and there a uEnv.txt

ok - so there is no way to to use the SD to boot a SATA-device?

is bootheaders and uboot included in the boot-partition? So I “just” need to copy the partition on the emmc?

of course you can boot from sdcard and use ssd for rootfs, but you cannot boot directly from sata. you need either sdcard or emmc to get into uboot

then you can change rootfs passed to linux kernel

just override root and change it to the ssd (/dev/sdxy)

if you want to have uEnv.txt/kernel on ssd too it is a bit more difficult as you need to adjust device and partition and make sure sata is correctly intialized…as your uEnv.txt then is already on sata you need to change uboots builtin environment (= change the file from my repo and recompile/reflash uboot)

“you can boot from sdcard and use ssd for rootfs, but you cannot boot directly from sata. you need either sdcard or emmc to get into uboot”

Ok great, this is what im trying at the moment.

“then you can change rootfs passed to linux kernel” Ok but where i need to change this? Where is the file located that you attached? Is it somewhere on the Boot-Partition? Sorry, i was not able to find it.

Find an image that boots from emmc and then edit somewhere in the line of uEnv.txt:

bootargs=

You put

root=PARTLABEL=root–on-my-sata

Where root–on-my-sata is the name that you have set using parted

make sure you change rootfs in your fstab too

Is there any image you can recommend?

When i understand Frank correct in his first response

"uboot is running in ram and do not know from which device it was booted" 

uEnv.txt will not work.

Is there any pre-compiled images i can use?

I got the Kernel that i use now from Franks-google-drive: https://drive.google.com/drive/folders/1WnmFOaHjXp8oSYinGaL7khKlA4l21Dmc

Should i use a different one?

Sorry for my stupid questions, and thanks for your patience.

Check out this post about fstab:

https://unix.stackexchange.com/a/433260

basicly my debian images support emmc too with some adjustments like changing root in uEnv.txt and in fstab

this is my last image (but you can use buster too)

for kernels you should use a newer one than from my gdrive

they got compiled after each commit to the main-branches (LTS kernels)

will update 5.15 soon, but currently do some work for new bpi-r2 pro, so had not yet time for updating main branches

your log says that my script detects SD boot so it will try to load from sdcard. if you remove sdcard it 
should print emmc

ok i moved the Boot-Partition from SD to MMC, and removed the SD-Card. It is not booting, without the SD, and there is no output on the UART.

Check out this post about fstab

i don’t really understand how “fstab” help me in this case. Should i mount the emmc here so that uEnv.txt will be found by uBoot on bootup?

basicly my debian images support emmc too with some adjustments like changing root in uEnv.txt and in fstab

I have Ubuntu 20.4.03 installed at the moment. I don’t really want to downgrade to an older version, and setup everything else from the beginning.

you have to put bootheaders, uboot and the boot-partition to emmc and there a uEnv.txt

is there any manual how to do this? I found this http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:storage from you Frank. But i’m unsure what i need to install first (preloader?, uboot?) And i’m also not sure if this manual for ubuntu 14.x is still up to date.

it should show at least bootrom, else check your bootswitch if you have one

fstab is only needed for linux (mounting of rootfs if it is not the sdcard - change to emmc)

uboot does not mount :wink: it looks for uEnv.txt on sdcard or emmc (depending of sdcard inserted)

installation on emmc: https://wiki.fw-web.de/doku.php?id=en/bpi-r2/storage#install_os_on_emmc

basicly you need only the steps to fill the boot0 partition with the emmc preloader, then flash my debian-image to emmc userpartition (/dev/mmcblkX), change uenv.txt (for uboot - root passed to linux kernel) and fstab (mount of rootfs)

ok thanks for this info!

i followed your manual: https://wiki.fw-web.de/doku.php?id=en/bpi-r2/storage#install_os_on_emmc and used the “basic debian bullseye image with kernel 5.10.64”.

I did the first 3 steps without any errors. In step 4 i moved the unzipped Image to the sd card and moved it via “dd” to the mmc. I just don’t know what to do here:

unzip -p <XXX.img.zip> | pv | dd of=<device> bs=10M status=noxfer

Where do i get the Zip-File and where should move it to? Or is it not necessary?

I skipped this point for now, and tried to boot the R2 without SD-Card. But uBoot is still not displayed. I also checked the bootswitch. But it the same result when its switched to SD or EMMC. Is there anything i forgot?

this is dd’ing the image to user-partition, if you have the image already uncompressed, you can do

dd if=image | pv | dd of=.....

or if you don’t need status or have not installed pv

dd if=image of=device ...

maybe adding status=progress (newer dd imho have it) instead of noxfer

as i said, you should see at least bootrom (~10 lines of output before any other header is read)…for uboot you have to write the image. if you see bootrom but no further output maybe partition config is wrong or preloader on boot0 is missing

ok, i used your image (linked above) and put it on a sd-card. I changed uEnv.txt and fstab to my ssd with the ROOT-partition on it - and it works! yeah! Thanks for that!

Then i tried to move the image on the emmc (https://bananapi.gitbook.io/bpi-m3/zh/howtoburnlinuximagetoemmc) and removed the sd card. It does not boot anymore. As long as i press the power-button, the leds are on. When i release ti after 15seconds, all leds are off. No message on UART. Boot-switch does not change anything.

i would like to try it again with your manual frank: https://wiki.fw-web.de/doku.php?id=en/bpi-r2/storage#install_os_on_emmc but i’m still stucked at step 4 - unable to find the zip file.

As i said above,you have to flash the image to emmc main partition…if you have uncompressed it before you need no (g)unzip,simply dd if=image of=targetdevice