• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Getting Started with the Standard System with Hi3516 (IDE Mode)
2
3> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
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 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.
8
9In addition to the small system, the Hi3516DV300 development board also supports the standard system. This topic describes how to develop the standard system on Hi3516DV300 by using DevEco Device Tool.
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. By default, the software is not installed.
110       }
111       ```
112   2. Create the **applications/sample/hello/bundle.json** file and add the description of the **sample** component. The content is as follows:
113
114       ```
115       {
116           "name": "@ohos/hello",
117           "description": "Hello world example.",
118           "version": "3.1",
119           "license": "Apache License 2.0",
120           "publishAs": "code-segment",
121           "segment": {
122               "destPath": "applications/sample/hello"
123           },
124           "dirs": {},
125           "scripts": {},
126           "component": {
127               "name": "hello",
128               "subsystem": "sample",
129               "syscap": [],
130               "features": [],
131               "adapted_system_type": [ "mini", "small", "standard" ],
132               "rom": "10KB",
133               "ram": "10KB",
134               "deps": {
135                   "components": [],
136                   "third_party": []
137               },
138               "build": {
139                   "sub_component": [
140                       "//applications/sample/hello:helloworld"
141                   ],
142                   "inner_kits": [],
143                   "test": []
144               }
145           }
146       }
147       ```
148
149       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**.
150
1513. Modify the subsystem configuration file.
152
153   Add the configuration of the new subsystem to the **build/subsystem_config.json** file.
154
155
156   ```
157   "sample": {
158       "path": "applications/sample/hello",
159       "name": "sample"
160     },
161   ```
162
1634. Modify the product configuration file.
164
165   In the **productdefine/common/products/Hi3516DV300.json** file, add the **hello** part after the existing part.
166
167   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
168   >
169   > 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**.
170
171
172   ```
173       "usb:usb_manager_native":{},
174       "applications:prebuilt_hap":{},
175       "sample:hello":{},
176       "wpa_supplicant-2.9:wpa_supplicant-2.9":{},
177   ```
178
179
180## Building Source Code
181
182With 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.
183
184> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
185>
186> The build environment of Hi3516DV300 is Ubuntu.
187
1881. Click **Project Settings** on the menu bar to access the Hi3516DV300 project configuration page.
189
190   ![en-us_image_0000001274745038](figures/en-us_image_0000001274745038.png)
191
1922. On the **Tool Chain** tab page, DevEco Device Tool automatically checks whether the dependent compiler toolchain is complete. If a message is displayed indicating that some tools are missing, click **Install** to automatically install the required tools.
193
194   ![en-us_image_0000001292531862](figures/en-us_image_0000001292531862.png)
195
1963. Install the toolchain related to Hi3516DV300. Certain tools may require the root access to install. In this case, enter the user password in the **TERMINAL** window.
197
198   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
199   >
200   > - 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.
201   > - 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.
202
203   ![en-us_image_0000001274748606](figures/en-us_image_0000001274748606.png)
204
205   After the toolchain is automatically installed, the figure below is displayed.
206
207   ![en-us_image_0000001296270098](figures/en-us_image_0000001296270098.png)
208
2094. On the **hispark_taurus_standard** tab page, set **build_type**, whose default value is **debug**.
210
211   ![en-us_image_0000001325269477](figures/en-us_image_0000001325269477.png)
212
2135. Choose **PROJECT TASKS** > **hispark_taurus_standard** > **Build** to start building.
214
215   ![en-us_image_0000001292849062](figures/en-us_image_0000001292849062.png)
216
2176. Wait until **SUCCESS** is displayed in the **TERMINAL** window, indicating that the build is complete.
218
219   ![en-us_image_0000001366345198](figures/en-us_image_0000001366345198.png)
220
221   After the compilation is complete, go to the **out** directory of the project to view the generated files and perform burning operations.
222
223
224## Burning an Image
225
226Burning 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.
227
228The 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.
229
230Hi3516DV300 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.
231
232
233### Prerequisites
234
235- 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).
236
237- 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).
238
239
240### Procedure
241
2421. 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).
243
2442. 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).
245   - 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.
246   - 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.
247
248   ![en-us_image_0000001285658392](figures/en-us_image_0000001285658392.png)
249
2503. Click **Project Settings** on the menu bar to access the Hi3516DV300 project configuration page.
251
252   ![en-us_image_0000001275752808](figures/en-us_image_0000001275752808.png)
253
2544. On the **Tool Chain** tab page, set the Uploader burning tool. You can click **Install** on this page to install the tool online.
255
256   ![Phoenix-upload](figures/Phoenix-upload.png)
257
2585. On the **hispark_taurus_standard** tab page, set the burning options. The settings are automatically saved.
259
260   - **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**.
261      > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
262      >
263      > 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.
264      >
265      > 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.
266   - **upload_protocol**: Select the burning protocol **hiburn-usb**.
267   - **upload_port**: Select the serial port number obtained.
268
269   ![en-us_image_0000001338622229](figures/en-us_image_0000001338622229.png)
270
2716. Click **Upload** under **hispark_taurus_standard**.
272
273   ![en-us_image_0000001276281922](figures/en-us_image_0000001276281922.png)
274
275   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.
276
277   ![en-us_image_0000001326201857](figures/en-us_image_0000001326201857.png)
278
2797. 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.
280
281   ![en-us_image_0000001276122010](figures/en-us_image_0000001276122010.png)
282
283   When the "SUCCESS" message is displayed, it indicates that the burning is successful.
284
285   ![en-us_image_0000001275802150](figures/en-us_image_0000001275802150.png)
286
2878. When the burning is successful, perform the operations in [Running an Image](#running-an-image) to start the system.
288
289
290## Running an Image
291
292
293### Starting the System
294
295After the burning is complete, perform the following steps to start the system:
296
297> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
298>
299> This operation procedure is required only if this is the first time you burn an image for the standard system.
300
3011. In DevEco Device Tool, click **Monitor** to open the serial port tool.
302
303   ![quickstart-appendix-hi3516-ide-run](figures/quickstart-appendix-hi3516-ide-run.png)
304
3052. Restart the development board. Before the autoboot countdown ends, press any key to enter the system.
306
307   ![press-any-key-to-enter-the-system](figures/press-any-key-to-enter-the-system.gif)
308
3093. Run the following commands to set system boot parameters:
310
311   ```shell
312   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)';
313   ```
314
315
316   ```shell
317   setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000'
318   ```
319
320   ![setenv-bootargs](figures/setenv-bootargs.png)
321
3224. Save the parameter settings.
323
324   ```shell
325   save
326   ```
327
328   ![Save the parameter settings](figures/quickstart-appendix-hi3516-ide-run-set.png)
329
3305. Restart the development board to start the system.
331
332   ```shell
333   reset
334   ```
335
336   ![start the system](figures/quickstart-appendix-hi3516-ide-run-start.png)
337
338
339### Running a Hello World Program
340
341After 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.
342
343![helloworld](figures/helloworld.png)
344
345
346### Next
347
348Congratulations! You have finished all steps! Proceed to [develop a sample](../guide/device-clock-guide.md) to better familiarize yourself with OpenHarmony development.
349