How to make a bootable SD for BPI-R64 from scratch?

Hi all,

I tried to make a bootable SD from scratch with preloader_bpi-r64_forsdcard-2k.img from https://github.com/BPI-SINOVOIP/BPI-R64-bsp-4.19/tree/master/mt-pack/mtk/bpi-r64/bin but not succeded:

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 037B [000F]
System halt!

The command I used is (to write it after 2Kib from SD’ start):

sudo dd if=../../BPI-R64-bsp-4.19/mt-pack/mtk/bpi-r64/bin/preloader_bpi-r64_forsdcard-2k.img of=/dev/mmcblk0 bs=1k seek=2

As far as I understand the preloader couldn’t start yet. How to fix it?

This is how I tried, full log (without ATF and u-boot):

$ sudo parted -s /dev/mmcblk0 mklabel msdos
$ sudo parted -s /dev/mmcblk0 unit MiB mkpart primary fat32 -- 100MiB 356MiB
$ sudo parted -s /dev/mmcblk0 unit MiB mkpart primary ext2 -- 356MiB 1913MB
$ sudo partprobe /dev/mmcblk0

$ sudo mkfs.fat -F 32 /dev/mmcblk0p1 -n BPI-BOOT
$ sudo mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 /dev/mmcblk0p2 -L BPI-ROOT
$ sudo sync

$ sudo parted -s /dev/mmcblk0 print
Model: SD SB16G (sd/mmc)
Disk /dev/mmcblk0: 15,9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End     Size    Type     File system  Flags
 1      105MB  373MB   268MB   primary  fat32        lba
 2      373MB  1913MB  1539MB  primary  ext2

$ sudo dd if=../../BPI-R64-bsp-4.19/mt-pack/mtk/bpi-r64/bin/preloader_bpi-r64_forsdcard-2k.img of=/dev/mmcblk0 bs=1k seek=2

You need additional bootheaders before preloader

https://wiki.fw-web.de/doku.php?id=en:bpi-r64:storage

Thanks, I didn’t expect that BPI-R2-HEAD* files are required for R64 :slight_smile:

they are not r2-specific (only the name) its a basic bootheader SDBOOT-Header links to BRLYT-Header and BRLYT-Header to preloader. imho preloader loads ATF (on r64 only) and then uboot. i had copied the script lines from official script and got sd/emmc only working with all headers…also sd-preloader is needed for emmc :wink:

yes, you are right, in case of emmc it works without writing bootheaders

good to know…preloader was last i’ve tried, but have not removed the other bootheaders after that to try without them