Boot process\FreeBSD porting


I have searched a lot through forums, and Internet and was unable to find documentation on how BPI-R2 is booting. This info is needed for FreeBSD U-Boot patches.

It seems like loaders are in binary form, so there is no way to boot custom U-Boot, that will load FreeBSD ubldr.

If there is already some patchwork for U-Boot for BPI-R2 on FreeBSD, then could, please, someone provide it here?

Hi st41ker

Below is the image layout, I think it’s useful for you.

The source code of preloader is unable to released. If the uboot image is starting from 320KB to 1MB, it will be loaded by preloader automatically.

Hi Gary!

Thank you. So, BPI-R2-HEAD1-512b.img, BPI-R2-HEAD440-0k.img, and preloader_iotg7623Np1_emmc.bin must be the same to make it possible to boot motherboard initially? According to BPI-R2-bsp/scripts/ nothing changes there between different image versions.

Yes, the preloader is different for SD and EMMC, you can get them from link :

Thank you again!

Those files have a bit confusing names, unfortunately. Do you have brief description on each one?

The 0k,512b,2k are bytes skipped when writing the image… see (write_ubootimggz())

the 720p-2k is built by of r2-repo ( ) and contains preloader and uboot. It is “burned” also to sdcard (skipping 2048 bytes in output).

@garywang what is different on emmc? The first 2k (partitiontable in mbr + x)?

First 2Kb differ only in couple of bytes containing magic: EMMC_BOOT, or SDMMC_BOOT. Preloader also differs, but U-boot is the same I guess.

To build custom image you will need a lot of time, which is not so developer friendly.

like mentioned here bpi-copy seems to copy the full sd-card to emmc (also partition table,preloader+u-boot) so the preloader must be the same or am i missing anything?

There is no any partition table. Just look at images. Seems like it searches only for this magic bytes, and starts preloader.

On sd-card you have partitiontable (1 fat,1ext),that seems to be copied too.

@garywang is preloader_iotg7623Np1_emmc.bin the right preloader for emmc? is anotger preloader in the first 2k bytes needed?

The latest preloader for EMMC is

Please run command bpi-bootsel BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz /dev/mmcblk1boot0. Pleasee note that this preloader is programmed to /dev/mmcblk1boot0 partition.

And the /dev/mmcblk1(emmc user area) is to store ubuntu image which is the same as SD card.