0


3 开源鸿蒙OpenHarmony4.1源码下载、编译,生成OHOS_Image可执行文件的最简易流程

开源鸿蒙OpenHarmony4.1源码下载、编译,生成OHOS_Image可执行文件的最简易流程

作者将狼才鲸日期2024-03-01

  • 准备一台Windows电脑
  • 安装VMware或者VMware Player虚拟机
  • 从华为镜像下载Ubuntu系统,用国内源下载速度更快- Ubuntu 镜像说明- https://repo.huaweicloud.com/ubuntu-releases/ 选择要下载的系统版本- https://repo.huaweicloud.com/ubuntu-releases/18.04.6/ubuntu-18.04.6-desktop-amd64.iso 我使用此链接下载
  • 下载开源鸿蒙系统源码- https://repo.huaweicloud.com/harmonyos/os/ 选择要下载的系统版本- https://repo.huaweicloud.com/harmonyos/os/4.0-Release/code-v4.0-Release.tar.gz 我下载这个,28G
  • 在VMware虚拟机中安装Ubuntu系统
  • 安装完之后进入系统,使用命令行将官方源换成华为源,这样下载软件时更快- 参考自:https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/SEO/mirror/Ubuntu.pdf- sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak 备份配置文件- sudo sed -i “s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g” /etc/apt/sources.list- sudo sed -i “s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g” /etc/apt/sources.list- sudo apt-get update
  • 在Ubuntu系统中解压上面已经下载的openHarmony源码
  • 在Ubuntu系统中安装Docker- 官方文档介绍-Docker编译环境- sudo apt install docker.io- sudo docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 获取轻量系统镜像,获取小型和标准的则使用不同的参数
  • 将你下载好的鸿蒙源码在Ubuntu下解压,进入已经解压的源码根目录
  • 执行 sudo docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 将源码路径导入到Docker中
  • 编译- 轻型系统 - python3 build.py -p qemu_mini_system_demo@ohemu- 小型系统 - python3 build.py -p ipcamera_hispark_taurus@hisilicon- python3 build.py -p qemu_small_system_demo@ohemu- 编译工具和开发板都分为轻型、小型、标准,必须属于同一种类型,否则编译时各种报错
  • 编译成功后是这样的打印:
  1. [OHOS INFO][1614/1615] STAMP obj/build/ohos/images/make_images.stamp
  2. [OHOS INFO][1615/1615] STAMP obj/build/core/gn/images.stamp
  3. [OHOS INFO] ccache_dir = /root/.ccache, ccache_exec = /usr/bin/ccache
  4. [OHOS INFO] --------------------------------------------
  5. [OHOS INFO] ccache summary:
  6. [OHOS INFO] ccache version: 3.7.7
  7. [OHOS INFO] cache hit (direct): 0[OHOS INFO] cache hit (preprocessed): 0[OHOS INFO] cache miss: 0[OHOS INFO] hit rate: 0.00%
  8. [OHOS INFO] miss rate: 0.00%
  9. [OHOS INFO] Cache size (GB):
  10. [OHOS INFO] ---------------------------------------------
  11. [OHOS INFO] c targets overlap rate statistics
  12. [OHOS INFO] subsystem files NO. percentage builds NO. percentage overlap rate
  13. [OHOS INFO] hiviewdfx 120.8% 120.8% 1.00[OHOS INFO] kernel 90263.5% 90263.5% 1.00[OHOS INFO] security 614.3% 614.3% 1.00[OHOS INFO] startup 261.8% 261.8% 1.00[OHOS INFO] systemabilitymgr 151.1% 151.1% 1.00[OHOS INFO] thirdparty 39327.7% 39327.7% 1.00[OHOS INFO][OHOS INFO] c overall build overlap rate: 1.00[OHOS INFO][OHOS INFO][OHOS INFO] qemu_mini_system_demo@ohemu build success
  14. [OHOS INFO] Cost time: 0:05:47
  15. root@ff38bf1e3e75:/home/openharmony#
  16. jim@ubuntu:~/openHarmony/out/arm_mps2_an386/qemu_mini_system_demo$ ls
  17. all_parts_host.json build_configs config.h kconfig_files.txt OHOS_Image.bin src_installed_parts.json
  18. all_parts_info.json build.log error.log libs OHOS_Image.map src_sa_infos_tmp.json
  19. args.gn build.ninja etc NOTICE_FILES OHOS_Image.sym.sorted startup
  20. binary_installed_parts.json build.ninja.d gen obj packages thirdparty
  21. build.1709259296.3884952.log build.trace.gz hiviewdfx OHOS_Image security toolchain.ninja
  22. build.1709259767.6772568.log config.gni kconfig_env.txt OHOS_Image.asm sorted_action_duration.txt
  23. jim@ubuntu:~/openHarmony/out/arm_mps2_an386/qemu_mini_system_demo$
  • 生成的系统镜像image是这里面的OHOS_Image文件
  • 如需退出Docker,执行exit命令即可。这个命令会停止当前的Docker容器,并返回到您的操作系统。
  • 下一步就可以把编译好的操作系统在QEMU模拟器中运行起来了。
标签: 嵌入式 单片机 ARM

本文转载自: https://blog.csdn.net/qq582880551/article/details/136396307
版权归原作者 才鲸嵌入式 所有, 如有侵权,请联系我们删除。

“3 开源鸿蒙OpenHarmony4.1源码下载、编译,生成OHOS_Image可执行文件的最简易流程”的评论:

还没有评论