1、链接地址
uboot
ATF
2、工具链
ARM 64位平台需要aarch64工具链,可以在staging_dir/toolchain- aarch64_xxxxx中找到。另外dtc工具来为ATF编译.dts文件,一般在
Ubuntu中的device-tree-compiler包,编译后的u-boot/kernel源代码树中的脚本/dtc。
3、配置 u-boot
make XXXXX_defconfig
4. Compile u-boot
make CROSS_COMPILE=<toolchain-prefix>
工具链位置一般位于
~/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0-musl
下的aarch64-openwrt-linux
~/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0-musl/bin/aarch64-openwrt-linux-
5,编译ATF
make -f Makefile PLAT=<plat> BOOT_DEVICE=<bootdevice> BL33=<path-to-u-boot.bin> <optional-options> all fip
目标文件为bl2.img和fip.bin位于
<atf-src-dir>/build/<plat>/release
参数说明:
- PLAT=
mt7622/mt7981/mt7986/mt7988 - BOOT_DEVICE
- NMBM=
This option is valid only when BOOT_DEVICE= is set to snand or spim-nand.
This option is incompatible with UBI=1
Value Description
0 Disable NMBM (default)
1 Enable NMBM
- UBI=
Enable this option if FIP is located in a volume of UBI.
This option is valid only when BOOT_DEVICE= is set to snand or spim-nand.
This option is incompatible with NMBM=1
Value Description
0 Disable Full-UBI layout (default)
1 Enable Full-UBI layout
- DRAM_USE_DDR4=
This option is valid only for mt7981/mt7986/mt7988.
MT7988: this is used for single DDR4 chip.
Value Description
0 The DRAM chip is DDR3 (default)
1 The DRAM chip is DDR4
- DRAM_USE_COMB=
When this option suppresses DRAM_USE_DDR4.
This option is valid only for mt7988.
Value Description
0 No effect (default)
1 The MT7988 CPU uses KGD DDR die, or the board is using two DDR chips
- DDR4_4BG_MODE=
This option must be used with DRAM_USE_COMB=1.
This option is valid only for mt7988.
Value Description
0 No effect (default)
1 Enable DDR4 32-bit 8GBytes mode
- DDR3_FLYBY=
This option is valid only for mt7622.
Value Description
0 The board uses only one DRAM chip (default)
1 The board uses two dram chips (For BPI-R64)
- BOARD_BGA=
This option is valid only for mt7981.
Value Description
0 The chip package is QFN (MT7981C) (default)
1 The chip package is BGA (MT7981A/MT7981B)
- RAM_BOOT_DEBUGGER_HOOK=
This option is valid only when BOOT_DEVICE= is set to ram.
By using this option, the bl2.bin can be load by OpenOCD for debricking.
Please refer to: https://github.com/mtk-openwrt/openocd-scripts/tree/main/mt7622 16
Value Description
0 Disable debugger hook (default)
1 Enable debugger hook
- DEVICE_HEADER_OFFSET=
This option is valid only when PLAT is mt7622 and BOOT_DEVICE= is set to sdmmc.
This option specify the absolute address of the BL2 in the SD card.
This value must match the real address of the BL2 in the SD card otherwise the device will not boot.
The default value is 0x80000.
- ENABLE_JTAG=
This option is valid only when PLAT is mt7981/mt7988.
By default JTAG will be disabled in BL2.
Value Description
0 Disable JTAG (default)
1 Enable JTAG
- USE_MKIMAGE= and MKIMAGE=
If you don’t want to use the closed-source program bromimage to generate bl2.img, you can use the open-source replacement —— The mkimage from u-boot.
To enable using mkimage, these two parameters must be used together:
USE_MKIMAGE=1 MKIMAGE= <path-to-mkimage>
- OVERRIDE_FIP_BASE= and OVERRIDE_FIP_SIZE=
If both specified, they will override the default FIP base & size provided by each platform.
These options have no effect if UBI=1.
- OVERRIDE_UBI_START_ADDR=
These options is only valid for UBI=1.
If specified, it will override the default UBI partition start address, which is 0x200000.
- OVERRIDE_UBI_END_ADDR=
These options is only valid for UBI=1 and OVERRIDE_UBI_START_ADDR is set.
If specified, it will override the default UBI partition end address, which is 0, meaning the end of NAND.
- 例子
Build for BPI-R64 booting from SPI-NAND:
make -f Makefile PLAT=mt7622 BOOT_DEVICE=snand DDR3_FLYBY=1 all fip
Build for MT7986 booting from SD using DDR4:
make -f Makefile PLAT=mt7986 BOOT_DEVICE=sdmmc DRAM_USE_DDR4=1 all fip