系统安装

安装Ubuntu Server
Ubuntu Server 20.04.3 LTS 安装图解

必备工具

make

  1. $ sudo apt install make

gcc

  1. $ sudo apt install gcc

python

  1. $ sudo apt install python-is-python3

scons

  1. #
  2. $ sudo apt install scons

mtools

  1. # mcopy: command not found
  2. $ sudo apt install mtools

下载mkimage.stm32

下载地址: 详见官方文档

  1. # mkimage.stm32: not found
  2. $ sudo mv mkimage.stm32 /usr/local/sbin/
  3. # mkimage.stm32: Permission denied
  4. $ sudo chmod +x /usr/local/sbin/mkimage.stm32

Java

  1. # No such file or directory: 'java'
  2. sudo apt install openjdk-11-jre-headless

构建准备

  1. $ mkdir -pv bearpi-micro
  2. $ cd bearpi-micro
  3. $ git clone https://gitee.com/bearpi/bearpi-hm_micro_small.git
  4. $ cd bearpi-hm_micro_small

python depend

  1. $ sudo apt install python3-pip
  2. # No module named 'Crypto'
  3. $ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pycrypto
  4. # No module named 'ecdsa'
  5. $ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple ecdsa
  6. # 鸿蒙构建指令(hb)
  7. $ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build

开始构建

  1. # 进入源码目录,构建配置
  2. $ hb set
  3. # 输入 . 标识当前目录
  4. # 然后输入确定 确定编译的名称(bearpi_hm_micro)
  5. # 执行构建命令 (耗时比较久 2000多个文件包需要编译) -f (强制重头构建)
  6. $ hb build -t notest --tee -f
  7. # 安装过程剖析
  8. ## 1. 先安装llvm
  9. ## 2. 编译遇到问题(mkimage.stm32) 查看上面
  10. ## 3. No such file or directory: 'java'
  11. ## 4. arm-linux-ohoseabi-strip: not found 切换 sh 为 bash
  12. ## ine 89: mcopy: command not found

构建成功

image.png

再次,成了

参考文档

  1. 官方文档 【开源中国】
  2. hb构建命令文档 【Python官方仓库】