记录移植Uboot

建立自己的UBOOT编译配置

复制设置并写入.config

1
2
3
4
5
6
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/configs$ cp mx6ull_14x14_evk_emmc_defconfig igboard_defconfig
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/configs$ cd ..
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ make igboard_defconfig
#
# configuration written to .config
#

复制设置并写入.config

进入配置界面,修改配置文件

1
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ make menuconfig

image-20230525125218765

uboot配置节目

按选项来依次介绍是

ARM architecture ARM架构

ARM architecture ARM架构

用于指定芯片的ARM体系结构,有助于保证U-Boot与特定ARM处理器的指令集和硬件兼容性。

修改i.MX配置文件路径为自定义的板级支持包内的文件

ARM architecture

修改i.MX配置文件路径

格式为board\公司名称\产品名称\imximage.cfg

修改完毕后

General setup 一般设置

General setup 一般设置

其子菜单包含一些内核通用配置选项

() Local version - append to U-Boot release 允许用户在U-Boot版本后追加自定义标识符
[ * ] Automatically append version information to the version string 自动在版本后添加版本信息
[ * ] Optimize for size 优化固件大小。
[ ] Allow compiler to uninline functions marked ‘inline’ in full U-Boot 允许编译器取消内联标记为’inline’的函数。
[ ] Enable Link Time Optimizations 启用连接时优化。
[ ] Select U-Boot be run as a bootloader for XEN Virtual Machine 选择U-Boot作为XEN虚拟机的引导程序。
[ ] Select defaults suitable for booting general purpose Linux distributions 选择适用于引导通用Linux发行版的默认值。
[ ] Add arch, board, vendor and soc variables to default environment 将arch、board、vendor和soc变量添加到默认环境中。
(1) Number of DRAM banks DRAM存储器数量。
[ ] Enable kernel command line setup 启用内核命令行设置。
[ ] Enable kernel board information setup 启用内核板信息设置。
-*- Enable malloc() pool before relocation 在重定位之前启用malloc()池。
(0x2000) Size of malloc() pool before relocation 重定位之前的malloc()池的大小。
(0x1000000) Define memory for Dynamic allocation 定义动态分配的内存。0x1000000=16MB
[ * ] Configure standard U-Boot features (expert users) —> 配置标准U-Boot功能(专家用户)。

​ — Configure standard U-Boot features (expert users) 这个选项允许用户配置标准 U-Boot 功能,通常是供专家用户使用的。

​ [*] Init with zeros the memory reserved for malloc (slow)

​ 这个选项指定在使用 malloc 函数时是否将内存初始化为零。如果启用了此选项,malloc 分配的内存将被初始化为零。这会增加分配内存的时间,因为需要清零所有位。

​ [ ] Default malloc to init while reserving the memory for it 这个选项指定是否在 malloc 函数调用时初始化内存。如果没有启用此选项,则分配给 malloc 的内存不会被初始化,默认情况下,仅在第一次使用时才进行初始化。

​ [ ] Enable debug information for tools 这个选项指定是否启用工具的调试信息。如果启用此选项,则可以在调试 U-Boot 时获得更多信息。

[ ] 64bit physical address support 支持64位物理地址。
[ ] Recreate an ELF image from raw U-Boot binary 从原始U-Boot二进制文件重新创建ELF映像。
() Build target special images 构建目标特殊图像。
[ ] Use a custom location for the U-Boot linker script 使用自定义位置
(0x80800000) Address in memory to use by default 默认情况下在内存中使用的地址
(0x1000000) Define max stack size that can be used by U-Boot 定义U-Boot可用的最大堆栈大小。
[ ] Support for multiprocessor 支持多处理。
[ ] Compile API examples 编译API示例。

保持默认

General setup

API

API

用于启用或禁用 U-Boot 应用程序编程接口(API)。该选项允许其他软件使用 U-Boot 提供的 API 接口来与 U-Boot 进行通信,并执行一些操作,比如读取和写入存储设备、设置系统参数等。

保持默认

API

Boot Options 启动选项

Boot Options 启动选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 Boot images  --->      用于配置启动映像
[*] Enable support for Android Boot Images 启用对Android引导镜像的支持。
[ ] Support Flattened Image Tree 支持压缩映像树(FDT)。它是一种描述硬件设备和资源分配的数据结构。
[ ] Show image date and time when displaying image information 当显示映像信息时,显示映像的日期和时间。
[*] Enable support for the legacy image format 启用对旧版映像格式的支持。
[*] Enable raw initrd images 启用原始initrd映像的支持。
[ ] Set up board-specific details in device tree before boot 在启动之前在设备树中设置板级细节。
-*- Set up system-specific details in device tree before boot 在启动之前在设备树中设置系统级细节。
[ ] Update the device-tree stdout alias from U-Boot 从U-Boot更新设备树stdout别名。
() Extra Options (DEPRECATED) 额外选项(弃用)。
(0x87800000) Text Base 文本基准地址。
[ ] Determine CPU clock frequency at run-time 在运行时确定CPU时钟频率。
(0) CPU clock frequency CPU时钟频率。
[*] Enable arch_fixup_memory_banks() call 启用arch_fixup_memory_banks()调用。
[ ] Support booting Chrome OS 支持启动Chrome OS。
[ ] Support Chrome OS verified boot 支持Chrome OS验证启动。
[ ] Freescale PBL(pre-boot loader) image format support 支持Freescale PBL(预启动程序)映像格式。
Boot timing ---> 启动时间设置
[ ] Boot timing and reporting 使能引导时间计时和报告功能。
(0) Address to stash boot timing information 指定存储启动时间信息的内存地址。
(0x1000) Size of boot timing stash region 指定存储启动时间信息的内存大小。
[ ] Show boot progress in a board-specific manner 选择是否以板级特定的方式显示启动进度。
Boot media ---> 启动介质设置
[ ] Support for booting from NAND flash
[ ] Support for booting from ONENAND
[ ] Support for booting from QSPI flash
[ ] Support for booting from SATA
[ ] Support for booting from SD/EMMC
[ ] Support for booting from SD/EMMC and enable QSPI
[ ] Support for booting from SPI flash
Autoboot options ---> 自动引导选项
[*] Autoboot 启动自动引导
(3) delay in seconds before automatically booting 指系统从上电开始到自动启动操作系统之间的等待时间,这里设置为3s
[ ] Stop autobooting via specific input key / string 表示是否允许用户通过特定的输入键或字符串来停止自动引导过程,这里没设置故为任意键,反之设置了就需要按特定键位才能停止自动引导
[ ] Allow a specify key to run a menu from the environment 表示是否允许用户在系统运行过程中通过按下某个指定的键来进入引导菜单。这个选项可以让用户在需要时快速地进入到引导菜单中,选择要启动的操作系统或者执行其他的操作。
[ ] Enable boot arguments 启用启动参数。
[ ] Support substituting strings in boot arguments支持在启动参数中进行字符串替换
[*] Enable a default value for bootcmd 启用默认的启动命令
() bootcmd value 用户可以在这里输入默认的启动命令,或者对现有的启动命令进行修改
[ ] Enable preboot 启用预启动设置。这个选项可以让用户在系统启动之前进行一些基本的配置,例如设置环境变量或者初始化硬件设备,以便系统能够顺利地启动。
() Default fdt file 这个选项是针对嵌入式设备的,允许用户指定一个默认的设备树文件,以便系统能够正确地识别和使用硬件设备。

Boot Options 启动选项

保持默认即可

Console 控制台功能

Console 控制台功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[ ] Console recording                                                  该选项允许将控制台输出记录到文件中,以便在后期分析。
[ ] Add functionality to disable console completely 这个选项可以禁用所有控制台输出,通常在需要更高安全性的环境中使用。
() Board specific string to be added to uboot version string 该选项允许为U-Boot版本字符串添加特定于板子的标识。
(4) loglevel 该选项定义了控制台输出的日志级别,包括DEBUG、INFO、WARNING等级别。
[ ] Support a silent console 如果启用此选项,控制台将不会在启动时显示,但仍然可以通过串口等方式进行交互。
[ ] Buffer characters before the console is available 此选项允许在控制台可用之前缓冲字符,以防止在控制台准备好之前丢失有用信息。
-*- Enable console multiplexing 该选项允许将控制台输出发送到多个设备,例如串口和LCD屏幕等。
[*] Select console devices from the environment 选择可用的控制台设备列表
[ ] Allow board control over console overwriting 允许板子控制是否覆盖控制台输出
[ ] Update environment variables during console init 允许在控制台初始化期间更新环境变量
[ ] Don't display the console devices on boot 启用此选项后,控制台设备列表将不会在启动时显示。
-*- Allow deregistering stdio devices 允许注销控制台设备。
[ ] Allow deregistering stdio devices in SPL 在SPL(Secondary Program Loader)中也允许注销控制台设备
[*] Enable a null device for stdio 启用空设备以进行stdio输出。

