1# Getting Started with the Standard System with Hi3516 (IDE Mode)
2
3> ![icon-caution.gif](public_sys-resources/icon-caution.gif) **CAUTION**
4>
5> **Since OpenHarmony 3.2, the standard system does not perform adaptation verification for the Hi3516D V300 development board. You are advised to use RK3568 to develop standard-system devices.**
6>
7> **If you still use Hi3516D V300 to develop standard-system devices, adaptation may fail. Contact the chip supplier to obtain the adaptation guide and complete adaptation by yourself.**
8
9In addition to the small system, the Hi3516D V300 development board also supports the standard system. This topic describes how to develop the standard system on Hi3516DV300 with DevEco Device Tool, by walking you through a simple example.
10
11
12The following exemplifies how to run the first program on the development board. This program displays the message "Hello World!"
13
14
15Before development, complete the following preparations:
16
17
18- [Setting Up the Development Environment](quickstart-ide-env-win.md)
19
20- [Creating a Project and Obtaining Source Code](quickstart-ide-import-project.md)
21
22
23## Writing a Hello World Program
24
25
26### Example Directory
27
28
29```
30applications/sample/hello
31 │── BUILD.gn
32 │── include
33 │   └── helloworld.h
34 │── src
35 │   └── helloworld.c
36 ├── bundle.json
37 build
38 └── subsystem_config.json
39 productdefine/common
40 └── products
41     └── Hi3516DV300.json
42```
43
44
45### How to Develop
46
47Perform the steps below in the source code directory:
48
491. Create a directory and write the service code.
50
51   Create the **applications/sample/hello/src/helloworld.c** directory and file whose code is shown in the following example. You can customize the content to be printed. For example, you can change **World** to **OHOS**. Declare the string printing function **HelloPrint** in the **helloworld.h** file. You can use either C or C++ to develop a program.
52
53
54      ```
55      #include <stdio.h>
56      #include "helloworld.h"
57      int main(int argc, char **argv)
58      {
59          HelloPrint();
60          return 0;
61      }
62      void HelloPrint()
63      {
64          printf("\n\n");
65          printf("\n\t\tHello World!\n");
66          printf("\n\n");
67      }
68      ```
69
70   Add the header file **applications/sample/hello/include/helloworld.h**. The sample code is as follows:
71
72
73      ```
74      #ifndef HELLOWORLD_H
75      #define HELLOWORLD_H
76      #ifdef __cplusplus
77      #if __cplusplus
78      extern "C" {
79      #endif
80      #endif
81      void HelloPrint();
82      #ifdef __cplusplus
83      #if __cplusplus
84      }
85      #endif
86      #endif
87      #endif // HELLOWORLD_H
88      ```
89
902. Create a build file.
91   1. Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows:
92
93       ```
94       import("//build/ohos.gni") # Import the build template.
95       ohos_executable("helloworld") {# Executable module.
96         sources = [       # Source code of the module.
97           "src/helloworld.c"
98         ]
99         include_dirs = [  # Directory of header files on which the module depends.
100           "include"
101         ]
102         cflags = []
103         cflags_c = []
104         cflags_cc = []
105         ldflags = []
106         configs = []
107         deps =[]    # Internal dependencies of the component.
108         part_name = "hello"    # Component name. This parameter is mandatory.
109         install_enable = true # Whether to install the software by default. This parameter is optional.
110                                 By default, the software is not installed.
111       }
112       ```
113   2. Create the **applications/sample/hello/bundle.json** file and add the description of the **sample** component. The content is as follows:
114
115       ```
116       {
117           "name": "@ohos/hello",
118           "description": "Hello world example.",
119           "version": "3.1",
120           "license": "Apache License 2.0",
121           "publishAs": "code-segment",
122           "segment": {
123               "destPath": "applications/sample/hello"
124           },
125           "dirs": {},
126           "scripts": {},
127           "component": {
128               "name": "hello",
129               "subsystem": "sample",
130               "syscap": [],
131               "features": [],
132               "adapted_system_type": [ "mini", "small", "standard" ],
133               "rom": "10KB",
134               "ram": "10KB",
135               "deps": {
136                   "components": [],
137                   "third_party": []
138               },
139               "build": {
140                   "sub_component": [
141                       "//applications/sample/hello:helloworld"
142                   ],
143                   "inner_kits": [],
144                   "test": []
145               }
146           }
147       }
148       ```
149
150    The **bundle.json** file consists of two parts. The first part describes the information about the subsystem to which the component belongs, and the second part defines the build configuration for the component. When adding a component, you must specify the **sub_component** of the component. Add the APIs provided for other components, if any, in **inner_kits**. Add the test cases, if any, in **test**.
151
1523. Modify the subsystem configuration file.
153
154   Add the configuration of the new subsystem to the **build/subsystem_config.json** file.
155
156
157   ```
158   "sample": {
159       "path": "applications/sample/hello",
160       "name": "sample"
161     },
162   ```
163
1644. Modify the product configuration file.
165
166   In the **productdefine/common/products/Hi3516DV300.json** file, add the **hello** part after the existing part.
167
168   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
169   >
170   > In this example, the OpenHarmony-v3.1-Release version is used, where the Hi3516 configuration file is **productdefine/common/products/Hi3516DV300.json**. In OpenHarmony-v3.2-Beta2 and later versions, the Hi3516 configuration file is **vendor/hisilicon/Hi3516DV300/config.json**.
171
172
173   ```
174       "usb:usb_manager_native":{},
175       "applications:prebuilt_hap":{},
176       "sample:hello":{},
177       "wpa_supplicant-2.9:wpa_supplicant-2.9":{},
178   ```
179
180
181## Building Source Code
182
183With DevEco Device Tool, you can easily build source code of the Hi3516DV300 development board, thanks to its productivity-boosting features, such as the compiler toolchain, detection of the build environment dependencies, and one-click installation of the dependencies.
184
185> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
186>
187> The build environment of Hi3516DV300 is Ubuntu.
188
1891. Click **Project Settings** on the menu bar to access the Hi3516DV300 project configuration page.
190
191   ![en-us_image_0000001274745038](figures/en-us_image_0000001274745038.png)
192
1932. On the **Tool Chain** tab page, DevEco Device Tool automatically checks whether the dependent compiler toolchain is complete.
194
195   - If any tool is indicated as **uninstalled** (![status_uninstall](figures/status_uninstall.png)), click **Download Uninstalled Tools** to install all the required tools, or click **Download** next to a tool to install the specific tool.
196   - If some tool types are missing, click **Add Utility** to add them.
197   - If **Download** is not available for a missing tool, it is not cataloged in DevEco Device Tool. In this case, you need to download the tool to the local host and click **Import** to import it.
198   - If the status of **OpenHarmony Environment Dependency** is abnormal (![status_uninstall](figures/status_uninstall.png), click **Install**.
199
200   ![3516_standard_false](figures/3516_standard_false.png)
201
202   Certain tools may require the root access to install. For these tools, enter the user password in the **TERMINAL** window as prompted.
203
204   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
205   >
206   > - If pip fails to be installed, [change the Python source](https://device.harmonyos.com/en/docs/documentation/guide/ide-set-python-source-0000001227639986) and try again.
207   > - If apt fails to be installed, [change the apt source](https://device.harmonyos.com/en/docs/documentation/guide/faq-toolchain-install-0000001301623822) and try again.
208
209   ![en-us_image_0000001274748606](figures/en-us_image_0000001274748606.png)
210
211   After the installation is complete, the status of the tools and environment dependencies is displayed as ![status_install](figures/status_install.png).
212
2134. On the **hispark_taurus_standard** tab page, set **build_type**, whose default value is **debug**.
214
215   ![en-us_image_0000001325269477](figures/en-us_image_0000001325269477.png)
216
2175. Choose **PROJECT TASKS** > **hispark_taurus_standard** > **Build** to start building.
218
219   ![en-us_image_0000001292849062](figures/en-us_image_0000001292849062.png)
220
2216. Wait until **SUCCESS** is displayed in the **TERMINAL** window, indicating that the build is complete.
222
223   ![en-us_image_0000001366345198](figures/en-us_image_0000001366345198.png)
224
225   After the compilation is complete, go to the **out** directory of the project to view the generated files and perform burning operations.
226
227
228## Burning an Image
229
230Burning is the process of downloading compiled program files to a development board to provide a basis for subsequent debugging. With the one-click burning function of DevEco Device Tool, you can burn images on development boards quickly and efficiently.
231
232The images of Hi3516DV300 are burnt in the Windows environment. After burning is initiated, DevEco Device Tool copies the target program files generated in the Ubuntu environment to the specified Windows directory in remote mode, and then burns the program files to Hi3516DV300 using the Windows burning tool.
233
234Hi3516DV300 supports burning for the standard system through the USB port and network port. This topic describes how to burn source code through the USB port.
235
236
237### Prerequisites
238
239- The serial port driver has been installed on Hi3516DV300. For details, see [Installing the Serial Port Driver on the Hi3516D V300 Development Board](https://device.harmonyos.com/en/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695).
240
241- The USB port driver has been installed on Hi3516DV300. For details, see [Installing the USB Port Driver on the Hi3516D V300 Development Board](https://device.harmonyos.com/en/docs/documentation/guide/usb_driver-0000001058690393).
242
243
244### Procedure
245
2461. Connect the computer and the target development board through the serial port and USB port. For details, see [Hi3516 Development Board](quickstart-appendix-hi3516.md).
247
2482. In DevEco Device Tool, choose **REMOTE DEVELOPMENT** > **Local PC** to check the connection status between the remote computer (Ubuntu build environment) and the local computer (Windows build environment).
249   - If ![en-us_image_0000001326512673](figures/en-us_image_0000001326512673.png) is displayed on the right of **Local PC**, the remote computer is connected to the local computer. In this case, no further action is required.
250   - If ![en-us_image_0000001275432904](figures/en-us_image_0000001275432904.png) is displayed, click the connect icon. During the connection, DevEco Device Tool will restart. Therefore, to avoid task interruptions, do not connect to DevEco Device Tool when downloading or building source code.
251
252   ![en-us_image_0000001285658392](figures/en-us_image_0000001285658392.png)
253
2543. Click **Project Settings** on the menu bar to access the Hi3516DV300 project configuration page.
255
256   ![en-us_image_0000001275752808](figures/en-us_image_0000001275752808.png)
257
2584. On the **Tool Chain** tab page, DevEco Device Tool automatically checks for the uploader tool.
259
260   - If the tool is indicated as **uninstalled** (![status_uninstall](figures/status_uninstall.png)), click **Download Uninstalled Tools** to install all the required tools, or click **Download** next to a tool to install the specific tool.
261   - If **Download** is not available for a missing tool, it is not cataloged in DevEco Device Tool. In this case, you need to download the tool to the local host and click **Import** to import it.
262
263   ![3516_standard_false](figures/3516_standard_false.png)
264
2655. On the **hispark_taurus_standard** tab page, set the burning options. The settings are automatically saved.
266
267   - **upload_partitions_profile**: Select the burning profile file (preset by default), which specifies the files to be burnt, start address and length of the partition, and other burning settings. In addition, select **Enable to use upload_partitions_profile**.
268      > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
269      >
270      > In the burning profile file, you can change the start address and length of the partition based on the size of the files to be burnt. Make sure the size of the partition is greater than that of the files to be burnt and the partition addresses of the files do not overlap.
271      >
272      > If this is the first time you burn files to the development board, select **Enable to use upload_partitions_profile for upload** so that the upload_partitions file will be automatically generated. Afterward, select **Enable to use upload_partitions_profile for upload** only when you need to generate a new **upload_partitions** file.
273   - **upload_protocol**: Select the burning protocol **hiburn-usb**.
274   - **upload_port**: Select the serial port number obtained.
275
276   ![en-us_image_0000001338622229](figures/en-us_image_0000001338622229.png)
277
2786. Click **Upload** under **hispark_taurus_standard**.
279
280   ![en-us_image_0000001276281922](figures/en-us_image_0000001276281922.png)
281
282   When the "Operation paused, Please press Enter key to continue" message is displayed, which indicates that the transfer is complete, press **Enter** to start burning.
283
284   ![en-us_image_0000001326201857](figures/en-us_image_0000001326201857.png)
285
2867. When the following information is displayed in the **TERMINAL** window, press and hold the **Update** key within 15 seconds, remove and insert the USB cable, and then release the **Update** key to start burning.
287
288   ![en-us_image_0000001276122010](figures/en-us_image_0000001276122010.png)
289
290   When the "SUCCESS" message is displayed, it indicates that the burning is successful.
291
292   ![en-us_image_0000001275802150](figures/en-us_image_0000001275802150.png)
293
2948. When the burning is successful, perform the operations in [Running an Image](#running-an-image) to start the system.
295
296
297## Running an Image
298
299
300### Starting the System
301
302After the burning is complete, perform the following steps to start the system:
303
304> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
305>
306> This operation procedure is required only if this is the first time you burn an image for the standard system.
307
3081. In DevEco Device Tool, click **Monitor** to open the serial port tool.
309
310   ![quickstart-appendix-hi3516-ide-run](figures/quickstart-appendix-hi3516-ide-run.png)
311
3122. Restart the development board. Before the autoboot countdown ends, press any key to enter the system.
313
314   ![press-any-key-to-enter-the-system](figures/press-any-key-to-enter-the-system.gif)
315
3163. Run the following commands to set system boot parameters:
317
318   ```shell
319   setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)';
320   ```
321
322
323   ```shell
324   setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000'
325   ```
326
327   ![setenv-bootargs](figures/setenv-bootargs.png)
328
3294. Save the parameter settings.
330
331   ```shell
332   save
333   ```
334
335   ![Save the parameter settings](figures/quickstart-appendix-hi3516-ide-run-set.png)
336
3375. Restart the development board to start the system.
338
339   ```shell
340   reset
341   ```
342
343   ![start the system](figures/quickstart-appendix-hi3516-ide-run-start.png)
344
345
346### Running a Hello World Program
347
348After the system is started, start the serial port tool, run the **helloworld** command in any directory, and press **Enter**. If the message "Hello World!" is displayed, the program runs successfully.
349
350![helloworld](figures/helloworld.png)
351
352
353### Next
354
355Congratulations! You have finished all steps! Proceed to [develop a sample](../guide/device-clock-guide.md) to better familiarize yourself with OpenHarmony development.
356