BPI R3: How I was able to boot OpenBSD 7.5 and failed. :)

The purpose of this Tutorial is to communication how I was able to boot OpenBSD on a BananaPI BPI-R3.

Nice board! Ultimately, I failed, but I got quite far! So, here is a little help for the next poor soul attempting to do so. The board requires a multistage boot with ARM trusted Firmware. Which is not trivial.

And when booting from an SD Card, it requires a certian partition layout.

So what I did was to start of with a working image, and compiled U-Boot, ARM Trusted Firmware from scratch, and set up an OpenBSD partition.

Afterwards, I loaded the EFI loader into memory, and ran it to start the bsd.rd kernel.

BEWARE: I wrote most of this from memory, so there might be some hickups.

  1. CAVEATS There are three major problems with my approach:

    a. I had to use a template image for the SD card from Frank W. I was not able to create my own (setting up the partition table etc). b. One step in building the second stage bootloader bl2.img involved a black box: there is a binary-only tool in the arm-trusted-firmware repository, which adds a header and a 256 Bit signature to the bl2.bin file. c. I was unable to compile a useable .dtb file myself, so I had to borrow one. (Even though I know now how it came to be. :slight_smile: )

  2. PREREQUISITES

1.1 Hardware I used a BananaPI BPI-R3, a PL2303 TTL for UART connection, a 32GByte SD card and an SD Card writer. I compiled everything on a Laptop which has a Ubuntu/OpenBSD dualboot.

1.2 Software I used Ubuntu 22.04 for this, as well as OpenBSD 7.5. On my Linux machine, I installed the following packages:


  sudo apt install opencu
  sudo apt install build-esstential
  sudo apt install dtc
  sudo apt install bison
  sudo apt install ncurses-dev
  sudo apt install gcc-aarch64-linux-gnu
  sudo apt install gcc-aarch64-linux-binutils
  1. DOWNLOADING I downloaded the following:

  wget -c https://raw.githubusercontent.com/frank-w/u-boot/r3-atf/gpt_sdmmc_100m6g.img
  git clone https://github.com/u-boot/u-boot
  git clone https://github.com/mtk-openwrt/arm-trusted-firmware
  wget -c https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.tar.xz
  tar xvfJ linux-6.5.tar.xz

  (
    mkdir Boot
    cd Boot/
    wget -c https://ftp.debian.org/debian/dists/stable/main/installer-arm64/current/images/netboot/netboot.tar.gz
    wget -c https://ftp.openbsd.org/pub/OpenBSD/7.5/arm64/bsd.rd
    wget -c https://ftp.openbsd.org/pub/OpenBSD/7.5/arm64/BOOTAA64.EFI
  )
  1. BUILDING

Before you build you need to unpack the configuration. I took the liberty of adding them to the appendix of this file.

 (
    cd u-boot
    cp ../config-u-boot .config
    make CROSS_COMPILE=aarch64-linux-gnu- V=1 clean
    yes "" | make CROSS_COMPILE=aarch64-linux-gnu- V=1
  )
  cp u-boot/u-boot.bin arm-trusted-firmware
  (
    cd arm-trusted-firmware
    mkdir build
    cp ../config-arm-trusted-firmware build/.config
    make CROSS_COMPILE=aarch64-linux-gnu- V=1 clean
    yes "" | make CROSS_COMPILE=aarch64-linux-gnu- V=1
  )
  cpp -I linux-6.5/include/ -I linux-6.5/arch/arm64/boot/dts/mediatek/ linux-6.5/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | dtc -I dts - -O dtb -o mt7986a-bananapi-bpi-r3.dtb

THE LAST STEP FAILS, btw. The .dtb IS NOT CORRECT. I downloaded a better dtb file from the OpenBSD packages later. (See chapter 6)


  1. COLLECTING THE ARTIFACTS

Now I almost had everything

  mkdir -p Sdcard Boot
  cp gpt_sdmmc_100m6g.img Sdcard/
  cp arm-trusted-firmware/build/mt7986/release/bl2.img Sdcard/
  cp arm-trusted-firmware/build/mt7986/release/fip.bin Sdcard/
  cp u-boot/arch/arm/dts/mt7986a-bpi-r3-sd.dtb Boot/
  cp mt7986a-bananapi-bpi-r3.dtb Boot/
  1. WRITING IT ON THE SDCARD (Danger!!)
  SDCARD="/dev/sdc"
  dd if=Sdcard/gpt_sdmmc_100m6g.img of=$SDCARD bs=1M
  gdisk $SDCARD

