基于soc的嵌入式系統(tǒng)解析方案
2.1.3 加載應(yīng)用程序
用戶應(yīng)用程序可通過target目錄加載到根文件系統(tǒng)中,可根據(jù)需要重建romdisk映像。應(yīng)用程序在userland目錄下,編譯生成運(yùn)行文件后拷貝到target目錄樹中,并根據(jù)target目錄的內(nèi)容創(chuàng)建romdisk.flash文件。新建一個(gè)應(yīng)用程序,首先打開一個(gè) linuxdeveloperbash窗,在userland目錄中創(chuàng)建一個(gè)目錄app,應(yīng)用程序源文件存放在此目錄中,然后在 userland/app/中建立一個(gè)makefile文件。
makefile內(nèi)容如下所示,其中appfile為應(yīng)用程序名。
stackslze=8192
include../../rules.mak
all:appfile.relocbflt
sources=appfile.c
install:
$(romfsinst)appfile.reloebfh
$(romfsdir)/bin/appfile$(execsuffix)
clean:
rm-f *.[iods]core appfile appfile.*elf appfile.*bflt
運(yùn)行make對(duì)應(yīng)用程序進(jìn)行編譯并修改userland/.eonfig和/userland/makefile文件。在userland/. config文件中,增加一行config_my_app=y,在userland/makefile文件中,增加dir_$ (config_my_app)+=app,進(jìn)入userland子目錄,運(yùn)行make,即可將應(yīng)用程序安裝到userland/bin中,并根據(jù) userland/.config文件中相應(yīng)變量的指示將應(yīng)用程序二進(jìn)制拷貝到target目錄中。
最后,鍵入以下命令重新構(gòu)建romdisk映像文件(romdisk.flash),并下載到目標(biāo)板上。
[linux developer]…uclinux/:make clean_target
[linux developer]…uclinux/:make romfs
[linux developer]…uclinux/:nios-run romdisk.flash
2.1.4 運(yùn)行μclinux
完成μclinux內(nèi)核及文件系統(tǒng)的裝載后,即可運(yùn)行μclinux。鍵入g800000(800000為啟動(dòng)代碼地址,在sopc builder中設(shè)置),μclinux自動(dòng)完成初始化過程,用戶輸入登錄用戶名nios,密碼μclinux,出現(xiàn)μclinux的提示符#,表示已進(jìn)入μclinux運(yùn)行環(huán)境。
2.2 轉(zhuǎn)換器應(yīng)用程序的實(shí)現(xiàn)
轉(zhuǎn)換器應(yīng)用系統(tǒng)主要完成網(wǎng)絡(luò)接口和串行接口間的數(shù)據(jù)傳輸,所傳輸?shù)臄?shù)據(jù)流如圖4所示。μclinux操作系統(tǒng)中提供了網(wǎng)絡(luò)驅(qū)動(dòng)程序和串口驅(qū)動(dòng)程序,并提供了多線程的支持。
轉(zhuǎn)換器應(yīng)用系統(tǒng)中的串口收發(fā)數(shù)據(jù)和網(wǎng)絡(luò)口收發(fā)數(shù)據(jù)是異步進(jìn)行的,可分別作為一個(gè)任務(wù)來對(duì)待,任務(wù)間是并發(fā)的,因此可采用多線程程序設(shè)計(jì)技術(shù)來實(shí)現(xiàn)多任務(wù)間的并發(fā)執(zhí)行,系統(tǒng)主程序流程圖如圖5所示。
評(píng)論