Debian/Ubuntu image creation

may it be done like this?

dd if=/dev/sdb5 of=/dev/mmcblk0

?

i have installed utils

# history | grep mmc-
  213  apt install mmc-utils

not sure if you can set partconf with mmc-utils, but 0x1 imho is wrong…afair it should be 0x48, but if emmc boots till uboot…mhm, but it does not look like mine…

try booting in uboot from sdcard and run the mmc partconf

please post full output…it looks like emmc was preflashed, but it should be blank on userparttion after you created the filesystem on mmcblk0 directly without partition.

you need at least boot till uboot from emmc and if uboot itself can read sata drive you can boot from it (afair on r64 uboot was able to access sata).

tried to flash from uboot alone:

check order of mmc devices, start and list usb content

BPI-R64> mmc list                                                               
mmc@11230000: 0 (eMMC)                                                          
mmc@11240000: 1
BPI-R64> usb start                                                              
starting USB...                                                                 
Bus usb@1a0c0000: xhci-mtk usb@1a0c0000: hcd: 0x000000001a0c0000, ippc: 0x000000
xhci-mtk usb@1a0c0000: ports disabled mask: u3p-0x0, u2p-0x0                    
xhci-mtk usb@1a0c0000: u2p:2, u3p:1                                             
Register 300010f NbrPorts 3                                                     
Starting the controller                                                         
USB XHCI 0.96                                                                   
scanning bus usb@1a0c0000 for devices... 2 USB Device(s) found                  
       scanning usb for storage devices... 1 Storage Device(s) found            
BPI-R64>
BPI-R64> ls usb 0:1 r64                                                         
            ./                                                                  
            ../                                                                 
      512   r64_header_emmc.bin                                                 
    65597   bpi-r64_emmc_bl2.img                                                
   988948   bpi-r64_emmc_fip.bin                                                
                                                                                
3 file(s), 2 dir(s)

switch to boot0 block and write bl2

BPI-R64> mmc partconf 0 1 1 1
BPI-R64> fatload usb 0:1 $loadaddr r64/bpi-r64_emmc_bl2.img
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
65597 bytes read in 16 ms (3.9 MiB/s)
BPI-R64> printenv loadaddr 
loadaddr=0x44000000
BPI-R64> mmc write ${loadaddr} 0x0 0x400                   

MMC write: dev # 0, block # 0, count 1024 ... 1024 blocks written: OK

switch to userpart and flash first emmc-header

BPI-R64> mmc partconf 0 1 1 0
BPI-R64> fatload usb 0:1 $loadaddr r64/r64_header_emmc.bin 
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)        
512 bytes read in 10 ms (49.8 KiB/s)                                            
BPI-R64> mmc write ${loadaddr} 0x0 0x400                                        
                                                                                
MMC write: dev # 0, block # 0, count 1024 ... 1024 blocks written: OK

load and write fip (uboot)

BPI-R64> fatload usb 0:1 $loadaddr r64/bpi-r64_emmc_fip.bin                     
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)        
988948 bytes read in 92 ms (10.3 MiB/s)                                         
BPI-R64> mmc write ${loadaddr} 0x800 ${filesize}                                
                                                                                
MMC write: dev # 0, block # 2048, count 988948 ... 988948 blocks written: OK    
BPI-R64>

bl2 boots up but seems i need fip-partition (so i have to flash image first)

BPI-R64>                                                                        
F0: 102B 0000                                                                   
F5: 480A 0031                                                                   
F5: 480A 0031                                                                   
F3: 0000 0000                                                                   
V0: 0000 0000 [0001]                                                            
00: 0000 0000                                                                   
BP: 0400 0041 [0000]                                                            
G0: 1190 0000                                                                   
T0: 0000 02E7 [000F]                                                            
Jump to BL                                                                      
                                                                                
NOTICE:  BL2: v2.9(release):44cbe55c6 emmc                                      
NOTICE:  BL2: Built : 09:10:57, Feb  1 2024                                     
NOTICE:  WDT: Cold boot                                                         
NOTICE:  WDT: disabled                                                          
NOTICE:  CPU: MT7622                                                            
ERROR:   Partition 'fip' not found                                              
ERROR:   FIP boot source initialization failed with -2                          
PANIC at PC : 0x0000000000205318

i try to include emmc in r64 createimg…to not need flash sdmmc first and replace header and fip…so i can test the created image directly :slight_smile: pipeline is running…

BPI-R64> mmc list 
mmc@11230000: 0 (eMMC)
mmc@11240000: 1 (SD)
BPI-R64> usb start
starting USB...
Bus usb@1a0c0000: xhci-mtk usb@1a0c0000: hcd: 0x000000001a0c0000, ippc: 0x000000001a0c4700
xhci-mtk usb@1a0c0000: ports disabled mask: u3p-0x0, u2p-0x0
xhci-mtk usb@1a0c0000: u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 0.96
scanning bus usb@1a0c0000 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

you have a usb storage in front-usb-port??

