[Tutorial] Build, customize and use MediaTek open-source U-Boot and ATF

Booting from SD is a fallback if booting from SPI-NAND fails. For other boot devices, you must change the bootstrap pins to the corresponding combinations.

Hereā€™s updated procedures for flashing OpenWRT v23.05.0 & later on BPi R3:

Does mt7981b support nand booting the system, and then mounting emmc or SD card as storage space?

Yes, that should work. Since I can see the NAND when booting from eMMC, it should work vice versa.

does anyone know How to configure mt7981, uboot, openwrt, dts, default spi nand to boot into the system, and mount SD card as an external simple storage device? Thank you

Why asking again? This thread is only uboot+atf,no kernel/userspace.

When you want openwrt please ask there or in a openwrtone thread (maybe create one).

Ok, sorry, Iā€™ll try to ask on openwrt one, thank you

Hi @hackpascal, it looks like current atf code misses some files (wdt,mmc,spi,efuse)

Or has build been changed? I see menuconfig support compared to my old tree.

after i got the missing efuse error also on my default atf-branch i had to delete ./build/mt7988/release/ manually (make clean does not clean it up) to be able to compile my old branch again, but i got a strange error

  LD      build/mt7988/release/bl2/bl2.elf
/bin/sh: 1: -g: not found

when compiling the new tree, it also seems like the MAKE_BUILD_STRINGS was dropped from make_helpers/build_macros.mk which i had used to print the bootdevice in bl2/fip

looks like the error above was caused by my comit readding the MAKE_BUILD_STRINGS, to where was this moved?

uploaded my full tree to GitHub - frank-w/u-boot at mtk-atf-2025

finally got the 8GB variant working with the new atf-codeā€¦

NOTICE:  BL2: v2.12.0(release):v2.11.0-1599-gc6dad9faceb5
NOTICE:  BL2: Built : 23:34:17, Apr  7 2025
NOTICE:  WDT: [40000000] Software reset (reboot)
NOTICE:  CPU: MT7988
NOTICE:  EMI: DDR4 4BG mode
NOTICE:  EMI: Using DDR unknown settings
NOTICE:  EMI: Detected DRAM size: 8192 MB
NOTICE:  EMI: complex R/W mem test passed
NOTICE:  LVTS: Enable thermal HW reset
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.12.0(release):v2.11.0-1599-gc6dad9faceb5
NOTICE:  BL31: Built : 23:34:20, Apr  7 2025

only canā€™t get the build-version string working

linux also sees full 8G of ram

root@bpi-r4-8G:~# free
               total        used        free      shared  buff/cache   available
Mem:         8140504      202848     7922844        1592       89244     7937656
Swap:              0           0           0

but noticed that powerdown is not supported by atf-code (was working with old atf)

[   82.829046] reboot: Power down
ERROR:   Power-down unsupported.
PAļæ½
F0: 102B 0000

power down doesnā€™t really supported (was implemented as WFI). Only soft reset is supported.

But my older tree does not print this eror and does not rebootā€¦then atf imgo should hang if it cannot powerdown the pmic.

If I remember correctly, I was also struggling, it has to do with the tags in the git repo. Also pull the tags when cloning.