Bpi-r64 quick start (boot from eMMC)

hi, i see also the raise errors and unknown partitiontable (where i do not know if it is from sd or emmc)

mmc-part of preloader-output looks same as in your log

[mmc_init_mem_card 3140][SD0] Initialized, eMMC50                               
before host->cur_bus_clk(259740)                                                
[info][msdc_config_clksrc] input clock is 400000kHz                             
[info][msdc_set_startbit 1127] read data start bit at rising edge               
[SD0] SET_CLK(52000kHz): SCLK(50000kHz) MODE(2) DDR(1) DIV(1) DS(0) RS(0)       
host->cur_bus_clk(50000000)                                                     
[mmc_init_card]: finish successfully   

i wonder about this (needed for emmc to work?):

NAND: Recognize SNAND: ID [ef aa 21 ], Device Name [Winbond 1Gb], Page Size [2048]B Spare Size [64]B Total Size [128]MB
[mtk_snand] probe successfully!

[BBT] BMT.v2 is found at 0x3ff

also i see you have a newer build of uboot (not the one from the ubuntu-image)

U-Boot  (Oct 02 2019 - 15:01:05)

and you use a ubuntu 18.4 image i have not found yet (only 16.4 for r64). also in your wiki there is only ubuntu 16.4.

i guess you have changes in uboot/image (atf, bootheaders, …) which are not yet public

tried to fix emmc-boot like it’s done here:

using id instead of fixed “1”, but this leads to uboot-crash (maybe unaligned access)

Net:   mtk_eth                                                                                                                                     
Uip activated                                                                                                                                      
Hit any key to stop autoboot:  0                                                                                                                   
raise: Signal # 8 caught                                                                                                                           
ret2 = 1                                                                                                                                           
raise: Signal # 8 caught                                                                                                                           
ret2 = 1                                                                                                                                           
data abort                                                                                                                                         
pc : [<7ef4921c>]          lr : [<7ef494c4>]                                                                                                       
sp : 7cf297b8  ip : 7ef6f614     fp : 7ef39b6c                                                                                                     
r10: 00000002  r9 : 7cf29f40     r8 : 00000001                                                                                                     
r7 : 00000001  r6 : 7ef6f620     r5 : 7ef6f649  r4 : 7ef7a380                                                                                      
r3 : 00000000  r2 : 7ef6f620     r1 : 7ef6856f  r0 : 00000001                                                                                      
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32                                                                                                       
Resetting CPU ...

r64-uboot-emmc.patch (2,1 KB) for patching my bpi-r64 branch

@ray can you please decode the binary uploaded here: https://drive.google.com/open?id=1rLtG_nwjnfrbO0iXg0ezeB9SipUYk1fl to the crash-location

personal debugger? :slight_smile:

:stuck_out_tongue: if you can say me how to do it by myself :wink: but it seems that linaro objdump does not work like yours

objdump in that case

objdump -d u-boot > u-boot.asm

you’re right…i meant objdump…

arg…it looks like i have missed patching mmcinfo-helper-function itself (only changed forward declaration)

Partition Map for MMC device 0  --   Partition Type: DOS                                                                                           
                                                                                                                                                   
Part    Start Sector    Num Sectors     UUID            Type                                                                                       
  1     204800          524288          e43da9c5-01     0c                                                                                         
  2     729088          14211072        e43da9c5-02     83                                                                                         
mmc0 is available                                                                                                                                  
BPI-R64>
BPI-R64> ls mmc 0:1 bananapi/bpi-r64/linux                                                                                                         
            ./                                                                                                                                     
            ../                                                                                                                                    
 12500539   uimage                                                                                                                                 
     1011   uenv.txt                                                                                                                               
            dtb/                                                                                                                                   
                                                                                                                                                   
2 file(s), 3 dir(s)                                                                                                                                

this is my emmc :wink: (sd removed) :champagne:

and finally can load kernel from emmc and boot it (currently with buildroot initrd) :wink:

way is free to create debian buster-image for emmc

uploaded uboot-binaries to my gdrive

  • u-boot-mtk_r64_emmc_mt7531_gcc8.3.bin
  • u-boot-mtk_r64_emmc_rtl8367_gcc8.3.bin

to reflash ubuntu/debian-image for emmc-usage (maybe after flashing image to emmc)

https://drive.google.com/open?id=1Vg3eoHpx3nlZ9pTCZdDpC2l1pJ4rQh5i

