MY-IMX28 Linux-3.14.54 編譯手冊(3)
【接上一章節(jié)MY-IMX28 Linux-3.14.54 編譯手冊(2)】
7 應(yīng)用程序編譯
7.1 Linux應(yīng)用程序編譯
7.1.1 編寫應(yīng)用程序
進入工作目錄
$ cd ~/my-imx28/01_application/
編寫源代碼
$ vim hello.c
寫入以下代碼并保存
include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello, MYZR!\n");
return;
}
查看代碼
$ cat hello.c
7.1.2 編譯應(yīng)用程序
配置環(huán)境變量
$ source ~/my-imx28/03_tools/gcc-4.4.4-glibc-2.11.1-multilib-env
編譯
$ ${CROSS_COMPILE}gcc hello.c -o hello.out
注意:上面的命令有包含“$”號,即“${CROSS_COMPILE}gcc”,是引用我們source時產(chǎn)生的環(huán)境變量。
目標(biāo)文件
$ file hello.out
可以看到目標(biāo)文件 hello.out 的屬性。
8 文件系統(tǒng)
8.1 文件系統(tǒng)rootfs.tar.bz2
用以下的方式增加自己的應(yīng)用:(把MY-IMX28_Born_Tool\Profiles\MX28 Linux Update\OS Firmware\files\image-linux-31454/rootfs.tar.bz2復(fù)制到“~/my-imx28/04_image/”目錄下)。
8.2 文件系統(tǒng)filesystem.ubifs
復(fù)制mkfs.ubifs,ubinize到電腦的“/usr/bin”目錄下(如果電腦有這兩個應(yīng)用就不需要復(fù)制了);復(fù)制build_rootfs和ubinize.cfg到“~/my-imx28/04_image/”目錄。
9 燒寫方式
至此,我們在“~/my-imx28/02_source/”得到了除文件系統(tǒng)以外的一套燒錄文件。包括“u-boot.sb”、“imx28-evk.dtb”、“zImage”、“rootfs.tar.bz2”。
9.1 使用MFGTOOL燒寫
把文件“u-boot.sb”、“imx28-evk.dtb”、“zImage”、“rootfs.tar.bz2復(fù)制到“MY-IMX28_Born_Tool\Profiles\MX28 Linux Update\OS Firmware\files\image-linux-31454”目錄下。按住REC按鍵,插上MINI USB線和電源線,接著打開MfgTool.exe,點擊“掃描設(shè)備”,檢測到HID設(shè)備時,松開REC按鍵,如下所示:
點擊菜單的“Options”,然后在選項“Profiles”選擇“MY-IMX28-3.14.54 NAND with uboot”,接著點擊“確定”,最后點擊“開始”。
燒寫成功后,點擊“停止”就OK了。
注意:如果你用的文件系統(tǒng)是rootfs-qt.tar.bz2,請選擇“QT-MY-IMX28-3.14.54 NAND with uboot”燒寫鏡像。
9.2 使用網(wǎng)絡(luò)燒寫
9.2.1 搭建TFTP (ubuntu系統(tǒng))
(1) Setup tftp server files (下載并安裝tftp)
$ sudo apt-get install tftpd tftp openbsd-inetd
(2) make a tftp directory (新建tftp目錄和改變其屬性)
Here we make /home/myzr/tftpt be a tftp directory.
$ mkdir /home/myzr/tftp
$ chmod 777 /home/myzr/tftp
(3) Open /etc/inetd.conf and edit it (修改配置文件的tftp目錄)
$ sudo gedit /etc/inetd.conf
Coment this line :
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp
Add new line:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /home/myzr/tftp
(4)Restarting tftp service (重啟tftp)
$ sudo /etc/init.d/openbsd-inetd restart
9.2.2 搭建NFS (網(wǎng)絡(luò)燒寫不需要用到nfs)
(1) Install NFS server package (下載并安裝nfs)
$ sudo apt-get install nfs-kernel-server
(2) Create NFS directory:/home/myzr/nfsroot (新建nfs目錄)
$ mkdir /home/myzr/nfsroot
(3) Configure mounted directory and authority (修改配置文件的nfs目錄)
$ sudo gedit /etc/exports
Add the following line at the end of the file:
/home/myzr/nfsroot *(rw,sync,no_root_squash)
(4) Restart the NFS service (重啟nfs)
$ sudo /etc/init.d/portmap restart
$ sudo /etc/init.d/nfs-kernel-server restart
9.2.3 tftp下載
(1) 把“u-boot.sb”、“imx28-evk.dtb”、“zImage”、“filesystem.ubifs”復(fù)制到“/home/myzr/tftp”目錄下。
(2) 設(shè)置環(huán)境變量(板子和電腦網(wǎng)線直連)
$ setenv ipaddr 192.168.3.104 (板子IP)
$ setenv serverip 192.168.3.110 (電腦IP)
(3) 燒寫
$ run update_nand_kernel (燒寫zImage)
$ run update_nand_fdt (燒寫fdt)
$ run update_nand_filesystem (燒寫文件系統(tǒng))
10 登錄方式
10.1 串口登錄
插上USB轉(zhuǎn)串口線和電源,開機后,差不多10秒后,在終端上敲回車鍵可以進入系統(tǒng)。
【下章節(jié)為MY-IMX28 Linux-3.14.54 編譯手冊(4)】
*博客內(nèi)容為網(wǎng)友個人發(fā)布,僅代表博主個人觀點,如有侵權(quán)請聯(lián)系工作人員刪除。