Building Oniro
Before beginning, ensure that git-lfs
and repo
are installed. It is recommended to have at least 100GB of free disk space available for the full build.
Obtaining the Source Code
To download the source code, execute the following commands in your terminal:
repo init -u https://github.com/eclipse-oniro4openharmony/manifest.git -b OpenHarmony-5.0.2-Release -m oniro.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
Other versions of Oniro are available in the Oniro manifest repository by checking the available branches. Some boards may require a specific version, so consult the Developer Boards section to ensure compatibility.
Fetching Prebuilt Tools
Once you have the source code run the following script to fetch the prebuilt tools:
Setting Up the Build Environment
For building the project, using an isolated Docker container is recommended for a clean and controlled build environment. Run the following command to start the Docker container:
docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_standard:3.2
Configuring and Starting the Build
Inside the Docker instance, set the target device for the build (e.g. rk3568) and use ccache to speed up subsequent builds:
Flashing
The flashing procedure is highly hardware specific and can be found in the Developer Boards section for each individual device.
Additional Tips and Troubleshooting
No HDC available in the system
If the hdc
tool is not available on your host system, build it using the ohos-sdk
:
Find the hdc
tool in out/sdk/ohos-sdk/linux/toolchains
. To verify the connection with the device, run:
For sending commands to the device:
To read hilog output:
Speeding Up Build Times
You can significantly reduce build times for subsequent builds by mounting directories for prebuilts and ccache when initiating the Docker container. This approach ensures that once the prebuilts are downloaded, they don't need to be fetched again, and the compilation cache is maintained across builds.
To apply this optimization, use the following command to start your Docker container:
docker run -it -v $(pwd):/home/openharmony/workdir -v ~/openharmony_prebuilts:/home/openharmony/openharmony_prebuilts -v ~/.ccache:/root/.ccache swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_standard:3.2
After starting the container with the above command, navigate to the workdir
directory before initiating the build process: