uboot環境配置 通過配置uboot讓它在啟動過程中從tftp獲取內核和設備樹,並從在載入內核之後把通過啟動參數將"從nfs掛載根文件系統"傳入內核。這個配置主要是通過uboot內建的" +`save`"設置環境變數的方式進行配置,下麵是我採用的uboot的環境變數,下麵是我用的環境變數設置: 就 ...
uboot環境配置
通過配置uboot讓它在啟動過程中從tftp獲取內核和設備樹,並從在載入內核之後把通過啟動參數將"從nfs掛載根文件系統"傳入內核。這個配置主要是通過uboot內建的"set 變數名 變數值
+save
"設置環境變數的方式進行配置,下麵是我採用的uboot的環境變數,下麵是我用的環境變數設置:
#pri #即printenv
baudrate=115200
bootargs=root=/dev/nfs nfsroot=192.168.0.50:/nfs rw console=ttySAC2,115200n8 init=/linuxrc ip=192.168.0.55 loglevel=7 clk_ignore_unused
bootcmd=tftp 41000000 uImage;tftp 42000000 exynos4412-origen.dtb;bootm 41000000 - 42000000
bootdelay=4
ethact=dm9000
ethaddr=11:22:33:44:55:66
fileaddr=41000000
filesize=26D213
gatewayip=192.168.2.1
ipaddr=192.168.0.55
netmask=255.255.255.0
serverip=192.168.0.50
stderr=serial
stdin=serial
stdout=serial
baudrate
就是波特率,習慣上就設成115200,根據硬體的不同可以相應的修改
bootargs
啟動參數,這個參數除了uboot要用,啟動內核之後還會傳入內核。
其中,root=/dev/nfs
表示開發板的根文件系統從nfs網路設備中載入,nfsroot=192.168.0.55:/nfs
表示從網路中的ip是192.168.0.55的主機中的/nfs目錄載入根文件系統,rw
表示可讀可寫,console=ttySAC2
表示使用的中端,115200
表示波特率,init=/linuxrc
表示啟動的祖先進程的位置,顯然這是給linux內核用的,ip=192.168.0.55
是開發板的ip,需要和主機在同一個網段,loglevel=7
就是登錄等級,這個不設也行,clk_ignore_unused
忽略時鐘。這個參數的實質是uboot傳入內核的,所以需要參考內核的啟動參數的相關文件,我在下麵做了簡要的說明。除了啟動參數,uboot還需要做一些其他的準備工作,並不是這個參數準備好了內核就可以工作了,比如,關於arm平臺的linux內核啟動條件,可以參考Linux內核源碼中的Documentation/arm/Booting ,這裡就不做說明瞭
bootcmd
啟動命令,tftp 41000000 uImage
表示從tftp網路中下載uImage內核鏡像到41000000地址處,tftp 42000000 exynos4412-origen.dtb
表示下載從tftp網路中下載設備樹文件到42000000地址處,bootm 41000000 - 42000000
表示從41000000啟動內核,我這沒有randisk,用-
代替,不是從41000000到42000000的意思!!!此外,一旦填入了ramdisk地址,內核就會從ramdisk掛載根文件系統而忽略nfs。最後,把設備樹從42000000傳入內核。
註意:多個命令之間用;
分隔,所以為了在設置變數的時候不立即執行,應該寫成set bootcmd tftp 41000000 uImage\;tftp 42000000 exynos4412-origen.dtb\;bootm 41000000 - 42000000
bootdelay
啟動倒計時的秒數
gatewayip
表示網關
ipaddr
表示開發板的ip
serverip
表示主機的ip
netmask
表示子網掩碼
stderr
,stdin
,stdout
表示標準輸入輸出錯誤設備,基本都填串口serial
Linux內核啟動參數
內核需要的啟動參數在linux-4.8.5/Documentation/kernel-parameters.txt
以及相應的文件中,這些參數就是uboot需要通過bootargs將他們準備好並傳給內核,當然,這些參數都是有預設值的,我們只需要對需要的參數進行配置,這裡列出這裡用到的幾個
noinitrd [RAM] Tells the kernel not to load any configured
initial RAM disk.
root= [KNL] Root filesystem
See name_to_dev_t comment in init/do_mounts.c.
nfsroot= [NFS] nfs root filesystem for disk-less boxes.
See Documentation/filesystems/nfs/nfsroot.txt.
rw [KNL] Mount root device read-write on boot
rootwait [KNL] Wait (indefinitely) for root device to show up.
Useful for devices that are detected asynchronously
(e.g. USB and MMC devices).
ip= [IP_PNP]
See Documentation/filesystems/nfs/nfsroot.txt.
console= [KNL] Output console device and options.
。。。
init= [KNL]
Format: <full_path>
Run specified binary instead of /sbin/init as init
process.
loglevel= All Kernel Messages with a loglevel smaller than the
console loglevel will be printed to the console.
。。。
clk_ignore_unused
[CLK]
Prevents the clock framework from automatically gating
clocks that have not been explicitly enabled by a Linux
device driver but are enabled in hardware at reset or
by the bootloader/firmware.
。。。
$grep ip= Documentation/filesystems/nfs/nfsroot.txt -A 20
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>
This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It was originally called 'nfsaddrs', but now the boot-time IP configuration works independently of NFS, so it was renamed to 'ip' and the old name remained as an alias for compatibility reasons.
。。。。
$grep nfsroot= Documentation/filesystems/nfs/nfsroot.txt -A 20
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
If the 'nfsroot' parameter is NOT given on the command line,
the default "/tftpboot/%s" will be used.
。。。