{"id":24785900,"url":"https://github.com/civilnet/torchpod-oh","last_synced_at":"2026-01-05T17:03:48.810Z","repository":{"id":274053850,"uuid":"921715932","full_name":"CivilNet/torchpod-oh","owner":"CivilNet","description":"用于OpenHarmony开发和编译的容器环境","archived":false,"fork":false,"pushed_at":"2025-02-23T06:16:06.000Z","size":2095,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T09:13:45.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CivilNet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-24T13:33:24.000Z","updated_at":"2025-03-08T03:58:16.000Z","dependencies_parsed_at":"2025-02-19T12:38:47.783Z","dependency_job_id":null,"html_url":"https://github.com/CivilNet/torchpod-oh","commit_stats":null,"previous_names":["civilnet/torchpod-oh"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CivilNet/torchpod-oh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CivilNet%2Ftorchpod-oh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CivilNet%2Ftorchpod-oh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CivilNet%2Ftorchpod-oh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CivilNet%2Ftorchpod-oh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CivilNet","download_url":"https://codeload.github.com/CivilNet/torchpod-oh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CivilNet%2Ftorchpod-oh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28217715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-29T14:33:33.467Z","updated_at":"2026-01-05T17:03:48.777Z","avatar_url":"https://github.com/CivilNet.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# torchpod-oh\n基于TorchPod的编译/运行OpenHarmony的容器环境。\n\n本项目将![open-harmony-edu-dist项目](https://gitee.com/open-harmony-edu-dist) TorchPod化，提供了在Linux、macOS、Windows上编译和运行OpenHarmony的图形化开发环境。\n\n\n# 部署\n使用gemfield/torchpod-oh镜像，部署和登录参考![TorchPod的部署和登录](https://github.com/DeepVAC/TorchPod?tab=readme-ov-file#%E9%83%A8%E7%BD%B2%E5%92%8C%E8%BF%90%E8%A1%8Ctorchpod)。\n\n请注意：如果想在编译后直接用qemu运行openharmony镜像，则部署TorchPod的时候需要使用root权限，也即docker命令行带--privileged=true 。\n\n# 编译\n- 克隆源代码\n```bash\nrepo init -u https://gitee.com/open-harmony-edu-dist/manifest -b refs/heads/OpenHarmony-5.0.2-Release --no-repo-verify\nrepo sync -c\nrepo forall -c 'git lfs pull'\nbash -x build/prebuilts_download.sh\n```\n- 修改源文件\n\n在以下文件中添加\u003cstdint.h\u003e头文件：\n```bash\narkcompiler/ets_runtime/ecmascript/common.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/util.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_util/include/file_layout.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_util/include/namemangler.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_util/include/profile_type.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_util/include/utils.h\narkcompiler/ets_runtime/ecmascript/compiler/codegen/maple/maple_util/src/mpl_logging.cpp #该文件同时添加\u003ccstring\u003e头文件\n\narkcompiler/runtime_core/assembler/assembly-debug.h\narkcompiler/runtime_core/libpandabase/os/stacktrace.h\narkcompiler/runtime_core/static_core/templates/events/events.h.erb\narkcompiler/runtime_core/templates/events/events.h.erb\n\ndeveloptools/global_resource_tool/src/config_parser.cpp #该文件同时添加\u003ccstring\u003e头文件\ndeveloptools/global_resource_tool/src/resource_util.cpp #该文件同时添加\u003ccstring\u003e头文件\n\ndrivers/hdf_core/framework/tools/hdi-gen/util/options.cpp\n```\n\n修改foundation/graphic/graphic_3d/lume/LumeBinaryCompile/lumeassetcompiler/src/main.cpp的add_directory函数为：\n```c++\nvoid add_directory(const std::string\u0026 path, const std::string\u0026 outpath)\n{\n    ......\n    while ((pDirent = readdir(pDir)) != NULL) {\n        // This structure may be statically allocated\n        size_t d_size = pDirent-\u003ed_reclen;\n        struct dirent* a_copy = static_cast\u003cstruct dirent*\u003e(std::malloc(d_size));\n        std::memcpy(a_copy, pDirent, d_size); ;\n        dirSet.insert(a_copy);\n    }\n\n    for (auto \u0026d : dirSet) {\n        if (d-\u003ed_type == DT_DIR) {\n            if (d-\u003ed_name[0] == '.') {\n                continue;\n            }\n            add_directory(p + d-\u003ed_name, op + d-\u003ed_name);\n            continue;\n        }\n        append_file(p + d-\u003ed_name, op + d-\u003ed_name);\n    }\n    for (auto\u0026 d : dirSet) {\n        std::free(d);\n    }\n\n    closedir(pDir);\n}\n```\n\n修改drivers/hdf_core/adapter/khdf/linux/network/src/net_device_adapter.c的NetDevReceive函数：\n```c++\nif (flag \u0026 IN_INTERRUPT) {\n  netif_rx(buff);\n} else {\n  netif_rx_ni(buff);\n}\n```\n改为：\n```c++\nnetif_rx(buff);\n```\n\n- 编译\n```bash\nbash -x ./build.sh --product-name x86_64_virt\n```\n\n- 编译产物：\n```bash\ngemfield@bf4ab8b417f9:/media/gemfieldU/qemu$ find out/x86_64_virt/ -type f -name *.img\nout/x86_64_virt/packages/phone/images/chip_prod.img\nout/x86_64_virt/packages/phone/images/eng_system.img\nout/x86_64_virt/packages/phone/images/updater.img\nout/x86_64_virt/packages/phone/images/ramdisk.img\nout/x86_64_virt/packages/phone/images/system.img\nout/x86_64_virt/packages/phone/images/vendor.img\nout/x86_64_virt/packages/phone/images/userdata.img\nout/x86_64_virt/packages/phone/images/sys_prod.img\n```\n以及\n```bash\nvendor/edu/x86_64_virt/qemu_run.sh\n```\n\n# 运行\n确保TorchPod容器是以root权限启动的（也即：docker命令行带--privileged=true）：\n```bash\ndocker run --privileged=true -v /home/gemfield:/media/gemfield -p 5900:5900 -eTORCHPOD_MODE=VNC -ePROTOCOL=X11 gemfield/torchpod-oh\n```\n登录TorchPod，执行以下三个步骤：\n```bash\n#切换到/opt/oh目录\n#第一步：执行initnetwork.sh\ngemfield@1f1f51e81a50:/opt/oh$ sudo ./initnetwork.sh \nNOTICE: must run with sudo.\n\ndnsmasq: no process found\n\nNow, run below 2 commands in your current konsole to set the environment variables: \n\n-----------------------------------------------------\nexport NET_OPTS=\"-netdev tap,id=net0,ifname=ohostap0,script=no,downscript=no -device virtio-net-pci,netdev=net0,mac=70:30:10:02:18:06\" \nexport OHOS_IMG_DIR=\u003cyour_ohos_img_dir\u003e\n-----------------------------------------------------\n\n#第二步：根据上述的输出结果，设置两个环境变量：\ngemfield@1f1f51e81a50:/opt/oh$ export NET_OPTS=\"-netdev tap,id=net0,ifname=ohostap0,script=no,downscript=no -device virtio-net-pci,netdev=net0,mac=70:30:10:02:18:06\"\ngemfield@1f1f51e81a50:/opt/oh$ export OHOS_IMG_DIR=/media/gemfield/images/\n\n#第三步：启动qemu\ngemfield@bf4ab8b417f9:/opt/oh$ ./qemu_run.sh\n```\n\n![OpenHarmony在TorchPod上启动](https://github.com/user-attachments/assets/29dc21c2-28a9-48ed-994d-2d1d6e60a483)\n\n\n此后可以使用hdc命令：\n```bash\n#IP地址默认为192.168.111.49，你也可以从qemu的终端上用ifconfig命令获得openharmony的IP地址\ngemfield@1f1f51e81a50:/opt/oh$ hdc tconn 192.168.111.49:55555\nConnect OK\ngemfield@1f1f51e81a50:/opt/oh$ hdc list targets -v\n192.168.111.49:55555            TCP     Connected       localhost\n\ngemfield@1f1f51e81a50:/opt/oh$ hdc shell \n# ls /\nbin        config       eng_system  lost+found     storage   tmp      \nchip_ckm   data         etc         mnt            sys       updater  \nchip_prod  dev          init        module_update  sys_prod  vendor   \nchipset    eng_chipset  lib         proc           system\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcivilnet%2Ftorchpod-oh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcivilnet%2Ftorchpod-oh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcivilnet%2Ftorchpod-oh/lists"}