• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Obtaining Source Code<a name="EN-US_TOPIC_0000001150448437"></a>
2
3## About OpenHarmony<a name="section6370143622110"></a>
4
5OpenHarmony is an open-source project launched by the OpenAtom Foundation. The purpose of this project is to build an open, distributed operating system \(OS\) framework for smart IoT devices in the full-scenario, full-connectivity, and full-intelligence era.
6
7The open-source code repositories are available at [https://openharmony.gitee.com](https://openharmony.gitee.com).
8
9## Overview of Source Code Acquisition<a name="section12763342204"></a>
10
11The OpenHarmony source code is open to you as [HPM parts](../hpm-part/hpm-part-about.md), which can be obtained in any of the following ways:
12
13-   **Method 1**: Acquire the source code from the Gitee code repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
14-   **Method 2**: Acquire the source code from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home). Visit [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use the **hpm-cli** tool to download and install the bundles and compilation toolchain on your local PC.
15-   **Method 3**: Download the compressed file of a distribution from a mirror site. This method provides a fast download speed, so you can also use this method for obtaining the source code of an earlier version.
16-   **Method 4**: Acquire the source code from the GitHub image repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
17
18## Method 1: Acquiring Source Code from the Gitee Code Repository<a name="section537312010229"></a>
19
20### When to Use<a name="section10881513459"></a>
21
22-   You want to establish a baseline based on stable OpenHarmony releases and distribute the baseline to your customers.
23
24-   You have interconnected your software with OpenHarmony and need official certification from OpenHarmony.
25
26-   You want to contribute code to the OpenHarmony community after obtaining official OpenHarmony certification for chips, modules, and applications.
27
28-   You need to rectify OpenHarmony issues.
29
30-   You want to learn OpenHarmony source code.
31
32
33### Prerequisites<a name="section102871547153314"></a>
34
351.  Register your account with Gitee.
362.  Register an SSH public key for access to Gitee.
373.  Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information.
38
39    ```shell
40    git config --global user.name "yourname"
41    git config --global user.email "your-email-address"
42    git config --global credential.helper store
43    ```
44
454. Run the following commands to install the **repo** tool:
46
47   In this example, **~/bin** is used as an example installation directory. You can change the directory as needed.
48
49   ```shell
50   mkdir ~/bin
51   curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
52   chmod a+x ~/bin/repo
53   pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
54   ```
55
565. Add the path of the **repo** tool to environment variables.
57
58   ```shell
59   vim ~/.bashrc               # Edit environment variables.
60   export PATH=~/bin:$PATH     # Add the path of the **repo** tool to the end of environment variables.
61   source ~/.bashrc            # Apply environment variables.
62   ```
63
64
65### How to Use<a name="section429012478331"></a>
66
67
68>![](../public_sys-resources/icon-note.gif) **NOTE**
69>
70>Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development.
71
72-   **Obtaining OpenHarmony release code**
73
74    For details about how to obtain the source code of an OpenHarmony release, see the [Release Notes](../../release-notes/Readme.md).
75
76-   **Obtaining OpenHarmony master code**
77
78    Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\)
79
80    ```shell
81    repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
82    repo sync -c
83    repo forall -c 'git lfs pull'
84    ```
85
86    Method 2: Use the **repo** tool to download the source code over HTTPS.
87
88    ```shell
89    repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
90    repo sync -c
91    repo forall -c 'git lfs pull'
92    ```
93
94
95## Method 2: Acquiring Source Code from DevEco Marketplace<a name="section463013147412"></a>
96
97### When to Use<a name="section26661067443"></a>
98
99If OpenHarmony is new to you, sample solutions are helpful to your development. You can obtain an open-source distribution from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), or customize a distribution by adding or deleting bundles of an open-source distribution. Then use the **hpm-cli** tool to download and install the bundles and compilation toolchain on your local PC.
100
101### Prerequisites<a name="section17544943123315"></a>
102
103You must install **Node.js** and HPM on your local PC. The installation procedure is as follows:
104
1051.  Install **Node.js**.
106
107    Download **Node.js** from its official website and install it on your local PC.
108
109    The [Node.js](https://nodejs.org/) version must be 12.x \(including npm 6.14.4\) or later. An LTS version is recommended.
110
1112.  Install the **hpm-cli** tool using **npm** delivered with **Node.js**.
112
113    Open the CMD window and run the following command:
114
115    ```shell
116    npm install -g @ohos/hpm-cli
117    ```
118
1193.  Run the following command to check whether the installation is successful. If the HPM version is displayed, the installation is successful.
120
121    ```shell
122    hpm -V or hpm --version
123    ```
124
1254.  Run the following command to upgrade the HPM version:
126
127    ```shell
128    npm update -g @ohos/hpm-cli
129    ```
130
131
132### How to Use<a name="section954619433333"></a>
133
1341.  Search for distributions.
135    1.  Access [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), and click **Equipment Bundle**. Then go to the **Open Source Distribution** page.
136    2.  Enter a keyword \(for example: **camera**\) in the search box. All matched distributions are found.
137    3.  Specify filter criteria, such as the bundle type \(for example: **Board support** or **Kernel support**\), to further filter the distributions.
138    4.  Find your desired distribution and click it to view details.
139
140        **Figure 1**  HPM page<a name="fig349416264520"></a>
141        ![](figures/hpm-page.png "hpm-page")
142
1432.  Learn more about the distribution.
144
145    1.  Read carefully the information about the distribution to learn its application scenarios, features, bundles, usage, and customization methods, as shown in the following figure.
146    2.  Click **Download** if you want to download the distribution to your local PC.
147    3.  Click **Custom** if you want to add or delete bundles of the distribution.
148
149        **Figure 2**  Example distribution<a name="fig142484411121"></a>
150        ![](figures/example-distribution.png "example-distribution")
151
1523.  Customize bundles.
153    1.  Access the **Custom solution** page, as shown in the following figure.
154    2.  Set the toggle switch next to a specific optional bundle to delete it from the distribution, or click **Add bundle** to add new bundles.
155    3.  Enter the basic information about your project, including the bundle name, version, and description, on the right pane.
156    4.  Click **Download**. The system generates the OpenHarmony code structure file \(for example, **my\_cust\_dist.zip**\) and saves it to your local PC.
157
158        **Figure 3**  Customizing bundles<a name="fig1256020372197"></a>
159        ![](figures/customizing-bundles.png "customizing-bundles")
160
1614.  Install bundles.
162    1.  Decompress the downloaded code structure file using CMD on Windows (or shell in Linux).
163    2.  In the generated directory, run the **hpm install** command to download and install bundles. If the **Install successful** message is displayed, the command has been executed successfully.
164    3.  Obtain the bundles. The downloaded bundles are stored in the **ohos\_bundles** folder under the project directory. \(The source code of some bundles will be copied to a specified directory after the bundles are installed.\)
165
166
167## Method 3: Acquiring Source Code from a Mirror Site<a name="section1186691118430"></a>
168
169To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
170
171The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](../../release-notes/Readme.md).
172
173**Table 1**  Sites for acquiring source code
174
175| **LTS Code**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
176| -------- | -------- | -------- | -------- | -------- |
177| Full code base (for mini, small, and standard systems)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz.sha256)| 7.0 GB |
178| Standard system solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz.sha256)| 973.7 MB |
179| Hi3861 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz.sha256)| 16.5 MB |
180| Hi3518 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz.sha256)| 158.1 MB |
181| Hi3516 solution-LiteOS (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz)| 248.9 MB |
182| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB |
183| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - |
184| **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
185| Full code base (for mini, small, and standard systems)| 3.2 Release    | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz.sha256)| 21.8 GB |
186| Hi3861 solution (binary)       | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz.sha256)| 22.9 MB |
187| Hi3516 solution-LiteOS (binary)| 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz.sha256)| 294.3 MB |
188| Hi3516 solution-Linux (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz.sha256)| 174.3 MB |
189| RK3568 standard system solution (binary)       | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz.sha256)| 3.9 GB |
190| RELEASE-NOTES | 3.2 Release| [Download](../../release-notes/OpenHarmony-v3.2-release.md)| - | - |
191| **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
192| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - |
193
194## Method 4: Acquiring Source Code from the GitHub Image Repository<a name="section23448418360"></a>
195
196>![](../public_sys-resources/icon-note.gif) **NOTE**
197>
198> The image repository is synchronized at 23:00 (UTC +8:00) every day.
199
200Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\)
201
202```shell
203repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify
204repo sync -c
205repo forall -c 'git lfs pull'
206```
207
208Method 2: Use the **repo** tool to download the source code over HTTPS.
209
210```shell
211repo init -u https://github.com/openharmony/manifest.git -b master --no-repo-verify
212repo sync -c
213repo forall -c 'git lfs pull'
214```
215
216## Source Code Directories<a name="section1072115612811"></a>
217
218The following table describes the OpenHarmony source code directories.
219
220**Table 2**  Source code directories
221
222| Directory| Description|
223| -------- | -------- |
224| applications | Application samples, for example, **camera**.|
225| base | Basic software service subsystem set and hardware service subsystem set.|
226| build | Bundle-based compilation, building, and configuration scripts.|
227| docs | Reference documents.|
228| domains | Enhanced software service subsystem set.|
229| drivers | Driver subsystem.|
230| foundation | Basic system capability subsystem set.|
231| kernel | Kernel subsystem.|
232| prebuilts | Compiler and tool chain subsystem.|
233| test | Test subsystem.|
234| third_party | Open-source third-party software.|
235| utils | Commonly used development utilities.|
236| vendor | Vendor-provided software.|
237| build.py | Build script file.|
238