Console 控制台功能

同样保持官方配置文件即可

Logging 日志记录

Logging 日志记录

Logging —>

​ [ ] Enable logging support 启用日志记录支持

Logging  日志记录

保持默认

Init options 初始化选项

Init options 初始化选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[ ] Call get_board_type() to get and display the board type          调用 get_board_type() 函数以获取并显示板子类型
[*] Display information about the CPU during start up 在启动期间显示有关 CPU 的信息
[*] Display information about the board during early start up 在早期启动期间显示有关板子的信息
[ ] Display information about the board during late start up 在晚期启动期间显示有关板子的信息

Start-up hooks ---> 启动钩子 (Start-up hooks)
[ ] Call arch-specific init soon after relocation 在重定位后立即调用特定于架构的初始化函数
[*] Call arch-specific init after relocation, when console is ready 在重定位后等待控制台准备就绪后再调用特定于架构的初始化函数
[*] Call board-specific init before relocation 在重定位前调用特定于板子的初始化函数
[ ] Call board-specific init after relocation 在重定位后调用特定于板子的初始化函数
-*- Execute Board late init 执行板子的延迟初始化操作
[ ] Call board-specific as last setup step 将板子特定的初始化作为最后一个设置步骤进行调用
[ ] Execute pre-relocation misc init 执行重定位前的杂项初始化操作
[ ] Execute Misc Init 执行杂项初始化操作
[ ] Enable I2C connected system identifier EEPROM 启用连接到 I2C 总线的系统识别 EEPROM

Init options 初始化选项

Security support 安全支持

Security support 安全支持

[ ] Stack Protector buffer overflow detection Stack Protector 缓冲区溢出检测。Stack Protector是一种用于检测缓冲区溢出漏洞的安全机制。

Security support  安全支持

Update support 更新支持

Update support 更新支持

[ ] Android A/B updates Android A/B更新是一种特殊的系统更新方式,它可确保在进行系统更新时,设备仍能够正常运行。与传统的系统更新方式不同,A/B更新会将新版本的系统文件安装到一个完全独立的分区中,这个分区称为“slot”或者“分区槽”。

Update support 更新支持

Blob list Blob链表设置

Blob list Blob链表设置

[ ] Support for a bloblist 对 Blob链表支持

Blob list是一种数据结构,通常用于存储和管理二进制大对象(Binary Large Objects,BLOB),例如图像、音频、视频等文件。它是一种线性的数据结构,由一个或多个二进制块组成,每个块称为Blob,Blob之间通过指针进行链接。

Blob list可以快速定位和读取大文件中的特定部分,同时还可以支持在不同Blob之间进行随机访问。这使得Blob list在处理大型文件时非常有用,因为它可以按需加载和释放数据块,以减少内存消耗和提高性能。

Blob list通常用于后端服务中,例如云存储服务、数据库、文件系统等,也可以作为一种数据传输格式,用于在客户端和服务器之间传输二进制数据。它可以帮助开发人员有效地管理和维护大型数据集合,并提供了一种可靠、灵活的数据存储和访问方案。

总的来说,Blob list是一种非常重要的数据结构,可以用于处理大型二进制数据集合,并提供了高效、可靠的数据存储和访问方案。

Blob链表设置

SPL / TPL PHP标准库支持

SPL / TPL PHP标准库支持

1
2
3
[ ] Check and report stack usage in SPL before relocation           在 SPL 进行重定位之前检查和报告堆栈使用情况。
[ ] Show more information when something goes wrong 当程序出现错误时显示更多的信息。
PowerPC and LayerScape SPL Boot options ---- 针对 PowerPC 和 LayerScape 平台的 SPL 启动选项。

SPL(Standard PHP Library)和 TPL(Template PHP Library)都是 PHP 中的标准库,它们提供了许多内置的数据结构、算法和函数,以帮助 PHP 开发人员更轻松地处理常见问题。

SPL / TPL PHP标准库支持

没用,不用管

FDT tools for simplefb support FDT工具simplefb包支持

[ ]FDT tools for simplefb support FDT工具simplefb包支持

