本人使用的开发板是imx6q_sarbe_sd(MCIMX6Q-SDB),以下记录如何通过u-boot设置SD,NFS启动。由于IMX6Q的linux包建议在ubuntu9.04下,非root用户下使用,首先ubuntu9.04有bug,其次非root用户,操作起来很不方便。
一:SD卡启动
SD卡启动,需要先把uboot,kernel,filesystem烧写到SD卡上。SD卡烧写前,可以先在windows下把它格式化。板子启动时SW6设置为8‘b0100_0010
以下几步为SD卡烧写步骤:
1,SD卡烧写
1.1,烧写uboot
sudo dd if=u-boot.bin of=/dev/sdb bs=512 seek=2 skip=2 conv=fsync
1.2,烧写uImage
sudo dd if=uImage of=/dev/sdb bs=512 seek=2048 conv=fsync
1.3,烧写filesystem
首先需要把SD卡分一个区来保存文件系统。操作步骤如下:
(1)分区
$ fdisk /dev/sdb
u [switch the unit to sectors instead of cylinders]
d [repeat this until no partition is reported by the 'p' command ]
n [create a new partition]
p [create a primary partition]
1 [the first partition]
16384 [starting at offset sector #16384, i.e. 8MB, which leaves enough space for the kernel, the boot loader and its configuration data]
<enter> [using the default value will create a partition that spans to the last sector of the medium]
w [ this writes the partition table to the medium and fdisk exits]
(2)卸载分区
$ sudo umount /dev/sdb1
(3)格式化分区,可以是ext3格式,或ext4
$ sudo mkfs.ext3 /dev/sdb1 Or $ sudo mkfs.ext4 /dev/sdb1
(4)挂载sdb1
$ mkdir /home/user/Freescale/mountpoint
$ sudo mount /dev/sdb1 /home/user/Freescale/mountpoint
(5)复制文件系统
$ cd /home/user/Freescale/rootfs
$ sudo cp -a * /home/user/Freescale/mountpoint
2,uboot变量设置
setenv loadaddr 0x10800000
setenv bootargs_base 'setenv bootargs console=ttymxc0,115200'
setenv bootargs_mmc 'setenv bootargs ${bootargs} ip=${ipaddr} root=/dev/mmcblk1p1 rootwait rw
setenv bootcmd_mmc 'run bootargs_base bootargs_mmc;mmc dev 2;mmc read ${loadaddr} 0x800 0x2000;bootm'
//注意这里的mmc dev 2,dev 2 对应板子上是slot3
setenv bootcmd 'run bootcmd_mmc'
saveenv
二:NFS启动
网络启动是在uboot起来后才能完成,因此必须先有SD卡进行uboot引导。uboot起来后,通过串口设置uboot变量,达到自己想要的启动方式。由于开发的过程kernel文件会不端更新,因此需要通过网络加载镜像文件,以下介绍使用tftpboot方式加载。
1,tftp下载uImage
1.1,设置ubuntu
(1) Setup tftp server files
# apt-get install tftpd tftp openbsd-inetd
(2) make a tftp directory Here we make /opt/tftpboot be a tftp directory.
# mkdir /opt/tftpboot
# chmod 777 /opt/tftpboot
(3) Open /etc/inetd.conf and edit it
# gedit /etc/inetd.conf
Add this line:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /opt/tftpboot
(4)Restarting tftp service
#sudo /etc/init.d/openbsd-inetd restart
可以根据你的uImage文件放在路径,修改上述路径;也可以在/opt/tftpboot目录下生成一个目标连接文件。
1.2,tftp下载uImage
MX6Q SABRESD U-Boot >tftpboot uImage
2,文件系统以NFS方式加载
2.1 ,设置ubuntu
(1), Install NFS server package
# apt-get install nfs-kernel-server
(2), Configure portmap
# dpkg-reconfigure portmap
Select “NO”
(3) ,Configure mounted directory and authority
# gedit /etc/exports
Add the following line at the end of the file:
/home/usr/ltib/rootfs *(rw,sync,no_root_squash)
(4) ,Restart the NFS service
#sudo /etc/init.d/portmap restart
#sudo /etc/init.d/nfs-kernel-server restart
2.2,通过串口设置uboot变量设置
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::eth0:off nfsroot=${serverip}:${nfsroot},v3,tcp
setenv bootcmd_net 'run bootargs_base bootargs_nfs;bootm'
setenv bootcmd 'tftpboot uImage; run bootcmd_net'
|