OpenHarmony系统-源码下载,环境搭建,编译,烧录,调试

获取源码

以OpenHarmony5.0.3为例

repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-5.0.3-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'

搭建环境

安装必要的工具和命令

apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools  pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6  gcc-arm-none-eabi vim ssh locales doxygenapt-get install -y libxinerama-dev libxcursor-dev libxrandr-dev libxi-devpip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple requests setuptools pymongo kconfiglib pycryptodome ecdsa ohos-build pyyaml prompt_toolkit==1.0.14 redis json2html yagmail python-jenkins pip3 install esdk-obs-python --trusted-host pypi.org pip3 install six --upgrade --ignore-installed six

编译

安装编译器及二进制工具

build/prebuilts_download.sh

编译

以DAYU200(RK3568)为例

./build.sh --product-name rk3568 --ccache --no-prebuilt-sdk

烧录系统

以DAYU200(RK3568)为例,其编译生成的镜像文件在下面位置,需要将其拷贝到window系统然后使用RK提供的RKDevTool进行烧录
out/rk3568/packages/phone/images

调试命令

hdc命令

hdc(Harmony Device Connector)是Openharmony标准的设备连接与调试工具,功能类似于 Android 的 adb。它用于开发过程中与设备(或模拟器)进行通信,包括文件传输、应用安装、日志查看、命令执行等

                         OpenHarmony device connector(HDC) ...---------------------------------global commands:-----------------------------------h/help [verbose]                     - Print hdc help, 'verbose' for more other cmds-v/version                            - Print hdc version-t connectkey                         - Use device with given connect key---------------------------------component commands:-------------------------------
session commands(on server):list targets [-v]                     - List all devices status, -v for detailstart [-r]                            - Start server. If with '-r', will be restart serverkill [-r]                             - Kill server. If with '-r', will be restart serverservice commands(on daemon):target mount                          - Set /system /vendor partition read-writewait                                  - Wait for the device to become availabletarget boot [-bootloader|-recovery]   - Reboot the device or boot into bootloader\recovery.target boot [MODE]                    - Reboot the into MODE.smode [-r]                            - Restart daemon with root permissions, '-r' to cancel rootpermissionstmode usb                             - Reboot the device, listening on USBtmode port [port]                     - Reboot the device, listening on TCP port---------------------------------task commands:-------------------------------------
file commands:file send [option] local remote       - Send file to devicefile recv [option] remote local       - Recv file from deviceoption is -a|-s|-z-a: hold target file timestamp-sync: just update newer file-z: compress transfer-m: mode syncforward commands:fport localnode remotenode            - Forward local traffic to remote devicerport remotenode localnode            - Reserve remote traffic to local hostnode config name format 'schema:content'examples are below:tcp:<port>localfilesystem:<unix domain socket name>localreserved:<unix domain socket name>localabstract:<unix domain socket name>dev:<device name>jdwp:<pid> (remote only)fport ls                              - Display forward/reverse tasksfport rm taskstr                      - Remove forward/reverse task by taskstringapp commands:install [-r|-s] src                   - Send package(s) to device and install themsrc examples: single or multiple packages and directories(.hap .hsp)-r: replace existing application-s: install shared bundle for multi-appsuninstall [-k] [-s] package           - Remove application package from device-k: keep the data and cache directories-s: remove shared bundledebug commands:hilog [-h]                            - Show device log, -h for detailshell [COMMAND...]                    - Run shell command (interactive shell if no command given)bugreport [FILE]                      - Return all information from the device, stored in file if FILE is specifiedjpid                                  - List PIDs of processes hosting a JDWP transporttrack-jpid [-a|-p]                    - Track PIDs of debug processes hosting a JDWP transport-a: include debug and release processes-p: don't display debug and release tagssecurity commands:keygen FILE                           - Generate public/private key; key stored in FILE and FILE.pub

hdc list targets

列出当前已连接的设备,相当于 adb devices

hdc shell

打开设备终端,进入设备的命令行环境.相当于 adb shell

hdc file send

向设备上传文件,相当于 adb push

hdc file recv

从设备下载文件相当于 adb pull

hdc install

安装 .hap 应用包到设备,相当于adb install

hdc uninstall

卸载应用(根据包名),相当于adb uninstall

hdc stdio

用于将本地标准输入输出重定向到远程设备,适合做调试时查看 log 或与远程进程交互

hdc start

启动 hdc 服务

hdc kill

停止 hdc 服务

hdc -t 192.168.1.100:8710 shell

通过网络链接调试设备,行当于adb connect & adb shell

hilog

hilog 是 OpenHarmony 中用于日志系统的命令行工具,类似于 Android 的 logcat。它可以帮助开发者在调试过程中查看系统运行日志、定位问题,是系统调试的重要工具之一

hilog -x

格式化日志输出,更易读

#过滤日志级别,常用级别debug,info,warn,error,fatal,
hilog -x -L error
#or
hilog -x -L E   # Error#过滤特定 tag 标签
hilog -x -T mytag#过滤多个 tag
hilog -x -T tag1 -T tag2#保存日志到文件
hilog -x > /data/logs/hilog.txt#清除日志缓存
hilog -c

其他

hb命令

hb 是OpenHarmony提供的构建工具命令行工具(类似于 Android 的 mm 或 make),用于配置、构建、打包、发布和安装 OpenHarmony 工程

hb set

配置构建环境,包括选择产品和构建目标板

usage: hb set [option]optional arguments:-h, --help            show this help message and exit-p PRODUCT_NAME, --product-name PRODUCT_NAMEDefault:''. Help:build a specified product. You could use this option like this: 1.'hb set --product-name rk3568@hihope' 2.'hb set --product-name rk3568' 3.'hb set'[graphical ui]--all [ALL]           Default:False. Help:Use a graphical interface to customize most compile-time parameters

hb env

查看当前 hb 环境的配置,包括构建路径、目标、构建类型等

usage: hb env [option]optional arguments:-h, --help            show this help message and exit-s SSHKEY, --sshkey SSHKEYDefault:''. Help: set sshkey-l [CLEAN], --clean [CLEAN]Default:false. Help: clean all env args--check [CHECK]       Default:True. Help:check that the current running environment contains all dependencies--install [INSTALL]   Default:False. Help:install all dependent software for compiling L0, L1 and L2 products-i [INDEP_BUILD], --indep-build [INDEP_BUILD]Default:false. Help: switch to independent build--part PART           Default:''. Help:Specify component name, run 'hb env --part {part_name}'--target-cpu {arm,arm64,x86_64,x64,mipsel,riscv64,loongarch64}Default:'arm'. Help:Specifies the desired cpu architecture for the build, each may support different cpu architectures, run 'hb env --target-cpu {cpu_architectures}' to set cpu architectures--target-os {android,ohos,mac,linux,windows}Default:''. Help:Specifies the desired os type for the build, each may support different os type, run 'hb env --target-os {os_type}' to setos type

hb build

执行构建操作,生成可执行镜像文件