FDT(Firmware Development Tool)是一个用于嵌入式系统开发的工具,它可以帮助开发人员创建、编译和调试设备固件。在 FDT 中,simplefb 是一个支持的框架,用于管理和操作 Linux 内核中的简单帧缓冲设备。

FDT工具simplefb包支持

Command line interface 命令行界面配置

Command line interface 命令行界面配置

只是界面设置而已,没必要配,保持默认即可,需要了解请自行查阅资料,太多了

Command line interface  命令行界面配置

Partition Types 分区类型

Partition Types 分区类型

1
2
3
4
5
6
7
8
9
10
[*] Enable Partition Labels (disklabels) support               启用支持BSD样式分区标签的功能。
[ ] Enable Apple's MacOS partition table 启用支持苹果MacOS分区表的功能。
[*] Enable MS Dos partition table 启用支持MS-DOS分区表的功能。
[ ] Enable ISO partition table 启用支持ISO分区表的功能。
[ ] Enable AMIGA partition table 启用支持AMIGA分区表的功能。
-*- Enable EFI GPT partition table 启用支持EFI GPT分区表的功能。
(128) Number of the EFI partition entries 设定EFI分区条目的数量。
(0) Offset (in bytes) of the EFI partition entries 设定EFI分区条目在磁盘上的偏移量。
-*- Enable support of UUID for partition 启用支持使用UUID作为分区标识符的功能。
[ ] Enable support of GUID for partition type 启用支持使用GUID作为分区类型标识符的功能。

Partition Types  分区类型

无需更改

Device Tree Control 设备树控制

Device Tree Control 设备树控制

1
2
3
4
5
6
7
8
9
10
11
[*] Run-time configuration via Device Tree                                 表示可以在运行时通过设备树进行配置。
[ ] Board-specific manipulation of Device Tree 表示可以针对特定的开发板进行设备树的操作。
[ ] Enable use of a live tree 表示支持使用动态设备树(live tree)。
Provider of DTB for DT control (Separate DTB for DT control) ---> 表示提供了用于设备树控制的设备树二进制文件(DTB),可以单独为设备树控制生成不同的 DTB 文件。
[ ] Provided by the board (e.g a previous loader) at runtime 表示在运行时由开发板或之前的引导程序提供设备树。
[ ] Omit the device tree output when building 表示构建时省略设备树输出。
(igboard-imx6ull) Default Device Tree for DT control 指定用于设备树控制的默认设备树。
() Extra .dtsi files to include when building DT control 表示构建设备树控制时需要包含的其他设备树源文件。
(0x8000) Size of memory reserved to uncompress the DTBs 表示保留用于解压缩设备树二进制文件(DTB)的内存大小。
[ ] Support embedding several DTBs in a FIT image for u-boot 表示支持在 FIT 镜像中嵌入多个 DTB。
[ ] Enable removal of device tree properties 表示允许移除设备树属性。

Device Tree Control 设备树控制

Provider of DTB for DT control

这里我们就可以把原版的Default Device Tree for DT control 中的名称自定义为我们自己设置让他加载的默认的设备树文件

1
2
3
# 这里设置名称为igboard-imx6ull
# 那么在uboot引导阶段就会去读取默认名称为igboard-imx6ull.dtb的设备树文件
(igboard-imx6ull) Default Device Tree for DT control

Environment 环境变量

