MY-IMX28 Linux-3.14.54 編譯手冊(3)
【接上一章節M(mǎn)Y-IMX28 Linux-3.14.54 編譯手冊(2)】
7 應用程序編譯
7.1 Linux應用程序編譯
7.1.1 編寫(xiě)應用程序
進(jìn)入工作目錄
$ cd ~/my-imx28/01_application/
編寫(xiě)源代碼
$ vim hello.c
寫(xiě)入以下代碼并保存
include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello, MYZR!\n");
return;
}
查看代碼
$ cat hello.c
7.1.2 編譯應用程序
配置環(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時(shí)產(chǎn)生的環(huán)境變量。
目標文件
$ file hello.out
可以看到目標文件 hello.out 的屬性。
8 文件系統
8.1 文件系統rootfs.tar.bz2
用以下的方式增加自己的應用:(把MY-IMX28_Born_Tool\Profiles\MX28 Linux Update\OS Firmware\files\image-linux-31454/rootfs.tar.bz2復制到“~/my-imx28/04_image/”目錄下)。
8.2 文件系統filesystem.ubifs
復制mkfs.ubifs,ubinize到電腦的“/usr/bin”目錄下(如果電腦有這兩個(gè)應用就不需要復制了);復制build_rootfs和ubinize.cfg到“~/my-imx28/04_image/”目錄。
9 燒寫(xiě)方式
至此,我們在“~/my-imx28/02_source/”得到了除文件系統以外的一套燒錄文件。包括“u-boot.sb”、“imx28-evk.dtb”、“zImage”、“rootfs.tar.bz2”。
9.1 使用MFGTOOL燒寫(xiě)
把文件“u-boot.sb”、“imx28-evk.dtb”、“zImage”、“rootfs.tar.bz2復制到“MY-IMX28_Born_Tool\Profiles\MX28 Linux Update\OS Firmware\files\image-linux-31454”目錄下。按住REC按鍵,插上MINI USB線(xiàn)和電源線(xiàn),接著(zhù)打開(kāi)MfgTool.exe,點(diǎn)擊“掃描設備”,檢測到HID設備時(shí),松開(kāi)REC按鍵,如下所示:
點(diǎn)擊菜單的“Options”,然后在選項“Profiles”選擇“MY-IMX28-3.14.54 NAND with uboot”,接著(zhù)點(diǎn)擊“確定”,最后點(diǎn)擊“開(kāi)始”。
燒寫(xiě)成功后,點(diǎn)擊“停止”就OK了。
注意:如果你用的文件系統是rootfs-qt.tar.bz2,請選擇“QT-MY-IMX28-3.14.54 NAND with uboot”燒寫(xiě)鏡像。
9.2 使用網(wǎng)絡(luò )燒寫(xiě)
9.2.1 搭建TFTP (ubuntu系統)
(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ò )燒寫(xiě)不需要用到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”復制到“/home/myzr/tftp”目錄下。
(2) 設置環(huán)境變量(板子和電腦網(wǎng)線(xiàn)直連)
$ setenv ipaddr 192.168.3.104 (板子IP)
$ setenv serverip 192.168.3.110 (電腦IP)
(3) 燒寫(xiě)
$ run update_nand_kernel (燒寫(xiě)zImage)
$ run update_nand_fdt (燒寫(xiě)fdt)
$ run update_nand_filesystem (燒寫(xiě)文件系統)
10 登錄方式
10.1 串口登錄
插上USB轉串口線(xiàn)和電源,開(kāi)機后,差不多10秒后,在終端上敲回車(chē)鍵可以進(jìn)入系統。
【下章節為MY-IMX28 Linux-3.14.54 編譯手冊(4)】
*博客內容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀(guān)點(diǎn),如有侵權請聯(lián)系工作人員刪除。