usage: hb build [option]optional arguments:-h, --help            show this help message and exit--target-cpu {arm,arm64,x86_64,x64,mipsel,riscv64,loongarch64}Default:''. Help:Specifies the desired cpu architecture for the build, each may support different cpu architectures, run 'hb set --all' tolist product all supported cpu architectures--target-os {android,ios}Default:''. Help:Specifies the desired os type for the build, each may support different os type, run 'hb set --all' to list product allsupported os type-p PRODUCT_NAME, --product-name PRODUCT_NAMEDefault:''. Help:Build a specified product. You could use this option like this: 1.'hb build --product-name rk3568@hihope' 2.'hb build--product-name rk3568'--rename-last-log [RENAME_LAST_LOG]Default:True. Help:You can use it to decide whether to keep the last build log--log-mode {normal,silent}Default:'normal'. Help:You can use this option to determine whether to use single-line refresh log mode--precise-branch PRECISE_BRANCHDefault:'dayu200_tdd'. Help:You can use this option to select the dayu200_tdd branch--ccache [CCACHE]     Default:True. Help:Enable ccache, this option could improve compilation speed. --stat-ccache can summary the cache data--xcache [XCACHE]     Default:False. Help:Enable xcache, this option could improve compilation speed. --stat-ccache can summary the cache data--enable-pycache [ENABLE_PYCACHE]Default:False. Help:Enable pycache, This option can improve the execution speed of python files--jobs JOBS           Deprecated, please do not use this option--disable-part-of-post-build [DISABLE_PART_OF_POST_BUILD [DISABLE_PART_OF_POST_BUILD ...]]Deprecated, please do not use this option-T [BUILD_TARGET [BUILD_TARGET ...]], --build-target [BUILD_TARGET [BUILD_TARGET ...]]Default:[]. Help:You use this option to specify a single compilation target, and use 'hb tool --ls' to list all build target--ninja-args [NINJA_ARGS [NINJA_ARGS ...]]Default:[]. Help:You can use it to pass parameters for the ninja phase, but you need to follow the specified command format. eg. --ninja-args=-dkeeprsp-f [FULL_COMPILATION], --full-compilation [FULL_COMPILATION]Default:[]. Help:You can use it to start full code compilation. The default compilation target is images. Use this option to add 'make_all'and 'make_test' to the build process.--strict-mode [STRICT_MODE]Default:False. Help:Check all produce of each phase to early terminates a potentially problematic compilation.--scalable-build [SCALABLE_BUILD]Default:False. Help:Select whether to read information from parts.json generate by preload--build-example [BUILD_EXAMPLE]Default:False. Help:Select whether to read information from subsystem_config_example.json--build-platform-name BUILD_PLATFORM_NAMEDefault:'phone'. Help:Name of the compilation platform. The current optional value is 'phone'--build-xts [BUILD_XTS]Default:False. Help:Select whether to load the components included in the subsystem xts--ignore-api-check [IGNORE_API_CHECK [IGNORE_API_CHECK ...]]Default:[]. Help:Skip the check of some subsystems--load-test-config [LOAD_TEST_CONFIG]Default:True. Help:Select whether to load the test field in bundle.json, that is, whether to call the test case--skip-partlist-check [SKIP_PARTLIST_CHECK]Default:False. Help:Skip the subsystem and component check in partlist file--build-type {release,profile,debug}Default:'release'. Help:Specify compile release or debug version--log-level {info,debug}Default:'INFO'. Help:Specify the log level during compilation. you can select two levels: debug, info. In debug mode, it show all commandlines while building, including cxx, link, solink, etc.--export-para [EXPORT_PARA [EXPORT_PARA ...]]Deprecated, please do not use this option--test [TEST [TEST ...]]Default:[]. Help:You can use it to choose test type. eg. --test xts--gn-args [GN_ARGS [GN_ARGS ...]]Default:[]. Help:Specify gn build arguments, you could use this option like this 'hb build --gn-args is_debug=true'--gn-flags [GN_FLAGS [GN_FLAGS ...]]Default:[]. Help:Specify gn build arguments, you could use this option like this 'hb build --gn-flags "--export-compile-commands"-c COMPILER, --compiler COMPILERDeprecated, please do not use this option--fast-rebuild [FAST_REBUILD]Default:False. Help:You can use it to skip prepare, preloader, gn_gen steps so we can enable it only when there is no change for gn relatedscript--root-perf-main {root,main,root_main}Default:root. Help:different kinds of root packages--runtime-mode {release,debug,profile}Default:release. Help:runtime mode--check-compilation-parameters [CHECK_COMPILATION_PARAMETERS]Default:false. Help:check compilation parameters--keep-ninja-going [KEEP_NINJA_GOING]Default:False. Help:When you need to debug one specific target, you can use this option to keep ninja going to skip some possible error until1000000 jobs fail--build-only-load [BUILD_ONLY_LOAD]Default:False. Help:Stop build until load phase ends--build-only-gn [BUILD_ONLY_GN]Default:False. Help:Stop build until gn phase ends--build-variant {user,root}Default:'root'. Help:specifies device operating mode--device-type DEVICE_TYPEDefault:'default'. Help:specifies device type--disable-package-image [DISABLE_PACKAGE_IMAGE]deprecated, please do not use this option--archive-image [ARCHIVE_IMAGE]Default:False. Help:archive image when build product complete--patch [PATCH]       Default:False. Help: Apply patches as per configuration in patch.yml, and handle rollback if needed.--rom-size-statistics [ROM_SIZE_STATISTICS]Default:False. Help:statistics on the actual rom size for each compiled component--stat-ccache [STAT_CCACHE]Default:True. Help:summary ccache hitrate, and generate ccache.log in ${HOME}/.ccache dir--get-warning-list [GET_WARNING_LIST]Default:True. Help:You can use it to collect the build warning and generate WarningList.txt in output dir--generate-ninja-trace [GENERATE_NINJA_TRACE]Default:True. Help:Count the duration of each ninja thread and generate the ninja trace file(build.trace.gz)--compute-overlap-rate [COMPUTE_OVERLAP_RATE]Default:True. Help:Compute overlap rate during the post build--clean-args [CLEAN_ARGS]Default:True. Help:clean all args that generated by this compilation while compilation finished--deps-guard [DEPS_GUARD]Default:True. Help:simplify code, remove concise dependency analysis, and speed up rule checking

hb clean

清除构建产物,释放空间,类似于 make clean

usage: hb clean [option]optional arguments:-h, --help            show this help message and exit--clean-all [CLEAN_ALL]Default:False. Help:clean all producer--clean-args [CLEAN_ARGS]Default:True. Help:clean all args that generated by last compilation--clean-out-product [CLEAN_OUT_PRODUCT]Default:False. Help:clean out/{product} directory that generated by last compilation--clean-ccache [CLEAN_CCACHE]Default:False. Help:clean .ccache directory which is in OHOS root . WARNING, clean ccache may cause something

hb 其他辅助命令

#管理或调用某些构建工具,比如 GN/Ninja、代码检查等
hb tool#独立构建指定模块(不需要全量编译)
hb indep_build#安装构建好的文件到目标设备(例如通过 hdc 工具),默认会推送 out 目录下的产物(如 *.hsp)到设备上安装运行
hb install#打包构建产物,生成系统镜像(如 system.img, userdata.img 等)
hb package#发布构建产物(通常到本地发布目录或镜像服务器等)
hb publish#更新项目依赖,例如拉取 third_party 代码,或更新子模块
hb update#向远程设备推送编译产物,等价于 hdc file send
hb push

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/77440.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue3 本地打包启动白屏解决思路!! !

“为什么我访问 http://127.0.0.1:5501/index.html 白屏&#xff0c;删了 index.html 再访问 / 就又活过来了&#xff1f;” —— 你的项目与 SPA 路由的“宫斗大戏” 一、问题复现 场景 本地通过 VSCode Live Server&#xff08;或其他静态服务器&#xff09;启动了打包后的 V…

数字人(2):数字人技术全景透视(2025演进版)

随着人工智能技术的迅猛发展,数字人技术发展也是一日千里。站在当下,着眼未来,我们一起在回眸透视过去的基础上,一起共同眺望数字人技术的未来。 一、数字人技术体系重构 我们可以用三维定义对数字人技术进行框架重构 维度 技术内涵 典型特征 物理层 人体数字化建模技术 …

小刚说C语言刷题——1035 判断成绩等级

