Boot Ubuntu from emmc/SSD

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

Hello,

I’ve followed-up through the process. I am not new to Linux, rather otherwise, but this is my first day playing with BananaPi R2. My problem is, that despite transferring partitions from SD (which boots fine), updating uboot and changing both uEnv.txt and fstab, the system refuses to boot with SD. With SD, I was able to just switch to EMMC rootFS, so if I’ll boot the system this way, I do use EMMC, I do see both / and /boot mounted…but it it doesn’t work without it.

I used bellow files: bpi-r2_noble_5.15.161-main.img BPI-R2-EMMC-boot0-DDR1600-0k-0905.img BPI-R2-720P-2k.img

The system won’t power on without SD. Any idea what could I be doing wrong?

You need to set partition and rootfs (/dev/…) in uEnv.txt and set /etc/fstab in the target rootfs

As you do not share your changes i cannot tell more…

Do you try to get sd working after booting from emmc or using ssd connected to sata bus?

Sd image should boot,have not touched build process long time,but maybe i missed copying the binary blobs for r2 to newer uboot branch…

root@bpi-r2:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root        6268480 1021720   4910684  18% /
tmpfs            1028136       0   1028136   0% /dev/shm
tmpfs             411256    1912    409344   1% /run
tmpfs               5120       0      5120   0% /run/lock
/dev/mmcblk1p1    261864   17128    244736   7% /boot
tmpfs             205624       8    205616   1% /run/user/0
/dev/mmcblk0p2  26417560 8217576  16839912  33% /mnt
root@bpi-r2:~# cat /etc/fstab 
# <file system>         <dir> <type>    <options>               <dump>  <pass>
/dev/mmcblk1p1          /boot vfat      errors=remount-ro       0       1
/dev/mmcblk1p2          /     ext4      defaults                0       0
root@bpi-r2:~# cat /boot/bananapi/bpi-r2/linux/uEnv.txt 
#
## uEnv.txt
#
bpi=bananapi
board=bpi-r2
chip=mt7623n
service=linux
#
##
#
kernel=uImage
#
##
#
kaddr=0x84000000
rdaddr=0x86000000
#
##
#
#root=/dev/ram
root=/dev/mmcblk1p2 rootfstype=ext4 rootwait
console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200
bootopts=vmalloc=496M debug=7 initcall_debug=0
#
##
#
abootargs=setenv bootargs board=${board} console=${console} root=${root} service=${service} ${bootopts}
#
##
#
ahello=echo Banana Pi ${board} chip: $chip Service: $service
#
##
#
aboot=if fatload $device $partition $rdaddr ${bpi}/berryboot.img; then bootm $kaddr $rdaddr ; else bootm $kaddr; fi
#
##
#
aload_kernel=fatload $device $partition $kaddr ${bpi}/${board}/${service}/${kernel}
#
##
#
uenvcmd=run ahello abootargs aload_kernel aboot
#
## END
root@bpi-r2:~#
root@bpi-r2:~# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"
root@bpi-r2:~# 

Thinking of it, only thing I didn’t do was to use UART to switch the order of partitions. Maybe I misunderstood that it is also needed. I do have UART USB jig somewhere around, so it wouldn’t be a problem. But the host doesn’t stay on, if I’ll try to boot it without SD, I have to keep pressing the power button, but it won’t boot.

Please let me know what information I could provide to be able to have a clue on what I do miss.

SD boots and works. But I can’t boot BananaPi R2 without SD. I can use SD to use EMMC rootfs, but the bootloader only starts the boot process if it is loaded off of SD - which is the state my system is in - booting with help of SD, but using EMMC as a rootfs.

ok, so booting from emmc is the problem…emmc needs the preloader/bl2 in boot0 partition and this partition needs to be set as active (mmc partconf)…the image itself can be simply flashed to userpart (/dev/mmcblkX, not partition in there)

for flashing preloader:

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:storage#preloader

mmc itself (including partconfig):

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:uboot#mmc

verified that binary blobs are in latest uboot branch so can be used by pipline building the full image to gdrive

I have flashed BPI-R2-EMMC-boot0-DDR1600-20191024-0k.img using bellow:

