# oh_utils **Repository Path**: forantar/oh_utils ## Basic Information - **Project Name**: oh_utils - **Description**: Utility scripts for working with `OpenHarmony`. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2025-07-23 - **Last Updated**: 2026-07-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oh Automates `openharmony` `clone/sync/build`. ## Initial setup Add `oh_utils` to `PATH`: ```bash export PATH=/path/to/oh_utils:$PATH ``` Get help: ```bash oh --help ``` Edit the generated `config` to meet your needs: ```bash vi /path/to/oh_utils/config ``` Refer to the `config.template`: ```bash cat /path/to/oh_utils/config.template ``` ## Commands All flags below are shown by `oh --help`. Flags marked *[global]* may be combined with any command. ### Global flags | Flag | Description | |---|---| | `--dr, --dry-run` | Print requested actions only, do not execute them. | | `-h, --help` | Print help. | ### Environment and config ```bash oh --setup-env # setup oh_utils environment (download/install packages etc.) oh --dump-env # dump oh_utils environment variables to be exported -f, --force-show-passwords # show plain passwords oh --config # print the oh_utils config ``` ### Full pipeline ```bash oh -a, --all # (default) run the openharmony building pipeline (clone/sync/build etc.) -r, --root # use the existing openharmony root folder (or create new by default) -i, --interactive # ask to perform a particular step -l, --label # add the label to the new openharmony root folder name ``` ### Repo management ```bash oh -i, --init # init the openharmony repo -b, --branch # use the branch (default: master) -m, --manifest # use the manifest -o, --oh-mirror # use the openharmony git mirror oh -s, --sync # sync openharmony repo's oh -r, --reset # reset openharmony repo's oh -l, --lfs # pull lfs oh -d, --prebuilts # download prebuilts ``` ### Build ```bash oh -b, --build # build target from the list, or by its gn name: # image | ace | arkoala | sdk | sdk-linux | sdk-windows | sdk-mac -f, --fast # use previously generated ninja files ``` For example, [re]build the `ace_engine` target: ```bash cd /path/to/openharmony oh -b ace ``` Build the OpenHarmony SDK for Linux: ```bash cd /path/to/openharmony oh -b sdk-linux ``` ### SDK packaging and upload ```bash oh --pack-sdk # prepare the openharmony SDK archives ``` `--pack-sdk` archives the SDK produced by `--build sdk*` into: ``` out/sdk/ohos-sdk-packages/ohos-sdk-.zip out/sdk/ohos-sdk-packages/ohos-sdk-.zip.version ``` By default both `windows` and `linux` are packed. To pack a single OS, set the `os_names` env var: ```bash os_names="linux" oh --pack-sdk ``` Preview the actions without executing: ```bash os_names="linux" oh --pack-sdk --dry-run ``` ### Reporting ```bash oh --report # print openharmony build statistics report oh --log # list the oh_utils global log ``` Every `oh` run log can be found in the global log: ```bash /path/to/oh_utils/.log # to list it: oh --log ``` ## Configure nightly builds with `cron` Note that cron runs in the `root` env, so make sure you have the `repo` tool in the root `PATH`: ```bash sudo which repo /usr/local/bin/repo ``` ```bash crontab -e # add the line: 0 4 * * * /path/to/oh_utils/oh -a ``` ## `openharmony` git mirror ### Create local mirror for specific `openharmony branch`: ```bash mkdir oh_mirror cd oh_mirror repo init -u https://gitcode.com/openharmony/manifest.git -b --no-repo-verify --mirror repo sync -c -j 12 --retry-fetches=10 --no-clone-bundle --no-tags repo forall -c 'git lfs pull' ``` ### Set up NFS share ```bash sudo apt install nfs-kernel-server sudo vi /etc/exports # Add line with local network subnet: # /path/to/oh_mirror XXX.XXX.XXX.0/24(rw,sync,no_subtree_check) sudo exportfs -a sudo systemctl restart nfs-kernel-server ``` ### Configure the mirror update with `cron` Note that cron runs in the `root` env, so make sure you have the `repo` tool in the root `PATH`: ```bash sudo which repo /usr/local/bin/repo ``` ```bash crontab -e # add the line: 0 0 * * * /path/to/oh_utils/oh --update-oh-mirror /path/to/oh_mirror ``` ### Mount NFS share on a client ```bash sudo apt install nfs-common sudo mkdir -p /mnt/nfs/oh_mirror # Instant mount: sudo mount -t nfs XXX.XXX.XXX.XXX:/path/to/oh_mirror /mnt/nfs/oh_mirror # Or permanent mount: sudo vi /etc/fstab # Add line with server IP: # XXX.XXX.XXX.XXX:/path/to/oh_mirror /mnt/nfs/oh_mirror nfs defaults 0 0 sudo mount -a ``` In `/path/to/oh_utils/config` set: ``` OH_MIRROR=/mnt/nfs/oh_mirror ``` # rk Flashes `openharmony` build artifacts or `openharmony` image to the `dayu200 rk3568` dev board. ## Setup Run the automated setup (downloads HiHope flashing tools, oh-tool, and OHOS SDK): ```bash rk -se ``` This configures `HIHOPE_PATH` and `HDC_PATH` in `oh_utils/config` automatically. ### Manual setup (fallback) Obtain the flashing tool: ```bash git clone https://gitee.com/hihope_iot/docs.git hihope_iot_docs ``` Add the path to `oh_utils/config`: ```bash HIHOPE_PATH=/path/to/hihope_iot_docs/HiHope_DAYU200/烧写工具及指南/linux ``` Download `ohos-sdk` from CI: https://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist Add the `hdc` path to `oh_utils/config`: ```bash HDC_PATH=/path/to/ohos-sdk//toolchains ``` ## Commands Get help: ```bash rk --help ``` ### Flash Flash a downloaded image: ```bash rk -fi /path/to/OpenHarmony_img.tar.gz # or pick from list: rk -fi ``` Flash a build artifact: ```bash rk -fb /path/to/build/dir # or pick from list: rk -fb ``` ### Device management ```bash rk -s # show all connected devices rk -s -v # show devices with OS version info rk -i # identify device (blink LED / wake screen) rk -c # configure device (standby, brightness, language, etc.) rk -u # mount device for write rk -a # send build artifacts to device ``` ### Other ```bash rk -li # list images from IMAGES_PATH rk -lb # list builds from BUILDS_PATH rk -r # create and apply udev rules (requires sudo) rk -t # show useful tips ``` ## Multiple devices When several boards are connected, target a specific one with `-d, --device `. The id is the serial reported by `rk -s` (same as `hdc list targets`). For a board in rockusb mode (loader/maskrom), the numeric `DevNo` from `rk -s` is also accepted: ```bash rk -d 2 -i # identify DevNo=2 rk -d -c # configure a specific device ``` To run a command against **every** connected device, use `-d all`: ```bash rk -d all -i # identify every connected device rk -d all -c # configure every connected device ``` `-d all` is supported by `-c` (configure), `-u` (mount), and `-i` (identify). Without `-d`, a single connected device is auto-selected; if several are connected and `-d` is omitted, `rk` prompts you to pick one. ### Flashing requires a single board `-fi` and `-fb` do **not** accept `-d`: the underlying `flash.py` cannot target a specific rockusb device, and every connected dayu200 board stays visible to rockusb even when booted (the OS exposes PID 0x5000 via `hdcd`). Leave only one board plugged in, then run: ```bash rk -fi -p ``` # docker/*** Decorized tools, which do their job in a virtualized environment (docker container). The main tool is "docker/ubuntu-2204-koala/bash". (see details in [docker/README.md](docker/README.md))