AliOS Things開發環境搭建
開發環境搭建官方文檔
1.安裝aos環境
1.1安裝python,pip,git
sudo apt-get install -y python python-pip git
1.2檢查上述工具是否安裝完成
hanqi@hanqi-PC:~/Desktop$ pip -V && python -V && git --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Python 2.7.13
git version 2.11.0
1.3安裝依賴庫和aos-cube
python -m pip install setuptools wheel aos-cube
1.4將aos命令添加到環境變量
# 編輯vim
vim ~/.bashrc
# 在末尾添加
export PATH="/home/hanqi/.local/bin/:$PATH"
# 更新配置
source ~/.bashrc
1.5驗證
hanqi@hanqi-PC:~$ aos -h
Usage: aos [OPTIONS] COMMAND [ARGS]...
Options:
-v, --verbose Verbose diagnostic output
-vv, --very-verbose Very verbose diagnostic output
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
check Do code check
create Create project or component
debug Start gdb server
devices List devices on serial ports
install Install components or tools
list List components and devices
make Make aos program/component
monitor Serial port monitor
open Open an example project
ota OTA firmware management tool
pack Pack and make a component package
remove Remove the installed component or package
upgrade Upgrade tools and components
upload Upload aos image
2.下載AliOS Things源碼
2.1Gitee阿里源碼
git clone https://gitee.com/alios-things/AliOS-Things.git
- 當git完畢之后會在home目錄下多一個AloOS-Things的目錄,里面就是AliOS Things源碼,其目錄結構如下
hanqi@hanqi-PC:~$ cd AliOS-Things/
hanqi@hanqi-PC:~/AliOS-Things$ ls
application build components core include LICENSE NOTICE platform projects README.md README-zh.md test
>
3.編譯源碼
3.1進入AliOS Things目錄,清除配置編譯
hanqi@hanqi-PC:~/AliOS-Things$ aos make distclean
aos-cube version: 0.5.11
Cleaning...
Done
3.2配置內核
hanqi@hanqi-PC:~/AliOS-Things$ aos make menuconfig
3.2.1配置模板工程(以helloworld為例)


3.2.2配置目標板(以LinuxHost為例)


3.3編譯工程
3.3.1開始編譯,但報錯
aos make
3.3.2因為缺少某個庫文件導致報錯,安裝對應文件即可(使用了32位指令,電腦是64位的,無法直接編譯執行32位機器指令)
sudo apt-get install g++-multilib
3.3.3再次編譯即可,最終如下
Build complete: helloworld_demo@linuxhost
3.4執行程序
- 編譯完成后會生成out文件夾,在
/home/hanqi/AliOS-Things/out/helloworld_demo@linuxhost/binary
目錄下會生成可執行文件,執行即可
Build complete: helloworld_demo@linuxhost
hanqi@hanqi-PC:~/AliOS-Things$ ls
aos_config.h application build components core include LICENSE NOTICE out platform projects README.md README-zh.md test
hanqi@hanqi-PC:~/AliOS-Things$ cd out/
hanqi@hanqi-PC:~/AliOS-Things/out$ ls
config helloworld_demo@linuxhost
hanqi@hanqi-PC:~/AliOS-Things/out$ cd helloworld_demo@linuxhost/
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost$ ls
aos_all_components.mk auto_component binary config.mk includes libraries modules
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost$ cd binary/
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$ ls
helloworld_demo@linuxhost.bin helloworld_demo@linuxhost.map helloworld_demo@linuxhost_ota.bin.xz readme.txt
helloworld_demo@linuxhost.elf helloworld_demo@linuxhost_map.csv helloworld_demo@linuxhost.stripped.elf
helloworld_demo@linuxhost.hex helloworld_demo@linuxhost_ota.bin link.opts
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$ ./helloworld_demo@linuxhost.elf
cpu num is 1
Welcome to AliOS Things
nano entry here!
hello world! count 0
hello world! count 1
hello world! count 2
hello world! count 3
hello world! count 4
hello world! count 5
hello world! count 6
^C
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$