dd if=/root/BPI-R2-EMMC-boot0-DDR1600-20191024-0k.img of=/dev/mmcblk1boot0

That should be fine. As for EMMC selection in uBOOT - I’ll find my UART jig and check what needs to be done. Thanks.

Resolved. This is exactly what I missed. Thanks!

After connecting my RS232 JIG/UART USB dongle to it, it was very easy.

Do you have headers for the kernel which is part of Ubuntu Noble image? I’d like to rebuild zfs modules (I know it is discouraged with 32bit kernel).

you can build kernel on x86 with crosscompiler using my repo (faster than building natively on r2).

but if you cannot/do not want to do so, you can install headers using deb file from this repos releases, but have not tried it yet.

Yep, installing toolchain…had prior multilib setup installed due to prior builds of WINE, so I have to clean it up before trying. As for your repo, Google found it, downloading (quite slow today). BTW, you do have 6.5 kernel branch there - is it functional? Worth to try? Seems better than 5.15. Are mt6625 issues resolved? Aside from ZFS, I will have to build ath9k driver as well.

I have all versions :slight_smile: up to 6.13-rc1

But r2 internal wifi only works till 5.19 afair…6.0 introduced some changes were i could not update driver to…but if you do not need internal wifi on r2 you can also use 6.12 as it is latest/upcoming lts

Well, I would like to use internal Wifi as an AP, and additional Wifi in mPCI-e slot…

I intend to use this unit as a replacement for old Ubqt RouterStation I have on few roofs, so two wireless devices are required. But while my mPCI-E card works, internal wifi doesn’t.

As mentioned before, I used bpi-r2_noble_5.15.161-main.img image. And internal wifi doesn’t work in it:

root@ap-unimatrix:~# lspci
00:00.0 PCI bridge: MEDIATEK Corp. Device 0801 (rev 01)
00:01.0 PCI bridge: MEDIATEK Corp. Device 0801 (rev 01)
01:00.0 Network controller: Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)
02:00.0 IDE interface: ASMedia Technology Inc. ASM1061 Serial ATA Controller (rev 02)
root@ap-unimatrix:~# ifconfig | grep wlan
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
root@ap-unimatrix:~# 

while ath9k module is built-in as I’ve noticed (thus my wifi card works), zfs module isn’t and I am not certain what I do miss with internal wifi, as it is not even detected, and no matching driver is loaded:

root@ap-unimatrix:~# lsmod
Module                  Size  Used by
ath9k                 110592  0
ath9k_common           20480  1 ath9k
ath9k_hw              462848  2 ath9k,ath9k_common
ath                    32768  3 ath9k_hw,ath9k,ath9k_common
mac80211              839680  1 ath9k
spidev                 20480  0
libarc4                16384  1 mac80211
lima                   61440  0
gpu_sched              40960  1 lima
mtk_pmic_keys          16384  0
spi_mt65xx             20480  0
pwm_mediatek           16384  0
cfg80211              778240  4 mac80211,ath9k,ath,ath9k_common
fuse                  139264  1
nfnetlink              20480  2
ip_tables              24576  0
x_tables               36864  1 ip_tables
root@ap-unimatrix:~# 

As for building own kernel, I would like to, but…:

R2 internal wifi needs special activation method

https://wiki.fw-web.de/doku.php?id=en:bpi-r2:wlan#internal

Got it. And that script is also reason why it doesn’t work, when I do have ath9k loaded in mPCI-E, as it binds to wlan0/ap0, which confuses the script. Super. I will play with this to resolve this conflict, lets see if I’ll succeed.

Thanks

Update: I’ve created another (ap1) systemd-network profile, and udev profile for ath9k to move its device to wlan1. I am playing with forcing the system to spawn wlan0 instead of mt6625_0. But other than that, now I do see both internal and pcie wireless. really appreciated.

Still, ath9k module is unable to switch to master mode (AP), due to DSF. What a pain… Looks like I’ll have to both rebuild the kernel to allow unsigned regdomain.db, and then modify the regdomain to not require DSF for certain channels, as DSF doesn’t allow channels I want, although they are legally allowed.

I mapped the external wifi via udev ro another name and had the wifi.sh in autostart (rc.loxal)

es i know rhe driver for internal wifi is crap,but i had no other