鸿蒙轻量操作系统LiteOS_m移植1——下载源码并编译
1. 注册码云SSH公钥
在Linux端安装git、git-lfs、python:
sudo apt install git git-lfs python3-pip curl
配置用户信息:
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
公匙链接参考下面链接:
linux端生成公匙
Gitee公匙设置连接
2. 安装码云repo工具
安装路径以"~/bin"为例
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
将repo添加到环境变量
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
3.下载OpenHarmony源码
方法一
使用 https 协议下载,从版本发布Tag节点获取源码。可获取与版本发布时完全一致的源码。
repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
注:以上命令执行的文件目录请确保干净,不要有.git隐藏文件
方法二
直接下载镜像
OpenHarmony-v4.0-Release源码镜像地址
4.下载编译工具链
执行prebuilts_download.sh脚本
bash build/prebuilts_download.sh
5.安装hb命令
安装hb:
pip install build/hb
添加环境变量:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
6.编译
执行配置命令
hb set
举例:选择mini -> qemu_mini_system_demo
OHOS Which os_level do you need? (Use arrow keys)
❯ mini
small
standard
OHOS Which product do you need? (Use arrow keys)
display_demo
iotlink_demo
mini_distributed_music_player
xts_demo
chipsea
dsoftbus_demo
iotlink_demo
xts_demo
goodix
gr5515_sk_iotlink_demo
gr5515_sk_xts_demo
hihope
neptune_iotlink_demo
hisilicon
wifiiot_hispark_pegasus
hispark_pegasus_mini_system
hpmicro
hpm6750evk2
lockzhiner
lingpi
ohemu
qemu_ca7_mini_system_demo
qemu_cm55_mini_system_demo
qemu_csky_mini_system_demo
❯ qemu_mini_system_demo
qemu_riscv_mini_system_demo
qemu_xtensa_mini_system_demo
开始编译
hb build -f
编译结果:
[OHOS INFO] ---------------------------------------------
[OHOS INFO] ccache summary:
[OHOS INFO] cache hit (direct) : 0
[OHOS INFO] cache hit (preprocessed) : 0
[OHOS INFO] cache miss : 0
[OHOS INFO] hit rate: 0.00%
[OHOS INFO] mis rate: 0.00%
[OHOS INFO] ---------------------------------------------
[OHOS INFO] c targets overlap rate statistics
[OHOS INFO] subsystem files NO. percentage builds NO. percentage overlap rate
[OHOS INFO] hiviewdfx 12 0.9% 12 0.9% 1.00
[OHOS INFO] kernel 884 63.5% 884 63.5% 1.00
[OHOS INFO] security 60 4.3% 60 4.3% 1.00
[OHOS INFO] startup 26 1.9% 26 1.9% 1.00
[OHOS INFO] systemabilitymgr 15 1.1% 15 1.1% 1.00
[OHOS INFO] thirdparty 385 27.6% 385 27.6% 1.00
[OHOS INFO]
[OHOS INFO] c overall build overlap rate: 1.00
[OHOS INFO]
[OHOS INFO]
[OHOS INFO] qemu_mini_system_demo build success
[OHOS INFO] Cost time: 0:02:02
至此整个源码下载及编译过程就完成了,后面首先需要做的就是让LiteOS_m在板子上运行