1 Star 0 Fork 4.9K

fish / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
developing-the-first-example-program-running-on-hi3516.md 11.74 KB
一键复制 编辑 原始数据 按行查看 历史
NEEN 提交于 2021-03-12 17:59 . !197 Docs Update version 1.0.1

Developing the First Example Program Running on Hi3516

This section describes how to modify, compile, burn, and run the first program, and finally print Hello OHOS! on the develop board.

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 <stdio.h>
#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;
}

Building

If the Linux environment is installed using Docker, perform the compilation by referring to Using Docker to Prepare the Build Environment. If the Linux environment is installed using a software package, go to the root directory of the source code and run the following commands for source code compilation:

hb set (Set the building path.)
. (Select the current path.)
Select ipcamera_hispark_taurus@hisilicon and press Enter.
hb build -f (Start building.)

Figure 1 Settings

The result files are generated in the out/hispark_taurus/ipcamera_hispark_taurus directory.

NOTICE: The U-boot file of the Hi3516 development board can be obtained from the following path: vendor\hisi\hi35xx\hi3516dv300\uboot\out\boot\u-boot-hi3516dv300.bin

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.

  2. Open Device Manager, then check and record the serial port number corresponding to the development board.

    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.

  3. Open DevEco Device Tool and go to Projects > Settings.

  4. On the hi3516dv300 tab page, configure the programming options.

    • upload_port: Select the serial port number obtained in step 2.
    • upload_protocol: Select the programming protocol hiburn-net.
    • upload_partitions: Select the file to be programmed. By default, the fastboot, kernel, rootfs, and userfs files are programmed at the same time.

  5. Set the IP address of the network port. You are advised to set the local TCP/IPv4 address on your PC and then set the following options:

    • upload_net_server_ip: Select the IP address of your PC, such as 192.168.1.2.
    • upload_net_client_mask: Set the subnet mask of the development board, such as 255.255.255.0. Once the upload_net_server_ip field is set, this field will be automatically populated.
    • upload_net_client_gw: Set the gateway of the development board, such as 192.168.1.1. Once the upload_net_server_ip field is set, this field will be automatically populated.
    • upload_net_client_ip: Set the IP address of the development board, such as 92.168.1.3. Once the upload_net_server_ip field is set, this field will be automatically populated.

  6. Switch between the hi3516dv300_fastboothi3516dv300_kernel, hi3516dv300_rootfs, and hi3516dv300_userfs tab pages, and modify the settings. In general cases, you can leave the fields at their default settings. To change the default settings, select the target item in the New Option field first.

  7. When you finish modifying, click Save in the upper right corner.

  8. Open the project file and go to > PROJECT TASKS > env:hi3516dv300 > Upload to start programming.

  9. When the following message is displayed, power off the development board and then power it on.

  10. Start programming. When the following message is displayed, it indicates that the programming is successful.

Running an Image

  1. Connect to a serial port.

    NOTICE: If the connection fails, rectify the fault by referring to What should I do when no command output is displayed?.

    Figure 2 Serial port connection

    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 if the board is started for the first time or the startup parameters need to be modified; go to step 3 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.

    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.

    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 3 System startup

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 4 Program started successfully

1
https://gitee.com/fish_neil/docs.git
git@gitee.com:fish_neil/docs.git
fish_neil
docs
docs
master

搜索帮助