but you can also put the files somewhere else where you can access them from uboot…you can also flash the image from linux to the emmc (/dev/mmcblkX)

lets look how it goes now :slight_smile:

root@bpi-r64:~# cat /proc/partitions
major minor  #blocks  name

 179        0   31166976 mmcblk1
 179        1       2048 mmcblk1p1
 179        2        512 mmcblk1p2
 179        3        512 mmcblk1p3
 179        4     102400 mmcblk1p4
 179        5    6291456 mmcblk1p5
 179        8    7634944 mmcblk0
 179       16       4096 mmcblk0boot0
 179       24       4096 mmcblk0boot1
   8        0    2015232 sda
   8        1     460672 sda1
   8        2    1553408 sda2
root@bpi-r64:~# mount /dev/sda2 /mnt
root@bpi-r64:~# gunzip -c /mnt/bpi-r64_emmc.img.gz | dd bs=1M status=progress conv=notrunc,fsync of=/dev/mmcblk0

i have put it to the usb (sdb6) but no seen the files

scanning bus usb@1a0c0000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
BPI-R64> ls usb 0:1 r64 
BPI-R64> ls usb 0:0 r64 
BPI-R64> ls usb 0:6 r64 
BPI-R64> ls usb 0:5 r64 
BPI-R64> ls usb 0:4 r64 
BPI-R64> ls usb 0:3 r64 
BPI-R64> 

“r64” in my output is a folder on my usb-stick :wink:

just leave it and you should see files

r64-emmc image works :slight_smile:

F0: 102B 0000
F5: 480A 0031
F5: 480A 0031
F3: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0400 0041 [0000]
G0: 1190 0000
T0: 0000 0221 [000F]
Jump to BL

NOTICE:  BL2: v2.9(release):44cbe55c6 emmc
NOTICE:  BL2: Built : 09:10:57, Feb  1 2024
NOTICE:  WDT: [40000000] Software reset (reboot)
NOTICE:  CPU: MT7622
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.9(release):5ea2352da sdmmc
NOTICE:  BL31: Built : 10:22:10, Feb  3 2024


U-Boot 2024.01-bpi (Feb 03 2024 - 10:21:40 +0000)

CPU:   MediaTek MT7622
Model: mt7622-bpi-r64
DRAM:  1 GiB
Core:  60 devices, 23 uclasses, devicetree: separate
MMC:   mmc@11230000: 0, mmc@11240000: 1
Loading Environment from nowhere... OK
In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:   
Warning: ethernet@1b100000 (eth0) using random MAC address - 3a:16:32:21:e4:ff
eth0: ethernet@1b100000
Hit any key to stop autoboot:  0 
BPI-R64>

for others who try too:

  • flash emmc-image from sdcard linux: gunzip -c /mnt/bpi-r64_emmc.img.gz | dd bs=1M status=progress conv=notrunc,fsync of=/dev/mmcblk0
  • boot sdcard-uboot and flash bl2 to boot0 + set boot0 bootable like described here (emmc-header and fip already in the emmc-image so no need to flash again…only for updating uboot fip reflash is needed)

:rofl: i put in to the root

BPI-R64> ls usb 0:0     
            3018/
            System Volume Information/
      434   "5:AB>2K9 4>:C<5=B.txt
    65597   bpi-r64_emmc_bl2.img
   988948   bpi-r64_emmc_fip.bin
      512   r64_header_emmc.bin

4 file(s), 2 dir(s)
BPI-R64> fatload usb 0:0 $loadaddr bpi-r64_emmc_bl2.img    
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
65597 bytes read in 13 ms (4.8 MiB/s)
BPI-R64> 
BPI-R64> printenv loadaddr
loadaddr=0x44000000
BPI-R64> 

and i have the error during boot

  Press UP/DOWN to move, ENTER to select, ESC to quit
fit=bpi-r64.itb
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
5763796 bytes read in 1000 ms (5.5 MiB/s)

