OpenHarmony 编译固件 (基于HI3516)

开发板简介

OpenHarmony目前官方支持的设备较少,润和软件设计与研发的HiSpark AI Camera(基于HI3516)是其中之一。

如果你是OpenHarmony的初学者,可以通过这块开发板开始学习
在这里插入图片描述

开发板基本参数

配置 型号
SoC Hi3516DV300 (双核 900MHz Cortex A7 )
内存 1GB DDR3
外存 8GB eMMC

部分官方资料

#云盘资料链接: https://pan.baidu.com/s/1uiiCpbJqViGb7Qs6HdCb8g 提取码: ddab

#hihope社区
https://bbs.elecfans.com/group_1429

#润和 HiHope 社区 开源项目集合
https://gitee.com/hihopeorg

#hihope官网(原理图等开发资料,使用安装指导)
http://hihope.org/download/AllDocuments

#华为官网-HarmonyOS官方源码获取
https://device.harmonyos.com/cn/docs/start/introduce/oem_wifi_start_helloword-0000001051930719

编译OpenHarmony

OpenHarmony的代码托管在开源中国 https://gitee.com/openharmony/

你可以通过访问上述地址获取项目的最新代码和资料,因为OpenHarmony项目发展较快,本博客可能存在时效性问题,仅作为参考。

安装编译环境

建议使用64位Ubuntu 18.04系统来编译OpenHarmony。

本博客假定用户在Ubuntu 18.04系统中编译,其他版本的系统操作上可能又细微差异

如果你手边没有Ubuntu 18.04的环境,建议你安装一个虚拟环境,可根据你的使用习惯可自行安装,或者使用以下列表中任意一个软件进行安装

编译环境的硬盘与内存建议

  • 内存建议大于6GB,并且适当调大交换内存。物理内存和交换内存合计建议不低于12GB
  • 硬盘需要建议不低于100GB

在Ubuntu上安装必要的软件

# Ubuntu默认从国外服务器上下载软件,速度较慢
# 如果你在国内编译和开发,建议先切换国内源
#   中国科技大学		http://mirrors.ustc.edu.cn/help/ubuntu.html
#   清华大学		https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu
#   阿里云			https://developer.aliyun.com/mirror/ubuntu
sudo apt-get update
sudo apt-get install -y binutils git git-lfs gnupg flex bison gperf build-essential 
sudo apt-get install -y zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 
sudo apt-get install -y lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache
sudo apt-get install -y libgl1-mesa-dev libxml2-utils xsltproc unzip m4 wget bc python python3
sudo apt-get install -y libssl-dev mtools

# 安装repo工具,repo工具用于拉取OpenHarmony完整代码
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 | sudo tee /usr/local/bin/repo >/dev/null
sudo sed -i 's/env python$/env python3/' /usr/local/bin/repo 
sudo chmod a+x /usr/local/bin/repo

# 将/bin/sh设置为/bin/bash,若不设置可能会编译失败
sudo ln -sf bash /bin/sh

# 设置git信息
git config --global user.name your_name
git config --global user.email your_email

下载源代码

# 由于OpenHarmony源码目录外还会存在一个预下载目录,故建议将openharmony源码目录放到一个单独的目录中
# 本文假定 openharmony 源码目录位于 ~/ohos/openharmony,当然这个不是必须的

# 创建源码目录
mkdir -p ~/ohos/openharmony
cd ~/ohos/openharmony

# 开始拉取代码
repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
## 在网速较慢的情况下不容易 repo sync -c 可能会失败,可考虑使用ssh协议进行拉取,命令如下
## repo init -u ssh://[email protected]/openharmony/manifest.git -b master --no-repo-verify
## 需要注意的是ssh方式拉取需要注册一个gitee账号,并且将你的公钥添加的gitee设置中
## 请参考:https://gitee.com/help/articles/4181

# 下载OpenHarmony提供的一些必要工具
bash build/prebuilts_download.sh

下载完成后,目录结构如下所示

ohos/openharmony
├── applications
├── base
├── build
├── build.py -> build/lite/build.py
├── build.sh -> build/build_scripts/build.sh
├── developtools
├── device
├── docs
├── domains
├── drivers
├── foundation
├── interface
├── kernel
├── out
├── prebuilts
├── productdefine
├── projectpatch
├── test
├── third_party
├── utils
└── vendor

开始编译

cd ~/ohos/openharmony
bash build.sh 

编译成功后,固件将生成到如下位置

ohos/openharmony/out/ohos-arm-release/packages/phone/images
├── Hi3516DV300-emmc.xml
├── system.img
├── u-boot-hi3516dv300_emmc.bin
├── uImage
├── updater.img
├── userdata.img
└── vendor.img

下一章我们继续介绍如何将OpenHarmony烧录到开发板

猜你喜欢

转载自blog.csdn.net/qq_27299467/article/details/119792716