14.5.2 開發(fā)第一個應(yīng)用程序
1
安裝工具鏈
對于需要在不同的HOST主機(jī)上針對于G2L RemiPI進(jìn)行應(yīng)用開發(fā),我們需要手動安裝上一章節(jié)生成的工具鏈程序,才可以進(jìn)行后續(xù)的開發(fā)操作。
首先我們將poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolchain-3.1.20.sh工具鏈拷貝至ubuntu虛擬機(jī)家目錄下,拷貝完成后,直接執(zhí)行即可開始安裝,參考步驟如下。
ubuntu@ubuntu2004:~$ ls poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolchain-3.1.20.sh -l-rwxr-xr-x 1 ubuntu ubuntu 1967617427 May 9 05:23 poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolchain-3.1.20.shubuntu@ubuntu2004:~$ ./poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolchain-3.1.20.sh Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.$ . /opt/remi-sdk/environment-setup-aarch64-poky-linux$ . /opt/remi-sdk/environment-setup-armv7vet2hf-neon-vfpv4-pokymllib32-linux-gnueabi
安裝時,會彈出對話框,提示輸入安裝路徑,以及是否安裝,具體操作參考下圖所示:

2
測試工具鏈
執(zhí)行`source /opt/poky/3.1.20/environment-setup-aarch64-poky-linux`與`$CC-v`兩條命令:

出現(xiàn)以上信息,表示SDK安裝成功,接下來就可以直接使用安裝好的SDK進(jìn)行應(yīng)用開發(fā)。
配置完成工具鏈以后會有一下編譯器名稱,分別是:
?CC
?CFLAGS
?CXX
?CXXFLAGS
?LD
?LDFLAGS
?ARCH
?CROSS_COMPILE
?GDB
?OBJDUMP
編譯器。
C標(biāo)志,由C編譯器使用。
C++編譯器。
C++標(biāo)志,由CPP使用
鏈接器。
鏈接標(biāo)志,由鏈接器使用。
芯片架構(gòu)名稱。
用于內(nèi)核編譯。
調(diào)試器。
objdump。
如果你需要編譯系統(tǒng)鏡像配套的應(yīng)用程序,則需要在編譯時指定sysroot對應(yīng)的lib庫與頭文件。
lib64庫路徑
/opt/poky/3.1.20/sysroots/aarch64-poky-linux/usr/lib64

頭文件路徑
/opt/poky/3.1.20/sysroots/aarch64-poky-linux/usr/include