dd if=u-boot-mtk_r64_emmc_rtl8367_gcc8.3.bin of=/dev/mmcblk1 bs=1k seek=768
2 Likes

That works for the normal OpenWrt build. But if the OpenWrt included many third-party modules, the initramfs-kernel.bin may bigger than 20MB+, after load that kernel into flash via TFTP, the kernel decompress failed with error “Uncompressing Kernel Image … LZMA: uncompress or overwrite error 1”. I think it’s the kernel partition is too small to fit the big kernel. But i don’t know how to modify the kernel partition size. Could you please tell me how to?

Have a nice day! Is there a fresh working firmware assembly OpenWrt/LEDE?

Hi all,

I tried to boot from eMMC but failed. Neither using U-Boot Menu nor explicit commands

echo 0 > /sys/block/mmcblk0boot0/force_ro
dd if=preloader_evb7622_64_foremmc.bin of=/dev/mmcblk0boot0

from https://github.com/BPI-SINOVOIP/BPI-R64-BSP/blob/95b2edeed3a54529b0cf8598d52a2badd2069c8a/mt-pack/mtk/bpi-r64/configs/default/linux/preloader_evb7622_64_foremmc.bin

helped. I always get

F0: 102B 0000
F6: 3800 00A0
F3: 4000 0036
F5: 480A 0031
F5: 480A 0031
00: 1005 0000
F6: 3800 00A0
F3: 4000 0036
F5: 480A 0031
F5: 480A 0031
01: 102A 0001
02: 1005 0000
BP: 0000 00C0 [0001]
T0: 0000 0365 [000F] 
System halt!

What is the problem?

I successfully boot from SD. Also, I managed to change root partition in uEnv.txt file to eMMC’ one and load system from eMMC, but not the kernel.

I many times toggled Boot select switch (physical), but not understand how it works. It seems it doesn’t work with my BPI-R64, that is I got boot from SD in either cases and cannot boot anyhow without it.

That means that preloader does not get loaded…only bootrom.

You have executed the 2 lines from system booted by sdcard? Any error-message?

No, no errors. The output:

root@bpi-iot-ros-ai:~# curl -O https://raw.githubusercontent.com/BPI-SINOVOIP/BPI-R64-BSP/95b2edeed3a54529b0cf8598d52a2badd2069c8a/mt-pack/mtk/bpi-r64/configs/default/linux/preloader_evb7622_64_foremmc.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  140k  100  140k    0     0   137k      0  0:00:01  0:00:01 --:--:--  137k

root@bpi-iot-ros-ai:~# md5sum ./preloader_evb7622_64_foremmc.bin 
d8b8a577e2098ef1f98c610f4358ee77  ./preloader_evb7622_64_foremmc.bin
root@bpi-iot-ros-ai:~# echo 0 > /sys/block/mmcblk0boot0/force_ro
root@bpi-iot-ros-ai:~# echo 0 > /sys/block/mmcblk0boot1/force_ro
root@bpi-iot-ros-ai:~# cat /sys/block/mmcblk0boot0/force_ro /sys/block/mmcblk0boot1/force_ro
0
0

root@bpi-iot-ros-ai:~# dd if=preloader_evb7622_64_foremmc.bin of=/dev/mmcblk0boot0
280+0 records in
280+0 records out
143360 bytes (143 kB, 140 KiB) copied, 0.0320713 s, 4.5 MB/s

root@bpi-iot-ros-ai:~# dd if=preloader_evb7622_64_foremmc.bin of=/dev/mmcblk0boot1
280+0 records in
280+0 records out
143360 bytes (143 kB, 140 KiB) copied, 0.0290717 s, 4.9 MB/s

root@bpi-iot-ros-ai:~# dd if=/dev/mmcblk0boot0 of=preloader_evb7622_64_foremmc.bin_2 bs=143360 count=1
1+0 records in
1+0 records out
143360 bytes (143 kB, 140 KiB) copied, 0.00945774 s, 15.2 MB/s

root@bpi-iot-ros-ai:~# diff --brief ./preloader_evb7622_64_foremmc.bin ./preloader_evb7622_64_foremmc.bin_2 
root@bpi-iot-ros-ai:~# echo $?
0

poweroff, remove SD card

F0: 102B 0000
F5: 480A 0031
F5: 480A 0031
F3: 4000 0036
F2: 300C 0000
00: 1005 0000
F5: 480A 0031
F5: 480A 0031     
F3: 4000 0036
F2: 300C 0000 
01: 102A 0001
02: 1005 0000
BP: 0000 00C0 [0001] 
T0: 0000 035F [000F] 
System halt!

tried bootswitch? in 0-position? make sure it snaps into position…

bootswitch selects first boot-device

Tried both, no success. What really should do that switch in position 0 and what in position 1?

mhm, position 0 is booting emmc first

can you look with mmc-tools about your partition-config?

it should be 0x48

binary (copy to your system) https://github.com/frank-w/BPI-R2-4.14/blob/5.4-r64-main/utils/mmc/mmc

root@bpi-r64:~# ./mmc extcsd read /dev/mmcblk1 | grep 'PARTITION_CONFIG'                                                                                       
Boot configuration bytes [PARTITION_CONFIG: 0x00]
root@bpi-r64:~# ./mmc bootpart enable 1 1 /dev/mmcblk1                                                                                                         
root@bpi-r64:~# ./mmc extcsd read /dev/mmcblk1 | grep 'PARTITION_CONFIG'                                                                                       
Boot configuration bytes [PARTITION_CONFIG: 0x48]

Thanks, it works, really it works up to ‘U-Boot SD CARD’

  *** U-Boot SD CARD ***

     1. System Load Linux to SDRAM via TFTP.
     2. System Load Linux Kernel then write to Flash via TFTP.
     3. Boot Linux from SD.
     4. System Load U-Boot then write to Flash via TFTP.
     5. System Load U-Boot then write to Flash via Serial.
     6. System Load ATF then write to Flash via TFTP.
     7. System Load Preloader then write to Flash via TFTP.
     8. System Load ROM header then write to Flash via TFTP.
     9. System Load CTP then write to Flash via TFTP.
     a. System Load CTP then Boot to CTP (via Flash).
     b. System Load flashimage then write to Flash via TFTP.
     c. System Load partition table then write to Flash via TFTP.
     U-Boot console


  Press UP/DOWN to move or Press 1~9,a~b to choose, ENTER to select

Afterwards I used that your magic piece

dd if=u-boot-mtk_r64_emmc_rtl8367_gcc8.3.bin of=/dev/mmcblk0 bs=1k seek=768

change root and uEnv.txt and finally booted from emmc.

Thanks, Franks.

How does it work, u-boot-mtk_r64_emmc_rtl8367_gcc8.3.bin - how to build it/where is config etc? How you have changed that menu to

  *** U-Boot EMMC ***

     1. Reload Bootmenu
     2. Load Kernel from TFTP.
     3. Boot Linux from SD.
     U-Boot console


  Press UP/DOWN to move or Press 1~9,a~b to choose, ENTER to select

These binaries are build from this tree

See commits on how i changed menu.

You can change menu also with uEnv.txt. my version loads this file before display menu.so you need no recompile.

why using rtl version? As far as i see you have v1 board which has mt7531 switch…

If you don’t need ethernet you can use 2020-01 version from same repo different branch.

hi i try this way but not work always stay on ‘Starting kernel …’

which kernel do you use? which uboot, how do you try to load it?

stock ATF loads 32bit-uboot which switches to 64bot-mode after unpacking uImage. so uImage needs to be 32bit (armhf) and kernel needs to be 64bit

upstream uboot is 64bit which needs 64bit atf and needs 64bit uImage (aarch64) with 64bit kernel

also make sure your debug-console is set right (kernel cmdline vs. uart-order)

Thank you for your reply.:grinning:

first, i use Official Bootloader ‘U-Boot Emmc’ choose

–> (2). System Load Linux Kernel then write to Flash via TFTP

by tftp upload self-compile openwrt kernel ‘initramfs-kernel.bin’ version is 4.19

than always stay on ‘Starting kernel …’

and i use uart tools is minicom and ch341 chip 115200

please tell me where i wrong

thx

i have not done anything on r64 with openwrt…i only loaded linux kernel from uboot without using the flashing menuentries in stock uboot…

try loading your file without the flash command

as you see uboot-menu your uart setup is right so far…only kernel cmdline may not be right (console=…), so you don’t see kernel booting. maybe you can check if system is booted if you can ping router over ethernet (openwrts default ip/dhcp-ip)