1e41f4b71Sopenharmony_ci# Getting Started with the Standard System with Hi3516 (CLI Mode)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci> ![icon-caution.gif](public_sys-resources/icon-caution.gif) **CAUTION**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci> **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.**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> **If you still need to use Hi3516DV300 to develop standard-system devices, adaptation may fail. In this case, contact the chip supplier to obtain the adaptation guide or complete adaptation by yourself.**
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciIn 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 by using the command-line interface (CLI).
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ciThe following exemplifies how to run the first program on the development board. The created program outputs the message "Hello World!"
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciBefore development, [set up the development environment](quickstart-pkg-prepare.md).
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci## Writing a Hello World Program
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci### Example Directory
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci```
27e41f4b71Sopenharmony_ciapplications/sample/hello
28e41f4b71Sopenharmony_ci │── BUILD.gn
29e41f4b71Sopenharmony_ci │── include
30e41f4b71Sopenharmony_ci │   └── helloworld.h
31e41f4b71Sopenharmony_ci │── src
32e41f4b71Sopenharmony_ci │   └── helloworld.c
33e41f4b71Sopenharmony_ci ├── bundle.json
34e41f4b71Sopenharmony_ci build
35e41f4b71Sopenharmony_ci └── subsystem_config.json
36e41f4b71Sopenharmony_ci vendor/hisilicon
37e41f4b71Sopenharmony_ci └── Hi3516DV300
38e41f4b71Sopenharmony_ci     └── config.json
39e41f4b71Sopenharmony_ci```
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci### How to Develop
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciPerform the steps below in the source code directory:
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci1. Create a directory and write the service code.
47e41f4b71Sopenharmony_ci   
48e41f4b71Sopenharmony_ci   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.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci   ```
52e41f4b71Sopenharmony_ci   #include <stdio.h>
53e41f4b71Sopenharmony_ci   #include "helloworld.h"
54e41f4b71Sopenharmony_ci   int main(int argc, char **argv)
55e41f4b71Sopenharmony_ci   {
56e41f4b71Sopenharmony_ci       HelloPrint();
57e41f4b71Sopenharmony_ci       return 0;
58e41f4b71Sopenharmony_ci   }
59e41f4b71Sopenharmony_ci   void HelloPrint()
60e41f4b71Sopenharmony_ci   {
61e41f4b71Sopenharmony_ci       printf("\n\n");
62e41f4b71Sopenharmony_ci       printf("\n\t\tHello World!\n");
63e41f4b71Sopenharmony_ci       printf("\n\n");
64e41f4b71Sopenharmony_ci   }
65e41f4b71Sopenharmony_ci   ```
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci   Add the header file **applications/sample/hello/include/helloworld.h**. The sample code is as follows:
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci   ```
71e41f4b71Sopenharmony_ci   #ifndef HELLOWORLD_H
72e41f4b71Sopenharmony_ci   #define HELLOWORLD_H
73e41f4b71Sopenharmony_ci   #ifdef __cplusplus
74e41f4b71Sopenharmony_ci   #if __cplusplus
75e41f4b71Sopenharmony_ci   extern "C" {
76e41f4b71Sopenharmony_ci   #endif
77e41f4b71Sopenharmony_ci   #endif
78e41f4b71Sopenharmony_ci   void HelloPrint();
79e41f4b71Sopenharmony_ci   #ifdef __cplusplus
80e41f4b71Sopenharmony_ci   #if __cplusplus
81e41f4b71Sopenharmony_ci   }
82e41f4b71Sopenharmony_ci   #endif
83e41f4b71Sopenharmony_ci   #endif
84e41f4b71Sopenharmony_ci   #endif // HELLOWORLD_H
85e41f4b71Sopenharmony_ci   ```
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci2. Create a build file.
88e41f4b71Sopenharmony_ci   1. Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows:
89e41f4b71Sopenharmony_ci      
90e41f4b71Sopenharmony_ci       ```
91e41f4b71Sopenharmony_ci       import("//build/ohos.gni") # Import the build template.
92e41f4b71Sopenharmony_ci       ohos_executable("helloworld") {# Executable module.
93e41f4b71Sopenharmony_ci         sources = [       # Source code of the module.
94e41f4b71Sopenharmony_ci           "src/helloworld.c"
95e41f4b71Sopenharmony_ci         ]
96e41f4b71Sopenharmony_ci         include_dirs = [  # Directory of header files on which the module depends.
97e41f4b71Sopenharmony_ci           "include" 
98e41f4b71Sopenharmony_ci         ]
99e41f4b71Sopenharmony_ci         cflags = []
100e41f4b71Sopenharmony_ci         cflags_c = []
101e41f4b71Sopenharmony_ci         cflags_cc = []
102e41f4b71Sopenharmony_ci         ldflags = []
103e41f4b71Sopenharmony_ci         configs = []
104e41f4b71Sopenharmony_ci         deps =[]    # Internal dependencies of the component.
105e41f4b71Sopenharmony_ci         part_name = "hello"    # Component name. This parameter is mandatory.
106e41f4b71Sopenharmony_ci         install_enable = true # Whether to install the software by default. This parameter is optional. By default, the software is not installed.
107e41f4b71Sopenharmony_ci       }
108e41f4b71Sopenharmony_ci       ```
109e41f4b71Sopenharmony_ci   2. Create the **applications/sample/hello/bundle.json** file and add the description of the **sample** component. The content is as follows:
110e41f4b71Sopenharmony_ci      
111e41f4b71Sopenharmony_ci       ```
112e41f4b71Sopenharmony_ci       {
113e41f4b71Sopenharmony_ci           "name": "@ohos/hello",
114e41f4b71Sopenharmony_ci           "description": "Hello world example.",
115e41f4b71Sopenharmony_ci           "version": "3.1",
116e41f4b71Sopenharmony_ci           "license": "Apache License 2.0",
117e41f4b71Sopenharmony_ci           "publishAs": "code-segment",
118e41f4b71Sopenharmony_ci           "segment": {
119e41f4b71Sopenharmony_ci               "destPath": "applications/sample/hello"
120e41f4b71Sopenharmony_ci           },
121e41f4b71Sopenharmony_ci           "dirs": {},
122e41f4b71Sopenharmony_ci           "scripts": {},
123e41f4b71Sopenharmony_ci           "component": {
124e41f4b71Sopenharmony_ci               "name": "hello",
125e41f4b71Sopenharmony_ci               "subsystem": "sample",
126e41f4b71Sopenharmony_ci               "syscap": [],
127e41f4b71Sopenharmony_ci               "features": [],
128e41f4b71Sopenharmony_ci               "adapted_system_type": [ "mini", "small", "standard" ],
129e41f4b71Sopenharmony_ci               "rom": "10KB",
130e41f4b71Sopenharmony_ci               "ram": "10KB",
131e41f4b71Sopenharmony_ci               "deps": {
132e41f4b71Sopenharmony_ci                   "components": [],
133e41f4b71Sopenharmony_ci                   "third_party": []
134e41f4b71Sopenharmony_ci               },
135e41f4b71Sopenharmony_ci               "build": {
136e41f4b71Sopenharmony_ci                   "sub_component": [
137e41f4b71Sopenharmony_ci                       "//applications/sample/hello:helloworld"
138e41f4b71Sopenharmony_ci                   ],
139e41f4b71Sopenharmony_ci                   "inner_kits": [],
140e41f4b71Sopenharmony_ci                   "test": []
141e41f4b71Sopenharmony_ci               }
142e41f4b71Sopenharmony_ci           }
143e41f4b71Sopenharmony_ci       }
144e41f4b71Sopenharmony_ci       ```
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci       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. If there are APIs provided for other components, add them in **inner_kits**. If there are test cases, add them in **test**.
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci3. Modify the subsystem configuration file.
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci   Add the configuration of the new subsystem to the **build/subsystem_config.json** file.
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci   ```
154e41f4b71Sopenharmony_ci   "sample": {
155e41f4b71Sopenharmony_ci       "path": "applications/sample/hello",
156e41f4b71Sopenharmony_ci       "name": "sample"
157e41f4b71Sopenharmony_ci     },
158e41f4b71Sopenharmony_ci   ```
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci4. Modify the product configuration file.
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci   In the **vendor/hisilicon/Hi3516DV300/config.json** file, add the **hello** part after the existing part.
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci   ```
166e41f4b71Sopenharmony_ci       "usb:usb_manager_native":{},
167e41f4b71Sopenharmony_ci       "applications:prebuilt_hap":{},
168e41f4b71Sopenharmony_ci       "sample:hello":{},
169e41f4b71Sopenharmony_ci       "wpa_supplicant-2.9:wpa_supplicant-2.9":{},
170e41f4b71Sopenharmony_ci   ```
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci## Building Source Code
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ciYou can build source code with hb or the **build.sh** script. The following exemplifies how to build source code with hb. For details about how to build source code with the **build.sh** script, see [Building Source Code Using the build.sh Script](quickstart-pkg-common-build.md).
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ciFor details about the functions of the OpenHarmony compilation and building module, see [Compilation and Building Guide](../subsystems/subsys-build-all.md).
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci### Prerequisites
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci- The [required libraries and tools](quickstart-pkg-install-package.md) have been installed.
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci- The [compilation tools](quickstart-pkg-install-tool.md) have been installed.
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci- A **Hello World** program has been created with code written.
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci- The access to the Ubuntu environment is normal.
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci### Procedure
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ciGo to the root directory of the source code and run the build command.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci1. Set the build path.
196e41f4b71Sopenharmony_ci   
197e41f4b71Sopenharmony_ci   ```
198e41f4b71Sopenharmony_ci   hb set
199e41f4b71Sopenharmony_ci   ```
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci2. Select the current path.
202e41f4b71Sopenharmony_ci   
203e41f4b71Sopenharmony_ci   ```
204e41f4b71Sopenharmony_ci   .
205e41f4b71Sopenharmony_ci   ```
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci3. Select **hispark_taurus_standard** under **hisilicon** and press **Enter**.
208e41f4b71Sopenharmony_ci   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
209e41f4b71Sopenharmony_ci   >
210e41f4b71Sopenharmony_ci   > When adapting the development board to a specific use case, select an appropriate build form factor, that is, **product** settings. For details, see [Build Form Factors](quickstart-appendix-compiledform.md).
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci     **Figure 1** Hi3516 build settings 
213e41f4b71Sopenharmony_ci   
214e41f4b71Sopenharmony_ci   ![quick-start-hi3516-standard-build](figures/quick-start-hi3516-standard-build.png)
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci4. Start building.
217e41f4b71Sopenharmony_ci   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
218e41f4b71Sopenharmony_ci   > - To build a component (for example, **hello**), run the **hb build -T *targetName*** command.
219e41f4b71Sopenharmony_ci   > 
220e41f4b71Sopenharmony_ci   > - To build a product incrementally, run the **hb build** command.
221e41f4b71Sopenharmony_ci   > 
222e41f4b71Sopenharmony_ci   > - To build a product from the scratch, run the **hb build -f** command.
223e41f4b71Sopenharmony_ci   > 
224e41f4b71Sopenharmony_ci   > This example builds a product from the scratch.
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci   
227e41f4b71Sopenharmony_ci   ```
228e41f4b71Sopenharmony_ci   hb build -f
229e41f4b71Sopenharmony_ci   ```
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci5. Check the build result. If "build success" is displayed, the building is successful.
232e41f4b71Sopenharmony_ci   > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
233e41f4b71Sopenharmony_ci   >
234e41f4b71Sopenharmony_ci   > The build result and log files are stored in **out/hi3516dv300**.
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci## Burning an Image
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ciThe following exemplifies how to burn an image to Hi3516DV300 using HiTool. You can also do so using DevEco Device Tool, by following instructions in [Burning an Image](quickstart-appendix-hi3516-ide.md#burning-an-image).
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci### Prerequisites
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci- The source code of the development board has been compiled into files for burning.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci- [HiTool](http://www.hihope.org/download/download.aspx) has been installed on the client platform (for example, a Windows-based computer).
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci- The USB port driver has been installed on the client platform. 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).
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci- A serial port terminal tool, such as IPOP, has been installed on the client platform.
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci- The client platform and development board are connected using a USB cable and serial cable.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci### Procedure
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci1. Prepare the files to be burnt.
258e41f4b71Sopenharmony_ci   1. On the client platform, create a folder for storing the files to be burnt, for example, **D:\L2**.
259e41f4b71Sopenharmony_ci   2. Download the compiled source package to the client platform, decompress the package, and copy the files required for burning to the folder created in step 1.
260e41f4b71Sopenharmony_ci      
261e41f4b71Sopenharmony_ci      For the Hi3516DV300 development board, the files required for burning of the standard system are as follows: **boot.img**, **Hi3516DV300-emmc.xml**, **system.img**, **u-boot-hi3516dv300_emmc.bin**, **uImage**, **updater.img**, **userdata.img**, and **vendor.img**.
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci2. Burn the image files using HiTool.
264e41f4b71Sopenharmony_ci   1. Open HiTool.
265e41f4b71Sopenharmony_ci   2. Set up HiTool.
266e41f4b71Sopenharmony_ci      
267e41f4b71Sopenharmony_ci      Set the transfer mode to USB and burning mode to eMMC (the storage medium of the development board is eMMC).
268e41f4b71Sopenharmony_ci   3. Click **Browse** and select the burning configuration file (for example, **Hi3516DV300-emmc.xml**) from the folder created in step 1.
269e41f4b71Sopenharmony_ci      
270e41f4b71Sopenharmony_ci       ![quickstart-hi3516-standard-hitool-select](figures/quickstart-hi3516-standard-hitool-select.png)
271e41f4b71Sopenharmony_ci   4. After clicking the **Burn** button, press and hold the **Update** key next to the serial port on the development board, and remove and insert the USB cable.
272e41f4b71Sopenharmony_ci      
273e41f4b71Sopenharmony_ci      After the burning starts, logs are displayed in the console area at the bottom of HiTool.
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci      When the burning is complete, HiTool displays a dialog box indicating that the burning is successful.
276e41f4b71Sopenharmony_ci   5. Click **OK**.
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci3. Import startup parameters.
279e41f4b71Sopenharmony_ci   1. Use the terminal tool to enable the serial port.
280e41f4b71Sopenharmony_ci   2. Restart the development board by removing and inserting its power supply. Press **Enter** in the serial port terminal tool within 3 seconds.
281e41f4b71Sopenharmony_ci      
282e41f4b71Sopenharmony_ci      If **hisilicon \#** is displayed on the terminal tool page, the serial port of the development board is connected.
283e41f4b71Sopenharmony_ci   3. Copy the following startup parameters in the serial port terminal tool and press **Enter** to complete the setup.
284e41f4b71Sopenharmony_ci      
285e41f4b71Sopenharmony_ci       ```
286e41f4b71Sopenharmony_ci       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)';setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000'
287e41f4b71Sopenharmony_ci       
288e41f4b71Sopenharmony_ci       saveenv
289e41f4b71Sopenharmony_ci       
290e41f4b71Sopenharmony_ci       reset
291e41f4b71Sopenharmony_ci       ```
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci       > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
294e41f4b71Sopenharmony_ci       >
295e41f4b71Sopenharmony_ci       > When entering startup parameters, do not delete blank lines.
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci## Running an Image
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciAfter the system is started, copy the executable file **helloworld** in the **out** directory of the source code to the **bin** directory, and run the Hello World program as follows:
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci### Procedure
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci1. Go to the **bin** directory on the startup page.
306e41f4b71Sopenharmony_ci   
307e41f4b71Sopenharmony_ci   ```
308e41f4b71Sopenharmony_ci   cd bin
309e41f4b71Sopenharmony_ci   ```
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci2. Run the following command to run the **helloworld** program:
312e41f4b71Sopenharmony_ci   
313e41f4b71Sopenharmony_ci   ```
314e41f4b71Sopenharmony_ci   ./helloworld
315e41f4b71Sopenharmony_ci   ```
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci   If the message "Hello World!" is displayed, the program runs successfully.
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci### Next
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ciCongratulations! You have finished all steps! Proceed to [develop a sample](../guide/device-clock-guide.md) to better familiarize yourself with OpenHarmony development.
323