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, 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 (-)
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 -- :: UTC ()
IP-Config: Failed to open eth0
IP-Config: Failed to open eth1
IP-Config: No network devices available
ALSA device list:
#: 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 mtdblock0 (driver?)
b300 mmcblk1 driver: mmcblk
b301 mmcblk1p1 a9d0174c-
b302 mmcblk1p2 a9d0174c-
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(,)
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
===================================================================================================
常用命令备忘
# 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..xxx
setenv serverip 192.168..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
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};'