(Change the type of partition 6 to A600)

  dd if=Sdcard/bl2.img of=$SDCARD"1" bs=1M
  dd if=Sdcard/fip.bin of=$SDCARD"4" bs=1M


  yes | mkfs.msdos $SDCARD"5"
  yes | mkfs.ext4 $SDCARD"6"
  mount $SDCARD"5" /mnt/
  cp Boot/BOOTAA64.EFI /mnt/
  cp Boot/bsd.rd /mnt/
  cp Boot/mt7986a-bpi-r3-sd.dtb /mnt/
  cp Boot/mt7986a-bananapi-bpi-r3.dtb /mnt/
  cp Boot/
  (
    cat Boot/netboot.tar.gz | ( cd /mnt ; tar xvfz - )
  )
  umount /mnt/

********** BOTH OF THE .dtb FILES ARE WRONG! ******

I used the one from the OpenBSD dtb package.

  1. PREPARING OPENBSD

I rebooted my computer into OpenBSD. There, dmesg told me that my SD Card was device sd4. So I ran disklabel -E /dev/sd4

  add a a
  w
  q

Now I had a 6GB partition.

  newfs /dev/rsd4a
  mount /dev/sd4a /mnt
  wget -O /mnt/bsd.rd https://ftp.openbsd.org/pub/OpenBSD/7.5/arm64/bsd.rd
  umount /mnt

Then I patched the Device Tree Binary with a working one:


  mount.msdos /dev/sd4l /mnt

(I am not sure if it was sd4l or sd4mā€¦ The one with the MSDOS file system!)

  pkg_add dtb
  cp /usr/local/share/dtb/mediatek/mt7986a-bananapi-bpi-r3.dtb /mnt/mt7986a-bananapi-bpi-r3.okay.dtb
  umount /mnt
  1. BOOTING THE INSTALLER

I connected the PL2303 to the BananaPI, (GND Black to GND, TX green to RX, RX white to TX). Put the SD Card in, moved all the DIP switches to the upper position.

On the console, I ran

cu -l /dev/ttyU0 -s 115200

Switched on the BananaPI and waited for the BPI prompt.

  fatload mmc 0:5 0x46000000 /BOOTAA64.EFI
  fatload mmc 0:5 0x47000000 /mt7986a-bananapi-bpi-r3.okay.dtb
  bootefi 0x46000000 0x47000000

Then came the boot prompt.

boot bsd.rd

The last line was garbage, because the booted installer changed the baud rate. So I closed the terminal, and started a new one

cu -l /dev/ttyU0 -s 230400

Pressed enter, and was greeted by the familiar (I)nstall, (U)pgrade, (A)utoinstall or (S)hell?

dettus AT dettus DOT net

-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x

APPENDIX: CONFIGURATION (base64 encoded)

echo "
/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4JqrIbBdABGCgJLNlBI6IyIfgw6SjuZvks2f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waIw/0s+WvTCBYN3Df42y5OW4zvjhjgT3UBaFk+O51AtoIwQ0qE8GuK9v4HBqQKHKXAZZ
gSnR5YPoLeWns+gWTjW99r4LYOSOeCFKR6l+A38wdXzXQN5VoZ/5fQlqxIqJPp53UkD5pxKWEFIN
koYaiRm244UDaejcFitLQ5R8IdLgY4nf9fYvust1710xv8gmtduVwgcRrCyEcLdH3uLQYllE/XMn
HKq2NhlYuLF05g9OHOhG8iiAgPTdFgvBqFVNSxTnHF92Sm/I5B6+qzQ7yZPTwWSndFduBuFQe25A
tj45xAXCesifA3mE39WW7xvQhkhXzMFCCy4XHKTJBLh/gzwDFtQIS/yaRr4gKQVLTPUofdRRBi/E
NrG5SH5OQU1BgtiDHzweSKyohySCnvENsua1uF/CuME3jJNe7KCNaqbanGTKDhysMXwgMiBFlqP7
r8bHEXtbRaKZepG66x3TdyK5damzMgL7xHEXz2Nqp03AKVqM1UxCpDaaRc4iOIb9+EMFRoIqb/db
KrkqVuLaFVah/ZoXPZou/8Ov8J5aLrEmJ1JbHdEiLVCgrHFQPwn4kLVrHghRnrAV1XrTIE46T7t8
qAREviqC+V4sT+2LSYI+DyPrCzXVyj/Ca4i8XH+UhtIbR/7YBDb+8PIMXikqjPJS6/4AAAAAMFAD
tbr0p8gAAesEuw4AAM19u4qxxGf7AgAAAAAEWVo=" | \
base64 -d >config-arm-trusted-firmware.xz

