Beaglebone Black——u-boot环境变量解析

         在进行翻译之前先解说一下u-boot环境变量,u-boot环境变量是保存在非易失性存储(比如Flash)介质的一段内容,u-boot运行后会将这段内容搬到内存中,所以设置环境变量后要用savenv来将对内存中环境变量的修改保存到Flash中。很奇怪的是实际上在BBB开发板上并没有NAND Flash,在进入u-boot后,savenv无法保存你修改的环境变量,如果想要修改保存方法,估计得修改uboot源码,或者如果不想每次启动都要进入uboot设置环境变量而又不想修改保存方法,简单点的做法可以在uboot的源码树目录/include/configs/am335x_evm.h中修改环境变量,这种方法是把环境变量写死到代码中,当然需要重新编译uboot,好处就是可以DIY任意的命令组合,让系统随自己的意愿来启动。

          u-boot有了环境变量,使得它的可配置性增强,即可以在u-boot运行时进行灵活的配置,不会固定死。比如向内核传递启动参数时,如果没有环境变量,那么参数是固定死的,而实际情况中系统的情况可能是多种多样的,有时候是从串口启动,有时候是TFTP方式获取内核,有时候根文件系统是一个NFS,有时候是从SD卡启动,而有了环境变量,通过配置,使得u-boot可以进行更多样、更灵活的动作。

         u-boot环境变量使用起来有点像是脚本,比如设置环境变量setevn A B,那么变量A就是一个值,这个值是B,同时还可以递归使用,这时变量代表了一条语句,比如setevn AeqB setevn A B,那么运行run AeqB时,其动作就是setevn A B,当然,AeqB包含的内容可以不仅仅是一条语句,还可以更多语句以“;”分隔开,甚至是搭配if来进行各种判断,所以说环境变量使用有点像是脚本。

         以下翻译内容来自http://www.denx.de/wiki/view/DULG/UBootEnvVariables

------------------------------------------------------------------------------------------------------------------------------------------------------------

         The U-Boot environment is a block of memory that is kept on persistent storage and copied to RAM when U-Boot starts. It is used to store environment variables which can be used to configure the system. The environment is protected by a CRC32 checksum.

         This section lists the most important environment variables, some of which have a special meaning to U-Boot. You can use these variables to configure the behaviour of U-Boot to your liking.

               U-Boot环境变量是一段保存在永久性存储设备中的内容,当U-Boot启动时这段内容被复制到RAM中。这段内容保存的是环境变量,而这些环境变量又是用于配置系统。这些变量通过CRC32校验和来进行保护。

          以下列出了最重要的环境变量,其中的一些对于U-Boot有特殊的意义。你可以通过这些变量按照自己的意愿来配置U-Boot的行为。

 

           autoload: if set to "no" (or any string beginning with 'n'), the rarpb, bootp or dhcp commands will perform only a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP.

           autoload:如果这个变量设置为"no"或者任何以'n'开始的字符串,那么诸如rarpb、bootp、dhcp这些命令在执行时就仅仅会从BOOTP或者DHCP服务器对相关配置进行查询(比如本机被分配到的IP地址),而不会去通过TFTP下载任何镜像。

 

           autostart: if set to "yes", an image loaded using the rarpb, bootp, dhcp, tftp, disk, or docb commands will be automatically started (by internally calling the bootm command).

           autostart:如果这个变量设置为"yes",那么运行rarpb, bootp, dhcp, tftp, disk, docb这些命令时,在下载镜像文件后,文件将会自动被执行(通过内部调用bootm完成)。

 

           baudrate: a decimal number that selects the console baudrate (in bps). Only a predefined list of baudrate settings is available. When you change the baudrate (using the "setenv baudrate ..." command), U-Boot will switch the baudrate of the console terminal and wait for a newline which must be entered with the new speed setting. This is to make sure you can actually type at the new speed. If this fails, you have to reset the board (which will operate at the old speed since you were not able to saveenv the new settings.) If no "baudrate" variable is defined, the default baudrate of 115200 is used.

                  baudrate:一个用于选择控制台波特率的十进制数(单位bps)。只能从一个预设定的波特率列表中选择(波特率数值不能随意定的)。当要改变波特率时(用命令setenv baudrate ...),U-Boot将会转换控制台终端的波特率,并等待用户从新行输入速度设置。这是为了最终确保用户可以在新的波特率下进行输入。如果不能输入,那么就重启开发板(由于新的波特率设置并没有成功,所以重启操作将会以原来的波特率进行)。如果波特率没有设定,那么将使用默认的115200波特率。

 

           bootargs: The contents of this variable are passed to the Linux kernel as boot arguments (aka "command line").

           bootargs:这个变量的内容将作为启动参数传递给内核(又叫做command line)

 

           bootcmd: This variable defines a command string that is automatically executed when the initial countdown is not interrupted. This command is only executed when the variable bootdelay is also defined!

                  bootcmd:这个变量定义了一串命令,当u-boot启动时,会进行自减计数,计数到0时(如果计数过程中没有外部中断,比如任意按键),将自动开始执行这串命令。仅仅当bootdelay被设置的时候这个命令才会被执行。

 

           bootdelay: After reset, U-Boot will wait this number of seconds before it executes the contents of the bootcmd variable. During this time a countdown is printed, which can be interrupted by pressing any key.

