# Developing the First Example Program Running on Hi3516 - [Acquiring Source Code](#section215953714245) - [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb) - [Compiling Code](#section1077671315253) - [Burning](#section08153912587) - [Running an Image](#section380511712615) - [Running a Program](#section5276734182615) This section describes how to modify, compile, burn, and run the first program, and finally print **Hello OHOS!** on the develop board. ## Acquiring Source Code You need to acquire [Hi3516 source code](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz), download it on a Linux server, and decompress it. For more obtaining methods, see [Source Code Acquisition](../get-code/source-code-acquisition.md). ## Modifying a Program The code of **helloworld.c** in the **applications/sample/camera/app/src** directory is shown in the following example. You can customize the content to be printed. For example, you can change **OHOS** to **World**. You can use either C or C++ to develop a program. ``` #include #include "los_sample.h" int main(int argc, char **argv) { printf("\n************************************************\n"); printf("\n\t\tHello OHOS!\n"); printf("\n************************************************\n\n"); LOS_Sample(g_num); return 0; } ``` ## Compiling Code On the Linux server, execute the **build.py** script stored in the root directory of the source code package. The result files in the **out/ipcamera\_hi3516dv300** directory. ``` python build.py ipcamera_hi3516dv300 -b debug ``` ## Burning The Hi3516 development board allows you to burn flash memory over the USB port, serial port, or network port. The following uses the network port burning as an example. 1. Connect the PC and the target development board through the power port, serial port, and network port. In this section, the Hi3516DV300 is used as an example. For details, please refer to [Introduction to the Hi3516 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_3516-0000001052670587). 2. Open Device Manager, then check and record the serial port number corresponding to the development board. >![](public_sys-resources/icon-note.gif) **NOTE:** >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695). ![](figures/en-us_image_0000001057235010.png) 3. Go to **Configure** \> **Burn**. On the displayed page, set the programming information. ![](figures/en-us_image_0000001057354060.png) 4. Set **Burning Mode** to **network**. ![](figures/网口烧录-1.png) 5. Set the programming parameters. - Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001056443961_li142386399535). - Retain the default values for the baud rate and data bits, which have been adapted for the development board. - Set network connection parameters. - **Host IP address**: IP address of the local PC. You can run the **ipconfig** command in the CLT to view the IP address. - **Remote IP address**: IP address of the development board, which is automatically populated. - **Gateway**: gateway of the development board, which is automatically populated. - **Subnet mask**: subnet mask, which is automatically populated. - **MAC address of board**: physical address of the development board. ![](figures/en-us_image_0000001057543065.png) - Set the memory type. The settings are related to the receive type of the hardware. For details, please refer to the user guide delivered with the hardware. For example, the value is fixed at EMMC for Hi3516DV300. - Set the information about the files to be written according to the following table. The U-Boot file is not supported for programming through the network port.

File Name

Start Address

File Size

Enable

OHOS_Image.bin

1M

9M

Select the check box if this is the first time you are programing flash memory on the development board or if the content related to the kernel and driver is modified.

rootfs.img

10M

15M

Select the check boxes if this is the first time you are programing flash memory on the development board or if the files have been modified. It is recommended that you always select these check boxes.

userfs.img

25M

50M

![](figures/en-us_image_0000001057621705.png) 6. When you have done, click **Save** at the bottom to save the settings. 7. Click ![](figures/en-us_image_0000001057097113.png) next to **Burn** to start programming. ![](figures/en-us_image_0000001057911116.png) 8. Restart the development board within 15 seconds. 9. Wait until the programming is complete. If the following information is displayed on the console, it indicates that the programming is successful. ![](figures/en-us_image_0000001056648688.png) 10. If this is the first time you use the development board, use the [serial port tool](en-us_topic_0000001057649420.md) to modify the bootcmd and bootargs contents of U-Boot. For details, please refer to [Running an Image on the Hi3516](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_first_example-0000001051610926#ZH-CN_TOPIC_0000001052906247__section380511712615). ## Running an Image 1. Connect to a serial port. >![](public_sys-resources/icon-notice.gif) **NOTICE:** >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faqs-1.md#section14871149155911). **Figure 1** Serial port connection ![](figures/chuankou1.png) 1. Click **Serial port** to enable it. 2. Enter the serial port number queried in the "Burning" section \(COM11 is used in this example\) and press **Enter** until **hisillicon** is displayed. 3. Go to step [2](#l5b42e79a33ea4d35982b78a22913b0b1) if the board is started for the first time or the startup parameters need to be modified; go to step [3](#ld26f18828aa44c36bfa36be150e60e49) otherwise. 2. \(Mandatory when the board is started for the first time\) Modify the bootcmd and bootargs parameters of U-boot. You need to perform this step only once if the parameters need not to be modified during the operation. The board automatically starts after it is reset. >![](public_sys-resources/icon-notice.gif) **NOTICE:** >The default waiting time in the U-boot is 2s. You can press **Enter** to interrupt the waiting and run the **reset** command to restart the system after "hisillicon" is displayed. **Table 1** Parameters of the U-boot

Command

Description

setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800; go 0x80000000";

Run this command to read content that has a size of 0x4800 (9 MB) and a start address of 0x800 (1 MB) to the memory address 0x80000000. The file size must be the same as that of the OHOS_Image.bin file in the IDE.

setenv bootargs "console=ttyAMA0,115200n8 root=emmc fstype=vfat rootaddr=10 M rootsize=15 M rw";

Run this command to set the output mode to serial port output, baud rate to 115200, data bit to 8, rootfs to be mounted to the emmc component, and file system type to vfat.

rootaddr=10 M, rootsize=15 M rw indicates the start address and size of the rootfs.img file to be burnt, respectively. The file size must be the same as that of the rootfs.img file in the IDE.

saveenv

saveenv means to save the current configuration.

reset

reset means to reset the board.

>![](public_sys-resources/icon-notice.gif) **NOTICE:** >**go 0x80000000** \(optional\) indicates that the command is fixed in the startup parameters by default and the board automatically starts after it is reset. If you want to manually start the board, press **Enter** in the countdown phase of the U-boot startup to interrupt the automatic startup. 3. Run the **reset** command and press **Enter** to restart the board. After the board is restarted, **OHOS** is displayed when you press **Enter**. **Figure 2** System startup ![](figures/qi1.png) ## Running a Program In the root directory, run the **./bin/camera\_app** command to operate the demo program. The compilation result is shown in the following example. **Figure 3** Program started successfully ![](figures/qidong.png)