3
編寫應(yīng)用程序
接下來使用c語言編寫一個簡單的helloword程序,通過前面我們安裝好的工具鏈交叉編譯,最后上傳至G2L RemiPI安裝。
int main(int argc,char **argv){printf("Hello RemiPi!!\n");return 0;}
設(shè)置環(huán)境變量,編譯hello.c文件。
ubuntu@ubuntu2004:~$ source /opt/poky/3.1.20/environment-setup-aarch64-poky-linuxubuntu@ubuntu2004:~$ $CC hello.c -o helloIn file included from /opt/poky/3.1.20/sysroots/aarch64-poky-linux/usr/include/bits/libc-header-start.h:33,from /opt/poky/3.1.20/sysroots/aarch64-poky-linux/usr/include/stdio.h:27,from hello.c:1:/opt/poky/3.1.20/sysroots/aarch64-poky-linux/usr/include/features.h:397:4: warning:^~~~~~~ubuntu@ubuntu2004:~$ file hellohello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, BuildID[sha1]=eb528014693897face9614c09959056f19759777, with debug_info, not stripped
4
上傳并運(yùn)行
編譯完成后,通過前面章節(jié)介紹的SCP方式,發(fā)送到開發(fā)板內(nèi),然后運(yùn)行,即可看到C程序打印的Hello RemiPi!!
ubuntu@ubuntu2004:~/C-Test$ scp hello root@192.168.5.9:/mnt/hello 100% 13KB2.1MB/s 00:00
在開發(fā)板上執(zhí)行hello程序:
root@myir-remi-1g:/mnthelloroot@myir-remi-1g:/mnt# ./helloHello RemiPi!!
bitbake使用
14.6.1 顯示編譯過程
bitbake-v <>
14.6.2 清除編譯數(shù)據(jù)
bitbake-c cleanall recipe_name
清除包括clean、cleanall、cleanstate
14.6.3 編譯過程的信息
附帶debug信息:
bitbake-vDD
14.6.4 查看某個配方的任務(wù)
({recipe}_{version}.bb):
bitbake-c listtasks recipe_name
14.6.5 顯示所有配方的版本
當(dāng)前版本和首選版本:
bitbake-s
14.6.6 構(gòu)建一個recipe
執(zhí)行該recipe的所有tasks:
bitbade recipe-name
14.6.7 執(zhí)行某個recipe的.bb文件
bitbake-b {recipe}_{version}.bb
14.6.8 只運(yùn)行recipe中的某個task
bitbake-c your-task recipe-name
常見task:
do_build Default task for a recipe - depends on all other normaltasks required to 'build' a recipe
do_checkuri Validates the SRC_URI valuedo_checkuriall Validates the SRC_URI value for all recipes required to build a target
do_clean Removes all output files for a targetdo_cleanall Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate Removes all output files and shared state cache for a target
do_compile Compiles the source in the compilation directorydo_configure Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_devpyshell Starts an interactive Python shell for development/debugging
do_devshell Starts a shell with the environment set up for development/debugging
do_fetch Fetches the source codedo_fetchall Fetches all remote sources required to build a targetdo_install Copies files from the compilation directory to a holding area
do_listtasks Lists all defined tasks for a targetdo_package Analyzes the content of the holding area and splits itinto subsets based on available packages and files
do_package_qa Runs QA checks on packaged filesdo_package_qa_setscene Runs QA checks on packaged files (setscene version)do_package_setscene Analyzes the content of the holding area and splits itinto subsets based on available packages and files (setscene version)
do_package_write_ipk Creates the actual IPK packages and places them in thePackage Feed area
do_package_write_ipk_setscene Creates the actual IPK packages and places them in thePackage Feed area (setscene version)
do_packagedata Creates package metadata used by the build system to generate the final packages
do_packagedata_setscene Creates package metadata used by the build system to generate the final packages (setscene version)
do_patch Locates patch files and applies them to the source codedo_populate_lic Writes license information for the recipe that is collected later when the image is constructed
do_populate_lic_setscene Writes license information for the recipe that is collected later when the image is constructed (setscene version)
do_populate_sysroot Copies a subset of files installed by do_install intothe sysroot in order to make them available to other recipes
do_populate_sysroot_setscene Copies a subset of files installed by do_install intothe sysroot in order to make them available to other recipes (setscene version)
do_prebuiltdo_recipe_sanitydo_recipe_sanity_all
do_unpack Unpacks the source code into a working directory下載(fetch)、解包(unpack)、打補(bǔ)丁(patch)、配置(configure)、編譯(compile)、安裝(install)、打包(package)、staging、做安裝包
(package_write_ipk)、構(gòu)建文件系統(tǒng)等。
14.6.9 有錯繼續(xù)執(zhí)行
bitbake-k recipe-name
14.6.10 顯示包的依賴關(guān)系
注意必須是發(fā)行版包含的包才可以顯示

14.6.11 查看bitbake的版本信息
bitbake--version
14.6.12 bitbake使用說明
bitbake--help
如您在使用瑞薩MCU/MPU產(chǎn)品中有任何問題,可識別下方二維碼或復(fù)制網(wǎng)址到瀏覽器中打開,進(jìn)入瑞薩技術(shù)論壇尋找答案或獲取在線技術(shù)支持。
https://community-ja.renesas.com/zh/forums-groups/mcu-mpu/
未完待續(xù)
推薦閱讀
LVGL前臺程序開發(fā)相關(guān)操作——RZ MPU工業(yè)控制教程連載(53)
MQTT測試程序上機(jī)實(shí)驗(yàn)及程序開發(fā)——RZ MPU工業(yè)控制教程連載(55)
Modbus TCP Server程序開發(fā)與Yocto系統(tǒng)構(gòu)建——RZ MPU工業(yè)控制教程連載(56)



需要產(chǎn)品及方案支持
請掃碼登記