Debian/Ubuntu image creation

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

Not fipā€¦bl2 see above

now i done

BPI-R64> 
BPI-R64> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
BPI-R64> 
BPI-R64> mmc partconf 0 1 1 0
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... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
BPI-R64> 
BPI-R64> printenv loadaddr               
loadaddr=0x44000000
BPI-R64> fatload usb 0:0 $loadaddr r64_header_emmc.bin
ERROR: reserving fdt memory region failed (addr=0 size=43000000 flags=4)
512 bytes read in 7 ms (71.3 KiB/s)
BPI-R64> mmc write ${loadaddr} 0x0 0x400

MMC write: dev # 0, block # 0, count 1024 ... 1024 blocks written: OK
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 # 0, block # 2048, count 988948 ... 988948 blocks written: OK
BPI-R64>  

and when i wrote FIP, partition on emmc was erased

it seems i have BL2

but i not know how to write FIP

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

[/quote]


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
ERROR:   Partition 'fip' not found
ERROR:   FIP boot source initialization failed with -2
PANIC at PC : 0x0000000000205318

You have to write the image once to userpart to have the gpt defining fip partitionā€¦new atf code searches for fip partitionā€¦

Basicly what you did above

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

But check if mmcblk0 ist the right one,else you write to sdcard

After that bl2 should be able to see fip partition and starts fip from image

i did it many times (

partitions are created but they are empty

image

it maybe i downloaded the wrong image?

i have download it from

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

It is the right image,could you look with fdisk if partition naming is correct? Partitions have no content,thats right as fip has no filesystem and the other have no content.

Bl2 looks for gpt partition named ā€œfipā€ only to get its offset. Then code at this offset is loaded and executedā€¦there are no files which can be seen by filemanager

BPI-R64> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
BPI-R64> mmc part 

Partition Map for MMC device 0  --   Partition Type: EFI

Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000800	0x000017ff	"fip"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	31533f46-7e8a-4b07-b780-1c374dcd1c3d
  2	0x00001800	0x00001bff	"config"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	12e46ea3-df5f-4bc9-b0c8-7368576815d8
  3	0x00001c00	0x00001fff	"rf"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	821bb287-70b5-4461-9720-31dad116fcd8
  4	0x00002000	0x00033fff	"kernel"
	attrs:	0x0000000000000000
	type:	ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
	guid:	7950a19a-fb2d-4732-b394-b101b2280d21
  5	0x00034000	0x00d18000	"root"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	cd9838a8-eaf1-44b1-92f7-cb54b89dd12b
BPI-R64> 

Should be right so farā€¦as iā€™ve wrote above iā€™ve wrote only bl2 to boot0 and the emmc-image to userpart

And bl2 is booted so partconf is also right.

Really strange that it does not work for you :thinking:

Hello Frank, answer me pls

i have done, is it right ?

1. gunzip -c bpi-r64_emmc.img.gz | dd bs=1M status=progress conv=notrunc,fsync of=/dev/mmcblk0
2. BPI-R64> mmc dev 0
3. BPI-R64> mmc partconf 0 1 1 1
4. BPI-R64> fatload usb 0:0 $loadaddr bpi-r64_emmc_bl2.img
5. BPI-R64> mmc write ${loadaddr} 0x0 0x400
6. BPI-R64> mmc partconf 0 1 1 0
7. BPI-R64> fatload usb 0:0 $loadaddr r64_header_emmc.bin 
8. BPI-R64> mmc write ${loadaddr} 0x0 0x400
9. BPI-R64> fatload usb 0:0 $loadaddr bpi-r64_emmc_fip.bin
10. BPI-R64> mmc write ${loadaddr} 0x800 ${filesize}

you wrote

  • 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)

questions:

a) how to reflash fip if not need to flash again ?
b) where is root fs( /usr /home /var etc) on emmc?
c) where is kernel on emmc ?
d) it posible to boot kernel from sata ?
e) where is uEnv.txt on emmc ?
f) what to write to uEnv.txt to mount sata ?
g) where is fstab on emmc ?

Step 4 has to be bl2 not emmc-header. The other files are not needed (onls the partconf). As these parts are already in the emmc image youā€™ve flashed in first step.

For your answers,but we have to boot till uboot first:

a) fip flash like 9+10 above

b) rootfs is mmcblk0p6 but currently empty as my uboot-repo only creates the base imageā€¦you have to unpack a rootfs after flashing this base-imageā€¦you can use rootfs from sdcard not copy from running system,on r64 you need to change fstab to use the right devices for boot and root

c) kernel is similar to rootfs but in p5 not in base image but you can copy it from sdcard

d) r64 sata should work,but have not tried yet now. For automatic boot you have to change some vars in uEnv.txt,but this would be last step

e) it is on boot partition, on r64 in folder bananapi/bpi-r64/linux,but not created by my uboot-ci

f) this is the builtin env:

And this sata access in uboot: https://wiki.fw-web.de/doku.php?id=en:bpi-r64:uboot#sata Best way is maybe adding additional menu entry and setting device and partition to sata before calling newboot,similar to useusb on r3/r4

g) fstab is on rootfs (if filled - not yet) in etcā€¦like on sd

Thank You Frank !

i can to boot from emmc )

but now it`s looking for /dev/mmcbl1

[    2.426227] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    2.434177] Waiting for root device /dev/mmcblk1p5...

where can i fix it ?