14.5.2 開發第一個應用程序
1安裝工具鏈
對于需要在不同的HOST主機上針對于G2L RemiPI進行應用開發,我們需要手動安裝上一章節生成的工具鏈程序,才可以進行后續的開發操作。
首先我們將poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolchain-3.1.20.sh工具鏈拷貝至ubuntu虛擬機家目錄下,拷貝完成后,直接執行即可開始安裝,參考步驟如下。
左右滑動查看完整內容
ubuntu@ubuntu2004:~$ ls poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolc hain-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.sh ubuntu@ubuntu2004:~$ ./poky-glibc-x86_64-myir-image-full-aarch64-myir-remi-1g-toolch ain-3.1.20.sh Each time you wish to use the SDK in a new shell session, you need to s ource the environment setup script e.g. $ . /opt/remi-sdk/environment-setup-aarch64-poky-linux $ . /opt/remi-sdk/environment-setup-armv7vet2hf-neon-vfpv4-pokymllib32-linux-gnueab i
安裝時,會彈出對話框,提示輸入安裝路徑,以及是否安裝,具體操作參考下圖所示:
2測試工具鏈
執行`source /opt/poky/3.1.20/environment-setup-aarch64-poky-linux`與`$CC-v`兩條命令:
出現以上信息,表示SDK安裝成功,接下來就可以直接使用安裝好的SDK進行應用開發。
配置完成工具鏈以后會有一下編譯器名稱,分別是:
?CC
?CFLAGS
?CXX
?CXXFLAGS
?LD
?LDFLAGS
?ARCH
?CROSS_COMPILE
?GDB
?OBJDUMP
編譯器。
C標志,由C編譯器使用。
C++編譯器。
C++標志,由CPP使用
鏈接器。
鏈接標志,由鏈接器使用。
芯片架構名稱。
用于內核編譯。
調試器。
objdump。
如果你需要編譯系統鏡像配套的應用程序,則需要在編譯時指定sysroot對應的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編寫應用程序
接下來使用c語言編寫一個簡單的helloword程序,通過前面我們安裝好的工具鏈交叉編譯,最后上傳至G2L RemiPI安裝。
左右滑動查看完整內容
#includeint main(int argc,char **argv) { printf("Hello RemiPi!! "); return 0; }
設置環境變量,編譯hello.c文件。
左右滑動查看完整內容
ubuntu@ubuntu2004:~$ source /opt/poky/3.1.20/environment-setup-aarch64-poky-linux ubuntu@ubuntu2004:~$ $CC hello.c -o hello In 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: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp] # warning _FORTIFY_SOURCE requires compiling with optimization (-O) ^~~~~~~ ubuntu@ubuntu2004:~$ file hello hello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linke d, interpreter /lib64/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, BuildID[sha1]=eb5 28014693897face9614c09959056f19759777, with debug_info, not stripped
4上傳并運行
編譯完成后,通過前面章節介紹的SCP方式,發送到開發板內,然后運行,即可看到C程序打印的Hello RemiPi!!
左右滑動查看完整內容
ubuntu@ubuntu2004:~/C-Test$ scp hello root@192.168.5.9:/mnt/ hello 100% 13KB 2.1MB/s 00:00
在開發板上執行hello程序:
左右滑動查看完整內容
root@myir-remi-1g:/mnt# ls hello root@myir-remi-1g:/mnt# ./hello Hello RemiPi!!
14.6bitbake使用
14.6.1 顯示編譯過程
bitbake-v <>
14.6.2 清除編譯數據
bitbake-c cleanall recipe_name
清除包括clean、cleanall、cleanstate
14.6.3 編譯過程的信息
附帶debug信息:
bitbake-vDD
14.6.4 查看某個配方的任務
({recipe}_{version}.bb):
bitbake-c listtasks recipe_name
14.6.5 顯示所有配方的版本
當前版本和首選版本:
bitbake-s
14.6.6 構建一個recipe
執行該recipe的所有tasks:
bitbade recipe-name
14.6.7 執行某個recipe的.bb文件
bitbake-b {recipe}_{version}.bb
14.6.8 只運行recipe中的某個task
bitbake-c your-task recipe-name
常見task:
左右滑動查看完整內容
do_build Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
左右滑動查看完整內容
do_checkuri Validates the SRC_URI value
左右滑動查看完整內容
do_checkuriall Validates the SRC_URI value for all recipes required t o build a target
左右滑動查看完整內容
do_clean Removes all output files for a target do_cleanall Removes all output files, shared state cache, and downl oaded source files for a target
左右滑動查看完整內容
do_cleansstate Removes all output files and shared state cache for a t arget
左右滑動查看完整內容
do_compile Compiles the source in the compilation directory
左右滑動查看完整內容
do_configure Configures the source by enabling and disabling any bui ld-time and configuration options for the software being built
左右滑動查看完整內容
do_devpyshell Starts an interactive Python shell for development/deb ugging
左右滑動查看完整內容
do_devshell Starts a shell with the environment set up for developm ent/debugging
左右滑動查看完整內容
do_fetch Fetches the source code
左右滑動查看完整內容
do_fetchall Fetches all remote sources required to build a target
左右滑動查看完整內容
do_install Copies files from the compilation directory to a holdin g area
左右滑動查看完整內容
do_listtasks Lists all defined tasks for a target
左右滑動查看完整內容
do_package Analyzes the content of the holding area and splits it into subsets based on available packages and files
左右滑動查看完整內容
do_package_qa Runs QA checks on packaged files
左右滑動查看完整內容
do_package_qa_setscene Runs QA checks on packaged files (setscene version)
左右滑動查看完整內容
do_package_setscene Analyzes the content of the holding area and splits it into subsets based on available packages and files (setscene version)
左右滑動查看完整內容
do_package_write_ipk Creates the actual IPK packages and places them in the Package Feed area
左右滑動查看完整內容
do_package_write_ipk_setscene Creates the actual IPK packages and places them in the Package Feed area (setscene version)
左右滑動查看完整內容
do_packagedata Creates package metadata used by the build system to ge nerate the final packages
左右滑動查看完整內容
do_packagedata_setscene Creates package metadata used by the build system to g enerate the final packages (setscene version)
左右滑動查看完整內容
do_patch Locates patch files and applies them to the source code
左右滑動查看完整內容
do_populate_lic Writes license information for the recipe that is coll ected later when the image is constructed
左右滑動查看完整內容
do_populate_lic_setscene Writes license information for the recipe that is coll ected later when the image is constructed (setscene version)
左右滑動查看完整內容
do_populate_sysroot Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes
左右滑動查看完整內容
do_populate_sysroot_setscene Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes (setscene version)
do_prebuilt do_recipe_sanity do_recipe_sanity_all
左右滑動查看完整內容
do_unpack Unpacks the source code into a working directory
下載(fetch)、解包(unpack)、打補丁(patch)、配置(configure)、編譯(compile)、安裝(install)、打包(package)、staging、做安裝包
(package_write_ipk)、構建文件系統等。
14.6.9 有錯繼續執行
bitbake-k recipe-name
14.6.10 顯示包的依賴關系
注意必須是發行版包含的包才可以顯示
14.6.11 查看bitbake的版本信息
bitbake--version
14.6.12 bitbake使用說明
bitbake--help
-
Ubuntu
+關注
關注
5文章
569瀏覽量
30229 -
應用程序
+關注
關注
38文章
3305瀏覽量
58146 -
編譯
+關注
關注
0文章
665瀏覽量
33186 -
虛擬機
+關注
關注
1文章
954瀏覽量
28595
原文標題:bitbake使用——RZ MPU工業控制教程連載(61)
文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論