Environment 环境变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
()  Environment file to use                                                          这个选项允许用户指定一个特定的环境变量文件,U-Boot 将从该文件中加载和保存环境变量。如果不选择此选项,则 U-Boot 会使用默认的环境变量文件(通常是 boot.scr 或 u-boot.env)。
[*] Enable overwriting environment 这个选项启用了环境变量的覆盖功能,意味着当新的环境变量值被设置时,它们将覆盖旧值而不是追加到末尾。
[ ] Environment is not stored 这个选项表示环境变量不需要被存储在非易失性存储器中,而只在运行时存在。这通常用于一些临时测试或调试场景。
[ ] Environment in EEPROM 这个选项表示环境变量被存储在 EEPROM 中
[ ] Environment is in a FAT filesystem 这个选项表示环境变量被存储在一个 FAT 文件系统中,通常是一个 SD 卡或 USB 存储设备。
[ ] Environment is in a EXT4 filesystem 这个选项表示环境变量被存储在一个 EXT4 文件系统中,通常是某些 Linux 嵌入式设备的默认文件系统。
[ ] Environment in flash memory 这个选项表示环境变量被存储在闪存中
[*] Environment in an MMC device 这个选项表示环境变量被存储在一个 MMC 设备(例如 SD 卡)上。
[ ] Environment in a NAND device 这个选项表示环境变量被存储到NAND设备上
[ ] Environment in a non-volatile RAM
[ ] Environment is in OneNAND
[ ] Environment is in remote memory space
[ ] Environment is in SATA disk
[ ] Environment is in SPI flash
[ ] Enable redundant environment support 这个选项启用了环境变量的冗余支持功能,可以将多份相同的环境变量存储到不同的位置或介质上,以提高可靠性和可恢复性。
(0xE0000) Environment offset 指定了环境变量在存储介质中的偏移量,也就是从哪个地址开始读取和写入环境变量数据。
(0x2000) Environment Size 这个选项指定了环境变量数据的大小,以字节为单位。
[*] Relocate gd->env_addr 告诉 U-Boot 在运行时重新定位环境变量的内存地址,以防止与其他变量或数据重叠。
(1) mmc device number 这个选项指定了使用的 MMC 设备编号,在 U-Boot 中每个 MMC 设备都有一个唯一的编号。
(0) mmc partition number 指定了使用的 MMC 分区编号,在 U-Boot 中每个 MMC 设备上的每个分区都有一个唯一的编号。
[ ] Create default environment from file 如果选择了这个选项,U-Boot 将从文件中创建一个默认的环境变量,而不是使用预定义的默认值。这通常用于自定义配置和优化性能。
[*] Add run-time information to the environment 可以在运行时将信息添加到环境变量中
[ ] Amend environment by FDT properties 使用FDT属性修改环境变量。
[ ] Always append the environment with new data 始终将新数据追加到环境变量中。
[ ] Permit write access only to listed variables 只允许对列出的变量进行写访问。
[ ] Block forced environment operations 阻止强制执行环境操作。
[ ] Add a 'ver' environment variable with the U-Boot version 添加一个“ver”环境变量,其中包含U-Boot版本。

Environment  环境变量

Networking support 联网支持

Networking support 联网支持

1
2
3
4
5
6
7
8
9
10
11
12
13
14
--- Networking support                                                 
[ ] Enable generic udp framework 允许应用程序使用 UDP 协议进行通信
[ ] Send hostname to DNS server 将设备的主机名发送到 DNS 服务器以解析 IP 地址。
[*] Random ethaddr if unset 如果网络接口的 MAC 地址未设置,则随机生成一个。
[ ] NetConsole support 启用 NetConsole,一种通过网络远程调试和日志记录的方式。
[ ] Support IP datagram reassembly 在接收到分段 IP 数据报时重新组装它们。
(1468) TFTP block size 指定使用 TFTP 传输文件时每个块的最大大小(以字节为单位)。
(1) TFTP window size 指定 TFTP 传输期间窗口的大小,即发送方可以发送多少个数据块而无需等待确认。
[ ] Track TFTP transfers based on file size option 根据文件大小跟踪 TFTP 传输。
[ ] Get serverip value from Proxy DHCP response 从代理 DHCP 响应中获取 serverip,即 TFTP 服务器的 IP 地址。
(100) # of additional milliseconds to wait for ProxyDHCP response 等待 ProxyDHCP 响应的附加毫秒数(100):如果代理 DHCP 服务器响应时间较长,则可以通过增加此等待时间来等待响应。
[ ] Write the server's MAC address to 'serveraddr' 将 TFTP 服务器的 MAC 地址写入 'serveraddr' 环境变量。
[ ] Check the UDP checksum 启用 UDP 校验和检查
[ ] Use the 'serverip' env var for tftp, not bootp 使用 'serverip' 环境变量指定 TFTP 服务器的 IP 地址,而不是使用 BOOTP 协议。

Networking support  联网支持

这里只需要勾选一个随机网卡地址Random ethaddr if unset即可,为什么要设置随机网卡地址呢?我搜到的解释是

在 U-Boot 中,ethaddr 是 Ethernet MAC 地址的环境变量。如果没有设置 ethaddr,它将使用随机生成的 MAC 地址。这是为了避免在网络中出现重复的 MAC 地址,因为这可能会导致通信问题和网络故障。

在进行 U-Boot 测试时,打开 Random ethaddr if unset 选项可以确保测试环境中所有的网卡都具有唯一的 MAC 地址,从而避免意外发生通信问题和网络故障。此外,使用随机的 MAC 地址也有助于保护设备的安全性,因为攻击者难以预测设备的 MAC 地址,从而更难以进行针对性的攻击。

