BPI-R64 boot process

I want to build custom image for BPI-R64, probably with upstream U-Boot (I see that upstream has mt7622_rfb_defconfig (64-bit?)) and definitelly with upstream Linux, however I can’t find good description of how MediaTek MT7622 boots from sd card, so I have several question, mostly about U-Boot, because I cant even load U-Boot now)

  1. Does MT7623N from BPI-R2 have the same boot sequence as MT7622 from BPI-R64?
  2. Whether upstream U-Boot with config mt7622_rfb_defconfig could load upstream kernel for BPI-R64? Is it 32bit or 64bit U-Boot config? What is the difference between u-boot-mtk.bin and u-boot.bin
  3. What is the easiest way to load upstream U-Boot from SD card in 64 bit mode?
  4. What happens when BPI-R64 powers up with SW1 in position 1? According to official BSP It tries to load first stage loader starting from 2048 byte on SD card (in case of official BSP it is some prebuild binary preloader_bpi-r64_forsdcard-2k.img), which will load ATF (also prebuild BPI-R64-atf.img, and it is secret for me what id does), which, in turn, load U-Boot built from u-boot-mt, and this U-Boot loads Kernel. However, alternative way to load is to use modified upstream ATF from https://github.com/frank-w/BPI-R64-ATF repo, and in this case it seems mt7622 load first stage loader from offset 0x80000 or 524288 byte. That’s really strange.
  5. Does upstream kernel works fine with mt7622?


New bootchain uses opensource atf (my repo is not modified,i have only added some documentation and build-script to create and arrange the binaries.

  1. No, it has different offsets,using other binaries

  2. Mainline only supports 64bit uboot.only my repo can build 32bit uboot (for old bootchain).new bootchain uses 64bit uboot packed with part of ATF into a fip image.

  3. Build your u-boot.bin and copy it into cloned version of my atf repo (replacing my u-boot.bin). Then create the fip with my build.sh and flash it to an sdcard (block offset 0x800/2048). My build.sh can create the complete bootchain with gpt. So this is the easiest start (except using my image and replace the parts you want).

    sudo dd of=$target if=./fip_sdmmc.bin bs=512 seek=2048

  4. Prebuilt bpi binary is using 32bit uboot excep a special variant i have on my gdrive

  5. Upstream kernel works,but misses some things like some patches for bluetooth,adjusted thermalzone,better use my kernel repo :slight_smile:

Regards Frank

frank, thank you for fast reply, you are mvp!

You could give my image builder script a try and find out this way how to boot R64.

It boots Mainline U-Boot, if you enable the option. And mainline kernel

It seems that I’ve manage to build bootable Debain image using mainline u-boot (2020.10) & mainline kernel (5.15) and atf from frank’s repo (https://github.com/frank-w/BPI-R64-ATF).

Now I’m faced with problem that MT7531 didn’t work: there is no cairrier on wan interface with cable plugged in. At the same time MT7531 works fine with official image or image built by frank. First I thought that problem with mainline kernel, but it seems that even kernel from frank’s repo https://github.com/frank-w/BPI-R2-4.14/tree/5.10-main has same issue, when I’m building it.

I’m doing following commands to build kernel & install rootfs:

cd path/to/kernel/source

ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make mt7622_bpi-r64_defconfig
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make Image dtbs modules

cp linux/arch/arm64/boot/Image /mnt/boot/
cp linux/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dtb /mnt/boot/

debootstrap --arch arm64 stable /mnt/root http://deb.debian.org/debian/

ARCH=arm64 make INSTALL_MOD_PATH=/mnt/root modules_install

mkdir -p /mnt/root/lib/firmware/mediatek
cp utils/firmware/mediatek/mt7622* /mnt/root/firmware/mediatek/

Maybe I’m doing something wrong and forget some important steps?

Do you find difference in dmesg between my build and yours regarding mt7531?

One point might be my image uses fit instead of Image/dtb,but if system boots it should be no difference.

Have you flashed the right atf (bl2+uboot fip) for boot device?

Have you tried kernel compiled by you in my working image?

How have you configured network? You need to put eth0 up first,then dsa ports (wan,lan0-lan3)

How have you configured network? You need to put eth0 up first,then dsa ports (wan,lan0-lan3)

Indeed, network was just unconfigured, sry to bother.

Now the only issue - is not working internal wifi. There is no interface, no messages from mt7622_wmac module in dmesg output. It was kernel from https://github.com/frank-w/BPI-R2-4.14/tree/5.10-main configured with this config: https://github.com/frank-w/BPI-R2-4.14/blob/5.10-main/arch/arm64/configs/mt7622_bpi-r64_defconfig but with my rootfs.

Does anyone knows what should I check first to understand what was gone wrong?

have you loaded mt7615e module and firmware installed in your rootfs?

Yes, loading mt7615e helps. But why it doesn’t load automatically? I thought that if there is correct node in device tree module should me loaded automatically.

Afaik Devicetree does not load modules automaticly. Maybe next time module is loaded by default. If not you can add it to /etc/modules.conf or /etc/modprobe.d/

dts contains compatible which drivers check on probe, if there is no matching compatible, driver does not initialize/load completely/free itself

1 Like