Debian/Ubuntu image creation

no, i have not vendor image

can you describe more detail ?

where to get the bl2 and fip ? what to write in partconf ?

and may be it possible to boot from eMMC but root mount from SATA ? or redirect boot from SATA ?

my pipeline does not compile it yet, so you have to do the steps my pipeline does for emmc

so just clone my uboot-repo, switch to desired branch (2024-01-bpi is newest one)

but writing emmc instead of sdmmc into build.conf after switching to atf-branch

buildimage does not work yet, but you can flash sdmmc-image to emmc, write bl2 to boot0 and emmc-header and fip to emmc-user-partition (mmcblkX without pY) to the same positions as the createimg does above

you set partconf in uboot (need to check which dev via mmc dev or mmc list - first number, here 0 - is emmc on r64)

mmc partconf 0 1 1 0

or

mmc partconf 1 1 1 0

edit: have added r64 emmc bl2/fip to pipeline in 2024-01-bpi

when pipeline is ready you should be able to get the files for flashing

make sure you change /etc/fstab to emmc before booting rootfs else it cannot be mounted.

Seems you need to set root for emmc in uEnv.txt,as i only set partition in checksd (on r64 in bananapi/bpi-r64/linux on bpi-boot partition)

And yes you can copy rootfs to sata drive and need to change fstab again and change root-var in uEnv.txt,but first make emmc working :slight_smile:

@Krantic have you emmc booting till uboot or kernel?

Hello Frank

no, i cant

i did this

# dd if=bpi-r64_emmc_bl2.img of=/dev/mmcblk0boot0
# mkfs -t ext4 /dev/mmcblk0
# mount /dev/mmcblk0 /mnt
copy fs
# cp bpi-r64_emmc_fip.bin /mnt/bpi-r64_emmc_fip.bin 
# cp r64_header_emmc.bin /mnt/r64_header_emmc.bin
# mmc partconf 0 1 1 0
ERROR: unknown command 'partconf'
# mmc extcsd read /dev/mmcblk0boot0 | grep 'PARTITION_CONFIG'
Boot configuration bytes [PARTITION_CONFIG: 0x01]

and i got

*** 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
  U-Boot console

Press UP/DOWN to move, ENTER to select, ESC to quit

Loading Boot0000 ‘mmc 1:4’ failed

Loading from BootNext failed, falling back to BootOrder

Loading Boot0000 ‘mmc 1:4’ failed

EFI boot manager: Cannot load any image

BPI-R64>

not creating filesystem direct on this device…use the sdmmc image to write to mmcblkX and then replace boot-headers (emmc-header and fip), not copy them to filesystem but flashing to right positions see build.sh in mtk-atf branch above

if mmc-partconf is missing i need to add it in uboot first…

mhm, strange SUPPORT_EMMC_BOOT is set in r64 defconfig, so it should be available

ah, you try it from linux…mmc partconf is uboot command…the mmc excsd needs additional mmc-utils to be installed in linux

wonder why uboot is loaded and it looks like efiboot/bootdefault is triggered instead of my builtin environment

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