Device Drivers 设备驱动选项

不需要更改,保持设置

File systems 文件系统设置

File systems

1
2
3
4
5
6
7
8
9
10
11
12
13
14
这些是在Linux内核配置中的不同选项,用于启用不同类型的文件系统支持。
[ ] Enable BTRFS filesystem support BTRFS 是一种先进的文件系统,提供了高效的数据压缩和快照功能。
[ ] Enable CBFS (Coreboot Filesystem) CBFS 是 Coreboot 固件中嵌入的文件系统,可用于存储引导加载程序和其他固件相关文件。
[ ] Enable CBFS (Coreboot Filesystem) in SPL SPL 是 U-Boot 的第一个阶段启动程序,CBFS 支持可以让 SPL 读取 Coreboot 文件系统中的文件。
-*- Enable ext4 filesystem support ext4 是一种流行的 Linux 文件系统,提供了高性能和可靠性。
-*- Enable ext4 filesystem write support 允许对 ext4 文件系统进行写操作。
-*- Enable FAT filesystem support FAT 是一种常见的文件系统格式,通常用于移动设备和 Windows 系统之间的文件共享。
-*- Enable FAT filesystem write support 允许对 FAT 文件系统进行写操作。
(65536) Set maximum possible clustersize 设置 FAT 文件系统所使用的最大簇大小。
[ ] Enable JFFS2 filesystem support JFFS2 是一种针对闪存设备的文件系统,具有可靠性和高效性。
[ ] UBIFS silence verbose messages UBIFS 是用于闪存设备的更高级别的文件系统,可减少 UBIFS 冗长的输出消息。
[ ] Enable CRAMFS filesystem support CRAMFS 是一种只读文件系统,通常用于嵌入式设备上。
[ ] YAFFS2 filesystem support YAFFS2 是一种专门为闪存设备设计的文件系统,具有高效性和可靠性。
[ ] Enable SquashFS filesystem support SquashFS 是一种只读文件系统,通常用于 Linux 安装介质。

File systems 文件系统设置

Library routines 常用C库函数

Library routines 常用C库函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[ ] Enable support for non-identity virtual-physical mappings                                       
[ ] Access to physical memory region (> 4G)
[ ] Enable Software based BCH ECC
[ ] Optimize libraries for speed
[ ] Enable Dynamic tables for CRC
(0x80000) Android sparse image CHUNK_TYPE_FILL buffer size
[*] Use private libgcc
[ ] Do not reset the system on fatal error
-*- Enable regular expression support
Pseudo-random library support type (Pseudo-random library support) --->
[ ] Generate an ACPI (Advanced Configuration and Power Interface) table
[ ] Use a very small memset() in SPL
[ ] Use a very small memset() in TPL
[ ] Bit reverse library from Linux
[ ] Support for tracing of function calls and timing
[ ] Enable circular buffer support
[ ] Support the 'dhry' command to run the dhrystone benchmark
Security support --->
Android Verified Boot --->
Hashing Support --->
Compression Support --->
[ ] Enable function for getting errno-related string message
-*- Enable hexdump
[ ] Enable getopt
-*- Enable the FDT library
(0) Mask of conditions to assume for libfdt
[*] Enable the FDT library overlay support
[ ] Enable the FDT library for SPL
[ ] Enable the FDT library for TPL
[ ] SMBIOS parser
[*] Support running UEFI applications
[*] UEFI Boot Manager
Store for non-volatile UEFI variables (Store non-volatile UEFI variables as file) --->
[ ] Initial values for UEFI variables
(16384) Memory size of the UEFI variable store
[ ] UpdateCapsule() runtime service
[ ] Enable capsule-on-disk support
[*] Device path to text protocol
[*] Device path utilities protocol
[*] Device tree fixup protocol
[*] HII protocols
[*] Unicode collation protocol
[*] Support Unicode capitalization
(en-US) Language codes supported by firmware
[*] Workaround for GRUB on 32bit ARM
[*] EFI_RNG_PROTOCOL support
[*] EFI_FILE_LOAD2_PROTOCOL for Linux initial ramdisk
[ ] Support OPTEE library
[ ] Support OPTEE images
[ ] Support OPTEE bootm command
[ ] enable fdtdec test
[*] Enable the logical memory blocks library (lmb)
[*] Use a common number of memory and reserved regions in lmb lib
(8) Number of memory and reserved regions in lmb lib
[ ] Enable phandle check while getting sequence number