Set this variable to 0 boot without delay. Be careful: depending on the contents of your bootcmd variable, this can prevent you from entering interactive commands again forever!
Set this variable to -1 to disable autoboot.

                  bootdelay: 在重启后,u-boot在执行bootcmd之前会等待数秒钟。这段时间里面控制台终端会显示倒计数,倒计时过程中可以通过按任意键来中断。

           如果这个变量设置为0,即没有延时。注意:根据bootcmd的内容,这种设置可能让你永远无法再和u-boot进行命令交互。

           如果这个变量设置为-1,那么自动启动将会被禁止。(即每次u-boot启动时,都不会执行bootcmd,而是会停下来,等待用户的命令)

                  
           bootfile: name of the default image to load with TFTP

           bootfile:TFTP下载时,下载的默认映像文件名。(如果要下载其他文件名,则修改这个变量)

 

           cpuclk: (Only with MPC859 / MPC866 / MPC885 processors) On some processors, the CPU clock frequency can be adjusted by the user (for example to optimize performance versus power dissipation). On such systems the cpuclk variable can be set to the desired CPU clock value, in MHz. If the cpuclk variable exists and its value is within the compile-time defined limits (CFG_866_CPUCLK_MIN and CFG_866_CPUCLK_MAX = minimum resp. maximum allowed CPU clock), then the specified value is used. Otherwise, the default CPU clock value is set.

           cpuclk:一些处理器(仅仅包括MPC859 / MPC866 / MPC885处理器)的CPU时钟频率可以通过用户来进行调节(比如为了在性能和功率损耗之间进行优化)。在这样的系统中cpuclk可以设置成想要的CPU时钟频率,单位是MHz。如果cpuclk环境变量存在,而且其值属于程序被编译时定义的限制范围内,那么环境变量cpuclk指定的值将被使用,否则设置成默认的CPU时钟频率。(范围由CFG_866_CPUCLK_MIN 和 CFG_866_CPUCLK_MAX确定

 

          ethaddr: Ethernet MAC address for first/only ethernet interface (= eth0 in Linux)。This variable can be set only once (usually during manufacturing of the board). U-Boot refuses to delete or overwrite this variable once it has been set.

          ethaddr:第一个以太网接口(在linux系统中是eth0)的以太网MAC地址。通常在板子生产制作时这个变量的值只能被设置一次。一旦被设置,u-boot不能删除或者覆盖这个变量

 

          eth1addr: Ethernet MAC address for second ethernet interface (= eth1 in Linux).
          eth2addr: Ethernet MAC address for third ethernet interface (= eth2 in Linux).

          eth1addr:第二个以太网接口(在linux系统中是eth1)的以太网MAC地址。

          eth2addr:第三个以太网接口(在linux系统中是eth2)的以太网MAC地址。

 

          initrd_high: used to restrict positioning of initrd ramdisk images:
          If this variable is not set, initrd images will be copied to the highest possible address in RAM; this is usually what you want since it allows for maximum initrd size. If for some reason you want to make sure that the initrd image is loaded below the CFG_BOOTMAPSZ limit, you can set this environment variable to a value of "no" or "off" or "0". Alternatively, you can set it to a maximum upper address to use (U-Boot will still check that it does not overwrite the U-Boot stack and data).
          For instance, when you have a system with 16 MB RAM, and want to reserve 4 MB from use by Linux, you can do this by adding "mem=12M" to the value of the "bootargs" variable. However, now you must make sure that the initrd image is placed in the first 12 MB as well - this can be done with

=> setenv initrd_high 00c00000

         Setting initrd_high to the highest possible address in your system (0xFFFFFFFF) prevents U-Boot from copying the image to RAM at all. This allows for faster boot times, but requires a Linux kernel with zero-copy ramdisk support.

          initrd_high: 用于限制inird randisk镜像的位置

          如果这个变量没有进行设置,ramdisk将会被复制到RAM中的高位地址,这通常是用户所需要的,因为他能最大的满足ramdisk的尺寸。如果由于某些原因你想让ramdisk处于CFG_BOOTMAPSZ之下,那么将这个变量设置成"no"或者"off"或者"0"。同样,你也可以把它设置到最大允许的地址之上(U-Boot将会对这个地址进行检查以确保会不覆盖U-Boot的栈和数据)。

          比如,你的系统有一个16MB的RAM,想保留4MB给linux系统使用,那么你可以在bootargs中添加"mem=12M"然而,你必须确保ramdisk被放在前面的12MB中,这可以通过以下命令进行设置

=> setenv initrd_high 00c00000

          如果initrd_high设置到系统内存中最高的地址(0xFFFFFFFF),那么u-boot将不会把映像文件拷贝到RAM。这使得启动时间更短,但也需要linux内核支持ramdisk零拷贝。

 

          ipaddr: IP address; needed for tftp command

          loadaddr: Default load address for commands like tftp or loads.

          loads_echo: If set to 1, all characters received during a serial download (using the loads command) are echoed back. This might be needed by some terminal emulations (like cu), but may as well just take time on others.         

          mtdparts: This variable (usually defined using the mtdparts command) allows to share a common MTD partition scheme between U-Boot and the Linux kernel.

          ipaddr: 配合TFTP命令的本机(目标板)IP地址。

          loadaddr: 诸如TFTP或者loads等命令用到的默认下载到内存中地址。

          loads_echo: 如果设置为1,那么在从串口下载文件时(使用loads命令),所有接收到的字符都会被回显。这个功能在一些终端模拟器下(比如cu)是有用的,但也会消耗一些时间。

          mtdparts: 这个变量(通过mtdparts来设置)允许u-boot和linux内核之间共享一个MTD分区.

 

          pram: If the "Protected RAM" feature is enabled in your board's configuration, this variable can be defined to enable the reservation of such "protected RAM", i. e. RAM which is not overwritten by U-Boot. Define this variable to hold the number of kB you want to reserve for pRAM. Note that the board info structure will still show the full amount of RAM. If pRAM is reserved, a new environment variable "mem" will automatically be defined to hold the amount of remaining RAM in a form that can be passed as boot argument to Linux, for instance like that:

=> setenv bootargs ${bootargs} mem=\${mem}
=> saveenv

         This way you can tell Linux not to use this memory, either, which results in a memory region that will not be affected by reboots.

         pram:在开发板的配置中如果"Protected RAM" 特性被开启,这个变量可以被定义使得这种"protected RAM"空间被保留,也就是说这部分RAM不能被u-boot被重写。定义这个变量来为pRAM保留数个KB的内存。注意,描述板子信息的结构体仍然会显示出全部的RAM空间。如果有pRAM被保留,那么一个新的环境变量mem将被自动定义代表了剩余的RAM空间,并以启动参数的形式被传递给内核,比如像这样:

=> setenv bootargs ${bootargs} mem=\${mem}
=> saveenv

               这种方式下用户可以告诉linux不要使用这部分RAM空间,那么这部分空间就不会受重启的影响(里面的数据重启后仍然被保留)。

 

         serverip: TFTP server IP address; needed for tftp command.
         serial#: contains hardware identification information such as type string and/or serial number. This variable can be set only once (usually during manufacturing of the board). U-Boot refuses to delete or overwrite this variable once it hass been set.
         silent: If the configuration option CONFIG_SILENT_CONSOLE has been enabled for your board, setting this variable to any value will suppress all console messages. Please see doc/README.silent for details.
         verify: If set to n or no disables the checksum calculation over the complete image in the bootm command to trade speed for safety in the boot process. Note that the header checksum is still verified.

                serverip:TFTP服务器IP地址,TFTP命令会用到这个变量

         serial#: 这个变量包含了硬件识别信息,比如打印字符串或者序列号。这个变量只能被设置一次(在板子被生产的时候)。设置之后u-boot不会删除或者重写这个变量(也就是只读变量)。
         silent: 如果CONFIG_SILENT_CONSOLE被使能,设置这个变量为任何值,u-boot将会禁止所有控制台信息。详细请参考doc/README.silent。
         verify: 在系统启动过程中,有时候会牺牲一些速度以提高安全性,bootm命令会对一个完整的镜像文件进行检验和计算,而如果这个变量设置为n或者no,将会禁止这个校验和计算(启动速度也会因此而加快)。注意,头部的校验仍然会被保留。

 


The following environment variables may be used and automatically updated by the network boot commands

(bootp, dhcp, or tftp), depending the information provided by your boot server:


bootfile: see above
dnsip: IP address of your Domain Name Server
gatewayip: IP address of the Gateway (Router) to use
hostname: Target hostname
ipaddr: see above
netmask: Subnet Mask
rootpath: Pathname of the root filesystem on the NFS server
serverip: see above
filesize: Size (as hex number in bytes) of the file downloaded using the last bootp, dhcp, or tftp command.

 

以下的环境变量可能被用到,并且这些变量会被网络启动命令(bootp, dhcp, or tftp)根据启动服务器提供的信息自动更新,

bootfile: 见上文

dnsip: 域名服务器地址

gatewayip: 网关路由器地址

hostname: 目标主机名

ipaddr: 见上文

netmask: 子网掩码

rootpath: NFS服务器上根文件系统路径

serverip: 见上文

filesize: 最上一次使用诸如bootp, dhcp, or tftp command命令下载的文件的大小,以16进制数表示,单位字节。

 

----------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

 

你可能感兴趣的:(Beaglebone Black——u-boot环境变量解析)