QQ群:519230208,為避免廣告騷擾,申請時請注明 “開發者” 字樣
========================================================
執行命令
u-boot# env default -f -a; setenv ipaddr 192.168.0.100;setenv serverip 192.168.0.107;setenv image zImage;setenv fdt_file zImage-imx6ul-14x14-evk.dtb;setenv rootfsinfo 'setenv bootargs ${bootargs} root=/dev/nfs ip=dhcp nfsroot=${serverip}:/tftpboot/imx6ulevk.rootfs,v3,tcp';setenv bootcmd_net 'run rootfsinfo; dhcp ${image}; dhcp ${fdt_addr} ${fdt_file}; bootz ${loadaddr} - ${fdt_addr}';setenv bootcmd 'run bootcmd_net'
出現錯誤
CPU: Freescale i.MX6UL rev1.0 at 396 MHz
CPU: Temperature 38 C
Reset cause: POR
Board: MX6UL 14x14 EVK
I2C: ready
DRAM: 512 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Display: TFT43AB (480x272)
Video: 480x272x24
In: serial
Out: serial
Err: serial
switch to partitions #0, OK
mmc1 is current device
Net: FEC1
Normal Boot
Hit any key to stop autoboot: 0
BOOTP broadcast 1
DHCP client bound to address 192.168.0.105 (3 ms)
Using FEC1 device
TFTP from server 192.168.0.107; our IP address is 192.168.0.105
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########################
885.7 KiB/s
done
Bytes transferred = 6070432 (5ca0a0 hex)
BOOTP broadcast 1
DHCP client bound to address 192.168.0.105 (3 ms)
Using FEC1 device
TFTP from server 192.168.0.107; our IP address is 192.168.0.105
Filename 'zImage-imx6ul-14x14-evk.dtb'.
Load address: 0x83000000
Loading: ###
364.3 KiB/s
done
Bytes transferred = 34342 (8626 hex)
Kernel image @ 0x80800000 [ 0x000000 - 0x5ca0a0 ]
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
修改為(Thanks tony):
U-boot# setenv serverip 192.168.0.107; setenv bootargs console=ttymxc0,115200 debug root=/dev/nfs ip=dhcp nfsroot=${serverip}:/nfsroot/rootfs,v3,tcp dhcp 0x80800000 zImage; dhcp 0x83000000 zImage-imx6ul-14x14-evk.dtb; bootz 0x80800000 - 0x83000000
# 注釋
# setenv serverip 192.168.0.107; // 設置服務器地址
# setenv bootargs console=ttymxc0,115200 debug root=/dev/nfs ip=dhcp nfsroot=${serverip}:/nfsroot/rootfs,v3,tcp // boot屬性,串口顯示log,配置nfs加載rootfs
# dhcp 0x80800000 zImage; // 設置zImage的加載地址
# dhcp 0x83000000 zImage-imx6ul-14x14-evk.dtb; // 設置dtb文件的加載地址
# bootz 0x80800000 - 0x83000000 // 開始加載地址段之間的內容到內存
以下代碼可以從tftp加載zImage和zImage-imx6ul-14x14-evk.dtb,但加載rootfs時出錯,錯誤log
cpu cpu0: dev_pm_opp_get_opp_count: device OPP not found (-19) gpio_dvfs: disabling VSD_3V3: disabling can-3v3: disabling regulator-dummy: disabling imx mcc test is registered. snvs_rtc 20cc034.snvs-rtc-lp: setting system clock to 2015-08-19 02:41:11 UTC (1439952071) IP-Config: Failed to open eth0 IP-Config: Failed to open eth1 IP-Config: No network devices available ALSA device list: #0: wm8960-audio VFS: Unable to mount root fs via NFS, trying floppy. VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6 Please append a correct "root=" boot option; here are the available partitions: 1f00 32768 mtdblock0 (driver?) b300 15339520 mmcblk1 driver: mmcblk b301 8192 mmcblk1p1 a9d0174c-01 b302 851968 mmcblk1p2 a9d0174c-02 Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0) random: nonblocking pool is initialized
初步斷定是nfs服務器加載失敗, 先設置從sd卡中加載rootfs,可以正常啟動:
setenv bootargs 'console=ttymxc0,115200 debug ip=dhcp root=/dev/mmcblk1p2 rootwait rw'
進入系統后網卡無法正常打開
root@imx6ulevk:/usr/games# ifconfig eth0 up ifconfig: SIOCSIFFLAGS: No such device
查看系統信息
# dmesg | grep eth -C 5
===================================================================================================
常用命令備忘
# env default -f -a // 恢復默認設置 # saveenv // 保存設置到長期存儲emmc,否則掉電設置失效 # help or ? // 查看幫助信息 # print // 打印當前環境信息 # setenv ethaddr xx:xx:xx:xx:xx:xx // 因為要上網,如果網卡沒有mac地址,隨便搞個mac地址
# setenv ethaddr 00.01.02.03.04.05
===================================================================================================
boot四大件兒
Bootloader (U-boot); // 如果沒有指定boot設備,默認從SD/MMC啟動;
// MFGTool可以把u-boot image燒寫到任何所有設備,
// 可以通過dd命令把u-boot image燒寫到sdcard
// 通過u-boot命令行可以把u-boot image 燒寫到其他設備
Linux kernel image(zImage); // 所有I.MX的板子可以用同一套zImage
A device tree file (.dtb) for the board being used // 適配不同的硬件pin和軟件配置文件,專門做適配的一個東東;
// 注意在選擇上有個LDO bypass區別,硬件和系統工程師注意
A root file system(rootfs) for the particular system image // busybox, common libraries
========================================================
SD卡啟動
先准備一張4G卡,如果您有錢用8G也沒關系,只不過會有4G浪費不見了,有更多空間需求也可以自己適配。
可以通過一個命令一次燒寫四大件兒,XXX.sdcard這個文件都包含了,簡單方便。
也可以分批次一個一個燒寫四大件兒,靈活。
Table 1. Image layout |
|||
Start address (sectors) |
Size (sectors) |
Format |
Description |
0x400 bytes (2) |
0x9FFC00 bytes (20478) |
RAW |
U-Boot and reserved area |
0xa00000 bytes (20480) |
500 Mbytes (1024000) |
FAT |
Kernel zImage and DTBs |
0x25800000 bytes (1228800) |
Remaining space |
Ext3/Ext4 |
Rootfs |
准備第一次燒寫:
$ cat /proc/partitions // 找到自己sd卡的盤符,別找錯了,不然可能毀掉你的操作系統
$ sudo dd if=<.sdcard image> of=/dev/sdx bs=1M conv=fsync // 替換到屬於你的.sdcard image和u盤盤符
.sdcard image 這個東西很牛逼,已經對sdcard分好了區,如果你想分開燒寫四大件,你就得自己分區了:
$ sudo umount /dev/sdx // 先卸掉設備
$ sudo fdisk /dev/sdx // 進入磁盤分區程序,別怕費事兒,按順序把下邊兒命令敲了吧
p [lists the current partitions] d [to delete existing partitions. Repeat this until no unnecessary partitions
are reported by the 'p' command to start fresh.]
u [switch the unit to sectors instead of cylinders] n [create a new partition] p [create a primary partition - use for both partitions] 1 [the first partition] 20480 [starting at offset sector] 1024000 [size for the first partition to be used for the boot images] p [to check the partitions]
n p 2 1228800 [starting at offset sector, which leaves enough space for the kernel,
the bootloader and its configuration data] <enter> [using the default value will create a partition that extends to
the last sector of the media] p [to check the partitions]
w [this writes the partition table to the media and fdisk exits]
拷貝四大件兒
內容太多,就不一一拷貝了,參考文檔《i.MX_Linux_User's_Guide.pdf》
========================================================
從NFS啟動系統
setenv serverip 192.168.0.107 setenv consoleinfo 'console=ttymxc0,115200' setenv displayinfo 'video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24' setenv loadaddr 0x80800000 setenv fdt_addr 0x83000000 setenv fdt_file 'zImage-imx6ul-14x14-evk.dtb' setenv special 'uart_from_osc' setenv rootfsinfo 'root=/dev/nfs ip=dhcp nfsroot=${serverip}:/nfsroot/rootfs,v3,tcp' setenv bootargsset 'setenv bootargs ${consoleinfo} ${rootfsinfo} ${displayinfo} ${special}' setenv bootcmd_net 'run rootfsinfo bootargsset; dhcp ${image}; dhcp ${fdt_addr} ${fdt_file}; bootz ${loadaddr} - ${fdt_addr}' setenv bootcmd 'run bootcmd_net' ------------------------- setenv ipaddr 192.168.2.xxx setenv serverip 192.168.2.xxx setenv bootfile uImage setenv nfsroot /home/carmili/ltib/rootfs setenv bootargs_base 'setenv bootargs console=ttymxc0,115200' setenv bootargs_nfs 'setenv bootargs ${bootargs} root=/dev/nfs rw ip=${ipaddr }{serverip }:192.168.2.1:255.255.255.0::eth0ff nfsroot=${serverip}{nfsroot},v3,tcp setenv bootcmd_net 'run bootargs_base bootargs_nfs;bootm' setenv bootcmd 'tftpboot uImage; run bootcmd_net' ------------------------- U-Boot > setenv ipaddr 192.168.0.100 U-Boot > setenv serverip 192.168.0.107 U-Boot > setenv image zImage U-Boot > setenv fdt_file zImage-imx6ul-14x14-evk.dtb U-Boot > setenv rootfsinfo 'setenv bootargs ${bootargs} root=/dev/nfs ip=dhcp nfsroot=${serverip}:/tftpboot/imx6ulevk.rootfs,v3,tcp' U-Boot > setenv bootcmd_net 'run rootfsinfo; dhcp ${image}; dhcp ${fdt_addr} ${fdt_file}; bootz ${loadaddr} - ${fdt_addr}' U-Boot > setenv bootcmd 'run bootcmd_net'
從SD卡啟動
U-Boot > setenv mmcpart 1 U-Boot > setenv loadfdt 'fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}' U-Boot > setenv loadkernel 'fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} zImage' U-Boot > setenv bootcmd 'mmc dev ${mmcdev}; run loadkernel; run mmcargs; run loadfdt; bootz $ {loadaddr} - ${fdt_addr};'