Library routines 常用C库函数

这些也没什么特别需要修改了的,保持与官方给的一致就行

保存板子配置文件

保存并退出menuconfig后回到命令行

1
2
3
4
# 保存配置文件,复制.config重命名产生defconfig配置文件
make savedefconfig
# 将defconfig重命名为igboard_defconfig并覆盖configs内文件
mv defconfig configs/igboard_defconfig

image-20230525183254338

覆盖configs内文件

1
2
# 再执行一次导入设置
make igboard_defconfig

image-20230525183705465

导入成功,保存板子的配置文件成功

添加开发板对应的头文件

1
2
3
4
5
6
# 开发板对应的头文件在include/configs/下
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ cd include/configs
# 复制添加开发板对应的头文件
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/include/configs$ cp mx6ullevk.h igboard-imx6ull.h
# 创建overlay.h文件以支持设备树的overlay
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/include/configs$ touch igboard-imx6ull_overlay.h

添加开发板对应的头文件

1
2
# 修改头文件宏定义
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/include/configs$ vim igboard-imx6ull.h
1
2
3
// 将原本的#ifndef和#define修改为__IGBOARD_IMX6ULL_H来防止头文件重复包含
#ifndef __IGBOARD_IMX6ULL_H
#define __IGBOARD_IMX6ULL_H

防止头文件重复包含

1
2
# 编辑修改igboard-imx6ull_overlay.h
vim igboard-imx6ull_overlay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2022 LingYun IoT System Studio
*
* Device Tree overlay env for the LingYun IoT Gateway Board.
*/
#ifndef __IGBOARD_IMX6ULL_OVERLAY_H
#define __IGBOARD_IMX6ULL_OVERLAY_H

#if 0
dtoverlay_xxx is set in uEnv.txt, then load the corresponding dtbo file

if env exists dtoverlay_lcd && test ${dtoverlay_lcd} = 1 -o ${dtoverlay_lcd} = yes ; then
dtbo_file=lcd.dtbo;
echo "Applying DT overlay: $dtbo_file";
fatload mmc ${mmcdev}:${mmcpart} ${dtbo_addr} ${dtbo_dir}/${dtbo_file};
fdt addr ${fdt_addr};
fdt resize ${fdt_size};
fdt apply ${dtbo_addr};
fi;


if env exists dtoverlay_uart ; then
for i in ${dtoverlay_uart};
do
dtbo_file=uart$i.dtbo;
echo "Applying DT overlay: $dtbo_file";
fatload mmc ${mmcdev}:${mmcpart} ${dtbo_addr} ${dtbo_dir}/${dtbo_file};
fdt addr ${fdt_addr};
fdt apply ${dtbo_addr};
done;
fi;

#endif


#define FDT_APPLY_OVERLAY() \
"echo Applying DT overlay ==> ${dtbo_file}; " \
"fatload mmc ${mmcdev}:${mmcpart} ${dtbo_addr} ${dtbo_dir}/${dtbo_file}; " \
"fdt addr ${fdt_addr}; " \
"fdt resize ${fdt_size}; " \
"fdt apply ${dtbo_addr}; "

#define CHECK_APPLY_OVERLAY( name ) \
"if env exists dtoverlay_" name " && test ${dtoverlay_" name "} = 1 -o ${dtoverlay_" name "} = yes ; then " \
"setenv dtbo_file " name ".dtbo; " \
FDT_APPLY_OVERLAY() \
"fi; "

#define CHECK_APPLY_OVERLAYS_IDX( name ) \
"if env exists dtoverlay_" name "; then " \
"for i in ${dtoverlay_" name "}; do " \
"setenv dtbo_file " name "$i.dtbo; " \
FDT_APPLY_OVERLAY() \
" done;" \
"fi; "

#define CHECK_APPLY_OVERLAYS_DTBO( name ) \
"if env exists dtoverlay_" name "; then " \
"for f in ${dtoverlay_" name "}; do " \
"setenv dtbo_file $f.dtbo; " \
FDT_APPLY_OVERLAY() \
" done;" \
"fi; "

