# Developing the First Example Program Running on Hi3518 - [Acquiring Source Code](#section1726092873119) - [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb) - [Compiling Code](#section234175193114) - [Burning](#section57955241588) - [Running an Image](#section62131033183710) - [Follow-up Learning](#section9712145420182) This section describes how to modify, compile, burn, and run the first program on the board, and finally print **Hello OHOS!**. ## Acquiring Source Code You need to acquire [Hi3518 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 details, see [Source Code Acquisition](../get-code/source-code-acquisition.md). ## Modifying a Program The following example shows the **helloworld.c** code in the **applications/sample/camera/app/src** directory. You can customize the content to be printed. For example, you can change OHOS to World. You can use either ISO 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, access the root directory of the source code package and run the following script to compile the source code package. The result files are generated in the **out/ipcamera\_hi3518ev300** directory. ``` python build.py ipcamera_hi3518ev300 -b debug ``` ## Burning The USB port is the only burning mode supported by the Hi3518 development board. 1. Connect the PC and the target development board through the serial port and USB port. In this section, the Hi3518EV300 is used as an example. For details, please refer to [Introduction to the Hi3518 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_hi3518-0000001050170473). 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 **Device Tool** \> **Configure** \> **Burn**. On the displayed page, set the programming information. ![](figures/en-us_image_0000001057194144.png) 4. Set **Burning Mode** to **usbport**. ![](figures/en-us_image_0000001057392985.png) 5. Set the programming parameters. - Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001057313128_li101031912111518). - Retain the default values for the baud rate and data bits, which have been adapted for the development board. - Set the memory type. For the Hi3518 series development boards, the memory type is fixed at SPI NOR. - Set the information about the files to be written according to the following table.

File Name

Start Address

File Size

Enable

u-boot-development board name.bin

0

1M

Select the check box.

OHOS_Image.bin

1M

6M

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

7M

8M

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

15M

1M

![](figures/en-us_image_0000001057952739.png) 6. When you have done, click **Save** at the bottom to save the settings. 7. Click ![](figures/en-us_image_0000001057311476.png) next to **Burn** to start programming. >![](public_sys-resources/icon-note.gif) **NOTE:** >If this is the first time you program flash memory on the Hi3516 or Hi3518 board, the message "not find the Devices" may be displayed. In this case, follow the steps in [Installing the USB Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/cn/docs/ide/user-guides/usb_driver-0000001058690393) and start programming again. ![](figures/en-us_image_0000001058192356.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/usb烧录-6.png) 10. 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 Hi3518](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_example-0000001051610926#EN-US_TOPIC_0000001053422339__section62131033183710). ## 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-3.md#en-us_topic_0000001053466255_section14871149155911). **Figure 1** Serial port connection ![](figures/chuankou1-1.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 for the first burning\) Modify the **bootcmd** and **bootargs** parameters of U-boot. This step is a fixed operation and the result can be saved. However, you need to perform the following steps again if U-boot needs to be reburnt. **Table 1** Parameters of the U-boot

Command

Description

setenv bootcmd "sf probe 0;sf read 0x40000000 0x100000 0x600000;go 0x40000000";

Run this command to set the content of bootcmd. Select the flash whose number is 0, and read content that has a size of 0x600000 and a start address of 0x100000 to memory address 0x40000000. The size must be the same as that of the OHOS_Image.bin file in the IDE.

setenv bootargs "console=ttyAMA0,115200n8 root=flash fstype=jffs2 rw rootaddr=7 M rootsize=8 M";

In this command, bootargs is set to the serial port output, the baud rate is 115200, the data bit is 8, and the rootfs is mounted to the flash memory. The file system type is set to jffs2 rw, which provides the read-write attribute for the JFFS2 file system. rootaddr=7 M rootsize=8 M indicates the actual start address and length 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.

pri

pri means to view the displayed parameters.

>![](public_sys-resources/icon-notice.gif) **NOTICE:** >**go 0x40000000** \(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. If **hisilicon \#** is displayed during the startup, run the **reset** command. After the system automatically starts and **OHOS** is displayed, run the **./bin/camera\_app** command and then press **Enter**. The system is started successfully if information shown in the following figure is displayed. **Figure 2** Successful system startup and program execution ![](figures/successful-system-startup-and-program-execution.png "successful-system-startup-and-program-execution") ## Follow-up Learning Congratulations! You have finished all steps! You are advised to go on learning how to develop [Cameras with a Screen](../guide/camera-control.md).