Boot Ubuntu from emmc/SSD

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

ok so i need to flash the same image two times to the mmc? What should i put in as “targetdevice” for the second “dd”?

During partition-configuration: https://wiki.fw-web.de/doku.php?id=en:bpi-r2:uboot#change_partition-configuration_of_emmc i noticed that the “emmc” commands are not working - so i used “mmc” commands instead - is that also ok? I did the partition-configuration in uBoot - is that correct?

I tried it again, and it’s booting from MMC. But now i get this error during bootup:

[MEM] complex R/W mem test pass
0:dram_rank_size:80000000
[Dram_Buffer] dram size:-2147483648
[Dram_Buffer] structure size: 1725560
[Dram_Buffer] MAX_TEE_DRAM_SIZE: 0
Load u-boot from eMMC...
[PLFM] Init Boot Device: OK(0)

[PART] blksz: 512B
[PART] [0x0000000000000000-0x000000000003FFFF] "PRELOADER" (512 blocks)
[PART] [0x0000000000000000-0x000000000003FFFF] "MBR" (512 blocks)
[PART] [0x0000000000040000-0x00000000000BFFFF] "UBOOT" (1024 blocks)
[PART] [0x00000000000C0000-0x00000000000FFFFF] "CONFIG" (512 blocks)
[PART] [0x0000000000100000-0x000000000013FFFF] "FACTORY" (512 blocks)
[PART] [0x0000000000140000-0x000000000213FFFF] "BOOTIMG" (65536 blocks)
[PART] [0x0000000002140000-0x000000000413FFFF] "RECOVERY" (65536 blocks)
[PART] [0x0000000004140000-0x000000004413FFFF] "ROOTFS" (2097152 blocks)
[PART] [0x0000000044140000-0x000001FFC413FFFF] "USER" (-4194304 blocks)
[platform_vusb_on] PASS
[TOOL] PMIC not dectect usb cable!
[TOOL] <UART> listen  ended, receive size:0!
[TOOL] <UART> wait sync time 150ms->5ms
[TOOL] <UART> receieved data: ()

Device APC domain init setup:

 bootloader load uboot ,the address of uboot is 81E00000
[PART]partition name UBOOT
[PART]partition start block 0x200
[PART]partition size 0x80000
[PART]partition blks 0x400
[PART]partition flags 0x0
[PART]partition name 0x8
[bean] part->startblk(0x200) bdev->blksz(0x200) part->part_id(8) hdr(0xFFB50000)
[BlkDev.c 101 ]partition block size 0x200 ,blks:0xE90000
[BlkDev.c 101 ]partition block erase size 0x200

[PART] load "UBOOT" from 0x0000000000050000 (dev) to 0x81E00000 (mem) [SUCCESS]
[PART] load speed: 10462KB/s, 300000 bytes, 28ms
[BT_SD_PG] device info 0x8590 0x8A00 0xCB01 0x102
0:dram_rank_size:80000000
[PLFM] md_type[0] = 16
[PLFM] md_type[1] = 136

[PLFM] boot reason: 0
[PLFM] boot mode: 0
[PLFM] META COM0: 0
[PLFM] <0xFFB7CC10>: 0x0
[PLFM] boot time: 2012ms
[PLFM] DDR reserve mode: enable = 0, success = 0

[BLDR] jump to 0x81E00000
[BLDR] <0x81E00000>=0xEA0000B8
[BLDR] <0x81E00004>=0xE59FF014
No valid device tree binary found at 81e62d64
initcall sequence 81e39690 failed at call 81e32c39 (err=-1)
### ERROR ### Please RESET the board ###

emmc was in older uboot,in newer it is mmc…it is right,so you’ve booted.

You have r2 right? Afair uboot is same binary so i wonder why it does not find devicetree which is part of the binary.

Have you used the emmc preloader (boot0)? This is different to sdcard

Yes it’s a R2

i used this preloader from the manual: https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/100MB/BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz

anything else i can check?

please try one of the last 2

e.g. this:

https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/100MB/BPI-R2-EMMC-boot0-DDR1600-20191024-0k.img.gz

early preloader does not allow larger uboot binary, i do not remember the error appearing there, but current uboot for r2 contains usb and sata and so it will be larger than on first days when i’ve wrote the manual

Thanks for your help Frank! Now it is working.

one last thing: when i booted from SD, i needed to press the power-on button for more than 10 seconds. Now i just need to press it for 2-3 Seconds. Is there any reason why SD needs so long?

And is it possible to bridge the power on button? So that it will autostart like a raspberry pi? I read somewhere else, that this can cause other issues.

this is a hardware-limitation, that boards needs power for more than 10 seconds to keep on. you can bridge it or add additional power on otg port. but for first you need to make sure that you do not have mtk-pmic-keys active as they look if powerbutton is pressed and then trigger reboot/poweroff