not boot, at all (

neither from the flash neither from emm

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

bootrom does not find your bl2…so either partconf is wrong or bl2 is missing

try booting uboot from sdmmc and then do the bl2-steps till the second mmc partconf

BPI-R64> mmc partconf 0 1 1 1
BPI-R64> fatload usb 0:1 $loadaddr r64/bpi-r64_emmc_bl2.img
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
65597 bytes read in 16 ms (3.9 MiB/s)
BPI-R64> printenv loadaddr 
loadaddr=0x44000000
BPI-R64> mmc write ${loadaddr} 0x0 0x400                   

MMC write: dev # 0, block # 0, count 1024 ... 1024 blocks written: OK
BPI-R64> mmc partconf 0 1 1 0

does not booted from SD

have you written bl2 to sdmmc instead of emmc?

i dont know, how to check it ? i writen new SD, not boot

compare beginning of sdcard with unpacked sdmmc image :wink:

something like this (untested):

gunzip r64_sdmmc.img.gz
dd if=r64_sdmmc.img bs=1M count=1 | hexdump -C > img.txt
dd if=/dev/sdb bs=1M count=1 | hexdump -C > card.txt

diff img.txt card.txt

tested emmc flash does not affect sdmmc

F0: 102B 0000
F5: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0400 0041 [0000]
G0: 1190 0000
T0: 0000 01F9 [000F]
Jump to BL

NOTICE:  BL2: v2.9(release):v2.8.0-1343-gf369e3041c32 sdmmc
NOTICE:  BL2: Built : 19:57:27, Jul 19 2023
NOTICE:  WDT: [40000000] Software reset (reboot)
NOTICE:  CPU: MT7622
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.9(release):v2.8.0-1343-gf369e3041c32 sdmmc
NOTICE:  BL31: Built : 19:57:30, Jul 19 2023


U-Boot 2023.07-bpi-r4 (Jul 19 2023 - 19:55:02 +0200)

CPU:   MediaTek MT7622
Model: mt7622-bpi-r64
DRAM:  1 GiB
Core:  60 devices, 23 uclasses, devicetree: separate
MMC:   mmc@11230000: 0, mmc@11240000: 1
Loading Environment from nowhere... OK
In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:   
Warning: ethernet@1b100000 (eth0) using random MAC address - 16:67:ad:04:cb:57
eth0: ethernet@1b100000
Hit any key to stop autoboot:  0 
BPI-R64>

everything is fine, the card was just erased(i dont know why) and the other one that i recorded turned out to have a faulty r64_header_sdmmc.bin

wait till write process is really finished :slight_smile:

Thank you Frank, i`ll wait

Just use the sync command.

Hi all

again nothing works, i done

wget https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2024-01-bpi-2024.01-2024-02-03_1019/bpi-r64_emmc.img.gz

gunzip -c bpi-r64_emmc.img.gz | dd bs=1M status=progress conv=notrunc,fsync of=/dev/mmcblk0

BPI-R64> ls usb 0:0
            System Volume Information/
      512   r64_header_emmc.bin
    65597   bpi-r64_emmc_bl2.img
   988948   bpi-r64_emmc_fip.bin
3 file(s), 1 dir(s)

BPI-R64> mmc partconf 0 1 1 0
BPI-R64> fatload usb 0:0 $loadaddr bpi-r64_emmc_fip.bin    
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
988948 bytes read in 48 ms (19.6 MiB/s)
BPI-R64> mmc write ${loadaddr} 0x800 ${filesize}
MMC write: dev # 1, block # 2048, count 988948 ... 988948 blocks written: OK

didn’t load from emmc

Loading Boot0000 'mmc 0:4' failed
Loading from BootNext failed, falling back to BootOrder
Loading Boot0000 'mmc 0:4' failed
EFI boot manager: Cannot load any image
BPI-R64> 

but SDMMC was erased

fit=bpi-r64.itb
Can't set block device
BPI-R64> 

i think it`s because it writes to device #1

how to change target device?

Where do you write bl2?

mmc dev 0

switches to mmc device 0 (or use 1 if you want the other).

For bl2 you have to select boot0 via

mmc partconf 0 1 1 1

And the switch to userpart (last 1 to 0)

Currently you only overwrite fip which is already part of image on emmc userpart.

What is your full emmc bootlog?

where i need to write bpi-r64_emmc_fip.bin ? what partconf ?

NOTICE:  BL2: v2.9(release):5ea2352da emmc
NOTICE:  BL2: Built : 10:23:29, Feb  3 2024
NOTICE:  WDT: [40000000] Software reset (reboot)
NOTICE:  CPU: MT7622
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.9(release):5ea2352da sdmmc
NOTICE:  BL31: Built : 10:22:10, Feb  3 2024


U-Boot 2024.01-bpi (Feb 03 2024 - 10:21:40 +0000)

CPU:   MediaTek MT7622
Model: mt7622-bpi-r64
DRAM:  1 GiB
Core:  60 devices, 23 uclasses, devicetree: separate
MMC:   mmc@11230000: 0, mmc@11240000: 1
Loading Environment from nowhere... OK
In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:   
Warning: ethernet@1b100000 (eth0) using random MAC address - c2:df:d4:6f:57:79
eth0: ethernet@1b100000
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc1 is current device
Boot from SD
2563de1f-2078-4a2b-ab5d-dc9eaac9622a
success!
No EFI system partition
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables


  *** U-Boot Boot Menu ***

      1. Enter kernel-name to boot from SD/EMMC.
      2. Boot kernel from TFTP.
      3. Boot from SD/EMMC.
      mmc 1:4
      mmc 0:4
      U-Boot console


  Press UP/DOWN to move, ENTER to select, ESC to quit
Loading Boot0001 'mmc 0:4' failed
Loading from BootNext failed, falling back to BootOrder
Loading Boot0000 'mmc 1:4' failed
Loading Boot0001 'mmc 0:4' failed
EFI boot manager: Cannot load any image