华为鸿蒙操作系统学习(2):在Linux上面使用Docker构建鸿蒙code代码,搭建Dockerfile环境,并跑通构建代码Hi3516,但是使用同样的镜像构建Hi3581,构建失败。
目录
- 前言
- 1,关于鸿蒙系统
- 2,根据文档编写Dockerfile
- 3,使用镜像构建第一个程序Hi3516
- 4,构建另外一个程序Hi3861
- 5,总结
前言
本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/108621002
【鸿蒙系统分类】:
http://blog.csdn.net/freewebsys/article/category/10390587
【gitee项目地址】:
https://gitee.com/studyharmony/linux-build
未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
1,关于鸿蒙系统
OpenHarmony是开放原子开源基金会(OpenAtom Foundation)旗下开源项目,定位是一款面向全场景的开源分布式操作系统。
OpenHarmony在传统的单设备系统能力的基础上,创造性地提出了基于同一套系统能力、适配多种终端形态的理念,支持多种终端设备上运行,第一个版本支持128K-128M设备上运行,欢迎参加开源社区一起持续演进。
针对设备开发者,OpenHarmony采用了组件化的设计方案,可以根据设备的资源能力和业务特征进行灵活裁剪,满足不同形态的终端设备对于操作系统的要求。可运行在百K级别的资源受限设备和穿戴类设备,也可运行在百M级别的智能家用摄像头/行车记录仪等相对资源丰富的设备。
2,根据文档编写Dockerfile
环境搭建是第一步。
我觉得应该给个官方的Dockerfile,这样直接下载镜像得了。
https://gitee.com/studyharmony/linux-build/blob/master/Dockerfile
# 构建命令:
# docker build -t openharmony:dev . #使用 ubuntu:18.04 做基础镜像减少大小。
# 然后安装构建鸿蒙系统需要的软件FROM docker.io/ubuntu:18.04# https://developer.aliyun.com/mirror/
# https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b115c0SRA# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n" > /etc/apt/sources.list && \
echo "[global]\n\
trusted-host=mirrors.aliyun.com\n\
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone# 按照官方的方法继续软件安装:
# https://openharmony.gitee.com/openharmony/docs/blob/master/quick-start/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83-0.md# 将Linux shell改为bash
RUN apt update && apt-get install -y curl && rm -rf /bin/sh && ln -s /bin/bash /bin/sh# 这个是很少变的,放到前面
# 安装gn && 安装ninja && 安装LLVM编译工具链 && 安装hc-genRUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar && \tar -xf gn.1523.tar -C /opt/ && rm -f gn.1523.tarRUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar && \tar -xf ninja.1.9.0.tar -C /opt/ && rm -f ninja.1.9.0.tar# 724M 这个好大,每次都要下载好一会
RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar && \tar -xf llvm-linux-9.0.0-34042.tar -C /opt/ && rm -f llvm-linux-9.0.0-34042.tarRUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar && \tar -xf hc-gen-0.65-linux.tar -C /opt/ && rm -f hc-gen-0.65-linux.tar#安装gcc_riscv32 109M。
RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz && \tar -xf gcc_riscv32-linux-7.3.0.tar.gz -C /opt/ && rm -f gcc_riscv32-linux-7.3.0.tar.gz#增加语言utf-8
ENV LANG=zh_CN.UTF-8
ENV LC_CTYPE=zh_CN.UTF-8# llvm 和其他路径不一样。
RUN echo "export PATH=/opt/gn:/opt/ninja:/opt/llvm/bin:/opt/hc-gen:/opt/gcc_riscv32/bin:$PATH" >> /root/.bashrc # 安装Python环境
RUN apt-get install -y python3.8 python3-pip dosfstools scons mtools zip && \pip3 install setuptools kconfiglib pycryptodome six ecdsa && \rm -f /usr/bin/python && ln -s /usr/bin/python3.8 /usr/bin/python# 使用:
# mkdir -p data && docker run -it -v $PWD/data:/data openharmony:dev bash
然后构建一个docker镜像:
docker build -t openharmony:dev .
3,使用镜像构建第一个程序Hi3516
没有设备,就研究烧录了。
参考
https://openharmony.gitee.com/openharmony/docs/blob/master/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE%8B.md
镜像可以多次使用,映射一个本地data 文件夹:
mkdir -p data && docker run -it -v $PWD/data:/data openharmony:dev bash
进镜像之后
cd /data
mkdir code-hi3516
cd code-hi3516
curl -O https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz
tar -zxvf code-1.0.tar.gz# 直接执行 即可:
python build.py ipcamera_hi3516dv300 -b debug
最后显示构建成功,省略中间好多步。
conformance/interfaces/timer_settime/8-3 compile PASSED
conformance/interfaces/timer_settime/9-2 compile PASSED
conformance/interfaces/timer_settime/5-3 compile PASSED
../../../conformance/interfaces/timer_settime/5-1.c:92:6: warning: absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value [-Wabsolute-value]if (labs(tsleft.tv_sec - SLEEPDELTA) <= ACCEPTABLEDELTA) {^
../../../conformance/interfaces/timer_settime/5-1.c:92:6: note: use function 'llabs' insteadif (labs(tsleft.tv_sec - SLEEPDELTA) <= ACCEPTABLEDELTA) {^~~~llabs
1 warning generated.
conformance/interfaces/timer_settime/5-1 compile PASSED
conformance/interfaces/timer_settime/3-3 compile PASSED
conformance/interfaces/timer_settime/3-1 compile PASSED
conformance/interfaces/timer_settime/3-2 compile PASSED
conformance/interfaces/timer_settime/5-2 compile PASSED
conformance/interfaces/timer_settime/8-4 compile PASSED
conformance/interfaces/timer_settime/13-1 compile PASSED
make[2]: Entering directory '/data/code-hi3561/third_party/ltp/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/speculative'
conformance/interfaces/timer_settime/speculative/12-1 compile PASSED
conformance/interfaces/timer_settime/speculative/12-3 compile PASSED
conformance/interfaces/timer_settime/speculative/12-2 compile PASSED
make[2]: Leaving directory '/data/code-hi3561/third_party/ltp/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/speculative'
make[1]: Leaving directory '/data/code-hi3561/third_party/ltp/testcases/open_posix_testsuite/conformance/interfaces/timer_settime'
make: Leaving directory '/data/code-hi3561/third_party/ltp/testcases/open_posix_testsuite/conformance/interfaces'
[1328/1338] STAMP obj/test/xts/acts/open_posix_testsuite/conformance/interfaces/prebuild_ActsOpenPosixTest.stamp
[1329/1338] ACTION //test/xts/acts/open_posix_testsuite/conformance/interfaces:ActsOpenPosixTest(//build/lite/toolchain:linux_x86_64_clang)
[1330/1338] STAMP obj/test/xts/acts/open_posix_testsuite/conformance/interfaces/ActsOpenPosixTest.stamp
[1331/1338] STAMP obj/test/xts/acts/acts_compoment.stamp
[1332/1338] COPY bin/query.bin suites/acts/resource/tools/query.bin
[1333/1338] STAMP obj/test/xts/acts/query_copy.stamp
[1334/1338] ACTION //test/xts/acts:acts(//build/lite/toolchain:linux_x86_64_clang)
[1335/1338] STAMP obj/test/xts/acts/acts.stamp
[1336/1338] STAMP obj/build/lite/ohos.stamp
[1337/1338] ACTION //build/lite:gen_rootfs(//build/lite/toolchain:linux_x86_64_clang)
[1338/1338] STAMP obj/build/lite/gen_rootfs.stamp
ohos ipcamera_hi3516dv300 build success!
4,构建另外一个程序Hi3861
和第一个类似,但是下载了代码之后执行编译:
python build.py wifiiot
报错如下,看来和Hi3516 的项目构建的东西还是不一样的。
[196/197] ACTION //vendor/hisi/hi3861/hi3861:run_wifiiot_scons(//build/lite/toolchain:linux_x86_64_riscv32_gcc)
FAILED: obj/vendor/hisi/hi3861/hi3861/run_wifiiot_scons_build_ext_components.txt
python ../../build/lite/build_ext_components.py --path=../../vendor/hisi/hi3861/hi3861 --command=sh\ hm_build.sh
/usr/lib/scons/SCons/Defaults.py:213: SyntaxWarning: "is not" with a literal. Did you mean "!="?if len(operation_list) is not 2:
/data/code-hi3861/vendor/hisi/hi3861/hi3861/build/scripts/hi_config_parser.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?if option is '':
/usr/lib/python3/dist-packages/Crypto/Random/Fortuna/FortunaGenerator.py:28: SyntaxWarning: "is" with a literal. Did you mean "=="?if sys.version_info[0] is 2 and sys.version_info[1] is 1:
/usr/lib/python3/dist-packages/Crypto/Random/Fortuna/FortunaGenerator.py:28: SyntaxWarning: "is" with a literal. Did you mean "=="?if sys.version_info[0] is 2 and sys.version_info[1] is 1:
Traceback (most recent call last):File "/usr/lib/scons/SCons/Script/Main.py", line 1376, in main_exec_main(parser, values)File "/usr/lib/scons/SCons/Script/Main.py", line 1339, in _exec_main_main(parser)File "/usr/lib/scons/SCons/Script/Main.py", line 1006, in _mainSCons.Script._SConscript._SConscript(fs, script)File "/usr/lib/scons/SCons/Script/SConscript.py", line 255, in _SConscriptexec(compile(_file_.read(), _file_.name, 'exec'),File "/data/code-hi3861/vendor/hisi/hi3861/hi3861/SConstruct", line 34, in <module>from scripts import pkt_builderFile "/data/code-hi3861/vendor/hisi/hi3861/hi3861/build/scripts/pkt_builder.py", line 24, in <module>import make_upg_file as MAKE_IMAGEFile "/data/code-hi3861/vendor/hisi/hi3861/hi3861/build/scripts/make_upg_file.py", line 30, in <module>from Crypto.PublicKey import RSAFile "/usr/lib/python3/dist-packages/Crypto/PublicKey/RSA.py", line 78, in <module>from Crypto import RandomFile "/usr/lib/python3/dist-packages/Crypto/Random/__init__.py", line 29, in <module>from Crypto.Random import _UserFriendlyRNGFile "/usr/lib/python3/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>from Crypto.Random.Fortuna import FortunaAccumulatorFile "/usr/lib/python3/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>from . import FortunaGeneratorFile "/usr/lib/python3/dist-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 35, in <module>from Crypto.Util import CounterFile "/usr/lib/python3/dist-packages/Crypto/Util/Counter.py", line 59, in <module>from Crypto.Util import _counter
ImportError: cannot import name '_counter' from 'Crypto.Util' (/usr/lib/python3/dist-packages/Crypto/Util/__init__.py)During handling of the above exception, another exception occurred:Traceback (most recent call last):File "/usr/bin/scons", line 201, in <module>SCons.Script.main()File "/usr/lib/scons/SCons/Script/Main.py", line 1401, in mainSCons.Script._SConscript.SConscript_exception()File "/usr/lib/scons/SCons/Script/SConscript.py", line 319, in SConscript_exceptionstack = traceback.extract_tb(tb)File "/usr/lib/python3.8/traceback.py", line 72, in extract_tbreturn StackSummary.extract(walk_tb(tb), limit=limit)File "/usr/lib/python3.8/traceback.py", line 366, in extractf.lineFile "/usr/lib/python3.8/traceback.py", line 288, in lineself._line = linecache.getline(self.filename, self.lineno).strip()File "/usr/lib/python3.8/linecache.py", line 16, in getlinelines = getlines(filename, module_globals)File "/usr/lib/python3.8/linecache.py", line 47, in getlinesreturn updatecache(filename, module_globals)File "/usr/lib/python3.8/linecache.py", line 137, in updatecachelines = fp.readlines()File "/usr/lib/python3.8/codecs.py", line 322, in decode(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 699: invalid continuation byte
Traceback (most recent call last):File "../../build/lite/build_ext_components.py", line 64, in <module>sys.exit(main())File "../../build/lite/build_ext_components.py", line 58, in maincmd_exec(args.command)File "../../build/lite/build_ext_components.py", line 32, in cmd_execraise Exception("{} failed, return code is {}".format(cmd, ret_code))
Exception: ['sh', 'hm_build.sh'] failed, return code is 1
ninja: build stopped: subcommand failed.
you can check build log in /data/code-hi3861/out/wifiiot/build.log
5,总结
使用Docker镜像的方式,能最少的建设不同设备搭建环境的差异。
但是只成功构建了 Hi3516,没有构建成功 Hi3861 的Demo。
而且,我也没有设备。能成功构建,Demo 肯定可以烧录进去。
下面的就不研究了。接着开始看看相关的代码啦。
本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/108621002
博主地址是:https://blog.csdn.net/freewebsys
华为鸿蒙操作系统学习(2):在Linux上面使用Docker构建鸿蒙code代码,搭建Dockerfile环境,并跑通构建代码Hi3516,但是使用同样的镜像构建Hi3581,构建失败。相关推荐
- 华为鸿蒙操作系统学习(3):经过上次的编译发现,鸿蒙的整个项目的源代码现在使用的是v1.0版本。原来可以编译3个设备固件,但是只编译成功两个。使用Dockerfile进行源代码的构建,构建成功。
目录 前言 1,关于鸿蒙系统 2,使用 3,使用Dockerfile进行源代码的构建 3,总结 前言 本文的原文连接是: https://blog.csdn.net/freewebsys/articl ...
- 智能电视可以安装鸿蒙操作系统吗,智能电视或将现寡头垄断,鸿蒙凭为何能“上任”?...
电视机厂商密集发布新品,欲在今年下半年一决高下.8月10日,华为发布荣耀智慧屏:8月16日,TCL发布XESS智屏:8月19日,海信发布社交电视S7.就连拼多多,也联手JVC电视发布了4款" ...
- 【Linux学习笔记】Linux Centos7.4下的Ftp服务的搭建和使用及加密
Linux Centos7.4下的Ftp服务的搭建和使用 服务简介 一.Ftp服务的安装 1.1.安装ftp服务 1.2.启动ftp服务 1.3.将ftp服务设置为开机启动 1.4.停止ftp服务 二 ...
- vm虚拟机下linux安装python_VM中安装linux系统,安装VS Code,搭建Python环境
VM中安装linux系统 在linux系统中安装VSCode(Visual Studio Code) 1.从官网下载安装包 2.在下载目录打开终端安装 sudo dpkg -i code_1.32.3 ...
- Linux操作系统学习笔记(三十)docker和k8s的恩怨情仇
一. 简介 之前聊天发现很多小伙伴对docker和k8s了解甚少,所以决定分享一下在docker和k8s背后这些年容器发展的故事,谈不上以史为鉴,但是至少可以从中汲取经验教训,同时也能了解容器及容 ...
- Linux系统管理(5)——使用yum快速搭建LAMP环境【方便快捷版】
目录 1.安装Apache 2.安装MySQL 3.安装PHP 4.安装其他模块 重启服务 5.修改权限 6.安装phpMyAdmin
- linux cmd 字体,微软开源Cascadia Code新字体,该字体针对命令行和代码编辑器
本周微软不仅开源了他们的C++标准库(STL),而且他们现在也开源了Cascadia Code的新字体. Cascadia Code主要针对开发人员,专门针对命令行应用程序和代码编辑器进行了优化.微软 ...
- 华为鸿蒙os的内核是Linux,谈华为鸿蒙内核和操作系统
作者 | 陆首群 谈到华为自研鸿蒙内核和操作系统,从华为透漏出来的信息来看,有点自相矛盾.扑朔迷离!我曾说过:真真假假,虚虚实实!这里有技术原因,也有外部原因. 一开始(大概是 2016 年左右),华 ...
- 嵌入式Linux操作系统学习规划,学习嵌入式开发需要哪些知识?
嵌入式Linux操作系统学习规划 ARM+LINUX路线,主攻嵌入式Linux操作系统及其上应用软件开发目标: (1) 掌握主流嵌入式微处理器的结构与原理(初步定为arm9) (2) 必须掌握一个嵌入 ...
最新文章
- AlwaysVisibleControlExtender
- HTTP详解(1)-工作原理【转】
- 独家 | 手把手教你处理数据中的缺失值
- IP别名与多网卡绑定(RHEL5/RHEL6)
- Windows 2003不同域之间迁移密码方法笔记截图
- 如何查看spark消耗的内存_Spark优化(三)----数据本地化及内存调优
- bat脚本交互输入_Shell脚本的应用(一)
- ubuntu 下LAMP服务器环境搭建
- 上海石库门建筑群中规模最大的张园 迎来历史性的“重生”
- android秋招面试题及答案,阿里巴巴2019秋招客户端开发工程师在线笔试题和面试题答案...
- 【解决】Oracle服务器ip地址被占用
- Jenkins+maven+SVN构建java项目中遇到的问题及解决
- VS2008SP1无法安装
- 机器人领域的会议和期刊【补充】
- 第九课堂-如何通过着装打造黄金比例完美好身材!
- 三维可视化与智慧消防的关系
- 15条技巧提高你的写作技巧
- 两年多的社招经验分享,我的跳槽经验总结(含阿里滴滴美团快手头条)
- 物联网笔记,基于华为云IOT
- JSP事件——键盘、鼠标、表单
热门文章
- 【jQuery】仿淘宝五星评价打分的实现
- 魔兽世界世界服务器无法响应,魔兽世界怀旧服世界服务器无法连接问题解决方案...
- 安卓手机卡顿怎么解决_苹果手机卡顿反应慢怎么办
- 利用FME读取Word中的表格
- 啡鸟集:掌握这个几个小技能,轻松做一杯咖啡
- 面向对象分析和设计(OOA,OOD,OOP,OOT)
- Java的开方和次方Math.sqrt()方法和Math.pow()方法以及求解有多少种连续正整数之和为N的算法详解
- SSD、HDD、SSHD是什么硬盘
- 中华人民共和国城市列表
- Qt excel VBA findNext及find使用