xz -d config-u-boot.xz
xz -d config-arm-trusted-firmware.xz

You can verify that it was decoded correctly:

md5sum config-u-boot config-arm-trusted-firmware
68851815fc3343889558072ca3b1c82d  config-u-boot
b55786845230bba7786fa3dee532896f  config-arm-trusted-firmware
1 Like

I should also mention that the working .dtb file had the following properties:


ls -l mt7986a-bananapi-bpi-r3.okay.dtb 
-rw-r--r-- 1 dettus dettus 18144 Aug 20 11:14 mt7986a-bananapi-bpi-r3.okay.dtb
md5sum mt7986a-bananapi-bpi-r3.okay.dtb
036ede35a1058a16e4777f9983fd2b80  mt7986a-bananapi-bpi-r3.okay.dtb

Which kernel are you using?

I used the default installation Kernel bsd.rd:

https://ftp.openbsd.org/pub/OpenBSD/7.5/arm64/bsd.rd

Did someone port all the necessary mtk drivers in the default bsd kernel?

No. Otherwise, I would haven gotten further.

which problem is with default dtb? notice that r3 requires the dtbo too for sd/emmc and nand/nor to access these devicesā€¦

how far did you got with openbsd? i only see building bootchain till efi boot in uboot and starting the installer (isnā€™t there any tool similar to debootstrap to get an openbsd rootfs)

but i guess there are drivers missing as eric already mention

Regarding the ā€œdefault dtbā€: Apparently, something is missing. It never goes past the bootloadetr. (See here: Bastelempfehlung FTTH + WiFi + Ethernet + OpenBSD? | Seite 3 | BSDForen.de - Die BSD-Community)

Quite frankly, I do not know how to apply the overlays.

However, using the dtb from the OpenBSD packages works. I can look up the build instructions, if you are interested? They basically use clang-cpp to get from the dts in the Linux Kernel to something dtc understands.

Regarding the ā€œmissing driversā€: Yes, OpenBSD is written by enthusiasts with little time. :slight_smile:

