介紹如何利用yotta 工具進行編譯 linux mbed client
what is yotta ?
- mbed OS applications as yotta executables
- yotta - to build the mbed example programs
- yotta is a module management system for C++ and C designed to make it easier to build better software by re-using code.
- yotta uses the CMake build system, and targets describe how the compiler should be run by providing a CMake
- yotta is written in python, and distributed using pip, the python package manager
- 利用yotta 可以到yotta 公開的 module registry (http://yotta.mbed.com/)下載 module (即library)來使用. 另外, yotta 目標希望可以用同一份原始碼來編譯出不同平台上的code
(yotta target <target_name>)
yottta 工具安裝
成功安裝完必要的dependency後 , 接著進行安裝 yotta1.) Installing Package Dependencies
sudo apt-get install python-setuptools cmake build-essential ninja-build python-dev
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
sudo apt-get install libssl-dev
sudo easy_install pip
sudo pip install yotta //wait and pray......
問題排除
如果按照上面步驟,安裝yotta, 套件找不到情況, 建立virtualenv , 解決python 相依套件的問題
Installing in a Virtualenv
Virtualenv is a way of separating different python programs installed on the same system from each other. If you have a complex python environment on your system it’s recommended that you install yotta inside a virtualenv.
- Ensure you have virtualenv itself installed. It can be installed with:
pip install virtualenv
Check that your installation is succesful by runningvirtualenv --version
. - Create a directory to use for the yotta virtualenv:
mkdir yotta-venv virtualenv ./yotta-venv
- activate the new virtualenv:
source ./yotta-venv/bin/activate
- install yotta in the virtualenv:
pip install yotta
- (optional) add the binary directory of your virtualenv to your PATH: (if you omit this step, you will need to run yotta as
../path/to/yotta-venv/bin/yotta
instead of simplyyotta
.export PATH="/path/to/yotta-venv/bin:$PATH"
Now yotta should work as normal. You will need to activate the virtualenv any time you want to run yotta commands (you can deactivate it afterwards, by simply running
deactivate
).Yotta 成功安裝畫面 |
編譯 mbed client linux Source
made sure you have installed yotta and all necessary toolchains.
- In the command prompt, go to mbed-client-linux-example.
- Set up the application with correct Certificate and Domain:A. Go to the mbed Device Connector website.B. Go to My devices -> Security credentials.C. Click GET MY DEVICE SECURITY CREDENTIALS. You will get the needed certificate information as well as the endpoint name and domain.D. Copy the security credentials to
source/security.h
. - In the command prompt, type
yotta target
arm-linux-native to set up the target device., 這裡會產生出資料匣 build/arm-linux-native - In the command prompt, type
yotta build
. The executable file will be created in the folderbuild/arm-linux-native/source/
.
(yotta build -d: 可加入debug 訊息輸出)
編譯code 時會去pubic repository 下載module , 故要求驗證身份 5. In the folder mbed-client-linux-example/build/arm-linux-native/source/ , run the executable from the command line, type ./mbed-client-linux-example . |
6. 若要將整個project 清空: 執行 yotta clean
The build process (what is ninja?)
---------------------
參考文件