“U-Boot overview”的版本间的差异

来自百问网嵌入式Linux wiki
(创建页面,内容为“== Das U-Boot == [https://en.wikipedia.org/wiki/Das_U-Boot Das U-Boot] ("the Universal Boot Loader" or U-Boot) is an open-source bootloader that can be used on ST bo…”)
 
 
(未显示同一用户的4个中间版本)
第1行: 第1行:
 
== Das U-Boot ==
 
== Das U-Boot ==
[https://en.wikipedia.org/wiki/Das_U-Boot Das U-Boot] ("the Universal Boot Loader" or U-Boot) is an open-source bootloader that can be used on ST boards to initialize the platform and load the Linux<sup>&reg;</sup> kernel.
+
[https://en.wikipedia.org/wiki/Das_U-Boot Das U-Boot] (“通用引导加载程序”或U-Boot) 是一种开源引导加载程序,可用于ST板上以初始化平台并加载Linux<sup>&reg;</sup> 内核。
  
* Official website: [https://www.denx.de/wiki/U-Boot https://www.denx.de/wiki/U-Boot]
+
* 官方网站: [https://www.denx.de/wiki/U-Boot https://www.denx.de/wiki/U-Boot]
* Official manual: [http://www.denx.de/wiki/U-Boot/Documentation|U-Boot project documentation] and [https://www.denx.de/wiki/DULG/Manual https://www.denx.de/wiki/DULG/Manual]
+
* 官方手册: [http://www.denx.de/wiki/U-Boot/Documentation|U-Boot project documentation] [https://www.denx.de/wiki/DULG/Manual https://www.denx.de/wiki/DULG/Manual]
* Official [https://www.denx.de/wiki/U-Boot/SourceCode '''source code'''] is available under [https://git-scm.com/ git] repository at [https://gitlab.denx.de/u-boot/u-boot]
+
* 官方的[https://www.denx.de/wiki/U-Boot/SourceCode '''源代码'''] 可在 [https://git-scm.com/ git] 存储库下找到[https://gitlab.denx.de/u-boot/u-boot]
 
   {{PC$}} git clone https://gitlab.denx.de/u-boot/u-boot.git
 
   {{PC$}} git clone https://gitlab.denx.de/u-boot/u-boot.git
  
Read the {{CodeSource | U-Boot | README | README file}} before starting using U-Boot. It covers the following topics:
+
在开始使用U-Boot之前,请阅读{{CodeSource | U-Boot | README | README file}}。它涵盖以下主题:
* source file tree structure
+
* 源文件树结构
* description of CONFIG defines
+
* 配置定义说明
* instructions for building U-Boot
+
* 关于构建U-Boot的说明
* brief description of the Hush shell
+
* Hush外壳的简要说明
* list of common environment variables
+
* 常用环境变量列表
  
 
== U-Boot overview ==
 
== U-Boot overview ==
 
[[File: STM32MPU Embedded Software architecture overview.png|link=STM32MPU Embedded Software architecture overview|thumb|Zoom out to STM32MPU Embedded Software]]
 
[[File: STM32MPU Embedded Software architecture overview.png|link=STM32MPU Embedded Software architecture overview|thumb|Zoom out to STM32MPU Embedded Software]]
The same U-Boot source can generate two pieces of firmware used in SPL and U-Boot [[Boot_chains_overview#STM32MP boot chains|STM32 MPU boot chain]]:
+
同一个U-Boot源可以生成SPL和U-Boot中使用的两个固件 [[Boot_chains_overview#STM32MP boot chains|STM32 MPU boot chain]]:
* Trusted boot chain: TF-A as FSBL and U-Boot as SSBL
+
* 受信任的引导链:TF-A作为FSBL,U-Boot作为SSBL
* Basic boot chain: SPL as FSBL and U-Boot as SSBL
+
* 基本启动链:SPL作为FSBL,U-Boot作为SSBL
  
 
<br clear=all>
 
<br clear=all>
  
{{Warning | The basic boot chain cannot be used for product development (see [[Boot_chains_overview#Boot_chains_features_set|Boot chains  
+
{{Warning | 基本启动链不能用于产品开发 (请参见[[Boot_chains_overview#Boot_chains_features_set|Boot chains  
overview]] for details).}}  
+
overview]] 以获取详细信息).}}  
It is provided only as an example of the simplest SSBL and to support upstream U-Boot development. However, several known limitations have been identified when SPL is used in conjunction with the minimal secure monitor provided within U-Boot for basic boot chain. They apply to:
+
它仅作为最简单的SSBL的示例提供,并支持上游U-Boot开发。但是,当SPL与U-Boot中提供的用于基本引导链的最小安全监视器结合使用时,已经发现了几个已知的限制。它们适用于:
* power
+
* 功率
* secure access to registers
+
* 安全访问寄存器
* limited features (STM32CubeProgrammer / boot from NAND Flash memory).  
+
* 有限的功能(STM32CubeProgrammer / boot from NAND Flash memory).  
No fix is planned for these limitations.
+
没有针对这些限制的修复计划。
  
 
=== SPL: FSBL for basic boot===
 
=== SPL: FSBL for basic boot===
The '''U-Boot SPL''' or '''SPL''' is the first stage bootloader (FSBL) for [[Boot_chains_overview#STM32MP boot chains|the basic boot chain]].<br/>It is a small binary (bootstrap utility) generated from the U-Boot source and stored in the internal limited-size embedded RAM. SPL main features are the following:
+
'''U-Boot SPL''' '''SPL''' [[Boot_chains_overview#STM32MP boot chains|the basic boot chain]]的第一阶段引导加载程序(FSBL)。<br/>它是从U-Boot源生成的小二进制文件(引导实用程序),并存储在内部有限大小的嵌入式RAM中。SPL的主要功能如下:
* It is loaded by the ROM code.
+
* 它由ROM代码加载。
* It performs the initial CPU and board configuration (clocks and DDR memory).
+
* 它执行初始的CPU和板配置(时钟和DDR内存)。
* It loads the SSBL (U-Boot) into the DDR memory.
+
* 它将SSBL(U-Boot)加载到DDR内存中。
  
 
=== U-Boot: SSBL ===
 
=== U-Boot: SSBL ===
'''U-Boot''' is the default second-stage bootloader (SSBL) for STM32 MPU platforms. It is used both for [[Boot_chains_overview#STM32MP boot chains|trusted and basic]] boot chains.
+
'''U-Boot''' 是STM32 MPU平台的默认第二阶段引导程序(SSBL)。它同时用于 [[Boot_chains_overview#STM32MP boot chains|trusted and basic]]引导链
SSBL main features are the following:
+
 
* It is configurable and expendable.
+
SSBL的主要功能如下:
* It features a simple command line interface (CLI), allowing users to interact over a serial port console.
+
* 它是可配置和消耗的。
* It provides scripting capabilities
+
* 它具有一个简单的命令行界面(CLI),允许用户通过串行端口控制台进行交互。
* It loads the kernel into RAM and gives control to the kernel
+
* 它提供脚本功能
* It manages several internal and external devices such as NAND and NOR Flash memories, Ethernet and USB.
+
* 它将内核加载到RAM中并控制内核
* It supports the following features and commands:
+
* 它管理多个内部和外部设备,例如NAND和NOR闪存,以太网和USB。
** File systems: FAT, UBI/UBIFS, JFFS
+
* 它支持以下功能和命令:
** IP stack: FTP
+
** 文件系统:FAT, UBI/UBIFS, JFFS
** Display: LCD, HDMI, BMP for splashcreen
+
** IP堆栈:FTP
 +
** 显示: LCD, HDMI, BMP for splashcreen
 
** USB: host (mass storage) or device (DFU stack)
 
** USB: host (mass storage) or device (DFU stack)
  
 
=== SPL phases ===
 
=== SPL phases ===
'''SPL''' executes the following main phases in SYSRAM:
+
'''SPL''' 在SYSRAM中执行以下主要阶段:
* '''board_init_f()''': driver initialization including DDR initialization (mininimal stack and heap: CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
+
* '''board_init_f()''': 驱动程序初始化,包括DDR初始化(最小堆栈和堆:CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
* configuration of heap in DDR memory (CONFIG_SPL_SYS_MALLOC_F_LEN)
+
* DDR内存中堆的配置(CONFIG_SPL_SYS_MALLOC_F_LEN)
* '''board_init_r()''': initialization of the other drivers activated in the SPL device tree
+
* '''board_init_r()''': 初始化在SPL设备树中激活的其他驱动程序
* loading and execution of U-Boot (or Kernel in Falcon mode<ref>https://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf</ref>: {{CodeSource | U-Boot | doc/README.falcon | README.falcon }}).
+
* 加载并执行U-Boot(或Falcon模式下的内核<ref>https://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf</ref>: {{CodeSource | U-Boot | doc/README.falcon | README.falcon }}).
  
 
=== U-Boot phases ===
 
=== U-Boot phases ===
'''U-Boot''' executes the following main phases in DDR memory:
+
'''U-Boot''' 在DDR内存中执行以下主要阶段:
* '''Pre-relocation''' initialization (common/board_f.c): minimal initialization (such as CPU, clock, reset, DDR and console) running at the CONFIG_SYS_TEXT_BASE load address.
+
* '''Pre-relocation''' 初始化 (common/board_f.c): 在CONFIG_SYS_TEXT_BASE加载地址上运行的最小初始化(例如CPU,时钟,重置,DDR和控制台)
* '''Relocation''': copy of the code to the end of DDR memory.
+
* '''Relocation''': 将代码复制到DDR内存的末尾。
* '''Post-relocation initialization''':(common/board_r.c): initialization of all the drivers.
+
* '''Post-relocation initialization''':(common/board_r.c): 初始化所有驱动程序。
* '''Command execution''' through autoboot (CONFIG_AUTOBOOT) or console shell
+
* '''Command execution''' 通过自动引导(CONFIG_AUTOBOOT)或控制台shell
** Execution of the boot command (by default [[#bootcmd|bootcmd=CONFIG_BOOTCOMMAND]]): <br/>for example, execution of the command <code>bootm</code> to:
+
** 启动命令的执行(默认情况下[[#bootcmd | bootcmd=CONFIG_BOOTCOMMAND]]):<br/>例如,将命令<code>bootm</code>执行到:
*** load and check images (such as kernel, device tree and ramdisk)
+
*** 加载并检查映像(例如内核,设备树和ramdisk)
*** fixup the kernel device tree
+
*** 修复内核设备树
*** install the secure monitor (optional) or
+
*** 安装安全监视器(可选)或
*** pass the control to the Linux kernel (or to another target application)
+
*** 将控制权传递给Linux内核(或另一个目标应用程序)
  
 
== U-Boot configuration ==
 
== U-Boot configuration ==
The U-Boot binary configuration is based on
+
U-Boot二进制配置基于
* '''Kbuild infrastructure''' (as in [[Menuconfig_or_how_to_configure_kernel|Linux Kernel]], you can use <code>make menuconfig</code> in U-Boot)<br/>The configurations are based on:
+
* '''Kbuild infrastructure''' ([[Menuconfig_or_how_to_configure_kernel|Linux Kernel]], 您可以在U-Boot中使用<code>make menuconfig</code> )<br/>配置基于以下各项:
** options defined in Kconfig files (CONFIG_ compilation flags)
+
** Kconfig 文件中定义的选项(CONFIG _ compilation 标志)
** the selected configuration file: {{CodeSource | U-Boot | configs/ | configs/stm32mp*_defconfig}}<br/>
+
** 所选配置文件:{{CodeSource | U-Boot | configs/ | configs/stm32mp*_defconfig}}<br/>
* '''other compilation flags''' defined in {{CodeSource | U-Boot | include/configs/ | include/configs/stm32mp*.h}}  (these flags are progressively migrated to Kconfig)<br/>The file name is configured through CONFIG_SYS_CONFIG_NAME.<br/>For  {{MicroprocessorDevice | device=15}}, the {{CodeSource | U-Boot | include/configs/stm32mp1.h | include/configs/stm32mp1.h}} file is used.
+
* '''other compilation flags''' 定义于{{CodeSource | U-Boot | include/configs/ | include/configs/stm32mp*.h}}  (这些标志将逐步迁移到Kconfig)<br/>文件名通过CONFIG_SYS_CONFIG_NAME配置。<br/>对于 {{MicroprocessorDevice | device=15}}, 使用了{{CodeSource | U-Boot | include/configs/stm32mp1.h | include/configs/stm32mp1.h}}文件。
  
* '''[[Device_tree|DeviceTree]]''': U-Boot and SPL binaries include a device tree blob that is parsed at runtime
+
* '''[[Device_tree|DeviceTree]]''': U-Boot和SPL二进制文件包括在运行时解析的设备树blob
All the configuration flags (prefixed by CONFIG_) are described in the source code, either in the {{CodeSource | U-Boot | README | README}} file or in the {{CodeSource | U-Boot | doc/ | documentation directory}}.<br/>For example, CONFIG_SPL activates the SPL compilation.<br />
+
所有的配置标志(前缀为 CONFIG_)都在源代码中描述, 或者在 {{CodeSource | U-Boot | README | README}} 文件中,或者在{{CodeSource | U-Boot | doc/ | documentation directory}}目录中。<br/>例如,CONFIG_SPL激活SPL编译<br />
Hence to compile U-Boot, [[#Kbuild|select the <target>]] and [[#Device_tree|the device tree]] for the board in order to choose a predefined configuration.<br/>
+
因此,为了选择一个预定义的配置,需要为主板编译 U-Boot,[[#Kbuild|select the <target>]] [[#Device_tree|the device tree]] <br/>
Refer to [[#U-Boot_build]] for examples.
+
有关示例,请参阅[[#U-Boot_build]]
  
 
=== Kbuild ===
 
=== Kbuild ===
  
Like the kernel, the U-Boot build system is based on [[Menuconfig_or_how_to_configure_kernel|configuration symbols]] (defined in Kconfig files). The selected values are stored in a '''.config''' file in the build directory, with the same makefile target. .<br/>
+
与内核一样,U-Boot构建系统也基于 [[Menuconfig_or_how_to_configure_kernel|configuration symbols]] (在Kconfig文件中定义). 选定的值存储在build目录的'''.config'''文件中,具有相同的Makefile目标。 <br/>
Proceed as follows:
+
按照以下步骤进行:
* Select a pre-defined configuration (defconfig file in {{CodeSource | U-Boot | configs/ | configs directory }}) and generate the first '''.config''':
+
* 选择预定义的配置({{CodeSource | U-Boot | configs/ | configs directory }}中的defconfig文件) 并生成第一个 '''.config''':
 
   {{PC$}} make <config>_defconfig.
 
   {{PC$}} make <config>_defconfig.
  
* Change the U-Boot compile configuration (modify .config) by using one of the following  five <code>make</code> commands:
+
* 使用以下五个<code>make</code> 命令之一更改U-Boot编译配置(修改.config):
 
   {{PC$}} '''make menuconfig''' {{Highlight|--> menu based program}}
 
   {{PC$}} '''make menuconfig''' {{Highlight|--> menu based program}}
 
   {{PC$}} make config  {{Highlight|--> line-oriented configuration}}
 
   {{PC$}} make config  {{Highlight|--> line-oriented configuration}}
第94行: 第95行:
 
   {{PC$}} make gconfig {{Highlight|--> GTK program}}
 
   {{PC$}} make gconfig {{Highlight|--> GTK program}}
 
   {{PC$}} make nconfig {{Highlight|--> ncurse menu based program}}
 
   {{PC$}} make nconfig {{Highlight|--> ncurse menu based program}}
You can then compile U-Boot with the updated .config.
+
然后,您可以使用更新的.config编译U-Boot。
  
Warning: the modification is performed locally in the build directory. It will be lost after a <code>make distclean</code>.
+
Warning: 修改是在构建目录的本地执行的。在<code> make distclean 之后它将丢失</code>.
  
Save your configuration to be able to use it as a defconfig file:
+
保存您的配置以将其用作defconfig文件:
 
   {{PC$}} make savedefconfig
 
   {{PC$}} make savedefconfig
This target saves the current config as a defconfig file in the build directory. It can then be compared with the predefined configuration (configs/stm32mp*defconfig).
+
此目标将当前配置保存为build目录中的defconfig文件。 然后可以将其与预定义的配置进行比较(configs/stm32mp*defconfig).
  
The other makefile targets are the following:
+
其他makefile目标如下:
  
 
   {{PC$}} make help
 
   {{PC$}} make help
第128行: 第129行:
  
 
=== Device tree ===
 
=== Device tree ===
Refer to {{CodeSource | U-Boot | doc/README.fdt-control | doc/README.fdt-control}} for details.
+
请参阅{{CodeSource | U-Boot | doc/README.fdt-control | doc/README.fdt-control}} 以获取详细信息。
  
The board device tree has the same binding as the kernel. It is integrated within the SPL and U-Boot binaries:
+
板设备树具有与内核相同的绑定。它集成在SPL和U-Boot二进制文件中:
* By default, it is appended at the end of the code  (CONFIG_OF_SEPARATE).
+
* 默认情况下,它被附加在代码的末尾(CONFIG_OF_SEPARATE).
* It is embedded in the U-Boot binary (CONFIG_OF_EMBED). This is useful for debugging since it enables easy .elf file loading.
+
* 它嵌入在U-Boot二进制文件(CONFIG_OF_EMBED)中。这对调试很有用,因为它可以轻松加载.elf文件。
  
A default device tree is available in the defconfig file (by setting CONFIG_DEFAULT_DEVICE_TREE).
+
defconfig文件中有一个默认的设备树(通过设置CONFIG_DEFAULT_DEVICE_TREE)。
  
You can either select another supported device tree using the DEVICE_TREE make flag. For stm32mp boards, the corresponding file is: {{CodeSource | U-Boot | arch/arm/dts/ | arch/arm/dts/stm32mp*.dts}}.
+
您可以使用DEVICE_TREE make标志选择另一个受支持的设备树。 对于stm32mp板,相应的文件为: {{CodeSource | U-Boot | arch/arm/dts/ | arch/arm/dts/stm32mp*.dts}}.
 
   {{PC$}} make DEVICE_TREE=<dts-file-name>
 
   {{PC$}} make DEVICE_TREE=<dts-file-name>
  
or provide a precompiled device tree blob (using EXT_DTB option):
+
或提供预编译的设备树blob(using EXT_DTB option):
 
   {{PC$}} make EXT_DTB=boot/<dts-file-name>.dtb
 
   {{PC$}} make EXT_DTB=boot/<dts-file-name>.dtb
  
The SPL device tree is also generated from this device tree. However to reduce its size, the U-Boot makefile uses the fdtgrep tool to parse the full U-Boot DTB and identify all the drivers required by SPL.
+
SPL设备树也从该设备树生成。 但是为了减小其大小,U-Boot生成文件使用fdtgrep工具来解析完整的U-Boot DTB并识别SPL所需的所有驱动程序。
  
To do this, U-Boot uses specific device-tree flags to define if the associated driver is initialized prior to U-Boot relocation and/or if the associated node is present in SPL :
+
为此,U-Boot使用特定的设备树标志来定义相关的驱动程序是否在U-Boot重定位之前初始化和/或相关的节点是否存在于SPL中:
* '''u-boot,dm-pre-reloc''' => present in SPL, initialized before relocation in U-Boot
+
* '''u-boot,dm-pre-reloc''' => 存在于SPL中,在U-Boot中重新定位之前初始化
* '''u-boot,dm-pre-proper''' => initialized before relocation in U-Boot
+
* '''u-boot,dm-pre-proper''' => 在U-Boot中重新定位之前初始化
* '''u-boot,dm-spl''' => present in SPL
+
* '''u-boot,dm-spl''' => 存在于SPL中
  
In the device tree used by U-Boot, these flags '''need to be added in each node''' used in SPL or in U-Boot before relocation and for each used handle (clock, reset, pincontrol).
+
在U-Boot使用的设备树中,这些标志'''需要添加到SPL或U-Boot中使用的每个节点'''中,然后再进行重定位以及每个使用的句柄(时钟,复位,引脚控制)。
  
 
== U-Boot command line interface (CLI) ==
 
== U-Boot command line interface (CLI) ==
Refer to [http://www.denx.de/wiki/view/DULG/UBootCommandLineInterface U-Boot Command Line Interface].
+
请参阅 [http://www.denx.de/wiki/view/DULG/UBootCommandLineInterface U-Boot Command Line Interface].
  
If CONFIG_AUTOBOOT is activated, you have CONFIG_BOOTDELAY seconds (2s by default) to enter the console by pressing any key, after the line below is displayed and [[#bootcmd|bootcmd]] is executed (CONFIG_BOOTCOMMAND):
+
如果CONFIG_AUTOBOOT已激活,则在显示以下行并执行[[#bootcmd|bootcmd]](CONFIG_BOOTCOMMAND)后,您有CONFIG_BOOTDELAY秒(默认情况下为2秒)通过按任意键进入控制台:
   Hit any key to stop autoboot: 2
+
   Hit any key to stop autoboot:  2
  
 
=== Commands ===
 
=== Commands ===
The commands are defined in {{CodeSource | U-Boot | cmd/ | cmd/*.c}}. They are activated through the corresponding '''CONFIG_CMD_*''' configuration flag.
+
这些命令在{{CodeSource | U-Boot | cmd/ | cmd/*.c}}. 通过相应的 '''CONFIG_CMD_*''' 配置标志激活它们。
  
Use the <code>help</code> command in the U-Boot shell to list the commands available on your device:
+
使用U-Boot shell中的<code>help</code> 命令列出设备上可用的命令:
 
   {{Board$}} help
 
   {{Board$}} help
  
Below the list of all commands extracted from [http://www.denx.de/wiki/view/DULG/Manual U-Boot Manual] ('''not-exhaustive'''):
+
以下是从中提取的所有命令的列表 [http://www.denx.de/wiki/view/DULG/Manual U-Boot Manual] ('''不详尽'''):
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupInfo Information Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupInfo Information Commands]
** bdinfo - prints Board Info structure
+
** bdinfo - 打印板信息结构
** coninfo - prints console devices and information
+
** coninfo - 打印控制台设备和信息
** flinfo - prints Flash memory information
+
** flinfo - 打印闪存信息
** iminfo - prints header information for application image
+
** iminfo - 打印应用程序映像的标题信息
** help - prints online help
+
** help - 打印在线帮助
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupMemory Memory Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupMemory Memory Commands]
** base - prints or sets the address offset
+
** base - 打印或设置地址偏移量
** crc32 - checksum calculation
+
** crc32 - 校验和计算
** cmp - memory compare
+
** cmp - 内存比较
** cp - memory copy
+
** cp - 内存拷贝
** md - memory display
+
** md - 内存显示
** mm - memory modify (auto-incrementing)
+
** mm - 内存修改(自动递增)
** mtest - simple RAM test
+
** mtest - 简单的RAM测试
** mw - memory write (fill)
+
** mw - 内存写入(填充)
** nm - memory modify (constant address)
+
** nm - 内存修改(常量地址)
** loop - infinite loop on address range
+
** loop - 地址范围内无限循环
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupFlash Flash Memory Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupFlash Flash Memory Commands]
** cp - memory copy
+
** cp - 内存复制
** flinfo - prints Flash memory information
+
** flinfo - 打印闪存信息
** erase - erases Flash memory
+
** erase - 清除闪存
** protect - enables or disables Flash memory write protection
+
** protect - 启用或禁用闪存写入保护
** mtdparts - defines a Linux compatible MTD partition scheme
+
** mtdparts - 定义与Linux兼容的MTD分区方案
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupExec Execution Control Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupExec Execution Control Commands]
** source - runs a script from memory
+
** source - 从内存运行脚本
** bootm - boots application image from memory
+
** bootm - 从内存启动应用程序映像
** go - starts application at address 'addr'
+
** go - 在地址‘addr’处启动应用程序
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupDownload Download Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupDownload Download Commands]
** bootp - boots image via network using BOOTP/TFTP protocol
+
** bootp - 使用BOOTP / TFTP协议通过网络引导映像
** dhcp - invokes DHCP client to obtain IP/boot params
+
** dhcp - 调用DHCP客户端以获得IP /启动参数
** loadb - loads binary file over serial line (kermit mode)
+
** loadb - 通过串行线加载二进制文件(kermit模式)
** loads - loads S-Record file over serial line
+
** loads - 通过串行线加载S-Record文件
** rarpboot- boots image via network using RARP/TFTP protocol
+
** rarpboot- 使用RARP/TFTP协议通过网络引导映像
** tftpboot- boots image via network using TFTP protocol
+
** tftpboot- 使用TFTP协议通过网络引导映像
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupEnvironment Environment Variables Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupEnvironment Environment Variables Commands]
** printenv- prints environment variables
+
** printenv- 打印环境变量
** saveenv - saves environment variables to persistent storage
+
** saveenv - 将环境变量保存到永久存储
** setenv - sets environment variables
+
** setenv - 设置环境变量
** run - runs commands in an environment variable
+
** run - 在环境变量中运行命令
** bootd - boots default, i.e., run 'bootcmd'
+
** bootd - 启动默认设置,即运行‘bootcmd’
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdFDT Flattened Device Tree support]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdFDT Flattened Device Tree support]
** fdt addr - selects the FDT to work on
+
** fdt addr - 选择要处理的FDT
** fdt list - prints one level
+
** fdt list - 打印等级一级
** fdt print - recursive printing
+
** fdt print - 递归打印
** fdt mknode - creates new nodes
+
** fdt mknode - 创建新节点
** fdt set - sets node properties
+
** fdt set - 设置节点属性
** fdt rm - removes nodes or properties
+
** fdt rm - 删除节点或属性
** fdt move - moves FDT blob to new address
+
** fdt move - 将FDT blob移动到新地址
** fdt chosen - fixup dynamic information
+
** fdt chosen - 固定动态信息
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupSpecial Special Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupSpecial Special Commands]
** i2c - I2C sub-system
+
** i2c - I2C子系统
 
* [http://www.denx.de/wiki/view/DULG/UBootStorageDevices Storage devices]
 
* [http://www.denx.de/wiki/view/DULG/UBootStorageDevices Storage devices]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupMisc Miscellaneous Commands]
 
* [http://www.denx.de/wiki/view/DULG/UBootCmdGroupMisc Miscellaneous Commands]
** echo - echoes args to console
+
** echo - 将参数返回到控制台
** reset - Performs a CPU reset 
+
** reset - 执行CPU重置
** sleep - delays the execution for a predefined time
+
** sleep - 将执行延迟预定义的时间
** version - prints the monitor version
+
** version - 打印监视器版本
 
+
要添加新命令,请参阅{{CodeSource | U-Boot | doc/README.commands }}.
To add a new command, refer to {{CodeSource | U-Boot | doc/README.commands }}.
 
  
 
=== U-Boot environment variables ===
 
=== U-Boot environment variables ===
  
The U-Boot behavior is configured through environment variables.
+
U-Boot行为是通过环境变量配置的。
  
Refer to [http://www.denx.de/wiki/view/DULG/UBootEnvVariables Manual] and {{CodeSource | U-Boot | README | README}} / Environment Variables.
+
环境变量请参阅[http://www.denx.de/wiki/view/DULG/UBootEnvVariables Manual] {{CodeSource | U-Boot | README | README}}
  
On the first boot, U-Boot uses a default environment embedded in the U-Boot binary. You can modify it by changing the content of CONFIG_EXTRA_ENV_SETTINGS in your configuration file (for example ./include/configs/stm32mp1.h) (see {{CodeSource | U-Boot | README | README}} / - Default Environment).
+
首次启动时,U-Boot使用嵌入在U-Boot二进制文件中的默认环境。 您可以通过更改配置文件中CONFIG_EXTRA_ENV_SETTINGS的内容 (例如 ./include/configs/stm32mp1.h) (请参阅 {{CodeSource | U-Boot | README | README}} / - 默认环境).
  
This environment can be modified and saved in the boot device. When it is present, it is loaded during U-Boot initialization:
+
可以修改此环境并将其保存在引导设备中。 如果存在,它将在U-Boot初始化期间加载:
* for ''e''•MMC/SD card boot (CONFIG_ENV_IS_IN_EXT4), in the bootable ext4 partition "bootfs" in <br/>in file CONFIG_ENV_EXT4_FILE="uboot.env".
+
* 对于    ''e''•MMC/SD card boot (CONFIG_ENV_IS_IN_EXT4),位于文件 CONFIG_ENV_EXT4_FILE="uboot.env" 中的可引导ext4分区 "bootfs" 中。
* for NAND boot (CONFIG_ENV_IS_IN_UBI), in the two UBI volumes "config" (CONFIG_ENV_UBI_VOLUME) and "config_r"  (CONFIG_ENV_UBI_VOLUME_REDUND).
+
* 对于NAND引导 (CONFIG_ENV_IS_IN_UBI), 在两个UBI卷 "config" (CONFIG_ENV_UBI_VOLUME) "config_r"  (CONFIG_ENV_UBI_VOLUME_REDUND)中。
* for NOR boot (CONFIG_ENV_IS_IN_SPI_FLASH), in the u-boot_env mtd parttion (at offset CONFIG_ENV_OFFSET).
+
* 用于NOR引导 (CONFIG_ENV_IS_IN_SPI_FLASH), 位于u-boot_env mtd分区中 (在偏移量 CONFIG_ENV_OFFSET ).
  
 
==== env command ====
 
==== env command ====
  
The <code>env</code> command allows displaying, modifying and saving the environment in U-Boot console.
+
<code>env</code> 命令允许在U-Boot控制台中显示,修改和保存环境。
  
 
   {{Board$}} help env
 
   {{Board$}} help env
第257行: 第257行:
 
   env set [-f] name [arg ...]
 
   env set [-f] name [arg ...]
  
Example: proceed as follows to restore the default environment and save it. This is useful after a U-Boot upgrade:
+
示例:按以下步骤恢复默认环境并保存它。这在U-Boot升级后很有用:
  
 
   {{Board$}} env default -a
 
   {{Board$}} env default -a
第263行: 第263行:
  
 
==== bootcmd ====
 
==== bootcmd ====
"bootcmd" variable is the autoboot command. It defines the command executed when U-Boot starts (CONFIG_BOOTCOMMAND).
+
“bootcmd”变量是自动引导命令。它定义U-Boot启动时执行的命令 (CONFIG_BOOTCOMMAND).
  
For stm32mp,  CONFIG_BOOTCOMMAND="run bootcmd_stm32mp":
+
对于stm32mp,请使用 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp":
  
 
   {{Board$}} env print bootcmd     
 
   {{Board$}} env print bootcmd     
 
   bootcmd=run bootcmd_stm32mp
 
   bootcmd=run bootcmd_stm32mp
  
"bootcmd_stm32mp" is a script that selects the command to be executed for each boot device (see ./include/configs/stm32mp1.h), based on [[#Generic Distro configuration|generic distro scripts]]:
+
"bootcmd_stm32mp" 是一个脚本,它基于[[#Generic Distro configuration|generic distro scripts]]为每个引导设备选择要执行的命令,(请参阅 ./include/configs/stm32mp1.h):
* for serial/usb: execute the <code>stm32prog</code> command.
+
* 对于 serial/usb: 执行 <code>stm32prog</code> 命令。
* for mmc boot (''e''•MMC, SD card), boot only on the same device (bootcmd_mmc...).
+
* 对于 mmc boot (''e''•MMC, SD card), 只能在同一设备上启动 (bootcmd_mmc...).
* for nand boot, boot with on ubifs partition on nand (bootcmd_ubi0).
+
* 对于 nand boot, 请使用nand的ubifs分区(bootcmd_ubi0)引导。
* for nor boot, use the default order ''e''•MMC (SDMMC 1)/ NAND / SD card (SDMMC 0) / SDMMC2 (the default bootcmd: distro_bootcmd).
+
* 对于 nor boot, 使用默认顺序 ''e''•MMC (SDMMC 1)/ NAND / SD card (SDMMC 0) / SDMMC2 (默认的 bootcmd: distro_bootcmd).
  
 
   {{Board$}} env print bootcmd_stm32mp
 
   {{Board$}} env print bootcmd_stm32mp
  
You can then change this configuration:
+
然后,您可以更改此配置:
* either permanently in your board file (default environment by CONFIG_EXTRA_ENV_SETTINGS or change CONFIG_BOOTCOMMAND value) or
+
* 永久保存在您的电路板文件中 (通过 CONFIG_EXTRA_ENV_SETTINGS 或更改 CONFIG_BOOTCOMMAND 值的默认环境)
* temporarily in the saved environment:
+
* 暂时保存在存储环境中:
  
 
   {{Board$}} env set bootcmd run bootcmd_mmc0  
 
   {{Board$}} env set bootcmd run bootcmd_mmc0  
 
   {{Board$}} env save
 
   {{Board$}} env save
  
Note: To reset the environment to its default value:
+
注意:要将环境重置为其默认值:
  
 
   {{Board$}} env default bootcmd
 
   {{Board$}} env default bootcmd
第292行: 第292行:
 
=== Generic Distro configuration ===
 
=== Generic Distro configuration ===
  
Refer to {{CodeSource | U-Boot | doc/README.distro | doc/README.distro}} for details.
+
有关详细信息,请参阅{{CodeSource | U-Boot | doc/README.distro | doc/README.distro}}
  
This feature is activated by default on ST boards (CONFIG_DISTRO_DEFAULTS):
+
默认情况下,此功能在ST板上激活(CONFIG_DISTRO_DEFAULTS):
* one boot command (bootmcd_xxx) exists for each bootable device.
+
* 每个可引导设备都有一个引导命令(bootmcd_xxx)
* U-Boot is independent of the Linux distribution used.
+
* U-Boot独立于所使用的Linux发行版。
* bootcmd is defined in {{CodeSource | U-Boot | ./include/config_distro_bootcmd.h }}
+
* bootcmd是在{{CodeSource | U-Boot | ./include/config_distro_bootcmd.h }}中定义的。
  
When DISTRO is enabled, the command that is executed by default is {{CodeSource | U-Boot | include/config_distro_bootcmd.h}}:
+
启用DISTRO时,默认情况下执行的命令为{{CodeSource | U-Boot | include/config_distro_bootcmd.h}}:
 
   bootcmd=run distro_bootcmd
 
   bootcmd=run distro_bootcmd
  
This script tries any device found in the 'boot_targets' variable and executes the associated bootcmd.
+
此脚本尝试在“boot_targets”变量中找到任意设备,并执行关联的 bootcmd.
  
Example for mmc0, mmc1, mmc2, pxe and ubifs devices:
+
mmc0、mmc1、mmc2、pxe和ubifs设备示例:
 
   bootcmd_mmc0=setenv devnum 0; run mmc_boot
 
   bootcmd_mmc0=setenv devnum 0; run mmc_boot
 
   bootcmd_mmc1=setenv devnum 1; run mmc_boot
 
   bootcmd_mmc1=setenv devnum 1; run mmc_boot
第311行: 第311行:
 
   bootcmd_ubifs0=setenv devnum 0; run ubifs_boot
 
   bootcmd_ubifs0=setenv devnum 0; run ubifs_boot
  
U-Boot searches for a '''extlinux.conf''' configuration file for each bootable device. This file defines the kernel configuration to be used:  
+
U-Boot 搜索每个可引导设备的'''extlinux.conf''' 配置文件。这个文件定义了要使用的内核配置:
 
* bootargs
 
* bootargs
 
* kernel + device tree + ramdisk files (optional)
 
* kernel + device tree + ramdisk files (optional)
第318行: 第318行:
 
=== U-Boot scripting capabilities ===
 
=== U-Boot scripting capabilities ===
  
"Script files" are command sequences that are executed by the U-Boot command interpreter. This feature is particularly useful to configure U-Boot to use a real shell (hush) as command interpreter.
+
"Script files" 是由U-Boot命令解释器执行的命令序列。此功能对于将U-Boot配置为使用真实shell(Hush)作为命令解释程序特别有用。
  
See [http://www.denx.de/wiki/view/DULG/UBootScripts| U-Boot script manual] for an example.
+
参见 [http://www.denx.de/wiki/view/DULG/UBootScripts| U-Boot 脚本手册] 为例。
  
 
== U-Boot build ==
 
== U-Boot build ==
 
=== Prerequisites ===
 
=== Prerequisites ===
  
* a PC with Linux and tools:
+
* 装有Linux和工具的PC:
** see [[PC_prerequisites]]
+
** 参阅 [[PC_prerequisites]]
 
** [[#ARM cross compiler]]
 
** [[#ARM cross compiler]]
* U-Boot source code
+
* U-Boot源代码
** the latest STMicroelectronics U-Boot version
+
** 最新的STMicroelectronics U-Boot版本
*** tar.xz file from Developer Package (for example [[STM32MP1_Developer_Package#Installing_the_U-Boot|STM32MP1]])
+
*** 开发人员软件包中的tar.xz文件 (例如 [[STM32MP1_Developer_Package#Installing_the_U-Boot|STM32MP1]])
*** from GITHUB<ref>https://github.com/STMicroelectronics/u-boot</ref>, with <code>git</code> command
+
*** GITHUB<ref>https://github.com/STMicroelectronics/u-boot</ref>, 使用 <code>git</code> 命令
 
   {{PC$}} git clone https://github.com/STMicroelectronics/u-boot
 
   {{PC$}} git clone https://github.com/STMicroelectronics/u-boot
:* from the Mainline U-Boot in official GIT repository <ref>https://gitlab.denx.de/u-boot/u-boot.git or https://github.com/u-boot/u-boot</ref>
+
:* 从官方GIT存储库中的Mainline U-Boot <ref> https://gitlab.denx.de/u-boot/u-boot.git或https://github.com/u-boot/u-boot</ 参考>
 
   {{PC$}} git clone https://gitlab.denx.de/u-boot/u-boot.git
 
   {{PC$}} git clone https://gitlab.denx.de/u-boot/u-boot.git
  
 
==== ARM cross compiler ====
 
==== ARM cross compiler ====
  
A cross compiler <ref>https://en.wikipedia.org/wiki/Cross_compiler</ref> must be installed on your Host (X86_64, i686, ...) for the ARM targeted Device architecture. In addition, the $PATH and $CROSS_COMPILE environment variables must be configured in your shell.
+
必须在您的主机(X86_64,i686等)的主机上安装交叉编译器<ref> https://en.wikipedia.org/wiki/Cross_compiler </ ref>,以用于ARM定位的设备体系结构。 另外,必须在您的shell中配置$ PATH和$ CROSS_COMPILE环境变量。
  
You can use gcc for ARM, available in:
+
您可以将gcc用于ARM,可在以下位置使用:
* the SDK toolchain (see [[Cross-compile with OpenSTLinux SDK]])<br/>PATH and CROSS_COMPILE are automatically updated.
+
* SDK工具链 (请参阅 [[Cross-compile with OpenSTLinux SDK]])<br/>PATH和CROSS_COMPILE会自动更新。
* an existing package<br/>For example, install gcc-arm-linux-gnueabihf on Ubuntu/Debian: ({{PC$}} sudo apt-get.
+
* 现有软件包<br/>例如, 在 Ubuntu/Debian  上安装 gcc-arm-linux-gnueabihf : ({{PC$}} sudo apt-get.
* an existing toolchain:
+
* 现有的工具链:
** latest gcc toolchain provided by arm (https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads/)
+
** ARM提供的最新GCC工具链 (https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads/)
** gcc v7 toolchain provided by linaro: (https://www.linaro.org/downloads/)
+
** linaro提供的gcc v7工具链: (https://www.linaro.org/downloads/)
  
For example, to use ''gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz'' from arm, extract the toolchain in $HOME and update your environment with:
+
例如,要使用arm中的 ''gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz'' , 请提取$ HOME中的工具链并使用以下命令更新您的环境:
 
   {{PC$}} export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin:$PATH
 
   {{PC$}} export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin:$PATH
 
   {{PC$}} export CROSS_COMPILE=arm-none-linux-gnueabihf-
 
   {{PC$}} export CROSS_COMPILE=arm-none-linux-gnueabihf-
  
For example, to use '''gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz'''<br/>from https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/<br/>
+
例如, 要使用来自https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/ 中的<br/> '''gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz'''<br/>
Unzip the toolchain in $HOME and update your environment with:
+
要在$ HOME中解压缩工具链,并使用以下命令更新您的环境:
 
   {{PC$}} export PATH=$HOME/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin:$PATH
 
   {{PC$}} export PATH=$HOME/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin:$PATH
 
   {{PC$}} export CROSS_COMPILE=arm-linux-gnueabi-
 
   {{PC$}} export CROSS_COMPILE=arm-linux-gnueabi-
  
 
=== Compilation  ===
 
=== Compilation  ===
In the U-Boot source directory, select the <target> and the <device tree> for your configuration and then execute the <code>make all</code> command:
+
在U-Boot源目录中,选择用于配置的<target><device tree>,然后执行<code> make all </code>命令:
  
 
   {{PC$}} make <target>_defconfig
 
   {{PC$}} make <target>_defconfig
 
   {{PC$}} make DEVICE_TREE=<device-tree> all
 
   {{PC$}} make DEVICE_TREE=<device-tree> all
  
Optionally '''KBUILD_OUTPUT''' can be used to change the output directory to compile several targets or not to compile in the source directory. For example:
+
还可以选择使用 '''KBUILD_OUTPUT''' 更改输出目录以编译多个目标,或者不在源目录中编译。例如:
 
   {{PC$}} export KBUILD_OUTPUT=../build/basic
 
   {{PC$}} export KBUILD_OUTPUT=../build/basic
  
'''DEVICE_TREE''' can also be exported to your environment when only one board is supported. For example:
+
当仅支持一块板时,'''DEVICE_TREE''' 也可以导出到您的环境。 例如:
 
   {{PC$}} export DEVICE_TREE=stm32mp157c-ev1
 
   {{PC$}} export DEVICE_TREE=stm32mp157c-ev1
  
Examples from [[STM32MP15 U-Boot]]:
+
[[STM32MP15 U-Boot]]中的示例:
  
Three configurations are supported for  {{MicroprocessorDevice | device=15}}:
+
{{MicroprocessorDevice | device=15}}支持三种配置:
* {{Highlight|stm32mp15_trusted_defconfig}}: [[Boot_chains_overview#STM32MP boot chains|trusted boot chain]], U-Boot (without SPL) is unsecure and uses Secure monitor from TF-A
+
* {{Highlight|stm32mp15_trusted_defconfig}}: [[Boot_chains_overview#STM32MP boot chains|trusted boot chain]], U-Boot(无SPL)是不安全的,并且使用TF-A的安全监视器
* {{Highlight|stm32mp15_optee_defconfig}}: [[Boot_chains_overview#STM32MP boot chains|trusted boot chain]], U-Boot (without SPL) is unsecure and uses Secure monitor from SecureOS = [[OP-TEE overview|OP-TEE]]
+
* {{Highlight|stm32mp15_optee_defconfig}}: [[Boot_chains_overview#STM32MP boot chains|trusted boot chain]], U引导(不带SPL)是不安全的,并且使用来自SecureOS的安全监视器 = [[OP-TEE overview|OP-TEE]]
* stm32mp15_basic_defconfig: [[Boot_chains_overview#STM32MP boot chains|basic boot chain]], with an SPL as FSBL, U-BOOT is secure and installs monitor with PSCI
+
* stm32mp15_basic_defconfig: [[Boot_chains_overview#STM32MP boot chains|basic boot chain]], 以SPL作为FSBL,U-BOOT是安全的,并通过PSCI安装监视器
  
The board diversity is only managed with the device tree.
+
单板多样性仅通过设备树进行管理.
  
 
   {{PC$}} export KBUILD_OUTPUT=../build/trusted
 
   {{PC$}} export KBUILD_OUTPUT=../build/trusted
第389行: 第389行:
 
   {{PC$}} make DEVICE_TREE=stm32mp157c-<board>  all
 
   {{PC$}} make DEVICE_TREE=stm32mp157c-<board>  all
  
Use help to list other targets:
+
使用帮助列出其他目标:
 
   {{PC$}} make help
 
   {{PC$}} make help
  
 
=== Output files ===
 
=== Output files ===
The resulting U-Boot files are located in your build directory (U-Boot or KBUILD_OUTPUT).
+
生成的U-Boot文件位于您的构建目录 (U-Boot or KBUILD_OUTPUT)中。
  
Two binary formats are used for stm32mp devices:
+
stm32mp设备使用两种二进制格式:
* STM32 image format (*.stm32),  managed by mkimage U-Boot tools and [[Signing_tool]]. It is requested by ROM code and TF-A (see [[STM32 header for binary files]] for details).
+
* STM32图像格式(*.stm32),  由mkimage U-Boot工具和 [[Signing_tool]]管理。 ROM代码和TF-A请求它(详情请参阅 [[STM32 header for binary files]] )
* uImage (*.img) format, file including a U-Boot header, managed by SPL and U-Boot (for kernel load)
+
* uImage (*.img) 格式,包含U-Boot头的文件,由SPL和U-Boot管理(用于内核加载)。
  
The U-Boot generated files are the following
+
U-Boot生成的文件如下:
* For {{Highlight|'''Trusted boot chain'''}} (TF-A is used as FSBL, with or without OP-TEE)
+
* 对于 {{Highlight|'''Trusted boot chain'''}} (TF-A用作FSBL,带有或不带有OP-TEE)
** {{Highlight|'''u-boot.stm32'''}} : U-Boot binary with STM32 image header, loaded by TF-A
+
** {{Highlight|'''u-boot.stm32'''}} : 带有STM32映像头的U-Boot二进制文件,由TF-A加载
  
* For '''Basic boot chain''' (SPL is used as FSBL)
+
* 对于 '''Basic boot chain''' (SPL用作FSBL)
** '''u-boot-spl.stm32''' : SPL binary with STM32 image header, loaded by ROM code
+
** '''u-boot-spl.stm32''' : 带有STM32映像头的SPL二进制文件,由ROM代码加载
** '''u-boot.img''' : U-Boot binary with uImage header, loaded by SPL
+
** '''u-boot.img''' : 具有uImage标头的U-Boot二进制文件,由SPL加载
  
The files used to debug with gdb are
+
用于使用gdb进行调试的文件包括
* u-boot : elf file for U-Boot
+
* u-boot : U-Boot的elf文件
* spl/u-boot-spl : elf file for SPL
+
* spl/u-boot-spl : SPL的elf文件
  
 
== References ==
 
== References ==

2020年11月3日 (二) 11:58的最新版本

Das U-Boot

Das U-Boot (“通用引导加载程序”或U-Boot) 是一种开源引导加载程序,可用于ST板上以初始化平台并加载Linux® 内核。

 PC $> git clone https://gitlab.denx.de/u-boot/u-boot.git

在开始使用U-Boot之前,请阅读README | |}} README file 。它涵盖以下主题:

  • 源文件树结构
  • 配置定义说明
  • 关于构建U-Boot的说明
  • Hush外壳的简要说明
  • 常用环境变量列表

U-Boot overview

Zoom out to STM32MPU Embedded Software

同一个U-Boot源可以生成SPL和U-Boot中使用的两个固件 STM32 MPU boot chain:

  • 受信任的引导链:TF-A作为FSBL,U-Boot作为SSBL
  • 基本启动链:SPL作为FSBL,U-Boot作为SSBL


Warning.png 基本启动链不能用于产品开发 (请参见Boot chains overview 以获取详细信息).

它仅作为最简单的SSBL的示例提供,并支持上游U-Boot开发。但是,当SPL与U-Boot中提供的用于基本引导链的最小安全监视器结合使用时,已经发现了几个已知的限制。它们适用于:

  • 功率
  • 安全访问寄存器
  • 有限的功能(STM32CubeProgrammer / boot from NAND Flash memory).

没有针对这些限制的修复计划。

SPL: FSBL for basic boot

U-Boot SPLSPLthe basic boot chain的第一阶段引导加载程序(FSBL)。
它是从U-Boot源生成的小二进制文件(引导实用程序),并存储在内部有限大小的嵌入式RAM中。SPL的主要功能如下:

  • 它由ROM代码加载。
  • 它执行初始的CPU和板配置(时钟和DDR内存)。
  • 它将SSBL(U-Boot)加载到DDR内存中。

U-Boot: SSBL

U-Boot 是STM32 MPU平台的默认第二阶段引导程序(SSBL)。它同时用于 trusted and basic引导链

SSBL的主要功能如下:

  • 它是可配置和消耗的。
  • 它具有一个简单的命令行界面(CLI),允许用户通过串行端口控制台进行交互。
  • 它提供脚本功能
  • 它将内核加载到RAM中并控制内核
  • 它管理多个内部和外部设备,例如NAND和NOR闪存,以太网和USB。
  • 它支持以下功能和命令:
    • 文件系统:FAT, UBI/UBIFS, JFFS
    • IP堆栈:FTP
    • 显示: LCD, HDMI, BMP for splashcreen
    • USB: host (mass storage) or device (DFU stack)

SPL phases

SPL 在SYSRAM中执行以下主要阶段:

  • board_init_f(): 驱动程序初始化,包括DDR初始化(最小堆栈和堆:CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
  • DDR内存中堆的配置(CONFIG_SPL_SYS_MALLOC_F_LEN)
  • board_init_r(): 初始化在SPL设备树中激活的其他驱动程序
  • 加载并执行U-Boot(或Falcon模式下的内核[1]: doc/README.falcon | |}} README.falcon ).

U-Boot phases

U-Boot 在DDR内存中执行以下主要阶段:

  • Pre-relocation 初始化 (common/board_f.c): 在CONFIG_SYS_TEXT_BASE加载地址上运行的最小初始化(例如CPU,时钟,重置,DDR和控制台)
  • Relocation: 将代码复制到DDR内存的末尾。
  • Post-relocation initialization:(common/board_r.c): 初始化所有驱动程序。
  • Command execution 通过自动引导(CONFIG_AUTOBOOT)或控制台shell
    • 启动命令的执行(默认情况下 bootcmd=CONFIG_BOOTCOMMAND):
      例如,将命令bootm执行到:
      • 加载并检查映像(例如内核,设备树和ramdisk)
      • 修复内核设备树
      • 安装安全监视器(可选)或
      • 将控制权传递给Linux内核(或另一个目标应用程序)

U-Boot configuration

U-Boot二进制配置基于

  • DeviceTree: U-Boot和SPL二进制文件包括在运行时解析的设备树blob

所有的配置标志(前缀为 CONFIG_)都在源代码中描述, 或者在 README | |}} README 文件中,或者在doc/ | |}} documentation directory 目录中。
例如,CONFIG_SPL激活SPL编译
因此,为了选择一个预定义的配置,需要为主板编译 U-Boot,select the <target>the device tree
有关示例,请参阅#U-Boot_build

Kbuild

与内核一样,U-Boot构建系统也基于 configuration symbols (在Kconfig文件中定义). 选定的值存储在build目录的.config文件中,具有相同的Makefile目标。
按照以下步骤进行:

 PC $> make <config>_defconfig.
  • 使用以下五个make 命令之一更改U-Boot编译配置(修改.config):
 PC $> make menuconfig --> menu based program
 PC $> make config  --> line-oriented configuration
 PC $> make xconfig --> QT program[2]
 PC $> make gconfig --> GTK program
 PC $> make nconfig --> ncurse menu based program

然后,您可以使用更新的.config编译U-Boot。

Warning: 修改是在构建目录的本地执行的。在 make distclean 之后它将丢失.

保存您的配置以将其用作defconfig文件:

  PC $> make savedefconfig

此目标将当前配置保存为build目录中的defconfig文件。 然后可以将其与预定义的配置进行比较(configs/stm32mp*defconfig).

其他makefile目标如下:

  PC $> make help
 ....
 Configuration targets:
   config	  - Update current config utilising a line-oriented program
   nconfig         - Update current config utilising a ncurses menu based
                     program
   menuconfig	  - Update current config utilising a menu based program
   xconfig	  - Update current config utilising a Qt based front-end
   gconfig	  - Update current config utilising a GTK+ based front-end
   oldconfig	  - Update current config utilising a provided .config as base
   localmodconfig  - Update current config disabling modules not loaded
   localyesconfig  - Update current config converting local mods to core
   defconfig	  - New config with default from ARCH supplied defconfig
   savedefconfig   - Save current config as ./defconfig (minimal config)
   allnoconfig	  - New config where all options are answered with no
   allyesconfig	  - New config where all options are accepted with yes
   allmodconfig	  - New config selecting modules when possible
   alldefconfig    - New config with all symbols set to default
   randconfig	  - New config with random answer to all options
   listnewconfig   - List new options
   olddefconfig	  - Same as oldconfig but sets new symbols to their
                    default value without prompting

Device tree

请参阅doc/README.fdt-control | |}} doc/README.fdt-control 以获取详细信息。

板设备树具有与内核相同的绑定。它集成在SPL和U-Boot二进制文件中:

  • 默认情况下,它被附加在代码的末尾(CONFIG_OF_SEPARATE).
  • 它嵌入在U-Boot二进制文件(CONFIG_OF_EMBED)中。这对调试很有用,因为它可以轻松加载.elf文件。

defconfig文件中有一个默认的设备树(通过设置CONFIG_DEFAULT_DEVICE_TREE)。

您可以使用DEVICE_TREE make标志选择另一个受支持的设备树。 对于stm32mp板,相应的文件为: arch/arm/dts/ | |}} arch/arm/dts/stm32mp*.dts .

  PC $> make DEVICE_TREE=<dts-file-name>

或提供预编译的设备树blob(using EXT_DTB option):

  PC $> make EXT_DTB=boot/<dts-file-name>.dtb

SPL设备树也从该设备树生成。 但是为了减小其大小,U-Boot生成文件使用fdtgrep工具来解析完整的U-Boot DTB并识别SPL所需的所有驱动程序。

为此,U-Boot使用特定的设备树标志来定义相关的驱动程序是否在U-Boot重定位之前初始化和/或相关的节点是否存在于SPL中:

  • u-boot,dm-pre-reloc => 存在于SPL中,在U-Boot中重新定位之前初始化
  • u-boot,dm-pre-proper => 在U-Boot中重新定位之前初始化
  • u-boot,dm-spl => 存在于SPL中

在U-Boot使用的设备树中,这些标志需要添加到SPL或U-Boot中使用的每个节点中,然后再进行重定位以及每个使用的句柄(时钟,复位,引脚控制)。

U-Boot command line interface (CLI)

请参阅 U-Boot Command Line Interface.

如果CONFIG_AUTOBOOT已激活,则在显示以下行并执行bootcmd(CONFIG_BOOTCOMMAND)后,您有CONFIG_BOOTDELAY秒(默认情况下为2秒)通过按任意键进入控制台:

 Hit any key to stop autoboot:  2

Commands

这些命令在cmd/ | |}} cmd/*.c . 通过相应的 CONFIG_CMD_* 配置标志激活它们。

使用U-Boot shell中的help 命令列出设备上可用的命令:

 Board $> help

以下是从中提取的所有命令的列表 U-Boot Manual (不详尽):

  • Information Commands
    • bdinfo - 打印板信息结构
    • coninfo - 打印控制台设备和信息
    • flinfo - 打印闪存信息
    • iminfo - 打印应用程序映像的标题信息
    • help - 打印在线帮助
  • Memory Commands
    • base - 打印或设置地址偏移量
    • crc32 - 校验和计算
    • cmp - 内存比较
    • cp - 内存拷贝
    • md - 内存显示
    • mm - 内存修改(自动递增)
    • mtest - 简单的RAM测试
    • mw - 内存写入(填充)
    • nm - 内存修改(常量地址)
    • loop - 地址范围内无限循环
  • Flash Memory Commands
    • cp - 内存复制
    • flinfo - 打印闪存信息
    • erase - 清除闪存
    • protect - 启用或禁用闪存写入保护
    • mtdparts - 定义与Linux兼容的MTD分区方案
  • Execution Control Commands
    • source - 从内存运行脚本
    • bootm - 从内存启动应用程序映像
    • go - 在地址‘addr’处启动应用程序
  • Download Commands
    • bootp - 使用BOOTP / TFTP协议通过网络引导映像
    • dhcp - 调用DHCP客户端以获得IP /启动参数
    • loadb - 通过串行线加载二进制文件(kermit模式)
    • loads - 通过串行线加载S-Record文件
    • rarpboot- 使用RARP/TFTP协议通过网络引导映像
    • tftpboot- 使用TFTP协议通过网络引导映像
  • Environment Variables Commands
    • printenv- 打印环境变量
    • saveenv - 将环境变量保存到永久存储
    • setenv - 设置环境变量
    • run - 在环境变量中运行命令
    • bootd - 启动默认设置,即运行‘bootcmd’
  • Flattened Device Tree support
    • fdt addr - 选择要处理的FDT
    • fdt list - 打印等级一级
    • fdt print - 递归打印
    • fdt mknode - 创建新节点
    • fdt set - 设置节点属性
    • fdt rm - 删除节点或属性
    • fdt move - 将FDT blob移动到新地址
    • fdt chosen - 固定动态信息
  • Special Commands
    • i2c - I2C子系统
  • Storage devices
  • Miscellaneous Commands
    • echo - 将参数返回到控制台
    • reset - 执行CPU重置
    • sleep - 将执行延迟预定义的时间
    • version - 打印监视器版本

要添加新命令,请参阅doc/README.commands | |}} doc/README.commands .

U-Boot environment variables

U-Boot行为是通过环境变量配置的。

环境变量请参阅ManualREADME | |}} README

首次启动时,U-Boot使用嵌入在U-Boot二进制文件中的默认环境。 您可以通过更改配置文件中CONFIG_EXTRA_ENV_SETTINGS的内容 (例如 ./include/configs/stm32mp1.h) (请参阅 README | |}} README / - 默认环境).

可以修改此环境并将其保存在引导设备中。 如果存在,它将在U-Boot初始化期间加载:

  • 对于 e•MMC/SD card boot (CONFIG_ENV_IS_IN_EXT4),位于文件 CONFIG_ENV_EXT4_FILE="uboot.env" 中的可引导ext4分区 "bootfs" 中。
  • 对于NAND引导 (CONFIG_ENV_IS_IN_UBI), 在两个UBI卷 "config" (CONFIG_ENV_UBI_VOLUME) 和 "config_r" (CONFIG_ENV_UBI_VOLUME_REDUND)中。
  • 用于NOR引导 (CONFIG_ENV_IS_IN_SPI_FLASH), 位于u-boot_env mtd分区中 (在偏移量 CONFIG_ENV_OFFSET 处).

env command

env 命令允许在U-Boot控制台中显示,修改和保存环境。

 Board $> help env
 env - environment handling commands
 
 Usage:
 env default [-f] -a - [forcibly] reset default environment
 env default [-f] var [...] - [forcibly] reset variable(s) to their default values
 env delete [-f] var [...] - [forcibly] delete variable(s)
 env edit name - edit environment variable
 env exists name - tests for existence of variable
 env print [-a | name ...] - print environment
 env print -e [name ...] - print UEFI environment
 env run var [...] - run commands in an environment variable
 env save - save environment
 env set -e name [arg ...] - set UEFI variable; unset if 'arg' not specified
 env set [-f] name [arg ...]

示例:按以下步骤恢复默认环境并保存它。这在U-Boot升级后很有用:

 Board $> env default -a
 Board $> env save

bootcmd

“bootcmd”变量是自动引导命令。它定义U-Boot启动时执行的命令 (CONFIG_BOOTCOMMAND).

对于stm32mp,请使用 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp":

 Board $> env print bootcmd    
  bootcmd=run bootcmd_stm32mp

"bootcmd_stm32mp" 是一个脚本,它基于generic distro scripts为每个引导设备选择要执行的命令,(请参阅 ./include/configs/stm32mp1.h):

  • 对于 serial/usb: 执行 stm32prog 命令。
  • 对于 mmc boot (e•MMC, SD card), 只能在同一设备上启动 (bootcmd_mmc...).
  • 对于 nand boot, 请使用nand的ubifs分区(bootcmd_ubi0)引导。
  • 对于 nor boot, 使用默认顺序 e•MMC (SDMMC 1)/ NAND / SD card (SDMMC 0) / SDMMC2 (默认的 bootcmd: distro_bootcmd).
 Board $> env print bootcmd_stm32mp

然后,您可以更改此配置:

  • 永久保存在您的电路板文件中 (通过 CONFIG_EXTRA_ENV_SETTINGS 或更改 CONFIG_BOOTCOMMAND 值的默认环境) 或
  • 暂时保存在存储环境中:
 Board $> env set bootcmd run bootcmd_mmc0 
 Board $> env save

注意:要将环境重置为其默认值:

 Board $> env default bootcmd
 Board $> env save

Generic Distro configuration

有关详细信息,请参阅doc/README.distro | |}} doc/README.distro

默认情况下,此功能在ST板上激活(CONFIG_DISTRO_DEFAULTS):

启用DISTRO时,默认情况下执行的命令为include/config_distro_bootcmd.h| |}} include/config_distro_bootcmd.h :

 bootcmd=run distro_bootcmd

此脚本尝试在“boot_targets”变量中找到任意设备,并执行关联的 bootcmd.

mmc0、mmc1、mmc2、pxe和ubifs设备示例:

 bootcmd_mmc0=setenv devnum 0; run mmc_boot
 bootcmd_mmc1=setenv devnum 1; run mmc_boot
 bootcmd_mmc2=setenv devnum 2; run mmc_boot
 bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
 bootcmd_ubifs0=setenv devnum 0; run ubifs_boot

U-Boot 搜索每个可引导设备的extlinux.conf 配置文件。这个文件定义了要使用的内核配置:

  • bootargs
  • kernel + device tree + ramdisk files (optional)
  • FIT image

U-Boot scripting capabilities

"Script files" 是由U-Boot命令解释器执行的命令序列。此功能对于将U-Boot配置为使用真实shell(Hush)作为命令解释程序特别有用。

参见 U-Boot 脚本手册 为例。

U-Boot build

Prerequisites

 PC $> git clone https://github.com/STMicroelectronics/u-boot
 PC $> git clone https://gitlab.denx.de/u-boot/u-boot.git

ARM cross compiler

必须在您的主机(X86_64,i686等)的主机上安装交叉编译器<ref> https://en.wikipedia.org/wiki/Cross_compiler </ ref>,以用于ARM定位的设备体系结构。 另外,必须在您的shell中配置$ PATH和$ CROSS_COMPILE环境变量。

您可以将gcc用于ARM,可在以下位置使用:

例如,要使用arm中的 gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz , 请提取$ HOME中的工具链并使用以下命令更新您的环境:

 PC $> export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin:$PATH
 PC $> export CROSS_COMPILE=arm-none-linux-gnueabihf-

例如, 要使用来自https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/ 中的
gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz
要在$ HOME中解压缩工具链,并使用以下命令更新您的环境:

 PC $> export PATH=$HOME/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin:$PATH
 PC $> export CROSS_COMPILE=arm-linux-gnueabi-

Compilation

在U-Boot源目录中,选择用于配置的<target>和<device tree>,然后执行 make all 命令:

 PC $> make <target>_defconfig
 PC $> make DEVICE_TREE=<device-tree> all

还可以选择使用 KBUILD_OUTPUT 更改输出目录以编译多个目标,或者不在源目录中编译。例如:

 PC $> export KBUILD_OUTPUT=../build/basic

当仅支持一块板时,DEVICE_TREE 也可以导出到您的环境。 例如:

 PC $> export DEVICE_TREE=stm32mp157c-ev1

STM32MP15 U-Boot中的示例:

{{#vardefine:info|}}{{#vardefine:dev|MP15x lines}}{{#vardefine:info| More info.png}}STM32{{#var:dev}}{{#var:info}}支持三种配置:

  • stm32mp15_trusted_defconfig: trusted boot chain, U-Boot(无SPL)是不安全的,并且使用TF-A的安全监视器
  • stm32mp15_optee_defconfig: trusted boot chain, U引导(不带SPL)是不安全的,并且使用来自SecureOS的安全监视器 = OP-TEE
  • stm32mp15_basic_defconfig: basic boot chain, 以SPL作为FSBL,U-BOOT是安全的,并通过PSCI安装监视器

单板多样性仅通过设备树进行管理.

 PC $> export KBUILD_OUTPUT=../build/trusted
 PC $> make stm32mp15_trusted_defconfig
 PC $> make DEVICE_TREE=stm32mp157c-<board> all
 PC $> export KBUILD_OUTPUT=../build/optee
 PC $> export DEVICE_TREE=stm32mp157c-<board>
 PC $> make stm32mp15_optee_defconfig
 PC $> make all
 PC $> make stm32mp15_basic_defconfig
 PC $> make DEVICE_TREE=stm32mp157c-<board>  all

使用帮助列出其他目标:

 PC $> make help

Output files

生成的U-Boot文件位于您的构建目录 (U-Boot or KBUILD_OUTPUT)中。

stm32mp设备使用两种二进制格式:

  • STM32图像格式(*.stm32), 由mkimage U-Boot工具和 Signing_tool管理。 ROM代码和TF-A请求它(详情请参阅 STM32 header for binary files )。
  • uImage (*.img) 格式,包含U-Boot头的文件,由SPL和U-Boot管理(用于内核加载)。

U-Boot生成的文件如下:

  • 对于 Trusted boot chain (TF-A用作FSBL,带有或不带有OP-TEE)
    • u-boot.stm32 : 带有STM32映像头的U-Boot二进制文件,由TF-A加载
  • 对于 Basic boot chain (SPL用作FSBL)
    • u-boot-spl.stm32 : 带有STM32映像头的SPL二进制文件,由ROM代码加载
    • u-boot.img : 具有uImage标头的U-Boot二进制文件,由SPL加载

用于使用gdb进行调试的文件包括

  • u-boot : U-Boot的elf文件
  • spl/u-boot-spl : SPL的elf文件

References

<securetransclude src="ProtectedTemplate:PublicationRequestId" params="12893 | 2019-08-01 |"></securetransclude>