#define FDT_ENTRY_DEF_SETTINGS \
CHECK_APPLY_OVERLAY("lcd") \
CHECK_APPLY_OVERLAY("cam") \
CHECK_APPLY_OVERLAY("i2c1") \
CHECK_APPLY_OVERLAY("spi1") \
CHECK_APPLY_OVERLAYS_IDX("uart") \
CHECK_APPLY_OVERLAYS_IDX("can") \
CHECK_APPLY_OVERLAYS_IDX("pwm") \
CHECK_APPLY_OVERLAYS_DTBO("extra") \

#define MMC_FDT_OVERLAY_SETTING \
"fdt_size=0x10000\0" \
"dtbo_addr=0x83010000\0" \
"dtbo_dir=overlays\0" \
"mmcbootdto=echo Booting from mmc with overlay...; " \
"mmc dev ${mmcdev}; run mmcargs; run loadenvconf; " \
"run loadimage; run loadfdt; " \
FDT_ENTRY_DEF_SETTINGS \
"bootz ${loadaddr} - ${fdt_addr}\0"

#define ENABLE_UENV_FDTO_SUPPORT

#endif

添加板级支持包

详细的释义请看这里

1
2
3
4
5
6
7
# 从官方的板级支持包中复制

cp board/freescale/mx6ullevk board/lingyun/igboard-imx6ull -r

# 重命名mx6ullevk.c为igboard-imx6ull.c:

mv mx6ullevk.c igboard-imx6ull.c

image-20230525193153201

1
2
# 修改Makefile
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx/board/lingyun/igboard-imx6ull$ vim Makefile

修改Makefile

1
2
# 修改Kconfig文件
vim Kconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if TARGET_LINGYUN_IGBOARD_IMX6ULL 

config SYS_BOARD
default "igboard"

config SYS_VENDOR
default "lingyun"

config SYS_CONFIG_NAME
default "igboard"

config IMX_CONFIG
default "board/lingyun/igboard-imx6ull/imximage.cfg"

config SYS_TEXT_BASE
default 0x87800000
endif

修改Kconfig文件

1
2
# 修改MAINTAINERS
vim MAINTAINERS
1
2
3
4
5
6
LingYun IoT Gateway Board(IGBoard)
M: Guo Wenxue <guowenxue@gmail.com>
S: Maintained
F: board/lingyun/igboard-imx6ull/
F: include/configs/igboard-imx6ull.h
F: configs/igboard_defconfig

添加自己板子所对应的设备树文件

1
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ vim arch/arm/dts/igboard-imx6ull.dts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
//
// Copyright (C) 2016 Freescale Semiconductor, Inc.

/dts-v1/;

#include "imx6ull.dtsi"
#include "imx6ul-14x14-evk.dtsi"
#include "imx6ul-14x14-evk-u-boot.dtsi"

/ {
model = "LingYun IoT Gateway Board";
compatible = "fsl,imx6ull-14x14-evk", "fsl,imx6ull";
};

&clks {
assigned-clocks = <&clks IMX6UL_CLK_PLL3_PFD2>;
assigned-clock-rates = <320000000>;
};

修改 arch/arm/dts/Makefile

image-20230525195601624

将我们的开发板添加进编译 uboot 的编译选项,修改 arch/arm/mach-imx/mx6/Kconfig 文件

1
vim arch/arm/mach-imx/mx6/Kconfig
1
2
3
4
# 找到以下的配置,在该配置下方添加:
choice
prompt "MX6 board select"
optional
1
2
3
4
5
6
7
8
9
config TARGET_LINGYUN_IMX6ULL_IGBOARD
bool "LingYun IoT Gateway Kits Board(IGBoard)"
depends on MX6ULL
select BOARD_LATE_INIT
select DM
select DM_THERMAL
select IMX_MODULE_FUSE
select OF_SYSTEM_SETUP
imply CMD_DM

image-20230525200024710

再翻到最后,一堆 source 这里,将板子的配置添加上

1
source "board/lingyun/igboard-imx6ull/Kconfig"

image-20230525200149520

编译Uboot

1
2
# 清理之前编译产生的文件
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ make distclean

image-20230525200450113

1
2
# 设置编译配置文件为自定义的
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ make igboard_defconfig

image-20230525200424323

1
2
# 编译文件,我虚拟机设置了内核总数为8,这里8核一同编译,根据自己虚拟机设置修改一同编译的核数
noah@ubuntu:~/imx6ull/bsp/bootloader/uboot-imx$ make -j8

image-20230525200755088

编译完成