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.pswp.cn/pingmian/77440.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/77440.shtml
英文地址,請注明出處:http://en.pswp.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; 為了基于種子點的功能連…