Rockchip RK3399 - 移植uboot 2023.04 & linux 6.3
----------------------------------------------------------------------------------------------------------------------------
开发板 :NanoPC-T4
开发板
eMMC
:16GB
LPDDR3
:4GB
显示屏 :15.6 HDMI
接口显示屏
u-boot
:2023.04
linux
:6.3
----------------------------------------------------------------------------------------------------------------------------
在前面我们已经介绍了《编译Rockchip
官方》提供的uboot
源码,并下载到开发板中进行测试运行。这一节我们尝试下载最新的uboot
版本试试,当前最新版本为2023.04
。
一、uboot 2023.04
1.1 下载源码
u-boot
软件包下载网站:《https://ftp.denx.de/pub/u-boot/
》。
DENX
相关的网站:《http://www.denx.de/re/DPLG.html
》。
u-boot git
仓库:《https://gitlab.denx.de/u-boot/u-boot
》。
我们在ubuntu
运行如下命令:
root@zhengyang:/work/sambashare/rk3399# wget https://ftp.denx.de/pub/u-boot/u-boot-2023.04.tar.bz2
解压:
root@zhengyang:/work/sambashare/rk3399# tar -jxf u-boot-2023.04.tar.bz2
进入到uboot
文件夹里,这就是我们需要的uboot
的源码了:
root@zhengyang:/work/sambashare/rk3399# cd u-boot-2023.04
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ll
总用量 484
drwxrwxr-x 25 root root 4096 Apr 4 04:38 ./
drwxr-xr-x 14 root root 4096 May 21 15:22 ../
drwxrwxr-x 2 root root 4096 Apr 4 04:38 api/
drwxrwxr-x 14 root root 4096 Apr 4 04:38 arch/
-rw-rw-r-- 1 root root 21095 Apr 4 04:38 .azure-pipelines.yml
drwxrwxr-x 177 root root 4096 Apr 4 04:38 board/
drwxrwxr-x 2 root root 4096 Apr 4 04:38 boot/
-rw-rw-r-- 1 root root 814 Apr 4 04:38 .checkpatch.conf
drwxrwxr-x 10 root root 4096 Apr 4 04:38 cmd/
drwxrwxr-x 5 root root 4096 Apr 4 04:38 common/
-rw-rw-r-- 1 root root 2180 Apr 4 04:38 config.mk
drwxrwxr-x 2 root root 57344 Apr 4 04:38 configs/
drwxrwxr-x 2 root root 4096 Apr 4 04:38 disk/
drwxrwxr-x 20 root root 4096 Apr 4 04:38 doc/
drwxrwxr-x 74 root root 4096 Apr 4 04:38 drivers/
drwxrwxr-x 2 root root 4096 Apr 4 04:38 dts/
drwxrwxr-x 2 root root 4096 Apr 4 04:38 env/
drwxrwxr-x 4 root root 4096 Apr 4 04:38 examples/
drwxrwxr-x 15 root root 4096 Apr 4 04:38 fs/
-rw-rw-r-- 1 root root 44 Apr 4 04:38 .get_maintainer.conf
-rw-rw-r-- 1 root root 207 Apr 4 04:38 .gitattributes
drwxrwxr-x 2 root root 4096 Apr 4 04:38 .github/
-rw-rw-r-- 1 root root 1115 Apr 4 04:38 .gitignore
-rw-rw-r-- 1 root root 14133 Apr 4 04:38 .gitlab-ci.yml
drwxrwxr-x 36 root root 20480 Apr 4 04:38 include/
-rw-rw-r-- 1 root root 783 Apr 4 04:38 Kbuild
-rw-rw-r-- 1 root root 20750 Apr 4 04:38 Kconfig
drwxrwxr-x 24 root root 4096 Apr 4 04:38 lib/
drwxrwxr-x 2 root root 4096 Apr 4 04:38 Licenses/
-rw-rw-r-- 1 root root 4022 Apr 4 04:38 .mailmap
-rw-rw-r-- 1 root root 42030 Apr 4 04:38 MAINTAINERS
-rw-rw-r-- 1 root root 81547 Apr 4 04:38 Makefile
drwxrwxr-x 2 root root 4096 Apr 4 04:38 net/
drwxrwxr-x 5 root root 4096 Apr 4 04:38 post/
-rw-rw-r-- 1 root root 94985 Apr 4 04:38 README
-rw-rw-r-- 1 root root 491 Apr 4 04:38 .readthedocs.yml
drwxrwxr-x 6 root root 4096 Apr 4 04:38 scripts/
drwxrwxr-x 17 root root 4096 Apr 4 04:38 test/
drwxrwxr-x 15 root root 4096 Apr 4 04:38 tools/
1.2 配置uboot
uboot
的编译分为两步:配置、编译。单板的默认配置在configs
目录下,这里我们直接选择configs/evb-rk3399_defconfig
,这是Rockchip
评估板的配置:
CONFIG_ARM=y
CONFIG_SKIP_LOWLEVEL_INIT=y
CONFIG_COUNTER_FREQUENCY=24000000
CONFIG_ARCH_ROCKCHIP=y
CONFIG_TEXT_BASE=0x00200000
CONFIG_NR_DRAM_BANKS=1
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x300000
CONFIG_ENV_OFFSET=0x3F8000
CONFIG_DEFAULT_DEVICE_TREE="rk3399-evb"
CONFIG_DM_RESET=y
CONFIG_ROCKCHIP_RK3399=y
CONFIG_TARGET_EVB_RK3399=y
CONFIG_SPL_STACK=0x400000
CONFIG_DEBUG_UART_BASE=0xFF1A0000
CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_SYS_LOAD_ADDR=0x800800
CONFIG_DEBUG_UART=y
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-evb.dtb"
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_SPL_MAX_SIZE=0x2e000
CONFIG_SPL_PAD_TO=0x7f8000
CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
CONFIG_SPL_BSS_START_ADDR=0x400000
CONFIG_SPL_BSS_MAX_SIZE=0x2000
# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
CONFIG_SPL_STACK_R=y
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
CONFIG_TPL=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_GPT=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_TIME=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_MISC=y
CONFIG_MMC_HS400_SUPPORT=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_ROCKCHIP=y
CONFIG_SF_DEFAULT_SPEED=20000000
CONFIG_ETH_DESIGNWARE=y
CONFIG_GMAC_ROCKCHIP=y
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
CONFIG_PHY_ROCKCHIP_TYPEC=y
CONFIG_PMIC_RK8XX=y
CONFIG_REGULATOR_PWM=y
CONFIG_REGULATOR_RK8XX=y
CONFIG_PWM_ROCKCHIP=y
CONFIG_DM_RNG=y
CONFIG_RNG_ROCKCHIP=y
CONFIG_BAUDRATE=1500000
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550_MEM32=y
CONFIG_SYSRESET=y
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_DWC3=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_GENERIC=y
CONFIG_USB_HOST_ETHER=y
CONFIG_USB_ETHER_ASIX=y
CONFIG_USB_ETHER_ASIX88179=y
CONFIG_USB_ETHER_MCS7830=y
CONFIG_USB_ETHER_RTL8152=y
CONFIG_USB_ETHER_SMSC95XX=y
CONFIG_VIDEO=y
# CONFIG_VIDEO_BPP8 is not set
CONFIG_DISPLAY=y
CONFIG_VIDEO_ROCKCHIP=y
CONFIG_VIDEO_ROCKCHIP_MAX_YRES=1200
CONFIG_DISPLAY_ROCKCHIP_MIPI=y
CONFIG_SPL_TINY_MEMSET=y
CONFIG_ERRNO_STR=y
因此执行如下命令,生成.config
文件:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# make evb-rk3399_defconfig V=1
接着我们需要执行make menuconfig
做一些配置。
1.2.1 配置串口波特率
uboot
中默认的调试串口波特率是1500000
,有很多的调试终端不支持1.5M
的波特率,我们可以把波特率重新配置下;
Device Drivers --->
Serial --->
(115200) Default baudrate
注意:波特率数值如果无法删除,按CTRL+
回车键尝试。如果配置为1500000
,后面测试时串口输出内容一部分正常,偶尔出现乱码,考虑是串口波特率太高不稳定造成的,降低波特率到115200
尝试。
1.2.2 配置eMMC
为什么要去配置eMMC
呢?这个是因为我使用默认配置,编译后的uboot
下载到开发板出现了无法对eMMC
进行读写的问题,并且输出了如下错误:
sdhci_transfer_data: Error detected in status(0x208000)
然后我去比对了当前版本uboot
和Rockchip
官方(《Rockchip RK3399 - TPL/SPL
方式加载uboot
》)提供的uboot
单板配置configs/evb-rk3399_defconfig
的差异,发现当前版本默认开启了以下配置:
CONFIG_MMC_HS400_SUPPORT=y # 多出了这个
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y # 多出了这个
那CONFIG_MMC_HS400_SUPPOR
、CONFIG_MMC_SDHCI_SDMA
是什么呢?
CONFIG_MMC_HS400_SUPPORT
是一个配置选项,用于支持嵌入式设备中的高速 MMC(Multimedia Card)/SD(Secure Digital)
卡,默认情况下未启用。
启用这个选项可以让MMC/SD
卡在HS400
模式下运行,从而提高读写速度,但是需要确保硬件上支持HS400
模式,并且芯片厂商提供了对应的驱动程序。如果硬件不支持或驱动程序不可用,则启用此选项将会导致系统无法正常启动。
既然我们已经明白了该配置项的作用,那我们就要看一下我们的eMMC
芯片是否支持HS400
模式,这里用的开发板板载的eMMC
型号为:KLMAG2WEMB-B031
,找到芯片的datasheet
有关HS400 mode
的信息,具体定位到EXT_CSD
第196
个字节DEVICE_TYPE
,其值为0x57
;可以看到eMMC
工作在HS400
模式时,电压要求为1.8V
。
配置项CONFIG_MMC_SDHCI_SDMA
用于启用SD/SDIO/MMC
主机控制器使用DMA
方式进行数据传输。
这里我们暂且将CONFIG_MMC_HS400_SUPPORT
,CONFIG_MMC_SDHCI_SDMA
配置关掉:
Device Drivers --->
MMC Host controller Support --->
[ ] MMC debugging
[ ] enable HS400 support
[ ] Support IO voltage configuration
[ ] Support SDHCI SDMA
如果想查看eMMC
读写命令信息,可以打开MMC debuging
。
1.2.3 配置FIT
Boot options --->
Boot images --->
[*] Use a script to generate the .its script
(arch/arm/mach-rockchip/make_fit_atf.py) .its file generator script for U-Boot FIT image
我们之前介绍过在生成u-boot.itb
文件时,需要执行如下命令:
tools/mkimage -f u-boot.its u-boot.itb
mkimage
将its
文件以及对应的image data file
,打包成一个itb
文件,也就是uboot
可以识别的image file(FIT-uImage)
。
因为mkimage
是根据its
文件中的描述来打包镜像生成itb
文件(FIT-uImage
),所以首先需要制作一个its
文件,在its
文件中描述需要被打包的镜像,主要是bl31.bin
,dtb
文件,u-boot-nodtb.bin
。
这里我们需要使用到arch/arm/mach-rockchip/make_fit_atf.py
文件,这个是从Rockchip
官网uboot
下拷贝过来的,内容如下,这是一个python
脚本,主要就是生成一个u-boot.its
文件:
#!/usr/bin/env python2
"""
A script to generate FIT image source for rockchip boards
with ARM Trusted Firmware
and multiple device trees (given on the command line)
usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
"""
import os
import sys
import getopt
# pip install pyelftools
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
from elftools.elf.segments import Segment, InterpSegment, NoteSegment
ELF_SEG_P_TYPE='p_type'
ELF_SEG_P_PADDR='p_paddr'
ELF_SEG_P_VADDR='p_vaddr'
ELF_SEG_P_OFFSET='p_offset'
ELF_SEG_P_FILESZ='p_filesz'
ELF_SEG_P_MEMSZ='p_memsz'
DT_HEADER="""/*
* Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd
*
* Minimal dts for a SPL FIT image payload.
*
* SPDX-License-Identifier: GPL-2.0+ X11
*/
/dts-v1/;
/ {
description = "Configuration to load ATF before U-Boot";
#address-cells = <1>;
images {
uboot {
description = "U-Boot (64-bit)";
data = /incbin/("u-boot-nodtb.bin");
type = "standalone";
os = "U-Boot";
arch = "arm64";
compression = "none";
load = <0x%08x>;
hash {
algo = "sha256";
};
};
"""
DT_IMAGES_NODE_END="""
};
"""
DT_END="""
};
"""
def append_atf_node(file, atf_index, phy_addr):
"""
Append ATF DT node to input FIT dts file.
"""
data = 'bl31_0x%08x.bin' % phy_addr
print >> file, '\t\tatf@%d {' % atf_index
print >> file, '\t\t\tdescription = \"ARM Trusted Firmware\";'
print >> file, '\t\t\tdata = /incbin/("%s");' % data
print >> file, '\t\t\ttype = "firmware";'
print >> file, '\t\t\tarch = "arm64";'
print >> file, '\t\t\tos = "arm-trusted-firmware";'
print >> file, '\t\t\tcompression = "none";'
print >> file, '\t\t\tload = <0x%08x>;' % phy_addr
if atf_index == 1:
print >> file, '\t\t\tentry = <0x%08x>;' % phy_addr
print >> file, '\t\t\thash {'
print >> file, '\t\t\t\talgo = "sha256";'
print >> file, '\t\t\t};'
print >> file, '\t\t};'
print >> file, ''
def append_fdt_node(file, dtbs):
"""
Append FDT nodes.
"""
cnt = 1
for dtb in dtbs:
dtname = os.path.basename(dtb)
print >> file, '\t\tfdt {'
print >> file, '\t\t\tdescription = "U-Boot device tree blob";'
print >> file, '\t\t\tdata = /incbin/("u-boot.dtb");'
print >> file, '\t\t\ttype = "flat_dt";'
print >> file, '\t\t\tarch = "arm64";'
print >> file, '\t\t\tcompression = "none";'
print >> file, '\t\t\thash {'
print >> file, '\t\t\t\talgo = "sha256";'
print >> file, '\t\t\t};'
print >> file, '\t\t};'
print >> file, ''
cnt = cnt + 1
def append_conf_section(file, cnt, dtname, atf_cnt):
print >> file, '\t\tconfig {'
print >> file, '\t\t\tdescription = "Rockchip armv8 with ATF";'
print >> file, '\t\t\trollback-index = <0x0>;'
print >> file, '\t\t\tfirmware = "atf@1";'
print >> file, '\t\t\tloadables = "uboot",',
for i in range(1, atf_cnt):
print >> file, '"atf@%d"' % (i+1),
if i != (atf_cnt - 1):
print >> file, ',',
else:
print >> file, ';'
print >> file, '\t\t\tfdt = "fdt";'
print >> file, '\t\t\tsignature {'
print >> file, '\t\t\t\talgo = "sha256,rsa2048";'
print >> file, '\t\t\t\tpadding = "pss";'
print >> file, '\t\t\t\tkey-name-hint = "dev";'
print >> file, '\t\t\t\tsign-images = "fdt", "firmware", "loadables";'
print >> file, '\t\t\t};'
print >> file, '\t\t};'
print >> file, ''
def append_conf_node(file, dtbs, atf_cnt):
"""
Append configeration nodes.
"""
cnt = 1
print >> file, '\tconfigurations {'
print >> file, '\t\tdefault = "config";'
for dtb in dtbs:
dtname = os.path.basename(dtb)
append_conf_section(file, cnt, dtname, atf_cnt)
cnt = cnt + 1
print >> file, '\t};'
print >> file, ''
def generate_atf_fit_dts(fit_file_name, bl31_file_name, uboot_file_name, dtbs_file_name):
"""
Generate FIT script for ATF image.
"""
if fit_file_name != sys.stdout:
fit_file = open(fit_file_name, "wb")
else:
fit_file = sys.stdout
num_load_seg = 0
p_paddr = 0xFFFFFFFF
with open(uboot_file_name) as uboot_file:
uboot = ELFFile(uboot_file)
for i in range(uboot.num_segments()):
seg = uboot.get_segment(i)
if ('PT_LOAD' == seg.__getitem__(ELF_SEG_P_TYPE)):
p_paddr = seg.__getitem__(ELF_SEG_P_PADDR)
num_load_seg = num_load_seg + 1
assert (p_paddr != 0xFFFFFFFF and num_load_seg == 1)
print >> fit_file, DT_HEADER % p_paddr
with open(bl31_file_name) as bl31_file:
bl31 = ELFFile(bl31_file)
for i in range(bl31.num_segments()):
seg = bl31.get_segment(i)
if ('PT_LOAD' == seg.__getitem__(ELF_SEG_P_TYPE)):
paddr = seg.__getitem__(ELF_SEG_P_PADDR)
p= seg.__getitem__(ELF_SEG_P_PADDR)
append_atf_node(fit_file, i+1, paddr)
atf_cnt = i+1
append_fdt_node(fit_file, dtbs_file_name)
print >> fit_file, '%s' % DT_IMAGES_NODE_END
append_conf_node(fit_file, dtbs_file_name, atf_cnt)
print >> fit_file, '%s' % DT_END
if fit_file_name != sys.stdout:
fit_file.close()
def generate_atf_binary(bl31_file_name):
with open(bl31_file_name) as bl31_file:
bl31 = ELFFile(bl31_file)
num = bl31.num_segments()
for i in range(num):
seg = bl31.get_segment(i)
if ('PT_LOAD' == seg.__getitem__(ELF_SEG_P_TYPE)):
paddr = seg.__getitem__(ELF_SEG_P_PADDR)
file_name = 'bl31_0x%08x.bin' % paddr
with open(file_name, "wb") as atf:
atf.write(seg.data());
def get_bl31_segments_info(bl31_file_name):
"""
Get load offset, physical offset, file size
from bl31 elf file program headers.
"""
with open(bl31_file_name) as bl31_file:
bl31 = ELFFile(bl31_file)
num = bl31.num_segments()
print 'Number of Segments : %d' % bl31.num_segments()
for i in range(num):
print 'Segment %d' % i
seg = bl31.get_segment(i)
ptype = seg[ELF_SEG_P_TYPE]
poffset = seg[ELF_SEG_P_OFFSET]
pmemsz = seg[ELF_SEG_P_MEMSZ]
pfilesz = seg[ELF_SEG_P_FILESZ]
print 'type: %s\nfilesz: %08x\nmemsz: %08x\noffset: %08x' % (ptype, pfilesz, pmemsz, poffset)
paddr = seg[ELF_SEG_P_PADDR]
print 'paddr: %08x' % paddr
def main():
uboot_elf="./u-boot"
bl31_elf="./bl31.elf"
FIT_ITS=sys.stdout
opts, args = getopt.getopt(sys.argv[1:], "o:u:b:h")
for opt, val in opts:
if opt == "-o":
FIT_ITS=val
elif opt == "-u":
uboot_elf=val
elif opt == "-b":
bl31_elf=val
elif opt == "-h":
print __doc__
sys.exit(2)
dtbs = args
#get_bl31_segments_info("u-boot")
#get_bl31_segments_info("bl31.elf")
generate_atf_fit_dts(FIT_ITS, bl31_elf, uboot_elf, dtbs)
generate_atf_binary(bl31_elf);
if __name__ == "__main__":
main()
拷贝命令过来:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# cp ../u-boot/arch/arm/mach-rockchip/make_fit_atf.py ./arch/arm/mach-rockchip/
1.2.4 配置uboot
启动倒计时
如果在uboot
启动倒计时结束之前,没有按下任何键,将会执行那么将执行也就是bootcmd
中配置中的命令,bootcmd
中保存着默认的启动命令。
(5) delay in seconds before automatically booting
保存文件,输入文件名为evb-rk3399_defconfig
,在当前路径下生成evb-rk3399_defconfig
,存档:
root@zhengyang:/work/sambashare/rk3399/u-boot# mv evb-rk3399_defconfig ./configs/
注意:如果需要配置生效,需要使用make distclean
清除之前的配置,重新执行配置命令。
1.3 编译uboot
执行make
命令,生成u-boot
文件:
root@zhengyang:/work/sambashare/rk3399/u-boot# make ARCH=arm CROSS_COMPILE=arm-linux-
然后出现了如下错误:
binman: Filename 'atf-bl31' not found in input path (.,.,./board/rockchip/evb_rk3399,arch/arm/dts) (cwd='/work/sambashare/rk3399/u-boot-2023.04')
大致意思就是缺少了bl31.elf
文件,我们将《Rockchip RK3399 - TPL/SPL
方式加载uboot
》章节制作的bl31.elf
拷贝到uboot
根目录下:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# cp /work/sambashare/rk3399/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf ./
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# cp bl31.elf atf-bl31
重新编译,可以看到在 ./spl
、./tpl
目录下生成镜像文件:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ls tpl/u-boot*
tpl/u-boot.cfg tpl/u-boot-tpl tpl/u-boot-tpl.dtb tpl/u-boot-tpl.map tpl/u-boot-tpl.sym
tpl/u-boot-spl.lds tpl/u-boot-tpl.bin tpl/u-boot-tpl-dtb.bin tpl/u-boot-tpl-nodtb.bin
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ls spl/u-boot*
spl/u-boot.cfg spl/u-boot-spl.bin spl/u-boot-spl-dtb.bin spl/u-boot-spl.map spl/u-boot-spl.sym
spl/u-boot-spl spl/u-boot-spl.dtb spl/u-boot-spl.lds spl/u-boot-spl-nodtb.bin
二、idbloader.img
我们基于uboot
源码编译出TPL/SPL
,其中TPL
负责实现DDR
初始化,TPL
初始化结束之后会回跳到BootROM
程序,BootROM
程序继续加载SPL
,SPL
加载u-boot.itb
文件,然后跳转到uboot
执行。
idbloader.img
是由tpl/u-boot-tpl.bin
和spl/u-boot-spl.bin
文件生成,这里我们需要使用到tools
目录下的mkimage
工具。
2.1 tpl/u-boot-tpl.bin
在u-boot
目录下执行:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
Image Type: Rockchip RK33 (SD/MMC) boot image
Init Data Size: 53248 bytes
其中:
-n rk3399
将镜像文件的名称设置为rk3399
;-T rksd
将映像类型指定为Rockchip SD
卡启动映像;-d tpl/u-boot-tpl.bin
将生成的TPL
镜像文件tpl/u-boot-tpl.bin
指定为输入文件,而idbloader.img
则指定为输出文件。
生成idbloader.img
文件:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ll idbloader.img
-rw-r--r-- 1 root root 55296 May 21 17:12 idbloader.img
2.2 spl/u-boot-spl.bin
将spl/u-boot-spl.bin
合并到idbloader.img
:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# cat spl/u-boot-spl.bin >> idbloader.img
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ll idbloader.img
-rw-r--r-- 1 root root 143866 May 21 17:13 idbloader.img
三、u-boot.idb
3.1 u-boot.itd
生成规则
这里我们需要生成FIT image
,对应的镜像文件名称为u-boot.itd
,在顶层Makefile
定义有:
ifdef U_BOOT_ITS
u-boot.itb: u-boot-nodtb.bin \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
$(if $(CONFIG_MULTI_DTB_FIT),$(FINAL_DTB_CONTAINER)) \
$(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)
endif
ifneq ($(CONFIG_SPL_FIT_SOURCE),"") // 方式1. 如果自己已经有u-boot.its,配置CONFIG_SPL_FIT_SOURCE=u-boot.its
U_BOOT_ITS := u-boot.its
$(U_BOOT_ITS): $(subst ",,$(CONFIG_SPL_FIT_SOURCE))
$(call if_changed,copy)
else
ifneq ($(CONFIG_USE_SPL_FIT_GENERATOR),) // 方式2. 使用脚本生成 配置CONFIG_USE_SPL_FIT_GENERATOR=y
U_BOOT_ITS := u-boot.its
$(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE
$(srctree)/$(CONFIG_SPL_FIT_GENERATOR) \
$(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@ // 在$(patsubst %.c,%.o,$(dir) )中,patsubst把$(dir)中的变量符合后缀是.c的全部替换成.o
endif
endif
这里我们采用的配置CONFIG_SPL_FIT_GENERATOR
的方式来生成u-boot.its
,也就是我们在执行make menuconfig
时配置的:
CONFIG_SPL_FIT_SOURCE=""
CONFIG_USE_SPL_FIT_GENERATOR=y
CONFIG_SPL_FIT_GENERATOR="arch/arm/mach-rockchip/make_fit_atf.py"
3.2 编译
执行编译命令:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# make u-boot.itb ARCH=arm CROSS_COMPILE=arm-linux-
UPD include/generated/timestamp_autogenerated.h
ENVC include/generated/env.txt
ENVP include/generated/env.in
ENVT include/generated/environment.h
CC cmd/version.o
AR cmd/built-in.o
CC env/common.o
AR env/built-in.o
CC lib/efi_loader/dtbdump.o
LD lib/efi_loader/dtbdump_efi.so
OBJCOPY lib/efi_loader/dtbdump.efi
CC lib/efi_loader/initrddump.o
LD lib/efi_loader/initrddump_efi.so
OBJCOPY lib/efi_loader/initrddump.efi
LD u-boot
OBJCOPY u-boot-nodtb.bin
RELOC u-boot-nodtb.bin
./"arch/arm/mach-rockchip/make_fit_atf.py" \
arch/arm/dts/rk3399-evb.dtb > u-boot.its
MKIMAGE u-boot.itb
编译完成在当前路径下生成u-boot.its
、u-boot.itb
文件。
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ll u-boot.it*
-rw-r--r-- 1 root root 974224 May 21 17:14 u-boot.itb
-rw-r--r-- 1 root root 2423 May 21 17:14 u-boot.its
其中u-boot.its
文件内容如下:
/*
* Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd
*
* Minimal dts for a SPL FIT image payload.
*
* SPDX-License-Identifier: GPL-2.0+ X11
*/
/dts-v1/;
/ {
description = "Configuration to load ATF before U-Boot";
#address-cells = <1>;
images {
uboot {
description = "U-Boot (64-bit)";
data = /incbin/("u-boot-nodtb.bin");
type = "standalone";
os = "U-Boot";
arch = "arm64";
compression = "none";
load = <0x00200000>;
hash {
algo = "sha256";
};
};
atf@1 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0x00040000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0x00040000>;
entry = <0x00040000>;
hash {
algo = "sha256";
};
};
atf@2 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0xff3b0000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xff3b0000>;
hash {
algo = "sha256";
};
};
atf@3 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0xff8c0000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xff8c0000>;
hash {
algo = "sha256";
};
};
atf@4 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0xff8c1000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xff8c1000>;
hash {
algo = "sha256";
};
};
atf@5 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0xff8c2000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xff8c2000>;
hash {
algo = "sha256";
};
};
fdt {
description = "U-Boot device tree blob";
data = /incbin/("u-boot.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash {
algo = "sha256";
};
};
};
configurations {
default = "config";
config {
description = "Rockchip armv8 with ATF";
rollback-index = <0x0>;
firmware = "atf@1";
loadables = "uboot", "atf@2" , "atf@3" , "atf@4" , "atf@5" , "atf@6" ;
fdt = "fdt";
signature {
algo = "sha256,rsa2048";
padding = "pss";
key-name-hint = "dev";
sign-images = "fdt", "firmware", "loadables";
};
};
};
};
四、Linux 6.3
版本FIT uImage
在《Rockchip RK3399
- 移植linux 5.2.8
》中我们已经介绍了linux 5.2.8
版本FIT uImage
镜像的制作,这一节我们将简单介绍一下linux 6.3
版本FIT uImage
镜像的制作。
4.1 源码下载
我们这里下载linux-6.3
版本,执行如下命令:
root@zhengyang:/work/sambashare/rk3399# wget http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/kernel/v6.x/linux-6.3.tar.gz
解压:
root@zhengyang:/work/sambashare/rk3399# tar -xvf linux-6.3.tar.gz
4.2 配置Makefile
修改顶层的Makefile
,打开Makefile
文件,找到下面语句:
ARCH ?= $(SUBARCH)
修改为:
ARCH ?= arm64
CROSS_COMPILE ?= arm-linux-
其中,ARCH
是指定目标平台为 arm64 , CROSS_COMPILE 是指定交叉编译器,这里指定的是系统默认的交叉编译器,如要使用其它的,则要把编译器的全路径在这里写出。
交叉编译工具链安装参考:《https://www.cnblogs.com/zyly/p/17380243.html#_label3
》。
4.3 内核defconfig
配置
接下来要做的就是内核配置、编译了。单板的默认配置文件在arch/arm64/configs
目录下:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# ll arch/arm64/configs/defconfig
-rw-rw-r-- 1 root root 35014 Apr 24 03:02 arch/arm64/configs/defconfig
root@zhengyang:/work/sambashare/rk3399/linux-6.3# make defconfig
4.4 内核裁切
关于内核裁切内容比较多,参考《Rockchip RK3399
- 移植linux 5.2.8
》即可。其中有一些步骤略有不同:
(1) 由于我们不使用ramdisk
根文件系统,所以不用配置支持RAM
块设备;
(2) 在配置有限网卡驱动的时候发生一些变化:
Device Drivers --->
[*] Network device support --->
[*] Ethernet driver support --->
[*] STMicroelectronics devices
[*] STMicroelectronics Multi-Gigabit Ethernet driver
[*] STMMAC Platform bus support
[*] Rockchip dwmac support
(3) 配置支持SquashFS
文件系统;
File systems --->
-*- Miscellaneous filesystems
<*> SquashFS 4.0 - Squashed file system support
[*] Squashfs XATTR support
[*] Include support for ZLIB compressed file systems
[*] Include support for LZ4 compressed file systems
[*] Include support for LZO compressed file systems
[*] Include support for XZ compressed file systems
配置这个的目的是后面移植的ubuntu
根文件系统需要使用;如果不配置这个,当移植了ubuntu
根文件系统时,内核启动会出现类似下面的错误;
[ 9.192204] squashfs: SQUASHFS error: Filesystem uses "xz" compression. This is not supported
4.5 修改设备树
4.5.1 配置display-subsystem
设备节点
执行如下命令:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# vim arch/arm64/boot/dts/rockchip/rk3399.dtsi
将以下节点:
display-subsystem {
compatible = "rockchip,display-subsystem";
ports = <&vopl_out>, <&vopb_out>;
};
修改为:
display_subsystem: display-subsystem {
compatible = "rockchip,display-subsystem";
ports = <&vopl_out>, <&vopb_out>;
};
4.5.2 新增子节点属性
由于我使用的是HDMI
显示器,因此需要在arch/arm64/boot/dts/rockchip/rk3399-evb.dts
中为以下节点新增属性:
&i2c7 {
status = "okay";
};
&display_subsystem {
status = "okay";
};
&vopl {
status = "okay";
};
&vopl_mmu {
status = "okay";
};
&vopb {
status = "okay";
};
&vopb_mmu {
status = "okay";
};
&hdmi {
ddc-i2c-bus = <&i2c7>;
pinctrl-names = "default";
pinctrl-0 = <&hdmi_cec>;
status = "okay";
};
同时需要将edp
更改为禁用状态;
&edp {
status = "disabled";
....
};
4.6 编译内核
在linux
内核根目录下执行如下命令:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# make -j8
编译完成,在arch/arm64/boot/
文件夹下生成Image
镜像文件,以及设备树dst/rockchip/xxx.dtb
文件;
root@zhengyang:/work/sambashare/rk3399/linux-6.3# ll arch/arm64/boot/
总用量 52836
drwxrwxr-x 3 root root 4096 Jun 12 23:10 ./
drwxrwxr-x 14 root root 4096 Jun 12 22:54 ../
drwxrwxr-x 35 root root 4096 Apr 24 03:02 dts/
-rw-rw-r-- 1 root root 64 Apr 24 03:02 .gitignore
-rw-r--r-- 1 root root 40665600 Jun 12 23:10 Image
-rw-r--r-- 1 root root 139 Jun 12 23:10 .Image.cmd
-rw-r--r-- 1 root root 13585031 Jun 12 23:10 Image.gz
-rw-r--r-- 1 root root 106 Jun 12 23:10 .Image.gz.cmd
-rwxrwxr-x 1 root root 962 Apr 24 03:02 install.sh*
-rw-rw-r-- 1 root root 1198 Apr 24 03:02 Makefile
root@zhengyang:/work/sambashare/rk3399/linux-6.3/arch/arm64/boot/dts/rockchip# ls *rk3399*.dtb
rk3399-eaidk-610.dtb rk3399-gru-scarlet-kd.dtb rk3399-nanopi-m4b.dtb rk3399pro-rock-pi-n10.dtb rk3399-rock-pi-4c.dtb
rk3399-evb.dtb rk3399-hugsun-x99.dtb rk3399-nanopi-m4.dtb rk3399-puma-haikou.dtb rk3399-rockpro64.dtb
rk3399-ficus.dtb rk3399-khadas-edge-captain.dtb rk3399-nanopi-neo4.dtb rk3399-rock-4c-plus.dtb rk3399-rockpro64-v2.dtb
rk3399-firefly.dtb rk3399-khadas-edge.dtb rk3399-nanopi-r4s.dtb rk3399-rock960.dtb rk3399-roc-pc.dtb
rk3399-gru-bob.dtb rk3399-khadas-edge-v.dtb rk3399-nanopi-r4s-enterprise.dtb rk3399-rock-pi-4a.dtb rk3399-roc-pc-mezzanine.dtb
rk3399-gru-kevin.dtb rk3399-kobol-helios64.dtb rk3399-orangepi.dtb rk3399-rock-pi-4a-plus.dtb rk3399-roc-pc-plus.dtb
rk3399-gru-scarlet-dumo.dtb rk3399-leez-p710.dtb rk3399-pinebook-pro.dtb rk3399-rock-pi-4b.dtb rk3399-sapphire.dtb
rk3399-gru-scarlet-inx.dtb rk3399-nanopc-t4.dtb rk3399-pinephone-pro.dtb rk3399-rock-pi-4b-plus.dtb rk3399-sapphire-excavator.dtb
4.7 创建its
文件
因为mkimage
是根据its
文件中的描述来打包镜像生成itb
文件(FIT uImage
),所以首先需要制作一个its
文件,在its
文件中描述需要被打包的镜像,主要是kernel
镜像,dtb
文件。
我们创建一个kernel.its
文件,内容如下:
/*
* Simple U-Boot uImage source file containing a single kernel and FDT blob
*/
/dts-v1/;
/ {
description = "Simple image with single Linux kernel and FDT blob";
#address-cells = <1>;
images {
kernel {
description = "Vanilla Linux kernel";
data = /incbin/("arch/arm64/boot/Image.gz");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "gzip";
load = <0x280000>;
entry = <0x280000>;
hash-1 {
algo = "crc32";
};
hash-2 {
algo = "sha1";
};
};
fdt {
description = "Flattened Device Tree blob";
data = /incbin/("arch/arm64/boot/dts/rockchip/rk3399-evb.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
load = <0x8300000>;
entry = <0x8300000>;
hash-1 {
algo = "crc32";
};
hash-2 {
algo = "sha1";
};
};
};
configurations {
default = "conf-1";
conf-1 {
description = "Boot Linux kernel with FDT blob";
kernel = "kernel";
fdt = "fdt";
};
};
};
4.8 生成kernel.itb
在制作kernel.itb
时编译命令和《Rockchip RK3399
- 移植linux 5.2.8
》中说的略有不同,这里我们需要将u-boot-2023.04
路径下的mkimage
工具拷贝过来,然后在命令行使用mkimage
工具编译即可:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# cp ../u-boot-2023.04/tools/mkimage ./
root@zhengyang:/work/sambashare/rk3399/linux-6.3# ./mkimage -f kernel.its kernel.itb
需要注意的是这里一定不能指定-E
参数,不然uboot
在进行kernel
镜像hash
校验的时候就会失败。
五、烧录测试
由于我们每次修改程序后,重新编译步骤比较麻烦,这里我们可以将这些步骤编写成一个shell
脚本,这样每次执行就比较容易了。
5.1 自动构建脚本
在uboot
根目录下创建一个build.sh
文件:
#!/bin/bash
# 接收第一个参数 支持 ''|'config'|'clean'
step=$1
# 接收 V=1 支持编译输出详细信息
V=$2
cmd=${V%=*}
if [[ ${cmd} = 'V' ]]; then
V=${V#*=}
fi
if [[ ${step} == "config" ]];then
echo '----------------config evb-rk3399_defconfig------- -------------'
make evb-rk3399_defconfig V=${V}
fi
if [[ -z ${step} ]];then
echo "---------------1. compile uboot-------------------------------- "
make ARCH=arm CROSS_COMPILE=arm-linux- V=${V}
echo "---------------2. mkimahe idbloader----------------------------"
tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
cat spl/u-boot-spl.bin >> idbloader.img
echo "---------------3. make itb-------------------------------------"
make u-boot.itb ARCH=arm CROSS_COMPILE=arm-linux-
cp ./u-boot.itb ../rkdeveloptool
cp ./idbloader.img ../rkdeveloptool
fi
if [[ ${step} == "clean" ]];then
echo "-----------------clean-----------------------------------------"
make clean
make distclean
fi
然后给文件赋予可执行权限:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# chmod +x build.sh
5.1.1 clean
执行如下命令进行清理:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ./build.sh clean
5.1.2 配置
执行如下命令进行uboot
配置:
root@zhengyang:/work/sambashare/rk3399/u-boot# ./build.sh config
----------------config evb-rk3399_defconfig------- -------------
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
5.1.3 构建
执行如下命令进行uboot
编译、生成idbloader.img
、 u-boot.itb
文件,并拷贝到rkdeveloptool
目录下:
root@zhengyang:/work/sambashare/rk3399/u-boot-2023.04# ./build.sh
如果需要输出编译详情信息,追加V=1
参数即可。
5.2 烧录uboot
烧录方法有两种:
- 一种是基于
Rockchip
的官方烧录工具RKDevTool
;官方RKDevTool
是基于recovery
模式实现的,如果板子带有recovery
按键,可以使用这种方式; - 另外一种是在开发板上使用
rkdeveloptool
工具直接烧写eMMC
;这里我们采用rkdeveloptool
烧录的方式;
5.2.1 准备镜像
我们需按照之前的流程得到了idbloader.img
、u-boot.itb
文件,由于我们这里不进行内核和根文件系统的烧录,所以暂时不需要准备这俩。
按照Rockchip
官方要求将idbloader.img
烧录到eMMC
的0x40
扇区,u-boot.itb
烧录到0x4000
扇区。
我们需要将idbloader.img
、u-boot.itb
、kernel.itb
拷贝到rkdeveloptool
路径下:
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# cp ../u-boot-2023.04/u-boot.itb ./
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# cp ../linux-6.3/kernel.itb ./
5.2.2 进入MASKROM
升级模式
NanoPC-T4
开发板如需进入MASKROM
升级模式,需要进入如下操作:
- 将开发板连接上电源,并且连接
Type-C
数据线到PC
; - 按住
BOOT
键再长按Power
键开机(保持按下BOOT
键5
秒以上),将强制进入MASKROM
模式。
一般电脑识别到USB
连接,都会发出声音。或者观察虚拟机右下角是否突然多个USB
设备:右键点击链接;
5.2.3 下载uboot
使用下载引导命令去使目标机器初始化DDR
与运行usbplug
(初始化DDR
的原因是由于升级需要很大的内存,所以需要使用到DDR
);
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool db rk3399_loader_v1.27.126.bin
Downloading bootloader succeeded.
由于BootROM
启动会将《rk3399_loader_v1.27.126.bin
》将在到内部SRAM
中,然后跳转到ddr.bin
代码进行DDR
的初始化,ddr.bin
执行之后会回跳到BootROM
程序,BootROM
程序继续加载usbplug.bin
,由usbplug.bin
完成程序的下载以及烧录到eMMC
。
如果接上串口的话,执行完这一步可以看到如下输出信息:
DDR Version 1.27 20211018
In
Channel 0: LPDDR3, 800MHz
CS = 0
MR0=0x58
MR1=0x58
MR2=0x58
MR3=0x58
MR4=0x2
MR5=0x1
MR6=0x5
MR7=0x0
MR8=0x1F
MR9=0x1F
MR10=0x1F
MR11=0x1F
MR12=0x1F
MR13=0x1F
MR14=0x1F
MR15=0x1F
MR16=0x1F
CS = 1
MR0=0x58
MR1=0x58
MR2=0x58
MR3=0x58
MR4=0x2
MR5=0x1
MR6=0x5
MR7=0x0
MR8=0x1F
MR9=0x1F
MR10=0x1F
MR11=0x1F
MR12=0x1F
MR13=0x1F
MR14=0x1F
MR15=0x1F
MR16=0x1F
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=32 Size=2048MB
Channel 1: LPDDR3, 800MHz
CS = 0
MR0=0x58
MR1=0x58
MR2=0x58
MR3=0x58
MR4=0x2
MR5=0x1
MR6=0x5
MR7=0x0
MR8=0x1F
MR9=0x1F
MR10=0x1F
MR11=0x1F
MR12=0x1F
MR13=0x1F
MR14=0x1F
MR15=0x1F
MR16=0x1F
CS = 1
MR0=0x58
MR1=0x58
MR2=0x58
MR3=0x58
MR4=0x2
MR5=0x1
MR6=0x5
MR7=0x0
MR8=0x1F
MR9=0x1F
MR10=0x1F
MR11=0x1F
MR12=0x1F
MR13=0x1F
MR14=0x1F
MR15=0x1F
MR16=0x1F
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=32 Size=2048MB
256B stride
ch 0 ddrconfig = 0x101, ddrsize = 0x2020
ch 1 ddrconfig = 0x101, ddrsize = 0x2020
pmugrf_os_reg[2] = 0x3AA0DAA0, stride = 0xD
OUT
Boot1 Release Time: Jun 2 2020 15:02:17, version: 1.26
CPUId = 0x0
SdmmcInit=2 0
BootCapSize=100000
UserCapSize=14910MB
FwPartOffset=2000 , 100000
UsbBoot ...73858
powerOn 86071
使用wl命令烧写镜像到目标机器的eMMC
,需要注意的是访问DDR
所需的所有其他命令都应在使用db
命令之后才能使用;
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x40 idbloader.img
Write LBA from file (100%)
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x4000 u-boot.itb
Write LBA from file (100%)
如果有制作好《ext4
类型的根文件系统》,可以将根文件系统烧录到eMMC 0x40000
扇区处,烧录命令:
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x40000 busybox_ext4_rootfs.img
在烧写镜像完成后使用rd
命令重启目标机器:
root@zhengyang:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool rd
Reset Device OK.
需要注意的是:如果这个时候你也烧录了内核程序,执行完rd
命令后是无法进入uboot
命令的的,这里会直接启动内核。
5.3 测试u-boot
5.3.1 串口连接
使用准备好的US
B转串口适配器和连接线(需另购),连接开发板:
引脚 | 开发板接口 | USB转串口 |
---|---|---|
1 | GNC | - |
2 | VCC 5V | - |
3 | UART2DBG_TX | RX |
4 | UART2DBG_RX | TX |
5.3.2 MobaXterm
这里我使用的串口调试工具是MobaXterm
,选择串口端口,设置波特率为115200
,8
位数据位,1
位停止位。
5.3.3 上电
给开发板上电,通过串口打印输出:
U-Boot TPL 2023.04 (May 21 2023 - 17:50:22)
Channel 0: LPDDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
Trying to boot from BOOTROM
Returning to boot ROM...
U-Boot SPL 2023.04 (May 21 2023 - 17:50:22 +0800)
Trying to boot from MMC2
spl_load_fit_image: Skip load 'atf@5': image size is 0!
cannot find image node 'atf@6': -1
NOTICE: BL31: v2.8(release):c194aa0
NOTICE: BL31: Built : 19:26:54, May 11 2023
U-Boot 2023.04 (May 21 2023 - 17:50:25 +0800)
SoC: Rockchip rk3399
Reset cause: RST
Model: Rockchip RK3399 Evaluation Board
DRAM: 4 GiB (effective 3.9 GiB)
Core: 254 devices, 27 uclasses, devicetree: separate
MMC: mmc@fe320000: 1, mmc@fe330000: 0
Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Model: Rockchip RK3399 Evaluation Board
Net: eth0: ethernet@fe300000
Hit any key to stop autoboot: 0
在倒计时执行完之前,按CTRL+C
即可进入uboot
命令行。
5.3.4 设置ip
以及bootargs
这里我们这是本机和服务器的ip
地址:
=> setenv ipaddr 192.168.0.105
=> setenv serverip 192.168.0.200
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
ARM64
,在kernel
未建立console
之前,使用earlycon
,实现日志信息的打印,因此需要配置bootargs
,要加入如下选项:
earlycon=uart8250,mmio32,0xff1a0000,115200n8
其中uart8250
表示针对uart8250
这个串口设备,mio32
表示内存I/O
资源32
位,0xff1a0000
是RK3399
串口2寄存器基地址,115200
表示串口波特率。
uart8250
串口驱动定义在内核根目录drivers/tty/serial/8250/8250_early.c
文件中:
EARLYCON_DECLARE(uart8250, early_serial8250_setup);
有关uart8250
串口驱动是如何注册的,这里就不过多介绍了,具体可以参考《ARM64
是怎样使用earlycon
实现打印的》。
我们在uboot
命令行设置:
=> setenv bootargs earlycon=uart8250,mmio32,0xff1a0000 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
=> print bootargs
bootargs=earlycon=uart8250,mmio32,0xff1a0000 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
这里我通过root
属性指定了根文件系统所在位置,这里我使用的《ext4
类型的根文件系统》。
5.3.5 mmc
查看mmc
信息:
=> mmc list
mmc@fe320000: 1
mmc@fe330000: 0 (eMMC)
=> mmc info
Device: mmc@fe330000
Manufacturer ID: 15
OEM: 0
Name: AJNB4R
Bus Speed: 200000000
Mode: HS200 (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected
从上图中可以看到MMC
设备版本为5.1
, 14.6GiB
(eMMC
为16GB
),速度为20000000Hz=200MHz
, 8
位宽的总线。
5.4 烧录内核
5.4.1 下载kernel
我们将内核拷贝到tftp
文件目录:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# cp kernel.itb /work/tftpboot/
接着通过uboot
命令行将kernel.itb
下到内存地址0x10000000
处:
=> tftp 0x10000000 kernel.itb
ethernet@fe300000 Waiting for PHY auto negotiation to complete.... done
Speed: 100, full duplex
Using ethernet@fe300000 device
TFTP from server 192.168.0.200; our IP address is 192.168.0.105
Filename 'kernel.itb'.
Load address: 0x10000000
Loading: ###################################T #T #############################
#################################################################
#################################################################
############T #####################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################T ######################
#################################################################
####################
434.6 KiB/s
done
Bytes transferred = 13642712 (d02bd8 hex)
通过mmc write
命令将内核镜像烧录到eMMC
第0x8000
个扇区处:
=> mmc erase 0x8000 0xA000
MMC erase: dev # 0, block # 32768, count 40960 ... 40960 blocks erased: OK
=> mmc write 0x10000000 0x8000 0xA000
MMC write: dev # 0, block # 32768, count 40960 ... 40960 blocks written: OK
这里cnt
传入的是0xA000
,即写入大小为20MB
,已经大于kernel.itb
文件大小了。
5.4.2 bootm
启动内核
在uboot
命令行运行bootm 0x10000000
命令启动内核:
=> bootm 0x10000000
## Loading kernel from FIT Image at 10000000 ...
Using 'conf-1' configuration
Trying 'kernel' kernel subimage
Description: Vanilla Linux kernel
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x100000e8
Data Size: 13585031 Bytes = 13 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x00280000
Entry Point: 0x00280000
Hash algo: crc32
Hash value: 0578d39a
Hash algo: sha1
Hash value: f0790b17a3b016447624a6bb92736363d57a01ef
Verifying Hash Integrity ... crc32+ sha1+ OK
bootm_find_os images.os.load=0x280000 # kernel.its文件中kernel节点配置的"load"属性
bootm_find_os images.ep=0x280000 # kernel.its文件中kernel节点配置的"entry"属性
bootm_find_os images.os.image_start=0x100000e8
## Loading fdt from FIT Image at 10000000 ...
Using 'conf-1' configuration
Trying 'fdt' fdt subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x10cf4c98
Data Size: 55777 Bytes = 54.5 KiB
Architecture: AArch64
Load Address: 0x08300000
Hash algo: crc32
Hash value: c39db312
Hash algo: sha1
Hash value: 9e46b71eeb21f56806f66781dac12415cb25335b
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x10cf4c98 to 0x08300000
Booting using the fdt blob at 0x8300000
Working FDT set to 8300000
Uncompressing Kernel Image
kernel loaded at 0x00280000, end = 0x02948200
bootm_load_os 0x20000000=0x5aa5f00f
bootm_load_os 0x20000010=0xffffffff
Loading Device Tree to 00000000f4601000, end 00000000f46119e0 ... OK
Working FDT set to f4601000
## Transferring control to Linux (at address 280000)...
boot_jump_linux 0x280000=0xfa405a4d # 解压缩之后得到Image镜像,并加载到0x280000地址处
boot_jump_linux 0x280004=0x1469d827
boot_jump_linux 0x280014=0x0
boot_jump_linux 0xf4601000=0xedfe0dd0 #fdt镜像加载到0xf4601000地址处
boot_jump_linux 0xf4601004=0xe00000
boot_jump_linux 0xf4601014=0x11000000
Starting kernel ...
上面的日志信息里,我打印了内存地址0x280000
、0x280004
、0x280014
处的数据,可以看到和Image
镜像文件的内容是一样的。
![](https://gitee.com/zyly2033/blog-pic/raw/master/RockchipRK3399-移植uboot2023.04&linux6.3.md.assets/1328274-20230612235933103-772004701.png)
同时也打印了内存地址0xf4601000
、0xf4601004
、0xf4601014
处的数据,这里地址0xf4601004
和rk3399-evb.dtb
镜像文件内容不太一样,这个字段是表示itb
文件大小的(可能uboot
修改了这个字段的值),其它两个地址数据一样的。
![](https://gitee.com/zyly2033/blog-pic/raw/master/RockchipRK3399-移植uboot2023.04&linux6.3.md.assets/1328274-20230528173427339-237687883.png)
这里说明uboot
已经成功解压了zImage
,并将解压后的Image
加载到了0x280000
地址处,这个地址就是我们在kernel.its
文件kernel
节点load
属性指定的地址。
但是设备树的地址我们在kernel.its
文件fdt
节点load
属性指定的地址为0x8300000
,这里却被uboot
重定位到了0xf4601000
;
Working FDT set to 8300000
Uncompressing Kernel Image
kernel loaded at 0x00280000, end = 0x02948200
bootm_load_os 0x20000000=0x5aa5f00f
bootm_load_os 0x20000010=0xffffffff
Loading Device Tree to 00000000f4601000, end 00000000f46119e0 ... OK
Working FDT set to f4601000
不过这并不重要,因为它并不影响内核的启动。我们把内核启动的全部内容显示出来:
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.3.0 (root@zhengyang) (arm-linux-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205, GNU ld (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 2.39.0.20221210) #10 SMP PREEMPT Tue Jun 13 20:34:22 CST 2023
[ 0.000000] Machine model: Rockchip RK3399 Evaluation Board
[ 0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] efi: UEFI not found.
[ 0.000000] [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader!
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] NUMA: NODE_DATA [mem 0xf77ea9c0-0xf77ecfff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] On node 0, zone DMA: 512 pages in unavailable ranges
[ 0.000000] cma: Reserved 32 MiB at 0x00000000f5600000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.1 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: MIGRATE_INFO_TYPE not supported.
[ 0.000000] psci: SMC Calling Convention v1.2
[ 0.000000] percpu: Embedded 22 pages/cpu s50472 r8192 d31448 u90112
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] CPU features: detected: ARM erratum 845719
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 999432
[ 0.000000] Policy zone: DMA
[ 0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
[ 0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[ 0.000000] Memory: 3909540K/4061184K available (16832K kernel code, 4192K rwdata, 10164K rodata, 8384K init, 607K bss, 118876K reserved, 32768K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=6, Nodes=1
[ 0.000000] rcu: Preemptible hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=6.
[ 0.000000] Trampoline variant of Tasks RCU enabled.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=6
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[ 0.000000] GICv3: 256 SPIs implemented
[ 0.000000] GICv3: 0 Extended SPIs implemented
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GICv3: GICv3 features: 16 PPIs
[ 0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000fef00000
[ 0.000000] ITS [mem 0xfee20000-0xfee3ffff]
[ 0.000000] ITS@0x00000000fee20000: allocated 65536 Devices @2c80000 (flat, esz 8, psz 64K, shr 0)
[ 0.000000] ITS: using cache flushing for cmd queue
[ 0.000000] GICv3: using LPI property table @0x0000000002c40000
[ 0.000000] GIC: using cache flushing for LPI property table
[ 0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000002c50000
[ 0.000000] GICv3: GIC: PPI partition interrupt-partition-0[0] { /cpus/cpu@0[0] /cpus/cpu@1[1] /cpus/cpu@2[2] /cpus/cpu@3[3] }
[ 0.000000] GICv3: GIC: PPI partition interrupt-partition-1[1] { /cpus/cpu@100[4] /cpus/cpu@101[5] }
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[ 0.000001] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[ 0.013109] Console: colour dummy device 80x25
[ 0.018014] printk: console [tty0] enabled
[ 0.023578] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
[ 0.034909] pid_max: default: 32768 minimum: 301
[ 0.040105] LSM: initializing lsm=capability,integrity
[ 0.045942] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.054130] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.065451] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.073479] cblist_init_generic: Setting shift to 3 and lim to 1.
[ 0.080319] cblist_init_generic: Setting shift to 3 and lim to 1.
[ 0.087362] rcu: Hierarchical SRCU implementation.
[ 0.092666] rcu: Max phase no-delay instances is 1000.
[ 0.098823] Platform MSI: msi-controller@fee20000 domain created
[ 0.105882] PCI/MSI: /interrupt-controller@fee00000/msi-controller@fee20000 domain created
[ 0.115273] fsl-mc MSI: msi-controller@fee20000 domain created
[ 0.128185] EFI services will not be available.
[ 0.133726] smp: Bringing up secondary CPUs ...
[ 0.139533] Detected VIPT I-cache on CPU1
[ 0.139614] GICv3: CPU1: found redistributor 1 region 0:0x00000000fef20000
[ 0.139638] GICv3: CPU1: using allocated LPI pending table @0x0000000002c60000
[ 0.139698] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 0.140573] Detected VIPT I-cache on CPU2
[ 0.140635] GICv3: CPU2: found redistributor 2 region 0:0x00000000fef40000
[ 0.140654] GICv3: CPU2: using allocated LPI pending table @0x0000000002c70000
[ 0.140694] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[ 0.141463] Detected VIPT I-cache on CPU3
[ 0.141525] GICv3: CPU3: found redistributor 3 region 0:0x00000000fef60000
[ 0.141543] GICv3: CPU3: using allocated LPI pending table @0x0000000002d00000
[ 0.141581] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[ 0.142388] CPU features: detected: Spectre-v2
[ 0.142401] CPU features: detected: Spectre-v3a
[ 0.142411] CPU features: detected: Spectre-BHB
[ 0.142422] CPU features: detected: ARM erratum 1742098
[ 0.142430] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[ 0.142436] Detected PIPT I-cache on CPU4
[ 0.142507] GICv3: CPU4: found redistributor 100 region 0:0x00000000fef80000
[ 0.142526] GICv3: CPU4: using allocated LPI pending table @0x0000000002d10000
[ 0.142566] CPU4: Booted secondary processor 0x0000000100 [0x410fd082]
[ 0.143449] Detected PIPT I-cache on CPU5
[ 0.143510] GICv3: CPU5: found redistributor 101 region 0:0x00000000fefa0000
[ 0.143528] GICv3: CPU5: using allocated LPI pending table @0x0000000002d20000
[ 0.143561] CPU5: Booted secondary processor 0x0000000101 [0x410fd082]
[ 0.143676] smp: Brought up 1 node, 6 CPUs
[ 0.312533] SMP: Total of 6 processors activated.
[ 0.317733] CPU features: detected: 32-bit EL0 Support
[ 0.323422] CPU features: detected: 32-bit EL1 Support
[ 0.329097] CPU features: detected: CRC32 instructions
[ 0.334912] CPU: All CPU(s) started at EL2
[ 0.339469] alternatives: applying system-wide alternatives
[ 0.349523] devtmpfs: initialized
[ 0.364959] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.375717] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[ 0.384171] pinctrl core: initialized pinctrl subsystem
[ 0.392872] DMI not present or invalid.
[ 0.397977] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.406071] DMA: preallocated 512 KiB GFP_KERNEL pool for atomic allocations
[ 0.414299] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.423204] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.431973] audit: initializing netlink subsys (disabled)
[ 0.438141] audit: type=2000 audit(0.300:1): state=initialized audit_enabled=0 res=1
[ 0.439821] thermal_sys: Registered thermal governor 'step_wise'
[ 0.446700] thermal_sys: Registered thermal governor 'power_allocator'
[ 0.453384] cpuidle: using governor menu
[ 0.465151] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[ 0.472830] ASID allocator initialised with 65536 entries
[ 0.481540] Serial: AMBA PL011 UART driver
[ 0.514068] platform fe330000.mmc: Fixed dependency cycle(s) with /syscon@ff770000/phy@f780
[ 0.527861] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff8f0000/port/endpoint@2
[ 0.537554] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff900000/port/endpoint@2
[ 0.553098] gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.563190] rockchip-gpio ff720000.gpio: probed /pinctrl/gpio@ff720000
[ 0.570872] gpio gpiochip1: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.580854] rockchip-gpio ff730000.gpio: probed /pinctrl/gpio@ff730000
[ 0.588446] gpio gpiochip2: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.598423] rockchip-gpio ff780000.gpio: probed /pinctrl/gpio@ff780000
[ 0.606080] gpio gpiochip3: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.616047] rockchip-gpio ff788000.gpio: probed /pinctrl/gpio@ff788000
[ 0.623640] gpio gpiochip4: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.633599] rockchip-gpio ff790000.gpio: probed /pinctrl/gpio@ff790000
[ 0.645353] KASLR disabled due to lack of seed
[ 0.651086] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[ 0.658571] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[ 0.665471] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[ 0.672946] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[ 0.679841] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[ 0.687317] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[ 0.694212] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[ 0.701686] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[ 0.710727] ACPI: Interpreter disabled.
[ 0.720526] iommu: Default domain type: Translated
[ 0.725908] iommu: DMA domain TLB invalidation policy: strict mode
[ 0.733129] SCSI subsystem initialized
[ 0.737778] usbcore: registered new interface driver usbfs
[ 0.743856] usbcore: registered new interface driver hub
[ 0.749757] usbcore: registered new device driver usb
[ 0.756953] pps_core: LinuxPPS API ver. 1 registered
[ 0.762431] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.772495] PTP clock support registered
[ 0.777057] EDAC MC: Ver: 3.0.0
[ 0.781570] scmi_core: SCMI protocol bus registered
[ 0.788163] FPGA manager framework
[ 0.792025] Advanced Linux Sound Architecture Driver Initialized.
[ 0.799773] vgaarb: loaded
[ 0.803133] clocksource: Switched to clocksource arch_sys_counter
[ 0.810077] VFS: Disk quotas dquot_6.6.0
[ 0.814451] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 0.822222] pnp: PnP ACPI: disabled
[ 0.836111] NET: Registered PF_INET protocol family
[ 0.841763] IP idents hash table entries: 65536 (order: 7, 524288 bytes, linear)
[ 0.854222] tcp_listen_portaddr_hash hash table entries: 2048 (order: 3, 32768 bytes, linear)
[ 0.863731] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.872279] TCP established hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.881351] TCP bind hash table entries: 32768 (order: 8, 1048576 bytes, linear)
[ 0.890767] TCP: Hash tables configured (established 32768 bind 32768)
[ 0.898104] UDP hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.905638] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.913764] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.920458] RPC: Registered named UNIX socket transport module.
[ 0.926992] RPC: Registered udp transport module.
[ 0.932177] RPC: Registered tcp transport module.
[ 0.937354] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.944464] PCI: CLS 0 bytes, default 64
[ 0.949954] hw perfevents: enabled with armv8_cortex_a53 PMU driver, 7 counters available
[ 0.959485] hw perfevents: enabled with armv8_cortex_a72 PMU driver, 7 counters available
[ 0.969106] kvm [1]: IPA Size Limit: 40 bits
[ 0.976120] kvm [1]: vgic-v2@fff20000
[ 0.980204] kvm [1]: GIC system register CPU interface enabled
[ 0.986676] kvm [1]: vgic interrupt IRQ18
[ 0.991150] kvm [1]: Hyp mode initialized successfully
[ 0.998787] Initialise system trusted keyrings
[ 1.003910] workingset: timestamp_bits=42 max_order=20 bucket_order=0
[ 1.011432] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 1.018176] NFS: Registering the id_resolver key type
[ 1.023780] Key type id_resolver registered
[ 1.028394] Key type id_legacy registered
[ 1.032831] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 1.040219] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 1.048573] 9p: Installing v9fs 9p2000 file system support
[ 1.119296] Key type asymmetric registered
[ 1.123820] Asymmetric key parser 'x509' registered
[ 1.129248] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 244)
[ 1.137396] io scheduler mq-deadline registered
[ 1.142393] io scheduler kyber registered
[ 1.146849] io scheduler bfq registered
[ 1.180430] EINJ: ACPI disabled.
[ 1.231249] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 1.242233] printk: console [ttyS2] disabled
[ 1.247034] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 35, base_baud = 1500000) is a 16550A
[ 1.257065] printk: console [ttyS2] enabled
[ 1.257065] printk: console [ttyS2] enabled
[ 1.266470] printk: bootconsole [uart8250] disabled
[ 1.266470] printk: bootconsole [uart8250] disabled
[ 1.281782] SuperH (H)SCI(F) driver initialized
[ 1.288044] msm_serial: driver initialized
[ 1.299601] rockchip-vop ff8f0000.vop: Adding to iommu group 2
[ 1.306774] rockchip-vop ff900000.vop: Adding to iommu group 3
[ 1.318768] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 1.327772] [drm] unsupported AFBC format[3231564e]
[ 1.334310] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 1.343313] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 1.352821] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 1.370531] loop: module loaded
[ 1.376007] megasas: 07.725.01.00-rc1
[ 1.392334] tun: Universal TUN/TAP device driver, 1.6
[ 1.399740] thunder_xcv, ver 1.0
[ 1.403420] thunder_bgx, ver 1.0
[ 1.407073] nicpf, ver 1.0
[ 1.412706] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[ 1.420821] hns3: Copyright (c) 2017 Huawei Corporation.
[ 1.426832] hclge is initializing
[ 1.430574] e1000: Intel(R) PRO/1000 Network Driver
[ 1.436044] e1000: Copyright (c) 1999-2006 Intel Corporation.
[ 1.442518] e1000e: Intel(R) PRO/1000 Network Driver
[ 1.448083] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 1.454752] igb: Intel(R) Gigabit Ethernet Network Driver
[ 1.460808] igb: Copyright (c) 2007-2014 Intel Corporation.
[ 1.467078] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[ 1.474101] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[ 1.481444] sky2: driver version 1.30
[ 1.487833] rk_gmac-dwmac fe300000.ethernet: IRQ eth_wake_irq not found
[ 1.495271] rk_gmac-dwmac fe300000.ethernet: IRQ eth_lpi not found
[ 1.502294] rk_gmac-dwmac fe300000.ethernet: PTP uses main clock
[ 1.509181] rk_gmac-dwmac fe300000.ethernet: clock input or output? (input).
[ 1.517090] rk_gmac-dwmac fe300000.ethernet: TX delay(0x28).
[ 1.523434] rk_gmac-dwmac fe300000.ethernet: RX delay(0x11).
[ 1.529783] rk_gmac-dwmac fe300000.ethernet: integrated PHY? (no).
[ 1.536760] rk_gmac-dwmac fe300000.ethernet: cannot get clock clk_mac_speed
[ 1.544563] rk_gmac-dwmac fe300000.ethernet: clock input from PHY
[ 1.556401] rk_gmac-dwmac fe300000.ethernet: init for RGMII
[ 1.562846] rk_gmac-dwmac fe300000.ethernet: User ID: 0x10, Synopsys ID: 0x35
[ 1.570863] rk_gmac-dwmac fe300000.ethernet: DWMAC1000
[ 1.576723] rk_gmac-dwmac fe300000.ethernet: DMA HW capability register supported
[ 1.585109] rk_gmac-dwmac fe300000.ethernet: RX Checksum Offload Engine supported
[ 1.593492] rk_gmac-dwmac fe300000.ethernet: COE Type 2
[ 1.599347] rk_gmac-dwmac fe300000.ethernet: TX Checksum insertion supported
[ 1.607243] rk_gmac-dwmac fe300000.ethernet: Wake-Up On Lan supported
[ 1.614526] rk_gmac-dwmac fe300000.ethernet: Normal descriptors
[ 1.621165] rk_gmac-dwmac fe300000.ethernet: Ring mode enabled
[ 1.627700] rk_gmac-dwmac fe300000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[ 1.725692] RTL8211E Gigabit Ethernet stmmac-0:00: attached PHY driver (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[ 1.737022] RTL8211E Gigabit Ethernet stmmac-0:01: attached PHY driver (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[ 1.750894] VFIO - User Level meta-driver version: 0.3
[ 1.762894] ehci-platform fe3c0000.usb: EHCI Host Controller
[ 1.762921] ohci-platform fe3e0000.usb: Generic Platform OHCI controller
[ 1.762927] usbcore: registered new interface driver usb-storage
[ 1.762970] ohci-platform fe3e0000.usb: new USB bus registered, assigned bus number 1
[ 1.763109] ehci-platform fe380000.usb: EHCI Host Controller
[ 1.763164] ohci-platform fe3a0000.usb: Generic Platform OHCI controller
[ 1.763179] ehci-platform fe380000.usb: new USB bus registered, assigned bus number 2
[ 1.763202] ohci-platform fe3a0000.usb: new USB bus registered, assigned bus number 3
[ 1.763202] ohci-platform fe3e0000.usb: irq 46, io mem 0xfe3e0000
[ 1.763322] ohci-platform fe3a0000.usb: irq 45, io mem 0xfe3a0000
[ 1.763350] ehci-platform fe380000.usb: irq 44, io mem 0xfe380000
[ 1.769276] ehci-platform fe3c0000.usb: new USB bus registered, assigned bus number 4
[ 1.779176] ehci-platform fe380000.usb: USB 2.0 started, EHCI 1.00
[ 1.782039] i2c_dev: i2c /dev entries driver
[ 1.783583] ehci-platform fe3c0000.usb: irq 43, io mem 0xfe3c0000
[ 1.785806] i2c 0-001b: Fixed dependency cycle(s) with /i2c@ff3c0000/pmic@1b/regulators/LDO_REG3
[ 1.793423] hub 2-0:1.0: USB hub found
[ 1.815152] ehci-platform fe3c0000.usb: USB 2.0 started, EHCI 1.00
[ 1.823816] hub 2-0:1.0: 1 port detected
[ 1.897974] hub 3-0:1.0: USB hub found
[ 1.902230] hub 3-0:1.0: 1 port detected
[ 1.907920] hub 1-0:1.0: USB hub found
[ 1.912251] hub 1-0:1.0: 1 port detected
[ 1.917979] hub 4-0:1.0: USB hub found
[ 1.922297] hub 4-0:1.0: 1 port detected
[ 2.415160] usb 3-1: new low-speed USB device number 2 using ohci-platform
[ 2.511156] usb 1-1: new full-speed USB device number 2 using ohci-platform
[ 2.803153] rk3x-i2c ff3c0000.i2c: timeout, ipd: 0x00, state: 1
[ 2.809826] rk808 0-001b: failed to read the chip id at 0x17
[ 2.819375] rk808: probe of 0-001b failed with error -110
[ 2.826856] fan53555-regulator 0-0040: FAN53555 Option[8] Rev[1] Detected!
[ 2.839172] fan53555-regulator 0-0041: FAN53555 Option[8] Rev[1] Detected!
[ 2.857836] dw_wdt ff848000.watchdog: No valid TOPs array specified
[ 2.867639] ghes_edac: GHES probing device list is empty
[ 2.868054] cpu cpu0: OPP table can't be empty
[ 2.882691] sdhci: Secure Digital Host Controller Interface driver
[ 2.889639] sdhci: Copyright(c) Pierre Ossman
[ 2.896259] Synopsys Designware Multimedia Card Interface Driver
[ 2.905203] sdhci-pltfm: SDHCI platform and OF driver helper
[ 2.914795] mmc0: CQHCI version 5.10
[ 2.919687] ledtrig-cpu: registered to indicate activity on CPUs
[ 2.928460] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[ 2.943208] mmc0: SDHCI controller on fe330000.mmc [fe330000.mmc] using ADMA
[ 2.944417] input: SEMICO USB Keyboard as /devices/platform/fe3a0000.usb/usb3/3-1/3-1:1.0/0003:1A2C:4D7E.0001/input/input0
[ 3.015984] mmc0: Command Queue Engine enabled
[ 3.021041] mmc0: new HS400 Enhanced strobe MMC card at address 0001
[ 3.024072] hid-generic 0003:1A2C:4D7E.0001: input: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-fe3a0000.usb-1/input0
[ 3.029182] mmcblk0: mmc0:0001 AJNB4R 14.6 GiB
[ 3.050954] mmcblk0: p1 p2 p3 p4 p5
[ 3.057429] mmcblk0boot0: mmc0:0001 AJNB4R 4.00 MiB
[ 3.057457] input: SEMICO USB Keyboard Consumer Control as /devices/platform/fe3a0000.usb/usb3/3-1/3-1:1.1/0003:1A2C:4D7E.0002/input/input1
[ 3.064770] mmcblk0boot1: mmc0:0001 AJNB4R 4.00 MiB
[ 3.084536] mmcblk0rpmb: mmc0:0001 AJNB4R 4.00 MiB, chardev (511:0)
[ 3.135923] input: SEMICO USB Keyboard System Control as /devices/platform/fe3a0000.usb/usb3/3-1/3-1:1.1/0003:1A2C:4D7E.0002/input/input2
[ 3.150246] input: SEMICO USB Keyboard as /devices/platform/fe3a0000.usb/usb3/3-1/3-1:1.1/0003:1A2C:4D7E.0002/input/input4
[ 3.163010] hid-generic 0003:1A2C:4D7E.0002: input: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-fe3a0000.usb-1/input1
[ 3.179596] input: Logitech USB Receiver as /devices/platform/fe3e0000.usb/usb1/1-1/1-1:1.0/0003:046D:C52B.0003/input/input5
[ 3.252224] hid-generic 0003:046D:C52B.0003: input: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-fe3e0000.usb-1/input0
[ 3.272289] input: Logitech USB Receiver Mouse as /devices/platform/fe3e0000.usb/usb1/1-1/1-1:1.1/0003:046D:C52B.0004/input/input6
[ 3.286466] input: Logitech USB Receiver Consumer Control as /devices/platform/fe3e0000.usb/usb1/1-1/1-1:1.1/0003:046D:C52B.0004/input/input7
[ 3.360107] input: Logitech USB Receiver System Control as /devices/platform/fe3e0000.usb/usb1/1-1/1-1:1.1/0003:046D:C52B.0004/input/input8
[ 3.374790] hid-generic 0003:046D:C52B.0004: input: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-fe3e0000.usb-1/input1
[ 3.392518] hid-generic 0003:046D:C52B.0005: device has no listeners, quitting
[ 3.400782] usbcore: registered new interface driver usbhid
[ 3.407044] usbhid: USB HID core driver
[ 3.426309] NET: Registered PF_PACKET protocol family
[ 3.432113] 9pnet: Installing 9P2000 support
[ 3.436996] Key type dns_resolver registered
[ 3.466889] registered taskstats version 1
[ 3.472081] Loading compiled-in X.509 certificates
[ 3.523516] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 3.533689] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 3.542698] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 3.552304] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 3.561921] dwhdmi-rockchip ff940000.hdmi: Detected HDMI TX controller v2.11a with HDCP (DWC HDMI 2.0 TX PHY)
[ 3.575737] rockchip-drm display-subsystem: bound ff940000.hdmi (ops dw_hdmi_rockchip_ops)
[ 3.586591] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
[ 3.720667] Console: switching to colour frame buffer device 240x67
[ 3.766105] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[ 3.778697] ALSA device list:
[ 3.782111] No soundcards found.
[ 3.787386] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console
[ 3.801786] EXT4-fs (mmcblk0p5): mounted filesystem d1a04c89-1570-4150-95b4-be1eca7ea034 with ordered data mode. Quota mode: none.
[ 3.815965] VFS: Mounted root (ext4 filesystem) on device 179:5.
[ 3.823330] devtmpfs: mounted
[ 3.832426] Freeing unused kernel memory: 8384K
[ 3.837770] Run /sbin/init as init process
Please press Enter to activate this console. [ 13.939869] amba ff6d0000.dma-controller: deferred probe pending
[ 13.946698] amba ff6e0000.dma-controller: deferred probe pending
六、镜像文件下载
链接:https://pan.baidu.com/s/1qCDCnwdDlpGsJqfkArQy-A?pwd=1m19
。
参考文章
[1] Rockchip
参考官方移植
[2] Rockchip RK3399 - TPL/SPL
方式加载uboot
[3] 嵌入式Linux
之uboot
源码make
配置编译正向分析
[4] 嵌入式ARM64 Linux
内核FIT uimage
方式启动