MT7688 使用 u-boot-2021.01
mt7688 官方的 u-boot 太老太旧,主线 u-boot 似乎已经支持 mt7688 了。
见:https://github.com/u-boot/u-boot/commit/b02f76a83541fe9fe3a2918039b26fc133699c17
下载 u-boot-2021.01 https://sources.openwrt.org/u-boot-2021.01.tar.bz2
编译
解压:
tar xf u-boot-2021.01.tar.bz2
cd u-boot-2021.01
编译:
make linkit-smart-7688_defconfig
make ARCH=mips CROSS_COMPILE=/home/lql/work/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/bin/mipsel-openwrt-linux- -j5
问题1.哪个是可以烧到spi nor flash 上的文件?
经过测试, u-boot-with-spl.bin 是可以烧到spi nor flash 上的文件
问题2.如何修改 debug 串口?
-
dts 需要修改
-
xx_defconfig 需要修改
CONFIG_SPECIFY_CONSOLE_INDEX=y CONFIG_CONS_INDEX=1 // 1 表示 uart0
注意:新版 u-boot 串口波特率默认是 115200
问题3.reset 命令卡死?
可能原因:32M flash 有 4字节地址模式和3字节地址模式, 复位时如果没有从 4B 模式切回 3B 模式,就会出问题。
解决办法:CONFIG_SPI_FLASH_BAR=y 强制使用 3B 模式。
问题4.没有默认启动命令?
u-boot-2021.01 里面 mt7688 的默认env 里没有定义 bootcmd ,需要手动添加。
//board/seeed/linkit-smart-7688/Kconfig
if BOARD_LINKIT_SMART_7688
config SYS_BOARD
default "linkit-smart-7688"
config SYS_VENDOR
default "seeed"
config SYS_CONFIG_NAME
default "linkit-smart-7688" -------------------------------------------------------o
|
endif |
|
--------------------------------------------------------------------------------------------- |
|
include/config.h 这个是自动生成的 |
/* Automatically generated - do not edit */ |
#define CONFIG_BOARDDIR board/seeed/linkit-smart-7688 |
#include <config_uncmd_spl.h> |
#include <configs/linkit-smart-7688.h> <----------------------------------------o
#include <asm/config.h>
#include <linux/kconfig.h>
#include <config_fallbacks.h>
-----------------------------------------------------------------------------------------
#include <common.h> // 里面 #include <config.h>
#include <bootstage.h>
#include <command.h>
#include <env.h>
#include <env_internal.h>
#include <log.h>
#include <sort.h>
#include <linux/stddef.h>
#include <search.h>
#include <errno.h>
#include <malloc.h>
#include <u-boot/crc.h>
DECLARE_GLOBAL_DATA_PTR;
/************************************************************************
* Default settings to be used when no valid environment is found
*/
#include <env_default.h> // Z:\opt\u-boot-2017.11.git\include\env_default.h
env_set_default // Z:\opt\u-boot-2021.01\env\common.c
核心是添加 CONFIG_EXTRA_ENV_SETTINGS
问题5. OpenWrt 下编译u-boot 的各种问题
Q1: Build error: undefined reference to `pthread_once’
解决办法:修改 u-boot Makefile 加上 -pthread
参考:https://forum.openwrt.org/t/undefined-reference-to-pthread-once/65789/3
Q2:FATAL ERROR: Unrecognized check name “avoid_unnecessary_addr_size”
解决办法:修改 u-boot scripts/Makefile.lib , 用试错法兼容旧 dtc
解决 openwrt 中编译 u-boot 报错 FATAL ERROR: Unrecognized check name "avoid_unnecessary_addr_size"
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index dfb6722..a7eda10 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -175,6 +175,11 @@ ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
# Usage: $(call ld-ifversion, -ge, 22252, y)
ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
+# dtc-option
+# Usage: DTC_FLAGS += $(call dtc-option,-Wno-unit_address_vs_reg)
+dtc-option = $(call try-run,\
+ echo '/dts-v1/; / {};' | $(DTC) $(1),$(1),$(2))
+
######
###
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 56e9d54..1697bc0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -272,14 +272,16 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
# Disable noisy checks by default
ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
DTC_FLAGS += -Wno-unit_address_vs_reg \
- -Wno-unit_address_format \
- -Wno-avoid_unnecessary_addr_size \
- -Wno-alias_paths \
- -Wno-graph_child_address \
- -Wno-graph_port \
- -Wno-unique_unit_address \
- -Wno-simple_bus_reg \
- -Wno-pci_device_reg
+ -Wno-unit_address_format
+
+
+DTC_FLAGS += $(call dtc-option,-Wno-avoid_unnecessary_addr_size)
+DTC_FLAGS += $(call dtc-option,-Wno-alias_paths)
+DTC_FLAGS += $(call dtc-option,-Wno-graph_child_address)
+DTC_FLAGS += $(call dtc-option,-Wno-graph_port)
+DTC_FLAGS += $(call dtc-option,-Wno-unique_unit_address)
+DTC_FLAGS += $(call dtc-option,-Wno-simple_bus_reg)
+DTC_FLAGS += $(call dtc-option,-Wno-pci_device_reg)
参考:https://forum.openwrt.org/t/uboot-builds-failure-with-2020-01-for-openwrt-18-06/56009
Q3.LZMA u-boot.bin.lzma Error: Incorrect command
解决办法:修改 u-boot Makefile
--- a/Makefile
+++ b/Makefile
@@ -1009,7 +1009,7 @@ quiet_cmd_pad_cat = CAT $@
cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
quiet_cmd_lzma = LZMA $@
-cmd_lzma = lzma -c -z -k -9 $< > $@
+cmd_lzma = xz -F lzma -c -z -k -9 $< > $@
cfg: u-boot.cfg
说明:lzma = xz -F lzma