1.2. Ubuntu

ArtInChip 推荐的 Linux 发行版为 Ubuntu 20.04 LTS(Long Term Support)版本,其他版本也可行,只是安装软件包的依赖和版本不同。

1.2.1. 系统安装

虚拟机和 Ubuntu 20.04 的安装请参考 Luban 中的章节 Ubuntu

1.2.2. 下载 Luban-Lite

Luban-Lite 的代码托管于 Gitee 服务器中,可通过如下方式进行下载:

  • 客户注册 Gitee 账号,通过网页下载

  • 安装 Git,使用 git 命令进行下载

git clone https://gitee.com/artinchip/luban-lite.git

小技巧

建议下载或解压缩之后,在 SDK 根目录,建立 git 仓库,以便跟踪后续修改。

1.2.3. 编译环境准备

Luban-Lite SDK 的开发环境中,还需要安装一些依赖包,并对几个关键工具有版本要求:

  • Python2: 用于编译

  • SCons:自动化构建工具

  • Python3 + pycryptodomex: 用于打包和签名

安装的方法很多,本文提供基于 apt 的在线安装方案

1.2.3.1. 资源库更新

在国内使用 apt 进行软件安装,会经常碰到 http://cn.archive.ubuntu.com/ubuntu 无法访问或者访问速度非常慢,最简单的办法是替换成国内比较快的镜像网站,测试中 mirrors.aliyun.com 的效果很好

sudo gedit /etc/apt/sources.list   中  cn.archive.ubuntu.com 全部更换为 mirrors.aliyun.com
sudo apt-get update

1.2.3.2. 安装 SCons

SCons 是一个开发源码,以 Python 语言编码的自动化构建工具,它是 Make 的改进的、跨平台的替代品,因此 Luban lite 选择 SCons 作为构建工具, 但同时支持对 Makefile 的调用

sudo apt install SCons

1.2.3.3. 安装 pycryptodomex

pycryptodomex 是 Python 的一个加密库,可以通过用 pip 安装 whl 文件, 也可以通过源码进行编译安装, SDK tools/env/local_pkgs/ 中内置了 pycryptodomex 源码

两种安装都需要安装 pip 来提供相应的组件, 并且 ubuntu20.04 中默认安装的 python3-pip

sudo apt install pip
cd tools/env/local_pkgs/
tar xvf pycryptodomex-3.11.0.tar.gz
cd pycryptodomex-3.11.0
sudo python3 setup.py install

1.2.4. 编译检查

如果上述安装均成功,可以进入到 Luban-Lite, 使用 SCons 进行编译校验环境是否搭建成功

scons --list-def            //查看有多少配置
scons --apply-def=0         //选择 0 号配置
scons                       //编译

1.2.5. OneStep

OneStep 是 ArtInChip 对 SCons 工具的二次封装的总称,在基础命令上开发了一组更高效和方便的快捷命令, 以达到任意目录、只需一步的目的

在 Ubuntu 终端中,进入SDK 根目录,使用 source tools/onestep.sh 命令即可使用,包括:

$ h
Luban-Lite SDK OneStep commands:
  hmm|h                     : Get this help.
  lunch          [keyword]  : Start with selected defconfig.e.g. lunch mmc
  menuconfig|me             : Config SDK with menuconfig
  m                         : Build all and generate final image
  mc                        : Clean & Build all and generate final image
  mb                        : Build bootloader & app and generate final image
  c                         : Clean all
  croot|cr                  : cd to SDK root directory.
  cout|co                   : cd to build output directory.
  cbuild|cb                 : cd to build root directory.
  ctarget|ct                : cd to target board directory.
  godir|gd       [keyword]  : Go/jump to selected directory.
  list                      : List all SDK defconfig.
  i                         : Get current project's information.
  buildall                  : Build all the *defconfig in target/configs
  rebuildall                : Clean and build all the *defconfig in target/configs
  addboard|ab               : Add new board *defconfig in target/configs
  aicupg                    : Burn image file to target board