1.题目描述 输入某学生成绩&#xff0c;如果 86分以上(包括 86分&#xff09;则输出 VERY GOOD &#xff0c;如果在 60到 85之间的则输出 GOOD (包括 60和 85)&#xff0c;小于 60 的则输出 BAD。 输入 输入只有一行&#xff0c;包括 1个整数。 输出 输出只有一行&#xf…

React-在使用map循环数组渲染列表时须指定唯一且稳定值的key

在渲染列表的时候&#xff0c;我们须给组件或者元素分配一个唯一值的key, key是一个特殊的属性&#xff0c;不会最终加在元素上面&#xff0c;也无法通过props.key来获取&#xff0c;仅在react内部使用。react中的key本质是服务于diff算法, 它的默认值是null, 在diff算法过程中…

Zookeeper的通知机制是什么?

大家好&#xff0c;我是锋哥。今天分享关于【Zookeeper的通知机制是什么&#xff1f;】面试题。希望对大家有帮助&#xff1b; Zookeeper的通知机制是什么&#xff1f; 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 Zookeeper 的通知机制是其核心特性之一&#xf…

【LangChain实战】构建下一代智能问答系统:从RAG架构到生产级优化

打破传统问答系统的次元壁 当ChatGPT在2022年掀起AI革命时&#xff0c;开发者们很快发现一个残酷现实&#xff1a;通用大模型在专业领域的表现如同拿着地图的盲人&#xff0c;既无法理解企业私有数据&#xff0c;也无法保证事实准确性。这催生了RAG&#xff08;检索增强生成&a…

UDS中功能寻址可以请求多帧数据嘛?当ECU响应首帧后,诊断仪是通过物理寻址发送流控帧嘛?

文章目录 1. 前言📢1.1 功能寻址是否支持请求多帧数据?1.2 ECU发送首帧(FF)后,诊断仪如何发送流控帧(FC)?1.3 协议依据(ISO 14229-1)1.4 实际应用注意事项总结1. 前言📢 在UDS(Unified Diagnostic Services)协议中,功能寻址与物理寻址的使用规则以及多帧数据传…

PHP异常处理__Throwable

在 PHP 里&#xff0c;Throwable 是一个极为关键的接口&#xff0c;自 PHP 7 起被引入。它为错误和异常处理构建了一个统一的框架。下面会详细介绍 Throwable 的相关内容。 1. 基本概念 Throwable 是 Exception 和 Error 的父接口。在 PHP 7 之前&#xff0c;异常&#xff08…

无需训练的具身导航探索!TRAVEL:零样本视觉语言导航中的检索与对齐

作者&#xff1a; Navid Rajabi, Jana Kosecka 单位&#xff1a;乔治梅森大学计算机科学系 论文标题&#xff1a;TRAVEL: Training-Free Retrieval and Alignment for Vision-and-Language Navigation 论文链接&#xff1a;https://arxiv.org/pdf/2502.07306 主要贡献 提出…

Vue3+Vite+TypeScript+Element Plus开发-22.客制Table组件

系列文档目录 Vue3ViteTypeScript安装 Element Plus安装与配置 主页设计与router配置 静态菜单设计 Pinia引入 Header响应式菜单缩展 Mockjs引用与Axios封装 登录设计 登录成功跳转主页 多用户动态加载菜单 Pinia持久化 动态路由 -动态增加路由 动态路由-动态删除…

Java读取JSON文件并将其中元素转为JSON对象输出

&#x1f91f;致敬读者 &#x1f7e9;感谢阅读&#x1f7e6;笑口常开&#x1f7ea;生日快乐⬛早点睡觉 &#x1f4d8;博主相关 &#x1f7e7;博主信息&#x1f7e8;博客首页&#x1f7eb;专栏推荐&#x1f7e5;活动信息 文章目录 Java读取JSON文件并将其中元素转为JSON对象输…

Spring Boot自动配置原理深度解析:从条件注解到spring.factories