in linux we use fit-image wich does the apply of overlays in bootloader automaticly by using specific bootconfig (bootm $kaddr#$bootconf)ā€¦no idea how to do this with efi

your error in forum seems to point to rootfs

cannot open sd0a:/etc/random.seed: No such file or directory

which cannot be loaded from mmc if the sd/emmc overlay is not applied :wink:

for testing you could add the changes from dtso to the dts manually instead of replacing the dts

btw. i wonder about your uboot outputā€¦you write you use u-boot Ā· GitHub as uboot source, but i see in your bootlog parts from my builtin environment (bpi-r3.itb) :wink:

and when openbds does not support switch you have to write own driver to drive the switchā€¦else you can only use the left sfp on r3 as the other ports are clients of the switch and connected to the second mac

I think even the sfp mac needs ported mtk driversā€¦ Unless someone ports the mtk drivers, you wont be using much of the hardware.

of courseā€¦i guess only the syscons are probed without any mtk specific stuff (based on syscon fallback)ā€¦only arm64 basic, maybe clock and pinctrl (or they work because already initialized by uboot and not resettet like in linux-drivers)ā€¦peripherals are maybe not yet supportedā€¦

but missing switch framework (dsa in linux) can be a much larger problemā€¦the full ethernet-stack could be very much work

Yes, the bootlogs are from my first attempt with your bpi-r3 image. It worked, but I really REALLY wanted to know how. :slight_smile:

And there I am still struggling with the first stage bootloaderā€¦ The one which is hidden somewhere in your sd card imageā€¦

I did not record the bootlogs for my approach yet.

Bootrom loads bl2 (img with mtk header with SDMMC_BOOT not the bin) at offset 0x0ā€¦on emmc this part (with emmc header) has to be put into boot0 block

Bootrom loads bl2 (img with mtk header with SDMMC_BOOT not the bin) at offset 0x0

Yes, this is the part that I do not understandā€¦ Given that the partition starts at Sector 34:

; fdisk /dev/rsd4c
Disk: /dev/rsd4c       Usable LBA: 34 to 12805120 [59406336 Sectors]
   #: type                                 [       start:         size ]
------------------------------------------------------------------------
   0: Linux files*                         [          34:         8158 ]
   1: Linux files*                         [        8192:         1024 ]
   2: Linux files*                         [        9216:         4096 ]
   3: Linux files*                         [       13312:         4096 ]
   4: Linux files*                         [       17408:       204800 ]
   5: OpenBSD                              [      222208:     12582913 ]

; disklabel /dev/sd4c
# /dev/sd4c:
type: SCSI
disk: SCSI disk
label: SD/MMC          
duid: 7162704d6bdfbcd2
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 3697
total sectors: 59406336
boundstart: 222208
boundend: 12805121

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:         12582912           222208  4.2BSD   2048 16384 12960 
  c:         59406336                0  unused                    
  i:             8158               34  ext2fs                    
  j:             1024             8192  ext2fs                    
  k:             4096             9216  ext2fs                    
  l:             4096            13312  ext2fs                    
  m:           204800            17408  ext2fs

As promised, here is the full bootlog:

F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 103F 0000
F3: 1001 0000 [0200]
F3: 1001 0000
F6: 300C 0028
F5: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [3000]
T0: 0000 01CE [010F]
Jump to BL

NOTICE:  BL2: v2.10.0	(release):v2.4-rc0-5845-gbacca82a8
NOTICE:  BL2: Built : 09:21:14, Aug 20 2024
NOTICE:  WDT: Cold boot
NOTICE:  WDT: disabled
NOTICE:  CPU: MT7986 (2000MHz)
NOTICE:  EMI: Using DDR4 settings
NOTICE:  EMI: Detected DRAM size: 2048MB
NOTICE:  EMI: complex R/W mem test passed
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.10.0	(release):v2.4-rc0-5845-gbacca82a8
NOTICE:  BL31: Built : 09:21:19, Aug 20 2024
ofnode_read_bool: bootph-all: true
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: true
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: true
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: true
ofnode_read_u32_index: clock-parent: 0x3 (3)
ofnode_read_u32_index: clock-parent: 0x5 (5)
ofnode_read_u32_index: clock-parent: 0x4 (4)
ofnode_read_u32_index: clock-parent: (not found)
ofnode_read_bool: mediatek,force-highspeed: true


U-Boot 2024.10-rc3 (Aug 20 2024 - 09:20:28 +0200)

ofnode_read_u32_array: ranges: ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_bool: bootph-all: false
ofnode_read_bool: bootph-some-ram: false
ofnode_read_bool: bootph-pre-ram: false
ofnode_read_bool: bootph-pre-sram: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-pre-proper: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-vpl: false
ofnode_read_prop: reg: ofnode_read_bool: little-endian: false
ofnode_read_bool: big-endian: false
ofnode_read_bool: native-endian: false
CPU:   MediaTek MT7986
Model: BananaPi BPi-R3
DRAM:  2 GiB
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_bool: gpio-controller: true
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: false
ofnode_read_prop: regulator-name: fixed-3.3V
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: clock-parent: 0x3 (3)
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: clock-parent: 0x5 (5)
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: clock-parent: 0x4 (4)
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: clock-parent: (not found)
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_bool: mediatek,force-highspeed: true
Core:  39 devices, 14 uclasses, devicetree: separate
MMC:   ofnode_read_u32_index: bus-width: 0x4 (4)
ofnode_read_u32_index: max-frequency: 0x3197500 (52000000)
ofnode_read_bool: cap-sd-highspeed: true
ofnode_read_bool: cap-mmc-highspeed: false
ofnode_read_bool: sd-uhs-sdr12: false
ofnode_read_bool: sd-uhs-sdr25: false
ofnode_read_bool: sd-uhs-sdr50: false
ofnode_read_bool: sd-uhs-sdr104: false
ofnode_read_bool: sd-uhs-ddr50: false
ofnode_read_bool: mmc-ddr-1_8v: false
ofnode_read_bool: mmc-ddr-1_2v: false
ofnode_read_bool: mmc-hs200-1_8v: false
ofnode_read_bool: mmc-hs200-1_2v: false
ofnode_read_bool: mmc-hs400-1_8v: false
ofnode_read_bool: mmc-hs400-1_2v: false
ofnode_read_bool: mmc-hs400-enhanced-strobe: false
ofnode_read_bool: no-mmc-hs400: false
ofnode_read_bool: non-removable: false
ofnode_read_bool: cd-inverted: false
ofnode_read_bool: broken-cd: false
ofnode_read_bool: no-1-8-v: false
ofnode_read_u32_index: hs400-ds-delay: (not found)
ofnode_read_u32_index: mediatek,hs200-cmd-int-delay: (not found)
ofnode_read_u32_index: cmd_int_delay: (not found)
ofnode_read_u32_index: write_int_delay: (not found)
ofnode_read_u32_index: mediatek,latch-ck: (not found)
ofnode_read_u32_index: latch-ck: (not found)
ofnode_read_u32_index: r_smpl: 0x1 (1)
ofnode_read_bool: mediatek,hs400-cmd-resp-sel-rising: false
ofnode_read_u32_index: builtin-cd: (not found)
ofnode_read_bool: cd-active-high: false
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_bool: gpio-controller: false
ofnode_read_bool: gpio-controller: true
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>
mmc@11230000: 0
ofnode_read_u32_index: load-environment: (not found)
Loading Environment from MMC... ofnode_read_u32_index: vmmc-supply: 0xe (14)
ofnode_read_bool: gpios: false
ofnode_read_bool: enable-active-high: false
ofnode_read_bool: regulator-boot-on: true
ofnode_read_u32_index: startup-delay-us: (not found)
ofnode_read_u32_index: off-on-delay-us: (not found)
ofnode_read_u32_index: u-boot,off-on-delay-us: (not found)
ofnode_read_u32_index: regulator-min-microvolt: 0x325aa0 (3300000)
ofnode_read_u32_index: regulator-max-microvolt: 0x325aa0 (3300000)
ofnode_read_u32_index: regulator-init-microvolt: (not found)
ofnode_read_u32_index: regulator-min-microamp: (not found)
ofnode_read_u32_index: regulator-max-microamp: (not found)
ofnode_read_bool: regulator-always-on: true
ofnode_read_bool: regulator-boot-on: true
ofnode_read_u32_index: regulator-ramp-delay: (not found)
ofnode_read_bool: regulator-force-boot-off: false
ofnode_find_subnode: regulator-state-mem: <none>
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: vqmmc-supply: 0xe (14)
ofnode_read_prop: u-boot,mmc-env-partition: u-boot-env
Reading from MMC(0)... *** Warning - bad CRC, using default environment

In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:   ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: clock-parent: 0x5 (5)
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: reg: ofnode_read_bool: little-endian: false
ofnode_read_bool: big-endian: false
ofnode_read_bool: native-endian: false
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_u32_index: mediatek,gmac-id: 0x0 (0)
ofnode_find_subnode: mdio: <none>
ofnode_read_prop: phy-mode: 2500base-x
ofnode_find_subnode: fixed-link: fixed-link
ofnode_read_u32_index: speed: 0x9c4 (2500)
ofnode_read_bool: full-duplex: true
ofnode_read_prop: reg: ofnode_read_bool: little-endian: false
ofnode_read_bool: big-endian: false
ofnode_read_bool: native-endian: false
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_bool: pn_swap: false
ofnode_read_bool: mediatek,pnswap: false
ofnode_read_prop: mediatek,switch: mt7531
ofnode_read_bool: mediatek,mcm: false
ofnode_read_prop: assigned-clock-rates: <not found>
ofnode_read_prop: assigned-clock-rates: <not found>

Warning: ethernet@15100000 (eth0) using random MAC address - 7e:54:dc:35:97:fe
eth0: ethernet@15100000
ofnode_find_subnode: bios: <none>
ofnode_find_subnode: system: <none>
ofnode_read_prop: compatible: mediatek,mt7986
ofnode_read_prop: model: BananaPi BPi-R3
ofnode_find_subnode: baseboard: <none>
ofnode_read_prop: compatible: mediatek,mt7986
ofnode_read_prop: model: BananaPi BPi-R3
ofnode_find_subnode: chassis: <none>
ofnode_read_u32_array: ranges: regmap_raw_read_range: regmap size 3942645758 unknown
ofnode_read_prop: bootcmd: <not found>
ofnode_read_u32_index: bootsecure: (not found)
BPI-R3> fatls mmc 0:5 /
   227979   BOOTAA64.EFI
 18362795   bsd.rd
     9600   mt7986a-bpi-r3-sd.dtb
            debian-installer/
       65   version.info
    18144   mt7986a-bananapi-bpi-r3.dtb

5 file(s), 1 dir(s)

BPI-R3> fatload mmc 0:5 0x46000000 /BOOTAA64.EFI
227979 bytes read in 15 ms (14.5 MiB/s)
BPI-R3> fatload mmc 0:5 0x47000000 /mt7986a-bananapi-bpi-r3.dtb
18144 bytes read in 2 ms (8.7 MiB/s)
BPI-R3> bootefi 0x46000000 0x47000000
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
Booting /\BOOTAA64.EFI
disks: sd0*
>> OpenBSD/arm64 BOOTAA64 1.18
boot> boot bsd.rd
cannot open sd0a:/etc/random.seed: No such file or directory
booting sd0a:bsd.rd: 3023768+1214656+12712936+633232 [269381+91+701664+287051]=0x13edb50
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2024 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.5 (RAMDISK) #124: Wed Mar 20 20:05:58 MDT 2024
    [email protected]:/usr/src/sys/arch/arm64/compile/RAMDISK
real mem  = 2141921280 (2042MB)
avail mem = 2035347456 (1941MB)
random: boothowto does not indicate good seed
mainbus0 at root: Bananapi BPI-R3
psci0 at mainbus0: PSCI 1.1, SMCCC 1.4, SYSTEM_SUSPEND
efi0 at mainbus0: UEFI 2.10
efi0: Das U-Boot rev 0x20241000
smbios0 at efi0: SMBIOS 3.7.0
smbios0: vendor U-Boot version "2024.10-rc3" date 10/01/2024
smbios0: mediatek BananaPi BPi-R3
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu0: 512KB 64b/line 16-way L2 cache
cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16
"secmon" at mainbus0 not configured
"wmcpu-reserved" at mainbus0 not configured
"wo-emi" at mainbus0 not configured
"wo-emi" at mainbus0 not configured
"wo-ilm" at mainbus0 not configured
"wo-ilm" at mainbus0 not configured
"wo-data" at mainbus0 not configured
"wo-dlm" at mainbus0 not configured
"wo-dlm" at mainbus0 not configured
"wo-boot" at mainbus0 not configured
"oscillator-40m" at mainbus0 not configured
agtimer0 at mainbus0: 13000 kHz
simplebus0 at mainbus0: "soc"
agintc0 at simplebus0 shift 4:3 nirq 672 nredist 4: "interrupt-controller"
syscon0 at simplebus0: "infracfg"
syscon1 at simplebus0: "wed-pcie"
syscon2 at simplebus0: "topckgen"
syscon3 at simplebus0: "syscon"
syscon4 at simplebus0: "syscon"
syscon5 at simplebus0: "syscon"
syscon6 at simplebus0: "wed"
syscon7 at simplebus0: "wed"
syscon8 at simplebus0: "syscon"
syscon9 at simplebus0: "syscon"
"watchdog" at simplebus0 not configured
"apmixedsys" at simplebus0 not configured
"pinctrl" at simplebus0 not configured
"rng" at simplebus0 not configured
"crypto" at simplebus0 not configured
"pwm" at simplebus0 not configured
com0 at simplebusļæ½: ns16550a, 16 byte fifo
com0: console
com1 at simplebus0: ns16550a, 16 byte fifo
com2 at simplebus0: ns16550a, 16 byte fifo
"i2c" at simplebus0 not configured
"spi" at simplebus0 not configured
"spi" at simplebus0 not configured
"usb" at simplebus0 not configured
"thermal" at simplebus0 not configured
"pcie" at simplebus0 not configured
"t-phy" at simplebus0 not configured
"efuse" at simplebus0 not configured
"t-phy" at simplebus0 not configured
"ethernet" at simplebus0 not configured
"wifi" at simplebus0 not configured
"regulator-12vd" at mainbus0 not configured
pwmfan0 at mainbus0
"gpio-keys" at mainbus0 not configured
"i2c-gpio-0" at mainbus0 not configured
"i2c-gpio-1" at mainbus0 not configured
"leds" at mainbus0 not configured
"regulator-1p8v" at mainbus0 not configured
"regulator-3p3v" at mainbus0 not configured
sfp0 at mainbus0: can't get i2c bus
sfp1 at mainbus0: can't get i2c bus
softraid0 at root
scsibus0 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T
Welcome to the OpenBSD/arm64 7.5 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? s
# mount
/dev/rd0a on / type ffs (local)


And this is how you can compile a single DTB file:

wget  https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.tar.xz
gtar xvfJ linux-6.5.tar.xz
clang-cpp -nostdinc -I linux-6.5/arch/arm64/boot/dts/mediatek/ -I linux-6.5/scripts/dtc/include-prefixes/ -I linux-6.5/include/ -undef -D__DTS__ -x assembler-with-cpp linux-6.5/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | dtc -I dts -O dtb -o mt7986a-bananapi-bpi-r3.okay.dtb -

oh, sorry, bl2 on sdmmc is in partition1, not offset 0x0, as 0x0 is the mbr+gpt (spi was 0x0)

only flash my cards using my build.sh after getting it working for sdmmc :smiley:

but be sure to use the correct fileā€¦

and the mainline dts does not contain the mmc and spi related parts which differs for sdmmc/emmc and spi-nand/nor so you have to add these manually or build the dtso to dtbo and combine it with fdtoverlay

Okay! I found the solution to my first problem: Starting from scratch with a fresh SD card always resulted in a


F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 103F 0000
F3: 1001 0000 [0200]
F3: 1001 0000
F6: 300C 0028
F5: 480C 0000
00: 1005 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 103F 0000
F3: 1001 0000 [0200]
F3: 1001 0000
F6: 300C 0028
01: 102A 0001
02: 1005 0000
BP: 2000 00C0 [0001]
EC: 0000 0000 [3000]
T0: 0000 014F [010F]
System halt!

However, after using gdisk to set the attribute for the Partion 1 to ā€œLegacy Bootableā€ and the name of Partition 4 to ā€œfipā€, everything was booting smoothly.

F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 103F 0000
F3: 1001 0000 [0200]
F3: 1001 0000
F6: 300C 0028
F5: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [3000]
T0: 0000 0209 [010F]
Jump to BL

So, in other words: The first stage Bootloader was looking for the partition with the ā€œbootableā€ flag, and the second stage bootloader was looking for the Partition with the name ā€œfipā€.

Right, you see in my uboot-repo (mtk-atf branch) in build.sh how i create the imageā€¦there are all commands for it including the bootable flag :slight_smile:

You mean this one?

dtc -I dts -O dtb -o mt7986a-bananapi-bpi-r3-sd.dtbo mt7986a-bananapi-bpi-r3-sd.dtso
fdtoverlay -i mt7986a-bananapi-bpi-r3.dtb -o modified-full.dtb  mt7986a-bananapi-bpi-r3-sd.dtbo

(Using a dtso file with fdtoverlay results in a ā€œOverlay ā€˜mt7986a-bananapi-bpi-r3-sd.dtsoā€™ is incomplete (1024 / 1346656301 bytes read)ā€ error.

Fdtoverlay needs dtbo,right,but you should use the original bpi-r3 dtb not your current bsd version