【Aliso-things笔记】Ubuntu构建Alios-things开发环境

配置环境

系统环境为Ubuntu 14.04.5 64-bit,官方推荐的系统环境为Ubuntu 16.04 LTS (Xenial Xerus) 64-bit

$ sudo apt-get install -y python
$ sudo apt-get install -y gcc-multilib
$ sudo apt-get install -y libssl-dev libssl-dev:i386
$ sudo apt-get install -y libncurses5-dev libncurses5-dev:i386
$ sudo apt-get install -y libreadline-dev libreadline-dev:i386
$ sudo apt-get install -y python-pip
$ sudo apt-get install -y minicom

注意: python版本为2.7

安装aos-cube

首先, 用 python 包管理器 pip 来安装 aos-cube 和相关的依赖包在全局环境,以便于后续使用 AliOS Things Studio 进行开发。

$sudo pip install --upgrade setuptools
$sudo pip install --upgrade wheel
$sudo pip install --upgrade aos-cube

这里安装可能会遇到安装scons时安装出现如下错误

Installing collected packages: scons, pyaes, ecdsa
Running setup.py install for scons
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: -c --help [cmd1 cmd2 ...]
   or: -c --help-commands
   or: -c cmd --help

error: option --single-version-externally-managed not recognized
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/scons/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-v5mML1-record/install-record.txt --single-version-externally-managed --compile --user:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/scons/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-v5mML1-record/install-record.txt --single-version-externally-managed --compile --user failed with error code 1 in /tmp/pip_build_root/scons
Storing debug log for failure in /home/yystart/.pip/pip.log

解决方法:
首先将pip升级到最新版本

$sudo pip install --upgrade pip

然后下载当前版本的scons文件,例如scons-3.0.1.tar.gz,然后将文件拷贝到某个目录下,也可以放到python2.7/dist-packages/库目录下

$ tar xvf scons-3.0.1.tar.gz
$ mv scons-3.0.1 scons
$ cd scons
$ sudo python setup.py build
$ sudo python setup.py install

然后用下面的命令安装

$sudo pip install --user -e scons  #scons为源码目录
$sudo pip install --user -U aos-cube

AliOS-Things代码下载及编译

下载 AliOS Things 代码从GitHub克隆:

$ git clone https://github.com/alibaba/AliOS-Things.git

或者从国内镜像站点:

$ git clone https://gitee.com/alios-things/AliOS-Things.git    

接着进行编译工作,这里编译Linux测试版本

cd AliOS-Things
aos make helloworld@linuxhost

编译完成后,会在AliOS-Things目录下生成/out/helloworld@linuxhost生成的固件就位于该目录的binary下。

同理编译esp8266固件为:

$ aos make helloworld@esp8266

编译esp32固件为:

$ aos make helloworld@esp32devkitc

注意:
在安装aos-cube后,在Ubuntu下运行aos命令,但是终端显示无法找到该命令,这是由于aos命令所在的目录没有添加到环境变量中,随意无法识别,只要添加环境变量就可以了,操作步骤如下

  • 找到aos命令所在的目录
    在aos-cube目录下载,例如我在安装aos-cube是出现如下目录信息

    Requirement already satisfied: aos-cube in ./.local/lib/python2.7/site-packages (0.2.50)
    Requirement already satisfied: pyserial in /usr/local/lib/python2.7/dist-packages (from aos-cube) (3.4)
    Requirement already satisfied: esptool in ./.local/lib/python2.7/site-packages (from aos-cube) (2.5.0)
    Requirement already satisfied: scons in ./workspace/alios-things/scons/engine (from aos-cube) (3.0.1)
    Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from aos-cube) (2.2.1)
    Requirement already satisfied: pyaes in /usr/local/lib/python2.7/dist-packages (from esptool->aos-cube) (1.6.1)
    Requirement already satisfied: ecdsa in /usr/local/lib/python2.7/dist-packages (from esptool->aos-cube) (0.13)

所以直接使用find命令到~/.local中查找

$ find ~/.local -name aos

得到下面的结果
./.local/lib/python2.7/site-packages/aos
./.local/bin/aos
  • 设置环境变量
    将aos路径添加到环境变量中

    ALIOS=xxx/.local/bin/ #xxx要填写实际的路径
    export PATH=$PATH:$ALIOS
    

固件下载

$ aos upload helloworld@esp8266

注意:当我们将8266模块通过串口连接的Ubuntu系统时,会被系统是被为/dev/ttyUSBx类型设备,我们在使用aos upload命令烧写固件时,普通用户是没有操作串口权限的,所以需要将设备修改一下权限

$ sudo chmod 777 /dev/ttyUSBx

参考资料

alios-things wiki

你可能感兴趣的:(Alios-things)