大家好&#xff01;今天我们来深入探讨Spring Boot最神奇的特性之一——自动配置(Auto-configuration)。这个功能让Spring Boot如此受欢迎&#xff0c;因为它大大简化了我们的开发工作。让我们一起来揭开它的神秘面纱吧&#xff01;&#x1f440; &#x1f31f; 什么是自动配置…

【ELF2学习板】利用OpenMP采用多核并行技术提升FFTW的性能

目录 引言 OpenMP简介 编译OpenMP支持的FFTW库 部署与测试 测试程序 程序部署 测试结果 结语 引言 在前面已经介绍了在ELF2开发板上运行FFTW计算FFT。今天尝试利用RK3588的多核运算能力来加速FFT运算。FFTW利用多核能力可以考虑使用多线程或者OpenMP。今天介绍一下Ope…

2000-2017年各省城市天然气供气总量数据

2000-2017年各省城市天然气供气总量数据 1、时间&#xff1a;2000-2017年 2、来源&#xff1a;国家统计局、能源年鉴 3、指标&#xff1a;行政区划代码、城市、年份、城市天然气供气总量 4、范围&#xff1a;31省 5、指标说明&#xff1a;城市天然气供气总量是指在一定时间…

Hadoop的三大结构及其作用?

Hadoop是一个分布式存储和计算框架&#xff0c;其三大核心组件是HDFS&#xff08;Hadoop Distributed File System&#xff09;、YARN&#xff08;Yet Another Resource Negotiator&#xff09;和MapReduce。它们各自有着重要的作用&#xff0c;共同构成了Hadoop生态系统的基础…

【AI论文】ColorBench:视觉语言模型能否看到并理解多彩的世界?一个全面的色彩感知、推理和鲁棒性基准测试

摘要&#xff1a;颜色在人类感知中起着重要作用&#xff0c;通常在视觉推理中提供关键线索。 然而&#xff0c;尚不清楚视觉语言模型&#xff08;VLMs&#xff09;是否以及如何像人类一样感知、理解和利用颜色。 本文介绍了ColorBench&#xff0c;这是一个精心设计的创新基准&a…

Python番外——常用的包功能讲解和分类组合

目录 1. Web开发框架与工具 2. 数据处理与分析 3. 网络请求与爬虫 4. 异步编程 5. 数据库操作 6. 图像与多媒体处理 7. 语言模型与NLP 8. 安全与加密 9. 配置与工具 10. 其他工具库 11.典型组合场景 此章节主要是记录我所使用的包&#xff0c;以及模块。方便供自己方…

华硕原厂系统枪神9/9p超竟版-WIN11原装开箱出厂系统安装

华硕原厂系统枪神9/9p超竟版-WIN11-24H2-专业工作站版本安装可带F12-ASUSRecovery恢复功能 适用机型&#xff1a; G635LX、G635LW、G835LX、G835LW、G615LW、G615LP、G615LM、G615LH G815LW、G815LP、G815LM、G815LH、G635LR、G835LR、G615LR、G815LR 远程恢复安装&#xff…

拉取windows的docker镜像转到服务器上构建服务镜像

在windows上将拉取ubuntu的docker镜像转到服务器上 1.要求 1.1 要求windows和服务器安装好docker 2.拉取ubuntu镜像到windows&#xff08;dos操作&#xff0c;可能需要连接到外网&#xff09; 一旦你选择了一个合适的基础镜像&#xff0c;你可以使用docker pull命令从Docke…

T1结构像+RS-fMRI影像处理过程记录(数据下载+Matlab工具箱+数据处理)

最近需要仿真研究T1结构像RS-fMRI影像融合处理输出目标坐标的路线可行性。就此机会记录下来。 为了完成验证目标处理&#xff0c;首先需要有数据&#xff0c;然后需要准备对应的处理平台和工具箱&#xff0c;进行一系列。那么开始记录~ 前言&#xff1a; 为了基于种子点的功能连…