由于項(xiàng)目需要,把玩了半年的DSP(c6748),扔到了一邊,玩起了IMX6Q。本人使用的開(kāi)發(fā)板是imx6q_sarbe_sd(MCIMX6Q-SDB),以下記錄如何通過(guò)u-boot設(shè)置SD,NFS啟動(dòng)。由于IMX6Q的linux包建議在ubuntu9.04下,非root用戶下使用,首先ubuntu9.04有bug,其次非root用戶,操作起來(lái)很不方便。
SD卡啟動(dòng),需要先把uboot,kernel,filesystem燒寫到SD卡上。SD卡燒寫前,可以先在windows下把它格式化。板子啟動(dòng)時(shí)SW6設(shè)置為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卡分一個(gè)區(qū)來(lái)保存文件系統(tǒng)。操作步驟如下:
(1)分區(qū)
$ 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)卸載分區(qū)
$ sudo umount /dev/sdb1
(3)格式化分區(qū),可以是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)復(fù)制文件系統(tǒng)
$ cd /home/user/Freescale/rootfs
$ sudo cp -a * /home/user/Freescale/mountpoint
2,uboot變量設(shè)置
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 對(duì)應(yīng)板子上是slot3
setenv bootcmd 'run bootcmd_mmc'
saveenv
網(wǎng)絡(luò)啟動(dòng)是在uboot起來(lái)后才能完成,因此必須先有SD卡進(jìn)行uboot引導(dǎo)。uboot起來(lái)后,通過(guò)串口設(shè)置uboot變量,達(dá)到自己想要的啟動(dòng)方式。由于開(kāi)發(fā)的過(guò)程kernel文件會(huì)不端更新,因此需要通過(guò)網(wǎng)絡(luò)加載鏡像文件,以下介紹使用tftpboot方式加載。
1,tftp下載uImage
1.1,設(shè)置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
可以根據(jù)你的uImage文件放在路徑,修改上述路徑;也可以在/opt/tftpboot目錄下生成一個(gè)目標(biāo)連接文件。
1.2,tftp下載uImage
MX6Q SABRESD U-Boot >tftpboot uImage
2,文件系統(tǒng)以NFS方式加載
2.1 ,設(shè)置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,通過(guò)串口設(shè)置uboot變量設(shè)置
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'
聯(lián)系客服