1. 程式人生 > >Beaglebone Black——u-boot環境變數解析

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來進行各種判斷,所以說環境變數使用有點像是指令碼。

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

         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環境變數解析

         在進行翻譯之前先解說一下u-boot環境變數,u-boot環境變數是儲存在非易失性儲存(比如Flash)介質的一段內容,u-boot執行後會將這段內容搬到記憶體中,所以設定環境變數後要用savenv來將對記憶體中環境變數的修改儲存到Flash中。很奇怪的是

u-boot環境變數的設定與使用

今天本來是燒寫核心,結果一不小心把uboot也整不能用了,無奈之下只好重新燒個uboot,等都弄好以後,發現系統還是啟動不了,原來是啟動引數設定不對,於是找到了這篇文章,//是我新增的內容。 原文:      看到這個標題,可能覺得這個並沒有什麼的,其實不然,編好了

u-boot 環境變數引數設定

今天本來是燒寫核心,結果一不小心把uboot也整不能用了,無奈之下只好重新燒個uboot,等都弄好以後,發現系統還是啟動不了,原來是啟動引數設定不對,於是找到了這篇文章,//是我新增的內容。 原文:      看到這個標題,可能覺得這個並沒有什麼的,其實不然,編好了

[IMX6Q]u-boot環境變數原理分析

u-boot版本: v2009.08 一些重要引數如串列埠波特率,bootmcmd,loadaddr等引數,可能需要 動態修改除錯,u-boot提供了環境變數env用於儲存這些資訊到永久性儲存 介質如SD或者RAM中。RAM會丟失,而存於SD則下次開機依然存在。 u-bo

u-boot向kernel傳遞裝置樹、環境變數解析

u-boot向kernel傳遞裝置樹、環境變數解析 【 do_bootm_states---wzf test states:0x1 continue ...... need_boot_fn:0x0 states:0x1 ## Flattened Device

Spring Boot 環境變數讀取 和 屬性物件的繫結

凡是被Spring管理的類,實現介面 EnvironmentAware 重寫方法 setEnvironment 可以在工程啟動時,獲取到系統環境變數和application配置檔案中的變數。 如: @Configuration public class

java環境變數解析

java_home C:\Program Files\Java\jdk-10.0.1 classpath .;%JAVA_HOME%\lib\dt.jar; %JAVA_HOME%\lib\tools.jar path %JAVA_HOME%\bin; %JAVA_HO

Spring Boot 環境變數讀取 和 屬性物件的繫結 RelaxedPropertyResolver

凡是被Spring管理的類,實現介面 EnvironmentAware 重寫方法 setEnvironment 可以在工程啟動時,獲取到系統環境變數和application配置檔案中的變數。 如: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

u-boot-2014.10移植(7)修改環境變數的儲存位置

原來環境變數儲存在nor flash裡, 前面mtdparts分割槽第二個分割槽就是params 現在修改環境變數到nand裡,  搜尋default environment 在Env_common.c函式裡面: default_environment結構體default_environme

U-BOOT的常用環境變數

1、ipaddr是開發板的本地IP地址 2、serverip是開發板通過tftp指令去tftp伺服器下載東西時,tftp伺服器的IP地址。 3、gatewayip是開發板的本地閘道器地址 4、netmask是子網掩碼 5、ethaddr是開發板的本地網絡卡的MAC地址。 6、bo

BeagleBone Black 移植U-Boot (2 MLO、U-Boot)

原文:jexbat.com/categories/BeagleBone/ 什麼是 U-Boot 熟悉嵌入式開發的應該都聽過它,U-boot 就是啟動系統前的一段載入程式,雖然是載入程式,但是功能非常強大。 這一篇主要講解如何從無到有執行 U-Boot,關於 U-Boot 引導 Linux

Beaglebone Black——理論篇beaglebone black啟動——從串列埠獲得SPL、U-BOOT,TFTP伺服器獲得核心,NFS伺服器掛載根檔案系統

          一般來講啟動一個系統所需的bootloader(SPL/MLO、u-boot.img)和根檔案系統(/boot下包含核心zImage)要麼是放在NAND Flash,或者是SD卡,或者是eMMC,或者是USB中,那麼還有一種方式,就是所需要的這些檔案全部

配置u-boot 引數,構造NFS啟動Beaglebone Black板的作業系統

NOTE The printenv and help commands are useful for understanding these variables in more depth. If you wish to view the current value of a specific enviro

在linux系統中通過fw_printenv檢視和設定u-boot中的環境變數

uboot下可以通過命令訪問和修改環境變數,但是如果需要在Linux系統下訪問這些資料該怎麼辦呢?其實uboot早就幫我們想好了。      1、編譯fw_printenv工具     在你使用的uboot程式碼中用以下編譯指令:     make env     這樣就可

u-boot移植(十三)---代碼修改---裁剪及環境變量 一

相關 addition 並且 width load command 啟動程序 type 入參 一、內核裁剪   內核的裁剪首先就是修改我們的配置文件,即 include/configs/jz2440.h 文件,裏面定義的很多宏,我們也許用不上的就要去掉。 1 /*

六,移植uboot-設置默認環境變量,完善u-boot

fin 打補丁 目錄 3.1 partition 循環 char 註意 diff 文檔時間:2018-08-14 交叉編譯器:arm-linux-gcc-4.3.2 Ubuntu版本:16.04 uboot版本:2013.10 1,修改 uboot 默認環境變量 前面章

u-boot-2014.10移植(7)修改環境變量的存儲位置

protected 其中 netmask 變量存儲 fin n) ddr sin flash 原來環境變量存儲在nor flash裏, 前面mtdparts分區第二個分區就是params 現在修改環境變量到nand裏, 搜索default environment 在Env

spring boot 實現不同環境變數下讀取不同的配置檔案

首先,這個問題的出現是老大讓我寫一個在spring boot專案中實現不同裝置產生的日誌檔案大小不一樣。網上查了各種資料,還是沒有解決,都是寫了個片段,比如告訴你可以通過在 application.properties檔案中配置這句話來載入自己指定的配置好的日誌配置檔案logging.confi

解決 Flask 專案無法用 .env 檔案中解析的引數設定環境變數的錯誤

在 Windows 上啟動 Flask 專案時,工作目錄有 UTF-8 編碼的 .env 檔案,裡面配置的環境變數在 Python2 中識別為 Unicode 型別,導致下述錯誤: * Serving Flask app "bootstrap" (lazy loading) * Environme

Win10 環境下 SD 卡燒錄 U-boot 時出現 can not write image

技術分享 not 環境 解決 ffffff win pro proc color 解決方法:Win10 環境下 SD 卡燒錄 U-boot 時出現 can not write image