提交 37cc208b 编写于 作者: Y yangni 提交者: wenjun

Description: update docs 20210107

CommitID:90b0e9d610bad9ad7014d889110e055e29599d6d
上级 7958dbc6
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
- quick-start:[快速入门](quick-start/Readme-CN.md) - quick-start:[快速入门](quick-start/Readme-CN.md)
- get-code:[获取源码/获取工具](get-code/Readme-CN.md) - get-code:[获取源码/获取工具](get-code/Readme-CN.md)
- docker:[Docker镜像构建](docker/README.md) - docker:[Docker镜像构建](docker/README.md)
- driver:[驱动](driver/Readme-CN.md)
- kernel:[内核](kernel/Readme-CN.md) - kernel:[内核](kernel/Readme-CN.md)
- driver:[驱动](driver/Readme-CN.md)
- subsystems:[子系统](subsystems/Readme-CN.md) - subsystems:[子系统](subsystems/Readme-CN.md)
- bundles:[组件开发](bundles/Readme-CN.md) - bundles:[组件开发](bundles/Readme-CN.md)
- porting:[三方库移植](porting/Readme-CN.md)
- guide:[设备开发](guide/Readme-CN.md) - guide:[设备开发](guide/Readme-CN.md)
- security:[安全](security/Readme-CN.md) - security:[安全](security/Readme-CN.md)
- api-LinkIoT:[联接类模组API](api/api-LinkIoT/Readme-CN.md) - api-LinkIoT:[联接类模组API](api/api-LinkIoT/Readme-CN.md)
......
# HPM介绍<a name="ZH-CN_TOPIC_0000001071487274"></a>
随着OpenHarmony正式开源,HPM包管理器也应运而生。HPM全称HarmonyOS Package Manager,是OpenHarmony组件包的管理和分发工具。HPM主要是面向设备开发者,用于获取/定制OpenHarmony源码,执行安装、编译、打包、升级等操作的工具集。本文档将向开发者介绍如何使用HPM工具进行OpenHarmony组件的安装、编译、打包等操作。
...@@ -13,3 +13,8 @@ ...@@ -13,3 +13,8 @@
- [准备工作](准备工作.md) - [准备工作](准备工作.md)
- [组件开发](组件开发.md) - [组件开发](组件开发.md)
- [组件开发示例](组件开发示例.md)
- [HPM介绍](HPM介绍.md)
- [环境准备](环境准备.md)
- [操作实例](操作实例.md)
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
推荐安装 [Node.js](https://nodejs.org/) 12.x \(包含 npm 6.14.4\)或更高版本 \(推荐 12.13.0+\)。 推荐安装 [Node.js](https://nodejs.org/) 12.x \(包含 npm 6.14.4\)或更高版本 \(推荐 12.13.0+\)。
2. 通过Node.js自带的npm安装hpm-cli命令行工具。 2. 通过Node.js自带的npm安装hpm-cli命令行工具。执行以下命令:
打开CMD,执行以下命令:
``` ```
npm install -g @ohos/hpm-cli npm install -g @ohos/hpm-cli
......
# 操作实例<a name="ZH-CN_TOPIC_0000001072143838"></a>
环境准备好后,接下来本文以Hi3861平台为例,演示如何利用HPM进行组件的安装、编译和打包。
1. 执行以下命令,初始化安装目录(目录名可自行设置):
```
mkdir test3861
cd test3861
hpm init -t dist
```
初始化成功则显示:
```
Initialization finished.
```
2. 安装wifi\_iot发行版。
```
hpm install @ohos/wifi_iot
```
安装成功则显示:
```
Installed.
```
>![](public_sys-resources/icon-note.gif) **说明:**
>Hi3516平台采用下述命令:
>```
>hpm install @ohos/ip_camera_hi3516dv300
>```
>Hi3518平台采用下述命令:
>```
>hpm install @ohos/ip_camera_hi3518ev300
>```
3. 编译打包
```
hpm dist
```
编译成功会显示:
```
{{name}}: distribution building completed.
```
4. 上述所有命令执行成功后,在 ./out 目录下会生成编译结果,开发者可以将编译结果烧录到对应的开发板上进行测试。
# 环境准备<a name="ZH-CN_TOPIC_0000001071315859"></a>
- [linux服务器](#section20979554791)
- [安装Node.js](#section9954105413153)
- [安装HPM](#section15937194904819)
- [安装python环境](#section1621819180417)
- [安装文件打包工具](#section77617165913)
- [安装SCons](#section20558439191516)
## linux服务器<a name="section20979554791"></a>
准备一台装有Ubuntu 16.04 及以上 64 位系统的linux服务器(hpm是支持windows的,但是目前鸿蒙开源的Hi3861、Hi3516、Hi3518三个解决方案都只支持Ubuntu)。
将linux shell改为bash:
```
ls -l $(which sh)
# 如果指向的不是bash,则按以下方式修改:
# 方法一:执行以下命令,然后选择no
dpkg-reconfigure dash
# 方法二:先删除sh,再重新创建软连接
rm -f /bin/sh
ln -s bash /bin/sh
```
## 安装Node.js<a name="section9954105413153"></a>
推荐安装 Node.js 12.x (包含 npm 6.14.4)或更高版本(推荐 12.13.0+):
```
sudo apt-get install nodejs
sudo apt-get install npm
```
查看版本:
```
node --version # 查看nodejs版本
npm --version # 查看npm版本
```
补充:如果配置的源的nodejs版本太低,可以执行以下语句后再执行apt-get install:
```
curl -L https://deb.nodesource.com/setup_12.x | bash
```
## 安装HPM<a name="section15937194904819"></a>
通过 Node.js 自带的 npm(使用默认的源 https://registry.npmjs.org/ )安装 hpm-cli 命令行工具:
```
npm install -g @ohos/hpm-cli
```
安装完hpm-cli命令行工具后,执行以下命令可以查看hpm配置:
```
hpm config
```
上述命令执行后将会显示hpm的默认配置,您可以根据自己的喜好对默认配置进行修改,以下是hpm的常用配置:
```
registry = https://hpm.harmonyos.com # hpm注册中心地址,下载组件必须
strictSsl = true # 通过https连接时,是否需要校验证书
http_proxy = http://your-proxy-server:port # 配置HTTP代理
https_proxy = http://your-proxy-server:port # 配置HTTPS代理
```
hpm-cli的命令介绍可以参考:[hpm操作命令](组件管理.md#table10510164515371)
## 安装python环境<a name="section1621819180417"></a>
需使用python3.7以上版本,采用以下命令进行安装:
```
sudo apt-get install python3.8
sudo apt-get install python3-pip
sudo pip3 install setuptools
sudo pip3 install kconfiglib # 建议安装kconfiglib 13.2.0+版本
```
>![](public_sys-resources/icon-note.gif) **说明:**
>上述方式适用Hi3518和Hi3516两种平台,针对Hi3861平台采用以下方式安装python环境:
>```
>sudo apt-get install python3.8
>sudo apt-get install python3-pip
>sudo pip3 install setuptools
>sudo pip3 install kconfiglib # 建议安装kconfiglib 13.2.0+版本
>sudo pip3 install pycryptodome
>sudo pip3 install six --upgrade --ignore-installed six
>sudo pip3 install ecdsa
>```
如果当前系统中既存在python2又存在python3,参考以下方法将默认python修改为python3:
```
ll `which python`
rm /usr/bin/python
ln -s python3.8 /usr/bin/python
```
## 安装文件打包工具<a name="section77617165913"></a>
采用以下命令进行安装:
```
which mkfs.vfat # 如果没找到,执行以下命令安装
sudo apt-get install dosfstools
which mcopy # 如果没找到,执行以下命令安装
sudo apt-get install mtools
```
>![](public_sys-resources/icon-note.gif) **说明:**
>Hi3518和Hi3516两种平台需要安装打包工具,Hi3861平台不需要。
## 安装SCons<a name="section20558439191516"></a>
采用下述命令安装SCons:
```
sudo apt-get install scons # 推荐SCons版本是3.0.4+
```
>![](public_sys-resources/icon-note.gif) **说明:**
>Hi3861平台需要安装SCons,Hi3518和Hi3516两种平台不需要。
# 组件开发示例<a name="ZH-CN_TOPIC_0000001074472258"></a>
- **[HPM介绍](HPM介绍.md)**
- **[环境准备](环境准备.md)**
- **[操作实例](操作实例.md)**
# WELCOME-TO-OPEN-HARMONY # WELCOME TO OPENHARMONY
OpenHarmony is an open-source project launched by the OpenAtom Foundation and serves as an open-source, distributed operating system (OS) that is intended to address all conceivable usage scenarios. OpenHarmony is an open-source version of HarmonyOS. OpenHarmony is an open-source project launched by the OpenAtom Foundation and serves as an open-source, distributed operating system that is intended to address all conceivable usage scenarios. OpenHarmony is an open-source version of HarmonyOS.
HarmonyOS is a future-proof distributed operating system open to you as part of the initiatives for the all-scenario strategy, adaptable to a mobile office, fitness and health, social communication, and media entertainment, and so on. Unlike a legacy operating system that runs on a standalone device, HarmonyOS is built on a distributed architecture designed based on a set of system capabilities. It is able to run on a wide range of device forms, including smartphones, wearables, tablets, PCs, smart TVs, AI speakers, head units, earphones, and AR/VR glasses. HarmonyOS is a future-proof distributed operating system open to you as part of the initiatives for the all-scenario strategy. It is adaptable to mobile office, fitness and health, social communication, entertainment, and many other scenarios. Unlike any legacy operating system that runs on a standalone device, HarmonyOS is built on a distributed architecture designed based on a set of system capabilities. It is able to run on a wide range of device forms, including smartphones, wearables, tablets, PCs, smart TVs, AI speakers, head units, earphones, and AR/VR glasses.
## Motivation ## Motivation
The traditional OSs are limited to a specific type of device, OpenHarmony provides distributed features that are compatible with a wide range of different devices. The first version supports devices with 128 KB to 128 MB of memory. Join us as we keep updating OpenHarmony versions. Traditional OSs are limited to a specific type of device, while OpenHarmony provides distributed features that are compatible with a wide range of different devices. The first version supports devices with 128 KB to 128 MB of memory. Join us as we keep updating OpenHarmony versions.
For device developers, OpenHarmony utilizes a component-based design to tailor its features to better suit specific devices, based on each device's capabilities and service characteristics. OpenHarmony can run on devices with limited resources and wearables with hundreds of KB of memory, as well as more powerful devices, such as smart home cameras and dashcams with hundreds of MB of memory. For device developers, OpenHarmony utilizes a component-based design to tailor its features to better suit specific devices, based on each device's capabilities and service characteristics. OpenHarmony can run on devices with limited resources and wearables with hundreds of KB of memory, as well as more powerful devices, such as smart home cameras and dashcams with hundreds of MB of memory.
[中文版本](/Readme-CN.md) [中文版本](/Readme-CN.md)
## OpenHarmony Documentation ## OpenHarmony Documentation
- [Getting Started](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/Readme-EN.md) - [Getting Started](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/Readme-EN.md)
- [Source Code Acquisition/Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.md)) - [Source Code Acquisition/Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.md)
- [Device Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/driver/Readme-EN.md)
- [Kernel Usage Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/kernel/Readme-EN.md) - [Kernel Usage Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/kernel/Readme-EN.md)
- [Driver Usage Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/driver/Readme-EN.md)
- [Subsystem Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/subsystems/Readme-EN.md) - [Subsystem Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/subsystems/Readme-EN.md)
- [Bundle Development](https://gitee.com/openharmony/docs/blob/master/docs-en/bundles/Readme-EN.md) - [Bundle Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/bundles/Readme-EN.md)
- [Device Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/guide/Readme-EN.md)
- [Third-Party Library Porting Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/porting/Readme-EN.md)
- [Privacy and Security](https://gitee.com/openharmony/docs/blob/master/docs-en/security/Readme-EN.md) - [Privacy and Security](https://gitee.com/openharmony/docs/blob/master/docs-en/security/Readme-EN.md)
- [LinkIoT Modules API](https://gitee.com/openharmony/docs/blob/master/docs-en/api/api-LinkIoT/Readme-EN.md) - [LinkIoT Modules API](https://gitee.com/openharmony/docs/blob/master/docs-en/api/api-LinkIoT/Readme-EN.md)
- [SmartVision Devices API](https://gitee.com/openharmony/docs/blob/master/docs-en/api/api-SmartVision-Devices/Readme-EN.md) - [SmartVision Devices API](https://gitee.com/openharmony/docs/blob/master/docs-en/api/api-SmartVision-Devices/Readme-EN.md)
- [Glossary](https://gitee.com/openharmony/docs/blob/master/docs-en/term/glossary.md) - [Glossary](https://gitee.com/openharmony/docs/blob/master/docs-en/term/glossary.md)
## Start Contributing ## Start Contributing
OpenHarmony is an Open Source Community and encourages everyone in the community to submit the patches directly to the project. You can either contribute to the code or documentation. OpenHarmony is an open-source community and encourages everyone in the community to submit patches directly to the project. You can contribute either to the code or documentation.
- [Contributing to the Code](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/contributing-code.md) - [Contributing to the Code](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/contributing-code.md)
- [Contributing to the Documentation](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/documentation-contribution.md) - [Contributing to the Documentation](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/documentation-contribution.md)
For more details on Contribution, see [Contributing Documents](https://gitee.com/openharmony/docs/tree/master/docs-en/contibute) For more details on how to contribute, see [Contributing Documents](https://gitee.com/openharmony/docs/tree/master/docs-en/contibute).
## Get Source Code and Tools ## Get Source Code and Tools
To download the source code and tools required for the project, click the following links. To download the source code and tools required for the project, click the following links:
- [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.md) - [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.md)
- [Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/tool-acquisition.md) - [Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/tool-acquisition.md)
## Where to Turn for Help ## Where to Turn for Help
You can subscribe to the mailing list to get constant updates on new features, release road maps, and community activities. For Subscribing to the mailing list or any other support, see [Communication in Community](https://gitee.com/openharmony/docs/tree/master/docs-en/contribute/communication-in-community.md). You can subscribe to the mailing list to get constant updates on new features, released road maps, and community activities. For how to subscribe to the mailing list or get any other support, see [Communication in Community](https://gitee.com/openharmony/docs/tree/master/docs-en/contribute/communication-in-community.md).
## Code of Conduct ## Code of Conduct
OpenHarmony is committed to providing a welcoming and inspiring community for all. In order to maintain a collaborative environment, we recommend you to read and follow the community [Code of Conduct](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/code-of-conduct.md). OpenHarmony is committed to providing a welcoming and inspiring community for all. In order to maintain a collaborative environment, we recommend you read and follow the community [Code of Conduct](https://gitee.com/openharmony/docs/blob/master/docs-en/contribute/code-of-conduct.md).
## Contributors & Acknowledgements ## Contributors & Acknowledgements
A great Open source project wouldn't exist without the hard work of its many contributors. We'd like to invite anyone from around the world to participate in this exciting journey. And we're grateful for your time, passion, and efforts! A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to participate in this exciting journey, and we're grateful for your time, passion, and efforts!
## Release ## Release
In order to provide new features and bug fixes, the community constantly updates the code and provides new releases. For details on Release, see Release. In order to provide new features and bug fixes, the community constantly updates code and provides new releases.
...@@ -13,3 +13,8 @@ ...@@ -13,3 +13,8 @@
- [Preparations](preparations.md) - [Preparations](preparations.md)
- [Bundle Development](bundle-development.md) - [Bundle Development](bundle-development.md)
- [HPM User Guide](hpm-user-guide.md)
- [Introduction](introduction.md)
- [Preparations](preparations-1.md)
- [Development Example](development-example.md)
# Development Example<a name="EN-US_TOPIC_0000001072143838"></a>
This following uses the Hi3861 platform as an example to describe how to install, compile, and package components by using HPM.
1. Run the following commands to initialize the installation directory \(whose name can be customized\):
```
mkdir test3861
cd test3861
hpm init -t dist
```
If the following information is displayed, the initialization is successful:
```
Initialization finished.
```
2. Run the following command to install the **wifi\_iot** distribution:
```
hpm install @ohos/wifi_iot
```
If the following information is displayed, the installation is successful:
```
Installed.
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Run the following command for the Hi3516 platform:
>```
>hpm install @ohos/ip_camera_hi3516dv300
>```
>Run the following command for the Hi3518 platform:
>```
>hpm install @ohos/ip_camera_hi3518ev300
>```
3. Run the following command to build and package components:
```
hpm dist
```
If the building is successful, the following information is displayed:
```
{{name}}: distribution building completed.
```
4. Check the result in the **./out** directory. You can burn the distribution into the corresponding development board for testing.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
During bundle compilation, system-provided environment variables are required to define the output and link the required binary files. These variables are injected into the context for executing scripts based on service requirements. Therefore, their values can be directly obtained from the scripts. Currently, there are global and fixed environment variables in the system. During bundle compilation, system-provided environment variables are required to define the output and link the required binary files. These variables are injected into the context for executing scripts based on service requirements. Therefore, their values can be directly obtained from the scripts. Currently, there are global and fixed environment variables in the system.
Global variables are defined by the** envs** attribute in **bundle.json**. All dependent bundles can obtain the values of global variables. Global variables are defined by the **envs** attribute in **bundle.json**. All dependent bundles can obtain the values of global variables.
``` ```
{ {
......
# HPM User Guide<a name="EN-US_TOPIC_0000001074472258"></a>
- **[Introduction](introduction.md)**
- **[Preparations](preparations-1.md)**
- **[Development Example](development-example.md)**
# Introduction<a name="EN-US_TOPIC_0000001071487274"></a>
HarmonyOS Package Manager \(HPM\) manages and distributes OpenHarmony component packages. It offers you a tool set to obtain and customize OpenHarmony source code and perform operations such as installation, compilation, packaging, and upgrade.
This document describes how to use HPM to install, compile, and package OpenHarmony components.
# Preparations<a name="EN-US_TOPIC_0000001071315859"></a>
- [Linux Server](#section20979554791)
- [Node.js](#section9954105413153)
- [HPM](#section15937194904819)
- [Python Environment](#section1621819180417)
- [File Packaging Tool](#section77617165913)
- [SCons](#section20558439191516)
## Linux Server<a name="section20979554791"></a>
Prepare a 64-bit Linux server running Ubuntu 16.04 or later. HPM supports Windows Server, but the open-source Hi3861, Hi3516, and Hi3518 solutions support only Ubuntu.
Configure Ubuntu to use bash as the Linux system shell, by performing the following:
```
ls -l $(which sh)
# If the file does not point to bash, modify the file using either of the provided methods.
# Method 1: Run the following command and select no:
dpkg-reconfigure dash
# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash:
rm -f /bin/sh
ln -s bash /bin/sh
```
## Node.js<a name="section9954105413153"></a>
You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
```
sudo apt-get install nodejs
sudo apt-get install npm
```
Run the following commands to view Node.js and NPM versions:
```
node --version # Check the Node.js version.
npm --version # Check the NPM version.
```
Note: If the Node.js version of the source is outdated, run the following command before running **apt-get install**:
```
curl -L https://deb.nodesource.com/setup_12.x | bash
```
## HPM<a name="section15937194904819"></a>
Install the **hpm-cli** command line tool by using the NPM \(default source: https://registry.npmjs.org/\) provided by the Node.js.
```
npm install -g @ohos/hpm-cli
```
After **hpm-cli** is installed, run the following command to view default HPM configurations:
```
hpm config
```
You can modify the default configurations as required. The following lists common HPM configurations:
```
registry = https://hpm.harmonyos.com # Register with the HPM registration center. This is mandatory for downloading components.
strictSsl = true # Enable strict SSL verification as HTTPS is used for connection.
http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
```
For details about **hpm-cli** commands, see [HPM Commands](bundle-management.md#table10510164515371).
## Python Environment<a name="section1621819180417"></a>
Run the following commands to install Python later than 3.7:
```
sudo apt-get install python3.8
sudo apt-get install python3-pip
sudo pip3 install setuptools
sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment:
>```
>sudo apt-get install python3.8
>sudo apt-get install python3-pip
>sudo pip3 install setuptools
>sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
>sudo pip3 install pycryptodome
>sudo pip3 install six --upgrade --ignore-installed six
>sudo pip3 install ecdsa
>```
If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3:
```
ll `which python`
rm /usr/bin/python
ln -s python3.8 /usr/bin/python
```
## File Packaging Tool<a name="section77617165913"></a>
Run the following commands to install the tool:
```
which mkfs.vfat # If mkfs.vfat is not found, run the following command:
sudo apt-get install dosfstools
which mcopy # If mcopy is not found, run the following command:
sudo apt-get install mtools
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required.
## SCons<a name="section20558439191516"></a>
Run the following command to install SCons:
```
sudo apt-get install scons # SCons 3.0.4 or later is recommended.
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform.
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\). You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. 2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command:
Start **cmd.exe** to run the following command:
``` ```
npm install -g @ohos/hpm-cli npm install -g @ohos/hpm-cli
......
# Tool Acquisition<a name="EN-US_TOPIC_0000001055701144"></a> # Tool Acquisition<a name="EN-US_TOPIC_0000001055701144"></a>
- [Acquiring Compilation Toolchain](#section18750162432511) - [Using Docker to Prepare the Build Environment](#section107932281315)
- [HPM-based Docker](#section054931895313)
- [Standalone Docker Environment](#section980782720014)
- [Using a Software Package to Prepare the Build Environment](#section18750162432511)
- [Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)](#section12307171315108) - [Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)](#section12307171315108)
- [Tool Introduction](#section68281728193514) - [Tool Introduction](#section68281728193514)
- [Website](#section13785205443514) - [Website](#section13785205443514)
...@@ -10,11 +14,178 @@ ...@@ -10,11 +14,178 @@
- [Website](#section1572093543613) - [Website](#section1572093543613)
- [Usage Guidelines](#section1125615298385) - [Usage Guidelines](#section1125615298385)
## Acquiring Compilation Toolchain<a name="section18750162432511"></a> ## Using Docker to Prepare the Build Environment<a name="section107932281315"></a>
OpenHarmony provides the following two types of Docker environments for you to quickly get the development environment ready:
- HPM-based Docker environment: applicable when using the HarmonyOS Package Manager \(HPM\) to build a distribution.
- Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution.
The following table lists container-based options needed for building in the standalone Docker environment.
**Table 1** Docker image
<a name="table2790164495315"></a>
<table><thead align="left"><tr id="row3790644155317"><th class="cellrowborder" valign="top" width="17.97%" id="mcps1.2.5.1.1"><p id="p127896443535"><a name="p127896443535"></a><a name="p127896443535"></a>Compatible Hardware Platform</p>
</th>
<th class="cellrowborder" valign="top" width="29.110000000000003%" id="mcps1.2.5.1.2"><p id="p8789114445316"><a name="p8789114445316"></a><a name="p8789114445316"></a>Docker Image Repository</p>
</th>
<th class="cellrowborder" valign="top" width="8.43%" id="mcps1.2.5.1.3"><p id="p17896448533"><a name="p17896448533"></a><a name="p17896448533"></a>Tag</p>
</th>
<th class="cellrowborder" valign="top" width="44.49%" id="mcps1.2.5.1.4"><p id="p1278917444539"><a name="p1278917444539"></a><a name="p1278917444539"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row167901244115315"><td class="cellrowborder" valign="top" width="17.97%" headers="mcps1.2.5.1.1 "><p id="p6790144155314"><a name="p6790144155314"></a><a name="p6790144155314"></a>Hi3861/Hi3516/Hi3518</p>
</td>
<td class="cellrowborder" valign="top" width="29.110000000000003%" headers="mcps1.2.5.1.2 "><p id="p87901744185316"><a name="p87901744185316"></a><a name="p87901744185316"></a>swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker</p>
</td>
<td class="cellrowborder" valign="top" width="8.43%" headers="mcps1.2.5.1.3 "><p id="p15790184410536"><a name="p15790184410536"></a><a name="p15790184410536"></a>0.0.2</p>
</td>
<td class="cellrowborder" valign="top" width="44.49%" headers="mcps1.2.5.1.4 "><p id="p15790124416531"><a name="p15790124416531"></a><a name="p15790124416531"></a>The build environment for the <span id="text895113715412"><a name="text895113715412"></a><a name="text895113715412"></a>OpenHarmony</span> version has been pre-installed.</p>
</td>
</tr>
</tbody>
</table>
### HPM-based Docker<a name="section054931895313"></a>
**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and [hpm-cli](https://device.harmonyos.com/en/docs/develop/bundles/oem_bundle_guide_prepare-0000001050129846) development environments, perform the following steps to access the Docker environment:
**Setting Up the Docker Environment**
1. Initialize the installation template by running the following command in any of the working directories:
```
hpm init -t @ohos/docker_dist
```
2. Modify the **publishAs** field.
Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
3. Select the desired solution, and set the environment variables for the solution distribution.
ip\_camera\_hi3516dv300:
```
export solution=@ohos/ip_camera_hi3516dv300
```
ip\_camera\_hi3518ev300:
```
export solution=@ohos/ip_camera_hi3518ev300
```
wifiiot:
```
export solution=@ohos/wifi_iot
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>If you use the Windows command line, run the following command instead:
>```
>set solution=Distribution name
>```
**Building**
Start building. The following takes ip\_camera\_hi3518ev300 as an example.
Running the following command will automatically install the Docker, pull the image, and start the pulling and building of the corresponding solution in the container.
```
hpm run docker
```
The following will be displayed if the building is successful:
```
......
ohos ipcamera_hi3518 build success!
@ohos/ip_camera_hi3518ev300: distribution building completed.
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Docker can be automatically installed only on Ubuntu. If you are using any other operating system, manually install Docker before pulling the image. The operations are as follows:
>```
># Pull the image.
>docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2
># Build the distribution on Linux.
>hpm run distWithDocker
># When using Windows, make sure to configure the Git Bash.
>hpm config set shellPath "Git Bash path"
>hpm run distWithDocker
>```
### Standalone Docker Environment<a name="section980782720014"></a>
The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. After configuring the development environments, perform the steps below to access the Docker environment. The following steps use Ubuntu as an example \(Windows is also supported\).
**Method 1: Obtaining the Docker image from HuaweiCloud SWR**
1. Obtain the Docker image.
```
docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2
```
2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
```
docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2
```
3. Use the following build script to start the building for the wifiiot, ipcamera\_hi3516dv300, and ipcamera\_hi3518ev300 platforms.
```
python build.py wifiiot/ipcamera_hi3516dv300/ipcamera_hi3518ev300
```
```
```
**Method 2: Using the Dockerfile to Build a Local Docker Image**
1. Obtain the Dockerfile script for a local Docker image.
```
git clone https://gitee.com/openharmony/docs.git
```
2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
```
cd docs/docker
./build.sh
```
3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
```
docker run -it -v $(pwd):/home/openharmony openharmony-docker:0.0.2
```
4. Use the following build script to start the building for the wifiiot, ipcamera\_hi3516dv300, and ipcamera\_hi3518ev300 platforms.
```
python build.py wifiiot/ipcamera_hi3516dv300/ipcamera_hi3518ev300
```
## Using a Software Package to Prepare the Build Environment<a name="section18750162432511"></a>
If you do not use Docker, use a software package instead to install the compilation environment. Specially, download some compilation toolchains from the image sites listed in the following table.
The following table lists the compilation toolchain downloaded from an image site. For details about how to download and install all compilation tools, see [Setting Up a Hi3861 Development Environment](../quick-start/setting-up-a-development-environment.md), [Setting Up a Hi3516 Development Environment](../quick-start/setting-up-a-hi3516-board-environment.md), or [Setting Up a Hi3518 Development Environment](../quick-start/setting-up-a-development-environment-1.md) in _Quick Start_. For details about how to download and install all compilation tools, see [Setting Up the Hi3861 Development Environment](../quick-start/setting-up-the-hi3861-development-environment.md), [Setting Up the Hi3516 Development Environment](../quick-start/setting-up-the-hi3516-development-environment.md), or [Setting Up the Hi3518 Development Environment](../quick-start/setting-up-the-hi3518-development-environment.md) in _Quick Start_.
**Table 1** Acquiring compilation toolchain **Table 2** Acquiring compilation toolchain
<a name="table167961324122511"></a> <a name="table167961324122511"></a>
<table><thead align="left"><tr id="row87941124202517"><th class="cellrowborder" valign="top" width="16.35%" id="mcps1.2.6.1.1"><p id="p12231193484318"><a name="p12231193484318"></a><a name="p12231193484318"></a>Development Board</p> <table><thead align="left"><tr id="row87941124202517"><th class="cellrowborder" valign="top" width="16.35%" id="mcps1.2.6.1.1"><p id="p12231193484318"><a name="p12231193484318"></a><a name="p12231193484318"></a>Development Board</p>
...@@ -99,7 +270,7 @@ You need to check whether these tools are downloaded from the official channel. ...@@ -99,7 +270,7 @@ You need to check whether these tools are downloaded from the official channel.
2. Compare the generated digest with the officially provided one. 2. Compare the generated digest with the officially provided one.
If they are consistent, the **sha256sum** package you downloaded has not been tampered with. Otherwise, your package may be insecure. If they are consistent, the tool package you downloaded has not been tampered with. Otherwise, your package may be insecure.
## Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)<a name="section12307171315108"></a> ## Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)<a name="section12307171315108"></a>
......
...@@ -11,7 +11,12 @@ This use case takes **camera\_sample** \(contained in the source code\) as an ...@@ -11,7 +11,12 @@ This use case takes **camera\_sample** \(contained in the source code\) as an
- The compilation result of the sample code is stored in **out/ipcamera\_hi3516dv300/dev\_tools/bin/camera\_sample**. To ensure that the code can be executed on the development board, you can copy the file to a TF card through a card reader, or modify the compilation script of **camera\_sample** to copy the compilation result to **rootfs.img**. - The compilation result of the sample code is stored in **out/ipcamera\_hi3516dv300/dev\_tools/bin/camera\_sample**. To ensure that the code can be executed on the development board, you can copy the file to a TF card through a card reader, or modify the compilation script of **camera\_sample** to copy the compilation result to **rootfs.img**.
How to Modify: In source code path **applications/sample/camera/media/BUILD.gn**, replace the first **output\_dir = "$root\_out\_dir/dev\_ools"** with **output\_dir = "$root\_out\_dir/"**, recompile the source code repository, and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the development board. Modify the first **output\_dir** in the source code path **applications/sample/camera/media/BUILD.gn**.
- Before: **output\_dir = "$root\_out\_dir/dev\_tools"**
- After: **output\_dir = "$root\_out\_dir/"**
Recompile the source code repository and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board.
>![](public_sys-resources/icon-notice.gif) **NOTICE:** >![](public_sys-resources/icon-notice.gif) **NOTICE:**
>You should insert a TF card \(up to 128 GB supported\) for photographing and video recording before system startup. This way, the TF card will be automatically mounted to the **/sdcard** directory. If you insert the TF card after the system is started, you have to manually mount the TF card. >You should insert a TF card \(up to 128 GB supported\) for photographing and video recording before system startup. This way, the TF card will be automatically mounted to the **/sdcard** directory. If you insert the TF card after the system is started, you have to manually mount the TF card.
......
# Use Case<a name="EN-US_TOPIC_0000001055686082"></a> # Use Case<a name="EN-US_TOPIC_0000001055686082"></a>
- For details bout the development board, compilation, burning, and image running process, see [Getting Started with Hi3518](../quick-start/introduction-to-the-hi3518-development-board.md). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**. - For details about the development board, compilation, burning, and image running process, see [Getting Started with Hi3518](../quick-start/introduction-to-the-hi3518-development-board.md). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**.
**How to Modify**: In **applications/sample/camera/media/BUILD.gn**, replace **output\_dir = "$root\_out\_dir/dev\_tools"** with **output\_dir = "$root\_out\_dir/"**, recompile the source code repository, and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board. Modify **output\_dir** in **applications/sample/camera/media/BUILD.gn**.
- Before: **output\_dir = "$root\_out\_dir/dev\_tools"**
- After: **output\_dir = "$root\_out\_dir/"**
Recompile the source code repository and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board.
- The sample code for camera development is stored in **applications/sample/camera/media/camera\_sample.cpp**. - The sample code for camera development is stored in **applications/sample/camera/media/camera\_sample.cpp**.
......
# Third-Party Library Porting Guide
- [Third-Party Library Porting Guide](third-party-library-porting-guide.md)
- [Overview](overview.md)
- [Porting a Library Built Using CMake](porting-a-library-built-using-cmake.md)
- [Porting a Library Built Using Makefile](porting-a-library-built-using-makefile.md)
# Overview<a name="EN-US_TOPIC_0000001064570046"></a>
This document provides guidance for OpenHarmony developers to port third-party libraries that use common compiler organization modes, such as CMakeLists and Makefile. It describes how to set a toolchain in different compiler organization modes and how to add the compiling configuration of a library to the OpenHarmony project. Currently, this guide applies only to Hi3516DV300 and Hi3518EV300.
此差异已折叠。
# Porting a Library Built Using Makefile<a name="EN-US_TOPIC_0000001064218672"></a>
- [Source Code Acquisition](#section114115321416)
- [Cross-Compilation Settings](#section81263255384)
- [Library Test](#section1830015913391)
- [Adding the Compiled yxml Library to the Project](#section1898016213406)
The following shows how to port the yxml library.
## Source Code Acquisition<a name="section114115321416"></a>
Acquire the source code of yxml from [https://github.com/getdnsapi/yxml](https://github.com/getdnsapi/yxml). The following table lists the directory structure.
**Table 1** Directory structure of the source code
<a name="table16520154171813"></a>
<table><thead align="left"><tr id="row2052115419188"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1352111417181"><a name="p1352111417181"></a><a name="p1352111417181"></a>Directory</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p2521541171812"><a name="p2521541171812"></a><a name="p2521541171812"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row252164101814"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p747319438225"><a name="p747319438225"></a><a name="p747319438225"></a>yxml/bench/</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1852214114183"><a name="p1852214114183"></a><a name="p1852214114183"></a>Benchmark-related code</p>
</td>
</tr>
<tr id="row11402205216237"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p6473134382216"><a name="p6473134382216"></a><a name="p6473134382216"></a>yxml/test/</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2040355219237"><a name="p2040355219237"></a><a name="p2040355219237"></a>Input and output files as well as scripts of the test cases</p>
</td>
</tr>
<tr id="row35220418182"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1547384313229"><a name="p1547384313229"></a><a name="p1547384313229"></a>yxml/Makefile</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p7522041131814"><a name="p7522041131814"></a><a name="p7522041131814"></a>File for organizing compilation</p>
</td>
</tr>
<tr id="row17522144114180"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p6473164392210"><a name="p6473164392210"></a><a name="p6473164392210"></a>yxml/.gitattributes</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p145221541151817"><a name="p145221541151817"></a><a name="p145221541151817"></a>-</p>
</td>
</tr>
<tr id="row7522941131811"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12473144312217"><a name="p12473144312217"></a><a name="p12473144312217"></a>yxml/.gitignore</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p95231141121810"><a name="p95231141121810"></a><a name="p95231141121810"></a>-</p>
</td>
</tr>
<tr id="row13523841161812"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p72441217182819"><a name="p72441217182819"></a><a name="p72441217182819"></a>yxml/COPYING</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1752319414186"><a name="p1752319414186"></a><a name="p1752319414186"></a>-</p>
</td>
</tr>
<tr id="row165231641111810"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p347304312226"><a name="p347304312226"></a><a name="p347304312226"></a>yxml/yxml.c</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p4523174113188"><a name="p4523174113188"></a><a name="p4523174113188"></a>-</p>
</td>
</tr>
<tr id="row1452344110184"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18473643152213"><a name="p18473643152213"></a><a name="p18473643152213"></a>yxml/yxml.c.in</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1252317413187"><a name="p1252317413187"></a><a name="p1252317413187"></a>-</p>
</td>
</tr>
<tr id="row12744431142214"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p274693119222"><a name="p274693119222"></a><a name="p274693119222"></a>yxml/yxml-gen.pl</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p274753111227"><a name="p274753111227"></a><a name="p274753111227"></a>-</p>
</td>
</tr>
<tr id="row7967123412215"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1947314314225"><a name="p1947314314225"></a><a name="p1947314314225"></a>yxml/yxml.h</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p16967203462218"><a name="p16967203462218"></a><a name="p16967203462218"></a>-</p>
</td>
</tr>
<tr id="row3988153742217"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p109891737112216"><a name="p109891737112216"></a><a name="p109891737112216"></a>yxml/yxml.md</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10989123732213"><a name="p10989123732213"></a><a name="p10989123732213"></a>-</p>
</td>
</tr>
<tr id="row184521641102214"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p847314433221"><a name="p847314433221"></a><a name="p847314433221"></a>yxml/yxml-states</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p4453154111224"><a name="p4453154111224"></a><a name="p4453154111224"></a>-</p>
</td>
</tr>
</tbody>
</table>
## Cross-Compilation Settings<a name="section81263255384"></a>
The following steps show how to configure and modify the toolchains for cross-compiling the libraries built using CMake to compile executable files for the OpenHarmony platform.
1. Configure the toolchains.
Replace the original configuration of MakeFile \(listed in [Table 1](#table16520154171813)\) in the root directory of the yxml library with the following clang toolchains configuration.
clang toolchains configuration:
```
# Set the cross-compilation toolchain and ensure that the path of the toolchain has been added to the PATH environment variable.
CC:=clang
AR:=llvm-ar
# The --target and --sysroot flags must be specified.
CFLAGS:=-Wall -Wextra -Wno-unused-parameter -O2 -g --target=arm-liteos -march=armv7-a --sysroot=$(OHOS_ROOT_PATH)prebuilts/lite/sysroot
```
Original configuration:
```
CC:=gcc
AR:=ar
CFLAGS:=-Wall -Wextra -Wno-unused-parameter -O2 -g
```
2. Perform the compilation.
Run a Linux command to enter the directory \(listed in [Table 1](#table16520154171813)\) for storing yxml source files and then run the following command:
```
make test OHOS_SYSROOT_PATH=...
```
**OHOS\_SYSROOT\_PATH** specifies the absolute path of the directory where **sysroot** is located. Taking OpenHarmony for example, set **OHOS\_SYSROOT\_PATH** to the absolute path of **prebuilts/lite/sysroot/**.
3. View the result.
After step 2 is complete, a static library file and test case are generated in the **out** directory of the yxml library.
**Table 2** Directory structure of compiled files
<a name="table3271115435618"></a>
<table><thead align="left"><tr id="row1273454185610"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p3273154185616"><a name="p3273154185616"></a><a name="p3273154185616"></a>Directory</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p18273145445612"><a name="p18273145445612"></a><a name="p18273145445612"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1627317542567"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p13273154175620"><a name="p13273154175620"></a><a name="p13273154175620"></a>openHarmony/third_party/yxml/yxml/out/lib/</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p132744541562"><a name="p132744541562"></a><a name="p132744541562"></a>Static library file</p>
</td>
</tr>
<tr id="row112741554165612"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17274165475611"><a name="p17274165475611"></a><a name="p17274165475611"></a>openHarmony/third_party/yxml/yxml/out/test/</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p152741354135614"><a name="p152741354135614"></a><a name="p152741354135614"></a>Test cases as well as the input and output files</p>
</td>
</tr>
</tbody>
</table>
## Library Test<a name="section1830015913391"></a>
The test procedure for the yxml library is similar to that for the double-conversion library. For details, see [Library Test](porting-a-library-built-using-cmake.md#section6686144293611). The following describes how to use the test cases of the yxml library.
**Table 3** Directory structure of the test directory
<a name="table115941423164318"></a>
<table><thead align="left"><tr id="row1059515236433"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p55950233437"><a name="p55950233437"></a><a name="p55950233437"></a>Directory</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p4595192324313"><a name="p4595192324313"></a><a name="p4595192324313"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1759572304318"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17595323144319"><a name="p17595323144319"></a><a name="p17595323144319"></a>openHarmony/third_party/yxml/yxml/out/test/test.sh</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p25956235437"><a name="p25956235437"></a><a name="p25956235437"></a>Automatic test script, which cannot be used because <span id="text625264318457"><a name="text625264318457"></a><a name="text625264318457"></a>OpenHarmony</span> does not support automatic script execution. However, you can refer to this script to conduct a manual test.</p>
</td>
</tr>
<tr id="row155951823184312"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p659572313436"><a name="p659572313436"></a><a name="p659572313436"></a>openHarmony/third_party/yxml/yxml/out/test/test</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p7595102314319"><a name="p7595102314319"></a><a name="p7595102314319"></a>Executable file for testing.</p>
</td>
</tr>
<tr id="row359619238437"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p205969232436"><a name="p205969232436"></a><a name="p205969232436"></a>openHarmony/third_party/yxml/yxml/out/test/*.xml</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p559662344315"><a name="p559662344315"></a><a name="p559662344315"></a>Input test file.</p>
</td>
</tr>
<tr id="row959613236439"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1159652312438"><a name="p1159652312438"></a><a name="p1159652312438"></a>openHarmony/third_party/yxml/yxml/out/test/*.out</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18596182314318"><a name="p18596182314318"></a><a name="p18596182314318"></a>Expected output file.</p>
</td>
</tr>
</tbody>
</table>
The content of the **test.sh** file is as follows:
```
#!/bin/sh
for i in *.xml; do
b=`basename $i .xml`
o=${b}.out
t=${b}.test
./test <$i >$t
if [ -n "`diff -q $o $t`" ]; then
echo "Test failed for $i:"
diff -u $o $t
exit 1
fi
done
echo "All tests completed successfully."
```
The shell of OpenHarmony does not support input and output redirection symbols \(< and \>\). During the test, you need to copy the content in the **_\*_.xml** file to the shell and press **Enter**. The output content is displayed in the shell screen.
The following operations are performed based on the assumption that the OpenHarmony environment has been set up and the **nfs** directory has been mounted and accessed.
1. Execute the following command:
```
./test
```
2. Copy the content in the **_\*_.xml** file to shell.
Taking the **pi01.xml** file in the [test](#table115941423164318) directory as an example, copy the following content to shell and press **Enter**:
```
<?SomePI abc?><a/>
```
3. Check whether the output in the shell is the same as that of the **_\*_.out** file in the [test](#table115941423164318) directory.
The output is as follows:
```
pistart SomePI
picontent abc
piend
elemstart a
elemend
ok
```
The output is the same as the **pi01.out** file in the [test](#table115941423164318) directory. The test is passed.
## Adding the Compiled yxml Library to the OpenHarmony Project<a name="section1898016213406"></a>
The procedure for adding the yxml library is almost the same as that for adding the double-conversion library, except that the implementation of **build.gn** and **config.gni** files. For details, see [Adding the Compiled double-conversion Library to the OpenHarmony Project](porting-a-library-built-using-cmake.md#section1651053153715).
- The implementation of the newly added **BUILD.gn** file in the yxml library is as follows:
```
import("config.gni")
group("yxml") {
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
deps = [":make"]
}
}
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
action("make") {
script = "//third_party/yxml/build_thirdparty.py"
outputs = ["$target_out_dir/log_yxml.txt"]
exec_path = rebase_path(rebase_path("./yxml", root_build_dir))
command = "make clean && $MAKE_COMMAND"
args = [
"--path=$exec_path",
"--command=${command}"
]
}
}
```
- The configuration of the newly added **config.gni** file in the yxml library is as follows:
```
TEST_ENABLE = "YES"
if (TEST_ENABLE == "YES") {
MAKE_COMMAND = "make test OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/"
} else {
MAKE_COMMAND = "make OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/"
}
```
- The following table lists the directory structure of the OpenHarmony project.
**Table 4** Directory structure of the ported library
<a name="table13265185817173"></a>
<table><thead align="left"><tr id="row92666583171"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p2266105816178"><a name="p2266105816178"></a><a name="p2266105816178"></a>Directory</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p32661158161718"><a name="p32661158161718"></a><a name="p32661158161718"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1526655816175"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p226605811710"><a name="p226605811710"></a><a name="p226605811710"></a>openHarmony/third_party/yxml/BUILD.gn</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1626675812177"><a name="p1626675812177"></a><a name="p1626675812177"></a>GN file for adding the third-party library to the <span id="text1699851716117"><a name="text1699851716117"></a><a name="text1699851716117"></a>OpenHarmony</span> project</p>
</td>
</tr>
<tr id="row1726610589179"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12266115815170"><a name="p12266115815170"></a><a name="p12266115815170"></a>openHarmony/third_party/yxml/build_thirdpaty.py</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p122661958201719"><a name="p122661958201719"></a><a name="p122661958201719"></a>Script file for GN to call the <strong id="b8482154111113"><a name="b8482154111113"></a><a name="b8482154111113"></a>shell</strong> command to convert compilation from GN to Makefile.</p>
</td>
</tr>
<tr id="row7266195891714"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p162665581170"><a name="p162665581170"></a><a name="p162665581170"></a>openHarmony/third_party/yxml/config.gni</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p626712588175"><a name="p626712588175"></a><a name="p626712588175"></a>Third-party library compilation configuration file, which can be modified to determine whether the test cases will be used during the building</p>
</td>
</tr>
<tr id="row1272420109203"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17725101052012"><a name="p17725101052012"></a><a name="p17725101052012"></a>openHarmony/third_party/yxml/yxml/</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p87252109205"><a name="p87252109205"></a><a name="p87252109205"></a>Directory of the third-party library to be ported</p>
</td>
</tr>
</tbody>
</table>
# Third-Party Library Porting Guide<a name="EN-US_TOPIC_0000001073864042"></a>
- **[Overview](overview.md)**
- **[Porting a Library Built Using CMake](porting-a-library-built-using-cmake.md)**
- **[Porting a Library Built Using Makefile](porting-a-library-built-using-makefile.md)**
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
- [Hi3861 Development Board](hi3861-development-board.md) - [Hi3861 Development Board](hi3861-development-board.md)
- [Introduction to the Hi3861 Development Board](introduction-to-the-hi3861-development-board.md) - [Introduction to the Hi3861 Development Board](introduction-to-the-hi3861-development-board.md)
- [Setting Up a Development Environment](setting-up-a-development-environment.md) - [Setting Up the Hi3861 Development Environment](setting-up-the-hi3861-development-environment.md)
- [Developing the First Example Program Running on Hi3861](developing-the-first-example-program-running-on-hi3861.md) - [Developing the First Example Program Running on Hi3861](developing-the-first-example-program-running-on-hi3861.md)
- [Developing the Second Example Program Running on Hi3861](developing-the-second-example-program-running-on-hi3861.md) - [Developing the Second Example Program Running on Hi3861](developing-the-second-example-program-running-on-hi3861.md)
- [FAQs](faqs.md) - [FAQ on Hi3861](faq-on-hi3861.md)
- [Hi3516 Development Board](hi3516-development-board.md) - [Hi3516 Development Board](hi3516-development-board.md)
- [Introduction to the Hi3516 Development Board](introduction-to-the-hi3516-development-board.md) - [Introduction to the Hi3516 Development Board](introduction-to-the-hi3516-development-board.md)
- [Setting up a Development Environment](setting-up-a-development-environment-0.md) - [Setting Up the Hi3516 Development Environment](setting-up-the-hi3516-development-environment.md)
- [Developing the First Example Program Running on Hi3516](developing-the-first-example-program-running-on-hi3516.md) - [Developing the First Example Program Running on Hi3516](developing-the-first-example-program-running-on-hi3516.md)
- [Developing the First Driver Running on Hi3516](developing-the-first-driver-running-on-hi3516.md) - [Developing the First Driver Running on Hi3516](developing-the-first-driver-running-on-hi3516.md)
- [FAQs](faqs-1.md) - [FAQ on Hi3516](faq-on-hi3516.md)
- [Hi3518 Development Board](hi3518-development-board.md) - [Hi3518 Development Board](hi3518-development-board.md)
- [Introduction to the Hi3518 Development Board](introduction-to-the-hi3518-development-board.md) - [Introduction to the Hi3518 Development Board](introduction-to-the-hi3518-development-board.md)
- [Setting Up a Development Environment](setting-up-a-development-environment-2.md) - [Setting Up the Hi3518 Development Environment](setting-up-the-hi3518-development-environment.md)
- [Developing the First Example Program Running on Hi3518](developing-the-first-example-program-running-on-hi3518.md) - [Developing the First Example Program Running on Hi3518](developing-the-first-example-program-running-on-hi3518.md)
- [FAQs](faqs-3.md) - [FAQ on Hi3518](faq-on-hi3518.md)
...@@ -427,14 +427,14 @@ The following operations take a HDF-based UART driver as an example to show how ...@@ -427,14 +427,14 @@ The following operations take a HDF-based UART driver as an example to show how
## Compiling and Burning<a name="section660016185110"></a> ## Compiling and Burning<a name="section660016185110"></a>
Compile and burn images by referring to [Compiling Code](developing-the-first-example-program-running-on-hi3516.md#section1077671315253) and [Burning](developing-the-first-example-program-running-on-hi3516.md#section08153912587). Compile and burn images by referring to [Building](developing-the-first-example-program-running-on-hi3516.md#section1077671315253) and [Burning](developing-the-first-example-program-running-on-hi3516.md#section08153912587).
## Running an Image<a name="section197971119142915"></a> ## Running an Image<a name="section197971119142915"></a>
1. Connect to a serial port. 1. Connect to a serial port.
>![](public_sys-resources/icon-notice.gif) **NOTICE:** >![](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). >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faq-on-hi3516.md#section14871149155911).
**Figure 1** Serial port connection<a name="en-us_topic_0000001052906247_fig056645018495"></a> **Figure 1** Serial port connection<a name="en-us_topic_0000001052906247_fig056645018495"></a>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- [Acquiring Source Code](#section215953714245) - [Acquiring Source Code](#section215953714245)
- [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb) - [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb)
- [Compiling Code](#section1077671315253) - [Building](#section1077671315253)
- [Burning](#section08153912587) - [Burning](#section08153912587)
- [Running an Image](#section380511712615) - [Running an Image](#section380511712615)
- [Running a Program](#section5276734182615) - [Running a Program](#section5276734182615)
...@@ -33,36 +33,38 @@ int main(int argc, char **argv) ...@@ -33,36 +33,38 @@ int main(int argc, char **argv)
} }
``` ```
## Compiling Code<a name="section1077671315253"></a> ## Building<a name="section1077671315253"></a>
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. If the Linux environment is installed using Docker, perform the compilation by referring to [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). If the Linux environment is installed using a software package, go to the root directory of the source code and run the following command for source code compilation:
``` ```
python build.py ipcamera_hi3516dv300 -b debug python build.py ipcamera_hi3516dv300 -b debug
``` ```
The result files are generated in the **out/ipcamera\_hi3518ev300** directory.
## Burning<a name="section08153912587"></a> ## Burning<a name="section08153912587"></a>
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. 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). 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. <a name="en-us_topic_0000001056443961_li142386399535"></a>Open Device Manager, then check and record the serial port number corresponding to the development board. 2. <a name="en-us_topic_0000001071634529_li142386399535"></a>Open Device Manager, then check and record the serial port number corresponding to the development board.
>![](public_sys-resources/icon-note.gif) **NOTE:** >![](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). >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) ![](figures/en-us_image_0000001071792503.png)
3. Go to **Configure** \> **Burn**. On the displayed page, set the programming information. 3. Go to **Configure** \> **Burn**. On the displayed page, set the programming information.
![](figures/en-us_image_0000001057354060.png) ![](figures/en-us_image_0000001071904255.png)
4. Set **Burning Mode** to **network**. 4. Set **Burning Mode** to **network**.
![](figures/网口烧录-1.png) ![](figures/网口烧录-1.png)
5. Set the programming parameters. 5. Set the programming parameters.
- Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001056443961_li142386399535). - Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001071634529_li142386399535).
- Retain the default values for the baud rate and data bits, which have been adapted for the development board. - Retain the default values for the baud rate and data bits, which have been adapted for the development board.
- Set network connection parameters. - Set network connection parameters.
...@@ -70,73 +72,73 @@ The Hi3516 development board allows you to burn flash memory over the USB port, ...@@ -70,73 +72,73 @@ The Hi3516 development board allows you to burn flash memory over the USB port,
- **Remote IP address**: IP address of the development board, which is automatically populated. - **Remote IP address**: IP address of the development board, which is automatically populated.
- **Gateway**: gateway 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. - **Subnet mask**: subnet mask, which is automatically populated.
- **MAC address of board**: physical address of the development board. - **MAC address of board**: physical address of the development board. Retain the default value.
![](figures/en-us_image_0000001057543065.png) ![](figures/en-us_image_0000001072552472.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 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. - 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.
<a name="en-us_topic_0000001056443961_table833816126143"></a> <a name="en-us_topic_0000001071634529_table833816126143"></a>
<table><thead align="left"><tr id="en-us_topic_0000001056443961_row123381912111410"><th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001056443961_p933816122140"><a name="en-us_topic_0000001056443961_p933816122140"></a><a name="en-us_topic_0000001056443961_p933816122140"></a>File Name</p> <table><thead align="left"><tr id="en-us_topic_0000001071634529_row123381912111410"><th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001071634529_p933816122140"><a name="en-us_topic_0000001071634529_p933816122140"></a><a name="en-us_topic_0000001071634529_p933816122140"></a>File Name</p>
</th> </th>
<th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001056443961_p1533819122144"><a name="en-us_topic_0000001056443961_p1533819122144"></a><a name="en-us_topic_0000001056443961_p1533819122144"></a>Start Address</p> <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001071634529_p1533819122144"><a name="en-us_topic_0000001071634529_p1533819122144"></a><a name="en-us_topic_0000001071634529_p1533819122144"></a>Start Address</p>
</th> </th>
<th class="cellrowborder" valign="top" width="24.98%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001056443961_p1733831231411"><a name="en-us_topic_0000001056443961_p1733831231411"></a><a name="en-us_topic_0000001056443961_p1733831231411"></a>File Size</p> <th class="cellrowborder" valign="top" width="24.98%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001071634529_p1733831231411"><a name="en-us_topic_0000001071634529_p1733831231411"></a><a name="en-us_topic_0000001071634529_p1733831231411"></a>File Size</p>
</th> </th>
<th class="cellrowborder" valign="top" width="25.019999999999996%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001056443961_p1433851211145"><a name="en-us_topic_0000001056443961_p1433851211145"></a><a name="en-us_topic_0000001056443961_p1433851211145"></a>Enable</p> <th class="cellrowborder" valign="top" width="25.019999999999996%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001071634529_p1433851211145"><a name="en-us_topic_0000001071634529_p1433851211145"></a><a name="en-us_topic_0000001071634529_p1433851211145"></a>Enable</p>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody><tr id="en-us_topic_0000001056443961_row6339412101413"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001056443961_p14339131221416"><a name="en-us_topic_0000001056443961_p14339131221416"></a><a name="en-us_topic_0000001056443961_p14339131221416"></a>OHOS_Image.bin</p> <tbody><tr id="en-us_topic_0000001071634529_row6339412101413"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001071634529_p14339131221416"><a name="en-us_topic_0000001071634529_p14339131221416"></a><a name="en-us_topic_0000001071634529_p14339131221416"></a>OHOS_Image.bin</p>
</td> </td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001056443961_p133901211419"><a name="en-us_topic_0000001056443961_p133901211419"></a><a name="en-us_topic_0000001056443961_p133901211419"></a>1M</p> <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001071634529_p133901211419"><a name="en-us_topic_0000001071634529_p133901211419"></a><a name="en-us_topic_0000001071634529_p133901211419"></a>1M</p>
</td> </td>
<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001056443961_p1533951261412"><a name="en-us_topic_0000001056443961_p1533951261412"></a><a name="en-us_topic_0000001056443961_p1533951261412"></a>9M</p> <td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001071634529_p1533951261412"><a name="en-us_topic_0000001071634529_p1533951261412"></a><a name="en-us_topic_0000001071634529_p1533951261412"></a>9M</p>
</td> </td>
<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001056443961_p2574183818223"><a name="en-us_topic_0000001056443961_p2574183818223"></a><a name="en-us_topic_0000001056443961_p2574183818223"></a>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.</p> <td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001071634529_p2574183818223"><a name="en-us_topic_0000001071634529_p2574183818223"></a><a name="en-us_topic_0000001071634529_p2574183818223"></a>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.</p>
</td> </td>
</tr> </tr>
<tr id="en-us_topic_0000001056443961_row533914120143"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001056443961_p8339112111412"><a name="en-us_topic_0000001056443961_p8339112111412"></a><a name="en-us_topic_0000001056443961_p8339112111412"></a>rootfs.img</p> <tr id="en-us_topic_0000001071634529_row533914120143"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001071634529_p8339112111412"><a name="en-us_topic_0000001071634529_p8339112111412"></a><a name="en-us_topic_0000001071634529_p8339112111412"></a>rootfs.img</p>
</td> </td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001056443961_p733921271410"><a name="en-us_topic_0000001056443961_p733921271410"></a><a name="en-us_topic_0000001056443961_p733921271410"></a>10M</p> <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001071634529_p733921271410"><a name="en-us_topic_0000001071634529_p733921271410"></a><a name="en-us_topic_0000001071634529_p733921271410"></a>10M</p>
</td> </td>
<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001056443961_p13339181214145"><a name="en-us_topic_0000001056443961_p13339181214145"></a><a name="en-us_topic_0000001056443961_p13339181214145"></a>15M</p> <td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001071634529_p13339181214145"><a name="en-us_topic_0000001071634529_p13339181214145"></a><a name="en-us_topic_0000001071634529_p13339181214145"></a>15M</p>
</td> </td>
<td class="cellrowborder" rowspan="2" valign="top" width="25.019999999999996%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001056443961_p233901211146"><a name="en-us_topic_0000001056443961_p233901211146"></a><a name="en-us_topic_0000001056443961_p233901211146"></a>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.</p> <td class="cellrowborder" rowspan="2" valign="top" width="25.019999999999996%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001071634529_p233901211146"><a name="en-us_topic_0000001071634529_p233901211146"></a><a name="en-us_topic_0000001071634529_p233901211146"></a>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.</p>
</td> </td>
</tr> </tr>
<tr id="en-us_topic_0000001056443961_row1333901281418"><td class="cellrowborder" valign="top" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001056443961_p53391912131416"><a name="en-us_topic_0000001056443961_p53391912131416"></a><a name="en-us_topic_0000001056443961_p53391912131416"></a>userfs.img</p> <tr id="en-us_topic_0000001071634529_row1333901281418"><td class="cellrowborder" valign="top" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001071634529_p53391912131416"><a name="en-us_topic_0000001071634529_p53391912131416"></a><a name="en-us_topic_0000001071634529_p53391912131416"></a>userfs.img</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001056443961_p193391612161414"><a name="en-us_topic_0000001056443961_p193391612161414"></a><a name="en-us_topic_0000001056443961_p193391612161414"></a>25M</p> <td class="cellrowborder" valign="top" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001071634529_p193391612161414"><a name="en-us_topic_0000001071634529_p193391612161414"></a><a name="en-us_topic_0000001071634529_p193391612161414"></a>25M</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001056443961_p433918121148"><a name="en-us_topic_0000001056443961_p433918121148"></a><a name="en-us_topic_0000001056443961_p433918121148"></a>50M</p> <td class="cellrowborder" valign="top" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001071634529_p433918121148"><a name="en-us_topic_0000001071634529_p433918121148"></a><a name="en-us_topic_0000001071634529_p433918121148"></a>50M</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
![](figures/en-us_image_0000001057621705.png) ![](figures/en-us_image_0000001071514639.png)
6. When you have done, click **Save** at the bottom to save the settings. 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. 7. Click ![](figures/en-us_image_0000001072074632.png) next to **Burn** to start programming.
![](figures/en-us_image_0000001057911116.png) ![](figures/en-us_image_0000001071634537.png)
8. Restart the development board within 15 seconds. 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. 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) ![](figures/en-us_image_0000001071984311.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). 10. If this is the first time you use the development board, use the [serial port tool](https://device.harmonyos.com/en/docs/ide/user-guides/serial_port-0000001057649420) 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#EN-US_TOPIC_0000001052906247__section380511712615).
## Running an Image<a name="section380511712615"></a> ## Running an Image<a name="section380511712615"></a>
1. Connect to a serial port. 1. Connect to a serial port.
>![](public_sys-resources/icon-notice.gif) **NOTICE:** >![](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). >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faq-on-hi3516.md#section14871149155911).
**Figure 1** Serial port connection<a name="fig056645018495"></a> **Figure 1** Serial port connection<a name="fig056645018495"></a>
......
# Developing the First Example Program Running on Hi3861<a name="EN-US_TOPIC_0000001053302600"></a> # Developing the First Example Program Running on Hi3861<a name="EN-US_TOPIC_0000001053302600"></a>
- [Acquiring Source Code](#section1545225464016) - [Acquiring Source Code](#section1545225464016)
- [Compiling Source Code](#section1736014117148) - [Building](#section1736014117148)
- [Burning Images](#section1610612214150) - [Burning Images](#section1610612214150)
- [Connecting WLAN Module to the Internet](#section168257461059) - [Connecting WLAN Module to the Internet](#section168257461059)
...@@ -11,9 +11,11 @@ This example shows how to connect the WLAN module to the gateway using attention ...@@ -11,9 +11,11 @@ This example shows how to connect the WLAN module to the gateway using attention
You need to acquire [Hi3861 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). You need to acquire [Hi3861 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).
## Compiling Source Code<a name="section1736014117148"></a> ## Building<a name="section1736014117148"></a>
This section describes how to compile the WLAN module on a Linux server. This section describes how to perform the WLAN module building on a Linux server.
If the Linux environment is installed using Docker, perform the building by referring to [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). If the Linux environment is installed using a software package, perform the following steps:
1. Open the HUAWEI DevEco Device Tool and choose **View** \> **Terminal**. 1. Open the HUAWEI DevEco Device Tool and choose **View** \> **Terminal**.
...@@ -22,16 +24,16 @@ This section describes how to compile the WLAN module on a Linux server. ...@@ -22,16 +24,16 @@ This section describes how to compile the WLAN module on a Linux server.
![](figures/en-us_image_0000001055040538.png) ![](figures/en-us_image_0000001055040538.png)
On the TERMINAL page, run the ssh command, for example, **ssh _user_@_ipaddr_**, to connect to the Linux server. On the TERMINAL page, run the ssh command, for example, **ssh** **_user_@_ipaddr_**, to connect to the Linux server.
**Figure 2** TERMINAL page<a name="fig91165301546"></a> **Figure 2** TERMINAL page<a name="fig91165301546"></a>
![](figures/en-us_image_0000001054599199.png) ![](figures/en-us_image_0000001054599199.png)
2. Go to the root directory of the code and run the **python build.py wifiiot** command in the TERMINAL page to start compilation. 2. Go to the root directory of the code and run the **python build.py wifiiot** command in the TERMINAL page to start building.
**Figure 3** Running the compilation command on TERMINAL page<a name="fig17727115215612"></a> **Figure 3** Running the command on TERMINAL page<a name="fig17727115215612"></a>
![](figures/en-us_image_0000001055040596.png) ![](figures/en-us_image_0000001055040596.png)
...@@ -41,13 +43,13 @@ This section describes how to compile the WLAN module on a Linux server. ...@@ -41,13 +43,13 @@ This section describes how to compile the WLAN module on a Linux server.
**Figure 4** Successful building<a name="fig1262101218463"></a> **Figure 4** Successful building<a name="fig1262101218463"></a>
![](figures/successful-building.png "successful-building") ![](figures/successful-building.png "successful-building")
4. Run the following command to check whether the following files are generated in the **./out/wifiiot/** directory: 4. Check whether the following files are generated in the **./out/wifiiot/** directory.
``` ```
ls -l out/wifiiot ls -l out/wifiiot
``` ```
**Figure 5** Directory for storing compilation files<a name="fig38521346164618"></a> **Figure 5** Directory for storing the generated files<a name="fig38521346164618"></a>
![](figures/en-us_image_0000001055040654.png) ![](figures/en-us_image_0000001055040654.png)
......
...@@ -120,7 +120,7 @@ Call Stack 6 -- 3f5e24 addr:f78fc ...@@ -120,7 +120,7 @@ Call Stack 6 -- 3f5e24 addr:f78fc
To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is required. This file records the symbol addresses of the functions in the code in the flash memory and the disassembly information. The asm file is built and output together with the version software package and is stored in the **./out/wifiiot/** directory. To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is required. This file records the symbol addresses of the functions in the code in the flash memory and the disassembly information. The asm file is built and output together with the version software package and is stored in the **./out/wifiiot/** directory.
1. \(Optional\) Save the** CallStack** information to a txt file for editing. 1. \(Optional\) Save the **CallStack** information to a txt file for editing.
2. Open the asm file, search for the function address in each call stack, and list the corresponding function. Generally, you only need to find the functions matching the first several stacks to locate exceptions. 2. Open the asm file, search for the function address in each call stack, and list the corresponding function. Generally, you only need to find the functions matching the first several stacks to locate exceptions.
``` ```
...@@ -133,7 +133,7 @@ To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is ...@@ -133,7 +133,7 @@ To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is
Call Stack 6 -- 3f5e24 addr:f78fc Call Stack 6 -- 3f5e24 addr:f78fc
``` ```
3. Determined that an exception occurs in the **WadRecvCB** function based on the call stack information. 3. Determine that an exception occurs in the **WadRecvCB** function based on the call stack information.
![](figures/en-us_image_0000001054763554.png) ![](figures/en-us_image_0000001054763554.png)
......
# FAQ on Hi3516<a name="EN-US_TOPIC_0000001053466255"></a>
- [What should I do when the images failed to be burnt over the selected serial port?](#section627268185113)
- [What should I do when Windows-based PC failed to be connected to the board?](#section195391036568)
- [What should I do when the image failed to be burnt?](#section571164016565)
- [What should I do when the message indicating Python cannot be found is displayed during compilation and building?](#section1039835245619)
- [What should I do when no command output is displayed?](#section14871149155911)
## What should I do when the images failed to be burnt over the selected serial port?<a name="section627268185113"></a>
- **Symptom**
**Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port.
**Figure 1** Failed to open the serial port<a name="fig066333283916"></a>
![](figures/failed-to-open-the-serial-port.png "failed-to-open-the-serial-port")
- **Possible Causes**
The serial port has been used.
- **Solutions**
1. Search for the terminal using serial-xx from the drop-down list in the **TERMINAL** panel.
**Figure 2** Checking whether the serial port is used<a name="fig165994164420"></a>
![](figures/checking-whether-the-serial-port-is-used.png "checking-whether-the-serial-port-is-used")
2. Click the dustbin icon as shown in the following figure to disable the terminal using the serial port.
**Figure 3** Disabling the terminal using the serial port<a name="fig7911282453"></a>
![](figures/disabling-the-terminal-using-the-serial-port.png "disabling-the-terminal-using-the-serial-port")
3. Click **Burn**, select the serial port, and start burning images again.
**Figure 4** Restarting burning<a name="fig1138624316485"></a>
![](figures/changjian1.png)
## What should I do when Windows-based PC failed to be connected to the board?<a name="section195391036568"></a>
- **Symptom**
The file image cannot be obtained after clicking **Burn** and selecting a serial port.
**Figure 5** Failed to obtain the image file due to unavailable connection<a name="fig5218920223"></a>
![](figures/failed-to-obtain-the-image-file-due-to-unavailable-connection.png "failed-to-obtain-the-image-file-due-to-unavailable-connection")
- **Possible Causes**
The board is disconnected from the Windows-based PC.
Windows Firewall does not allow Visual Studio Code to access the network.
- **Solutions**
1. Check whether the network cable is properly connected.
2. Click **Windows Firewall**.
**Figure 6** Network and firewall setting<a name="fig62141417794"></a>
![](figures/network-and-firewall-setting.png "network-and-firewall-setting")
3. Click **Firewall & network protection**, and on the displayed page, click **Allow applications to communicate through Windows Firewall**.
**Figure 7** Firewall and network protection<a name="fig20703151111116"></a>
![](figures/firewall-and-network-protection.png "firewall-and-network-protection")
4. Select the Visual Studio Code application
**Figure 8** Selecting the Visual Studio Code application<a name="fig462316612165"></a>
![](figures/selecting-the-visual-studio-code-application.png "selecting-the-visual-studio-code-application")
5. Select the **Private** and **Public** network access rights for the Visual Studio Code application.
**Figure 9** Allowing the Visual Studio Code application to access the network<a name="fig132725269184"></a>
![](figures/allowing-the-visual-studio-code-application-to-access-the-network.png "allowing-the-visual-studio-code-application-to-access-the-network")
## What should I do when the image failed to be burnt?<a name="section571164016565"></a>
- **Symptom**
The burning status is not displayed after clicking **Burn** and selecting a serial port.
- **Possible Causes**
The IDE is not restarted after the DevEco plug-in is installed.
- **Solutions**
Restart the IDE.
## What should I do when the message indicating Python cannot be found is displayed during compilation and building?<a name="section1039835245619"></a>
- **Symptom**
![](figures/en-us_image_0000001055035538.png)
- **Possible Cause 1**: Python is not installed.
- **Solutions**
Install the Python environment by referring to [Installing a Python Environment](setting-up-the-hi3516-development-environment.md#section126442079459).
- **Possible Cause 2**: The soft link that points to the Python does not exist in the usr/bin directory.
![](figures/en-us_image_0000001054475589.png)
- **Solutions**
Run the following commands:
```
# cd /usr/bin/
# which python3
# ln -s /usr/local/bin/python3 python
# python --version
```
Example:
![](figures/en-us_image_0000001054875562.png)
## What should I do when no command output is displayed?<a name="section14871149155911"></a>
- **Symptom**
The serial port shows that the connection has been established. After the board is restarted, nothing is displayed when you press **Enter**.
- **Possible Cause 1**
The serial port is connected incorrectly.
- **Solutions**
Change the serial port number.
Start **Device Manager** to check whether the serial port connected to the board is the same as that connected to the terminal device. If the serial ports are different, perform step [1](developing-the-first-example-program-running-on-hi3516.md#l177d08e77bd441d38991da9be4572a74) in the **Running an Image** section to change the serial port number.
- **Possible Cause 2**
The U-boot of the board is damaged.
- **Solutions**
Burn the U-boot.
If the fault persists after you perform the preceding operations, the U-boot of the board may be damaged. You can burn the U-boot by performing the following steps:
1. Obtain the U-boot file.
>![](public_sys-resources/icon-notice.gif) **NOTICE:**
>The U-boot file of the two boards can be obtained from the following paths, respectively.
>- Hi3516DV300: vendor\\hisi\\hi35xx\\hi3516dv300\\uboot\\out\\boot\\u-boot-hi3516dv300.bin
>- Hi3518EV300: vendor\\hisi\\hi35xx\\hi3518ev300\\uboot\\out\\boot\\u-boot-hi3518ev300.bin
2. Burn the U-boot file by following the procedures for burning a U-boot file over USB.
Select the U-boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128)
3. Log in to the serial port after the burning is complete.
**Figure 10** Serial port displayed after the U-boot is burnt<a name="en-us_topic_0000001053466255_fig155914681910"></a>
![](figures/serial-port-displayed-after-the-u-boot-is-burnt.png "serial-port-displayed-after-the-u-boot-is-burnt")
# FAQ on Hi3518<a name="EN-US_TOPIC_0000001058898620"></a>
- [What should I do when the images failed to be burnt over the selected serial port?](#section1498892119619)
- [What should I do when Windows-based PC failed to be connected to the board?](#section8512971816)
- [What should I do when the image failed to be burnt?](#section1767804111198)
- [What should I do when the message indicating Python cannot be found is displayed during compilation and building?](#en-us_topic_0000001053466255_section1039835245619)
- [What should I do when no command output is displayed?](#en-us_topic_0000001053466255_section14871149155911)
## What should I do when the images failed to be burnt over the selected serial port?<a name="section1498892119619"></a>
- **Symptom**
**Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port.
**Figure 1** Failed to open the serial port<a name="en-us_topic_0000001053466255_fig066333283916"></a>
![](figures/failed-to-open-the-serial-port.png "failed-to-open-the-serial-port")
- **Possible Causes**
The serial port has been used.
- **Solutions**
1. Search for the terminal using serial-xx from the drop-down list in the **TERMINAL** panel.
**Figure 2** Checking whether the serial port is used<a name="en-us_topic_0000001053466255_fig165994164420"></a>
![](figures/checking-whether-the-serial-port-is-used.png "checking-whether-the-serial-port-is-used")
2. Click the dustbin icon as shown in the following figure to disable the terminal using the serial port.
**Figure 3** Disabling the terminal using the serial port<a name="en-us_topic_0000001053466255_fig7911282453"></a>
![](figures/disabling-the-terminal-using-the-serial-port.png "disabling-the-terminal-using-the-serial-port")
3. Click **Burn**, select the serial port, and start burning images again.
**Figure 4** Restarting burning<a name="en-us_topic_0000001053466255_fig1138624316485"></a>
![](figures/changjian1.png)
## What should I do when Windows-based PC failed to be connected to the board?<a name="section8512971816"></a>
- **Symptom**
The file image cannot be obtained after clicking **Burn** and selecting a serial port.
**Figure 5** Failed to obtain the image file due to unavailable connection<a name="en-us_topic_0000001053466255_fig5218920223"></a>
![](figures/failed-to-obtain-the-image-file-due-to-unavailable-connection.png "failed-to-obtain-the-image-file-due-to-unavailable-connection")
- **Possible Causes**
The board is disconnected from the Windows-based PC.
Windows Firewall does not allow Visual Studio Code to access the network.
- **Solutions**
1. Check whether the network cable is properly connected.
2. Click **Windows Firewall**.
**Figure 6** Network and firewall setting<a name="en-us_topic_0000001053466255_fig62141417794"></a>
![](figures/network-and-firewall-setting.png "network-and-firewall-setting")
3. Click **Firewall & network protection**, and on the displayed page, click **Allow applications to communicate through Windows Firewall**.
**Figure 7** Firewall and network protection<a name="en-us_topic_0000001053466255_fig20703151111116"></a>
![](figures/firewall-and-network-protection.png "firewall-and-network-protection")
4. Select the Visual Studio Code application
**Figure 8** Selecting the Visual Studio Code application<a name="en-us_topic_0000001053466255_fig462316612165"></a>
![](figures/selecting-the-visual-studio-code-application.png "selecting-the-visual-studio-code-application")
5. Select the **Private** and **Public** network access rights for the Visual Studio Code application.
**Figure 9** Allowing the Visual Studio Code application to access the network<a name="en-us_topic_0000001053466255_fig132725269184"></a>
![](figures/allowing-the-visual-studio-code-application-to-access-the-network.png "allowing-the-visual-studio-code-application-to-access-the-network")
## What should I do when the image failed to be burnt?<a name="section1767804111198"></a>
- **Symptom**
The burning status is not displayed after clicking **Burn** and selecting a serial port.
- **Possible Causes**
The IDE is not restarted after the DevEco plug-in is installed.
- **Solutions**
Restart the IDE.
## What should I do when the message indicating Python cannot be found is displayed during compilation and building?<a name="en-us_topic_0000001053466255_section1039835245619"></a>
- **Symptom**
![](figures/en-us_image_0000001058781525.png)
- **Possible Cause 1**
Python is not installed.
- **Solutions**
Install the Python environment by referring to [Installing a Python Environment](setting-up-the-hi3518-development-environment.md#section10807183719500).
- **Possible Cause 2**
![](figures/en-us_image_0000001058939672.png)
- **Solutions**
Run the following commands:
```
# cd /usr/bin/
# which python3
# ln -s /usr/local/bin/python3 python
# python --version
```
Example:
![](figures/en-us_image_0000001058781464.png)
## What should I do when no command output is displayed?<a name="en-us_topic_0000001053466255_section14871149155911"></a>
- **Symptom**
The serial port shows that the connection has been established. After the board is restarted, nothing is displayed when you press **Enter**.
- **Possible Cause 1**
The serial port is connected incorrectly.
- **Solutions**
Change the serial port number.
Start **Device Manager** to check whether the serial port connected to the board is the same as that connected to the terminal device. If the serial ports are different, perform step [1](developing-the-first-example-program-running-on-hi3518.md#li744118533233) in the **Running an Image** section to change the serial port number.
- **Possible Cause 2**
The U-boot of the board is damaged.
- **Solutions**
Burn the U-boot.
If the fault persists after you perform the preceding operations, the U-boot of the board may be damaged. You can burn the U-boot by performing the following steps:
1. Obtain the U-boot file.
>![](public_sys-resources/icon-notice.gif) **NOTICE:**
>The U-boot file of the two boards can be obtained from the following paths, respectively.
>- Hi3516DV300: vendor\\hisi\\hi35xx\\hi3516dv300\\uboot\\out\\boot\\u-boot-hi3516dv300.bin
>- Hi3518EV300: vendor\\hisi\\hi35xx\\hi3518ev300\\uboot\\out\\boot\\u-boot-hi3518ev300.bin
2. Burn the U-boot file by following the procedures for burning a U-boot file over USB.
Select the U-boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128)
3. Log in to the serial port after the burning is complete.
![](figures/en-us_image_0000001058719409.png)
# FAQ on Hi3861<a name="EN-US_TOPIC_0000001053143860"></a>
- [What should I do when the message is displayed during Python 3 installation?](#section1221016541119)
- [What should I do when the message is displayed during Python 3 installation?](#section1913477181213)
- [What should I do when the message is displayed during Python 3 installation?](#section108211415131210)
- [What should I do when the message is displayed during Python 3 installation?](#section2062268124)
- [What should I do when the message is displayed during compilation and building?](#section982315398121)
- [What should I do when the message is displayed during compilation and building?](#section102035451216)
- [What should I do when the message is displayed during compilation and building?](#section4498158162320)
- [What should I do when the message is displayed during compilation and building?](#section11181036112615)
- [What should I do when the message indicating Python cannot be found is displayed during compilation and building?](#section1571810194619)
- [What should I do when an error with occurs during installation?](#section691681635814)
## What should I do when the message **configure: error: no acceptable C compiler found in $PATH** is displayed during Python 3 installation?<a name="section1221016541119"></a>
- **Symptom**
The following error occurs during Python3 installation:
```
configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details
```
- **Possible Causes**
**gcc** is not installed.
- **Solutions**
1. Run the **apt-get install gcc** command to install **gcc** online.
2. After the installation, reinstall Python 3.
## What should I do when the message **-bash: make: command not found** is displayed during Python 3 installation?<a name="section1913477181213"></a>
- **Symptom**
The following error occurs during Python3 installation:
```
-bash: make: command not found
```
- **Possible Causes**
**make** is not installed.
- **Solutions**
1. Run the **apt-get install make** command to install **make** online.
2. After the installation, reinstall Python 3.
## What should I do when the message **zlib not available** is displayed during Python 3 installation?<a name="section108211415131210"></a>
- **Symptom**
The following error occurs during Python3 installation:
```
zipimport.ZipImportError: can't decompress data; zlib not avaliable
```
- **Possible Causes**
**zlib** is not installed.
- **Solutions**
Solution 1: Run the **apt-get install zlib** command to install **zlib** online.
Solution 2: If the software source does not contain **zlib**, download the source code from [http://www.zlib.net/](http://www.zlib.net/).
![](figures/10.png)
Then run the following commands to install **zlib** offline:
```
# tar xvf zlib-1.2.11.tar.gz
# cd zlib-1.2.11
# ./configure
# make && make install
```
After the installation, reinstall Python 3.
## What should I do when the message **No module named '\_ctypes'** is displayed during Python 3 installation?<a name="section2062268124"></a>
- **Symptom**
The following error occurs during Python3 installation:
```
ModuleNotFoundError: No module named '_ctypes'
```
- **Possible Causes**
**libffi** and **libffi-devel** are not installed.
- **Solutions**
1. Run the **apt-get install libffi\* -y** command to install **libffi** and **libffi-devel** online.
2. After the installation, reinstall Python 3.
## What should I do when the message **No module named 'Crypto'** is displayed during compilation and building?<a name="section982315398121"></a>
- **Symptom**
The following error occurs during compilation and building:
```
ModuleNotFoundError: No module named 'Crypto'
```
- **Possible Causes**
**Crypto** is not installed.
- **Solutions**
Solution 1: Run the **pip3 install Crypto** command to install **Crypto** online.
Solution 2: Install **Crypto** offline.
- Download the source code from [https://pypi.org/project/pycrypto/\#files](https://pypi.org/project/pycrypto/#files).
![](figures/en-us_image_0000001053462612.png)
- Save the source code package to the Linux server, decompress the package, and run the **python3 setup.py install** command to install **Crypto**.
- Rebuild an environment.
## What should I do when the message **No module named 'ecdsa'** is displayed during compilation and building?<a name="section102035451216"></a>
- **Symptom**
The following error occurs during compilation and building:
```
ModuleNotFoundError: No module named 'ecdsa'
```
- **Possible Causes**
**ecdsa** is not installed.
- **Solutions**
Solution 1: Run the **pip3 install ecdsa** command to install **ecdsa** online.
Solution 2: Install **ecdsa** offline.
- Download the installation package from [https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files).
![](figures/en-us_image_0000001053022609.png)
- Save the installation package to the Linux server and run the **pip3 install ecdsa-0.15-py2.py3-none-any.whl** command to install **ecdsa**.
- Rebuild an environment.
## What should I do when the message **Could not find a version that satisfies the requirement six\>=1.9.0** is displayed during compilation and building?<a name="section4498158162320"></a>
- **Symptom**
The following error occurs during compilation and building:
```
Could not find a version that satisfies the requirment six>=1.9.0
```
- **Possible Causes**
**six** is not installed.
- **Solutions**
Solution 1: Run the **pip3 install six** command to install **six** online.
Solution 2: Install **six** offline.
- Download the installation package from [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files).
![](figures/en-us_image_0000001052742629.png)
- Save the source code to the Linux server and run the **pip3 install six-1.14.0-py2.py3-none-any.whl** command to install **six**.
- Rebuild an environment.
## What should I do when the message **cannot find -lgcc** is displayed during compilation and building?<a name="section11181036112615"></a>
- **Symptom**
The following error occurs during compilation and building:
```
riscv32-unknown-elf-ld: cannot find -lgcc
```
- **Possible Causes**
The PATH is incorrectly written by **gcc\_riscv32**. There is an extra slash \(/\).
```
~/gcc_riscv32/bin/:/data/toolchain/
```
- **Solutions**
Modify the PATH by deleting the slash \(/\).
```
~/gcc_riscv32/bin:/data/toolchain/
```
## What should I do when the message indicating Python cannot be found is displayed during compilation and building?<a name="section1571810194619"></a>
- **Symptom**
The following error occurs during compilation and building:
```
-bash: /usr/bin/python: No such file or directory
```
- **Possible Cause 1:** Python is not installed.
- **Solutions**
Install Python by referring to [Installing a Python Environment](setting-up-the-hi3861-development-environment.md#section18835251192618).
- **Possible Cause 2:** The soft link that points to the Python does not exist in the **usr/bin** directory.
![](figures/en-us_image_0000001055372855.png)
- **Solutions**
Run the following commands to add a soft link:
```
# cd /usr/bin/
# which python3
# ln -s /usr/local/bin/python3 python
# python --version
```
Example:
![](figures/en-us_image_0000001055012855.png)
## What should I do when an error with **lsb\_release** occurs during **kconfiglib** installation?<a name="section691681635814"></a>
- **Symptom**
The following error occurs during **kconfiglib** installation:
```
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
```
- **Possible Causes**
The Python version matched with the **lsb\_release** module is different from the current Python version.
- **Solutions**
Run the **find / -name lsb\_release** command, for example, **sudo rm -rf /usr/bin/lsb\_release** to locate and delete **lsb\_release**.
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
- **[Introduction to the Hi3516 Development Board](introduction-to-the-hi3516-development-board.md)** - **[Introduction to the Hi3516 Development Board](introduction-to-the-hi3516-development-board.md)**
- **[Setting up a Development Environment](setting-up-a-development-environment-0.md)** - **[Setting Up the Hi3516 Development Environment](setting-up-the-hi3516-development-environment.md)**
- **[Developing the First Example Program Running on Hi3516](developing-the-first-example-program-running-on-hi3516.md)** - **[Developing the First Example Program Running on Hi3516](developing-the-first-example-program-running-on-hi3516.md)**
- **[Developing the First Driver Running on Hi3516](developing-the-first-driver-running-on-hi3516.md)** - **[Developing the First Driver Running on Hi3516](developing-the-first-driver-running-on-hi3516.md)**
- **[FAQs](faqs-1.md)** - **[FAQ on Hi3516](faq-on-hi3516.md)**
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
- **[Introduction to the Hi3518 Development Board](introduction-to-the-hi3518-development-board.md)** - **[Introduction to the Hi3518 Development Board](introduction-to-the-hi3518-development-board.md)**
- **[Setting Up a Development Environment](setting-up-a-development-environment-2.md)** - **[Setting Up the Hi3518 Development Environment](setting-up-the-hi3518-development-environment.md)**
- **[Developing the First Example Program Running on Hi3518](developing-the-first-example-program-running-on-hi3518.md)** - **[Developing the First Example Program Running on Hi3518](developing-the-first-example-program-running-on-hi3518.md)**
- **[FAQs](faqs-3.md)** - **[FAQ on Hi3518](faq-on-hi3518.md)**
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
- **[Introduction to the Hi3861 Development Board](introduction-to-the-hi3861-development-board.md)** - **[Introduction to the Hi3861 Development Board](introduction-to-the-hi3861-development-board.md)**
- **[Setting Up a Development Environment](setting-up-a-development-environment.md)** - **[Setting Up the Hi3861 Development Environment](setting-up-the-hi3861-development-environment.md)**
- **[Developing the First Example Program Running on Hi3861](developing-the-first-example-program-running-on-hi3861.md)** - **[Developing the First Example Program Running on Hi3861](developing-the-first-example-program-running-on-hi3861.md)**
- **[Developing the Second Example Program Running on Hi3861](developing-the-second-example-program-running-on-hi3861.md)** - **[Developing the Second Example Program Running on Hi3861](developing-the-second-example-program-running-on-hi3861.md)**
- **[FAQs](faqs.md)** - **[FAQ on Hi3861](faq-on-hi3861.md)**
# Subsystem Development Guidelines # Subsystem Development Guidelines
- [Distributed Remote Startup](distributed-remote-startup.md) - [Distributed Remote Startup](distributed-remote-startup.md)
- [Graphic](graphic.md) - [Graphics](graphics.md)
- [Graphics](graphics.md) - [Graphics](graphics-0.md)
- [Development Guidelines on Container Components](development-guidelines-on-container-components.md) - [Development Guidelines on Container Components](development-guidelines-on-container-components.md)
- [Development Guidelines on Layout Container Components](development-guidelines-on-layout-container-components.md) - [Development Guidelines on Layout Container Components](development-guidelines-on-layout-container-components.md)
- [Development Guidelines on Common Components](development-guidelines-on-common-components.md) - [Development Guidelines on Common Components](development-guidelines-on-common-components.md)
- [Development Guidelines on Animators](development-guidelines-on-animators.md) - [Development Guidelines on Animators](development-guidelines-on-animators.md)
- [Camera](camera.md) - [Multimedia](multimedia.md)
- [Overview](overview.md) - [Overview](overview.md)
- [Development Guidelines on Photographing](development-guidelines-on-photographing.md) - [Development Guidelines on Photographing](development-guidelines-on-photographing.md)
- [Development Guidelines on Video Recording](development-guidelines-on-video-recording.md) - [Development Guidelines on Video Recording](development-guidelines-on-video-recording.md)
- [Development Guidelines on Previewing](development-guidelines-on-previewing.md) - [Development Guidelines on Previewing](development-guidelines-on-previewing.md)
- [Overview](overview-1.md)
- [Audio and Video](audio-and-video.md)
- [Overview](overview-0.md)
- [Development Guidelines on Media Playback](development-guidelines-on-media-playback.md) - [Development Guidelines on Media Playback](development-guidelines-on-media-playback.md)
- [Development Guidelines on Media Recording](development-guidelines-on-media-recording.md) - [Development Guidelines on Media Recording](development-guidelines-on-media-recording.md)
- [Utils](utils.md)
- [Utils Overview](utils-overview.md)
- [Utils Development Guidelines](utils-development-guidelines.md)
- [Utils FAQ](utils-faq.md)
- [Application Framework](application-framework.md)
- [Overview](overview-2.md)
- [Setting Up a Development Environment](setting-up-a-development-environment.md)
- [Development Guidelines](development-guidelines.md)
- [Development Example](development-example.md)
- [FAQ](faq.md)
- [Compilation and Building](compilation-and-building.md)
- [Compilation and Building Overview](compilation-and-building-overview.md)
- [Compilation and Building Guidelines](compilation-and-building-guidelines.md)
- [Compilation and Building FAQ](compilation-and-building-faq.md)
- [Testing](testing.md)
- [DFX](dfx.md)
- [DFX](dfx-3.md)
- [Development Guidelines on the mini Framework](development-guidelines-on-the-mini-framework.md)
- [Development Guidelines on the featured Framework](development-guidelines-on-the-featured-framework.md)
- [FAQ](faq-4.md)
- [Reference](reference.md)
- [XTS](xts.md)
# Application Framework<a name="EN-US_TOPIC_0000001074304592"></a>
- **[Overview](overview-2.md)**
- **[Setting Up a Development Environment](setting-up-a-development-environment.md)**
- **[Development Guidelines](development-guidelines.md)**
- **[Development Example](development-example.md)**
- **[FAQ](faq.md)**
# Compilation and Building FAQ<a name="EN-US_TOPIC_0000001060804832"></a>
- [Invalid -- w option](#section1019152312222)
- [Ncurses library not found](#section21449422618)
- [Mcopy not found](#section12477184992615)
- [No riscv file or directory](#section178451337202716)
- [No Crypto](#section1241481172819)
- [Unexpected operator](#section3691222152919)
## Invalid -- w option<a name="section1019152312222"></a>
- **Problem**
The compilation fails, and **usr/sbin/ninja: invalid option -- w** is displayed.
- **Cause**
The Ninja version in the compilation environment is outdated and does not support the **--w** option.
- **Solution**
Uninstall Ninja and GN and follow the instructions provided in [Tool Acquisition](../get-code/tool-acquisition.md) to obtain the provided compilation toolchain.
## Ncurses library not found<a name="section21449422618"></a>
- **Problem**
The compilation fails, and **/usr/bin/ld: cannot find -lncurses** is displayed.
- **Cause**
The ncurses library is not installed.
- **Solution**
Run **sudo apt-get install lib32ncurses5-dev** to install the library.
## Mcopy not found<a name="section12477184992615"></a>
- **Problem**
The compilation fails, and **line 77: mcopy: command not found** is displayed.
- **Cause**
Mcopy is not installed.
- **Solution**
Run **sudo apt-get install dosfstools mtools** to install mcopy.
## No riscv file or directory<a name="section178451337202716"></a>
- **Problem**
The compilation fails, and **riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory** is displayed.
- **Cause**
Permission is required to access files in the **riscv** compiler path.
- **Solution**
Run **which riscv32-unknown-elf-gcc** and **chmod 755** to modify the permission to access the directory where **hcc\_riscv32** is located.
## No Crypto<a name="section1241481172819"></a>
- **Problem**
The compilation fails, and **No module named'Crypto loaded** is displayed.
- **Cause**
Crypto is not installed in Python3.
- **Solution**
Run **python3 --version** to check the Python version. Ensure that the Python version is 3.7 or later and run **sudo pip3 install pycryptodome**.
## Unexpected operator<a name="section3691222152919"></a>
- **Problem**
The compilation fails, and **xx.sh \[: xx upexpected operator** is displayed.
- **Cause**
The compilation environment is shell instead of bash.
- **Solution**
Run the following commands to switch the compilation environment:
**sudo rm -rf /bin/sh**
**sudo ln -s /bin/bash /bin/sh**
# Compilation and Building Guidelines<a name="EN-US_TOPIC_0000001060378721"></a>
- [Directory Structure](#section56731811102915)
- [Compilation Commands](#section1475192018291)
- [How to Develop](#section4207112818418)
## Directory Structure<a name="section56731811102915"></a>
```
build/lite # Primary directory for compilation and building
├── config # Compilation configuration items
│ ├── boards # Declaration of development board–related variables, including its name, target architecture, and target CPU
│ ├── component # Definition of templates related to OpenHarmony components, including static libraries, dynamic libraries, extension components, and emulator libraries
│ ├── kernel # Compilation variable declaration and configuration parameters for the OpenHarmony kernel
│ └── subsystem # OpenHarmony subsystem list
├── ndk # NDK-related compilation scripts and configuration parameters
├── platform # Platform-related configuration files
│ ├── hi3516dv300_liteos_a # Hi3516DV300 and LiteOS_A platform files, including full configuration tables and boot files
│ ├── hi3518ev300_liteos_a # Hi3518EV300 and LiteOS_A platform files, including full configuration tables and boot files
│ └── hi3861v100_liteos_riscv # Hi3861V100 and LiteOS_RISCV platform files, including full configuration tables and boot files
├── product # Full configuration tables of the product, including configuration units, the subsystem list, and the compiler
├── toolchain # Compilation toolchains, which contain the compiler paths, compilation options, and link options
└── tools # Tools on which compilation and building depend, for example, mkfs
```
## Compilation Commands<a name="section1475192018291"></a>
- Usage
```
python build.py product [options]
```
Replace **product** with **build/lite/produc/**_xxx_**.json**. Both the product name and components configured in the JSON file can be customized. By default, all components supported by the corresponding platform are contained in the JSON file.
- Compilation options
**-b, --build\_type** Debug or release
**-t, --test** Build with test suit
**-T, --target** Build single target
- Output directory: _root directory of the code_**/out/product**
## How to Develop<a name="section4207112818418"></a>
1. Add a component.
This step takes a custom component as an example to describe how to compile components, libraries, and executable files.
The example component consists of two features: **feature1** and **feature2**. The target of **feature1** is a dynamic library, and that of **feature2** is an executable file. The complete directory structure of the example component is as follows:
```
example # Custom component
├── BUILD.gn # GN script of the component. The name is fixed.
├── feature1 # Custom unit 1
│ ├── BUILD.gn # GN script of feature1. The name is fixed.
│ ├── include # Header file folder
│ │ └── helloworld1.h # Header file 1
│ └── src # Source file folder
│ └── helloworld1.c # Source file 1
├── feature2 # Custom unit 2
│ ├── BUILD.gn # GN script of feature2. The name is fixed.
│ ├── include # Header file folder
│ │ └── helloworld2.h # Header file 2
│ └── src # Source file folder
│ └── helloworld2.c # Source file 2
├── build.sh # (Optional) build.sh script of the custom component
└── Makefile # (Optional) Makefile script of the custom component
```
Example 1: GN script \(**example/feature1/BUILD.gn**\) for dynamic library compilation.
```
# Example for compiling the helloworld dynamic library
# Build.gn script of helloworld
shared_library("helloworld_lib") {
sources = [
"src/helloworld1.c"
]
include_dirs = [
"include",
"../feature2_example/include" # (Optional) Add feature2_example to this include if needed.
]
}
```
Example 2: GN script \(**example/feature2/BUILD.gn**\) for executable file compilation
The built-in **executable** function generates the executable file. Sample code is as follows:
```
# Compile the executable .bin file.
executable("hello_world_bin") {
sources = [
"src/helloworld2.c"
]
include_dirs = [
"include",
"../feature2_example/include" # (Optional) Add feature2_example to this include if needed.
]
# (Optional) Add feature1_example to this deps if needed.
deps = [
"../feature1_example:helloworld1"
]
}
```
Example 3: GN script \(**example/BUILD.gn**\) for component compilation
```
import("//build/lite/config/component/lite_component.gni")
lite_component("example_gn") {
features = [
"feature_example1:helloworld_lib",
"feature_example2:hello_world_bin",
]
}
```
Example 4: GN script for compiling **build.sh** or the **Makefile** project of a third-party open-source software
```
build_ext_component("example_mk") {
exec_path = rebase_path(rebase_path(".", root_build_dir))
outdir = rebase_path(get_path_info(".", "out_dir"))
prebuilts = "sh build.sh"
command = "make clean && make"
}
```
Global variables are defined in **build/lite/ohos\_var.gni.**
The following table describes common global variables.
**Table 1** Global variables
<a name="table520317612613"></a>
<table><thead align="left"><tr id="row13203861262"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p2203368619"><a name="p2203368619"></a><a name="p2203368619"></a>Variable</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p15203765620"><a name="p15203765620"></a><a name="p15203765620"></a>Value Range</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p6203669616"><a name="p6203669616"></a><a name="p6203669616"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row42036617616"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1643814011561"><a name="p1643814011561"></a><a name="p1643814011561"></a>ohos_kernel_type</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p114385019568"><a name="p114385019568"></a><a name="p114385019568"></a>"liteos_a", "liteos_riscv"</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p820396265"><a name="p820396265"></a><a name="p820396265"></a>Kernel type</p>
</td>
</tr>
<tr id="row62033619614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p134381805564"><a name="p134381805564"></a><a name="p134381805564"></a>board_name</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p9203161968"><a name="p9203161968"></a><a name="p9203161968"></a>"hi3516dv300", "hi3518ev300", "hi3861v100"</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p172031169619"><a name="p172031169619"></a><a name="p172031169619"></a>Development board</p>
</td>
</tr>
<tr id="row1620318610614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1143880135612"><a name="p1143880135612"></a><a name="p1143880135612"></a>ohos_build_compiler</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p22041613618"><a name="p22041613618"></a><a name="p22041613618"></a>"gcc", "clang"</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9204861469"><a name="p9204861469"></a><a name="p9204861469"></a>Compilation toolchain type</p>
</td>
</tr>
<tr id="row6392114583815"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p539294514383"><a name="p539294514383"></a><a name="p539294514383"></a>ohos_build_type</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p7392144510388"><a name="p7392144510388"></a><a name="p7392144510388"></a>"debug", "release"</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p53921145123819"><a name="p53921145123819"></a><a name="p53921145123819"></a>Compilation type</p>
</td>
</tr>
</tbody>
</table>
The following example code configures **ohos\_kernel\_type** in **component\_example/feature2\_example/BUILD.gn**
```
lite_library("helloworld") {
if (ohos_kernel_type == "liteos_a") {
target_type = "shared_library"
}
else if (ohos_kernel_type == "liteos_riscv") {
target_type = "static_library"
}
sources = [
"src/helloworld1.c"
]
include_dirs = [
"include"
]
}
```
2. Compile the product solution.
The configuration of the product solution is stored in a JSON file \(for example, **ipcamera\_hi3516dv300.json**\) under the **build/lite/product** directory. During the construction, the system reads the configuration file, which contains custom subsystems and components. To compile **ipcamera\_hi3516dv30**, for example, run the following command:
```
python build.py ipcamera_hi3516dv30
```
3. Obtain the compilation result.
Files generated after compilation are archived in the **out** directory. For example, run **python build.py wifiiot -b debug** in the directory where the code is located. After **wifiiot** is compiled, the following result is generated:
```
out/
└── wifiiot # Product name
├── args.gn # Custom variables for GN compilation
├── build.log # Compilation log
├── build.ninja
├── build.ninja.d
├── gen
├── Hi3861_boot_signed_B.bin # Signed bootloader backup file
├── Hi3861_boot_signed.bin # Signed bootloader file
├── Hi3861_loader_signed.bin # Loader file used by the burning tool
├── Hi3861_wifiiot_app_allinone.bin # Production line tooling burning file, which contains the independent burning program and loader program
├── Hi3861_wifiiot_app.asm # Kernel asm file
├── Hi3861_wifiiot_app_burn.bin # Burning file
├── Hi3861_wifiiot_app_flash_boot_ota.bin # Flash Boot upgrade file
├── Hi3861_wifiiot_app.map # Kernel map file
├── Hi3861_wifiiot_app_ota.bin # Kernel upgrade file
├── Hi3861_wifiiot_app.out # Kernel output file
├── Hi3861_wifiiot_app_vercfg.bin # Configuration with secure boot and kernel versions to prevent version rollback
├── libs # Library folder
├── NOTICE_FILE
├── obj
├── suites
└── toolchain.ninja
```
Note: You are advised to use the **Hi3861\_wifiiot\_app\_allinone.bin** program to burn files.
Run **python build.py ipcamera\_hi3518ev300 -b debug**. After the compilation is complete, the following result is generated \(similar to that for **ipcamera\_hi3516dv300**\):
```
out/
└── ipcamera_hi3518ev300 # Product name
├── args.gn # Custom variables for GN compilation
├── bin # Link to the folder where the .bin file locates
├── bm_tool.map # map file
├── build.log # Compilation log
├── build.ninja
├── build.ninja.d
├── bundle_daemon_tool.map # map file
├── data # Configuration file of media resources on which the camera depends.
├── dev_tools # R&D self-testing
├── foundation.map # map file
├── gen
├── libaudio_api.so
├── libs # Library files
├── liteos.bin # Basic kernel file for LiteOS
├── media_server.map # map file
├── NOTICE_FILE
├── obj # Compilation result folder containing binary files
├── OHOS_Image # Unstriped .bin file of the LiteOS package
├── OHOS_Image.asm # Assembly code
├── OHOS_Image.bin # LiteOS package for burning
├── OHOS_Image.map # map file
├── rootfs.img # Compiled library and application image
├── rootfs.tar # Compressed rootfs
├── suites # XTS compilation result
├── test # Test case compilation result
├── toolchain.ninja
├── userfs # User-readable and -writable partition
├── userfs.img # User-readable and -writable partition in .img format, corresponding to the /storage directory after system startup.
└── vendor # Firmware and configuration files of the chip
```
# Compilation and Building Overview<a name="EN-US_TOPIC_0000001060646620"></a>
- [Basic Concepts](#section175012297491)
- [Working Principles](#section193961322175011)
- [Limitations and Constraints](#section2029921310472)
The compilation and building subsystem provides a framework based on Generate Ninja \(GN\) and Ninja. This subsystem allows you to:
- Build products based on different chip platforms. For example, you can build IP camera products on the Hi3518EV300 and Hi3516DV300 development boards and WLAN module–based products on Hi3861 development boards.
- Build a customized product that is generated according to HarmonyOS Package Manager \(HPM\) configurations.
## Basic Concepts<a name="section175012297491"></a>
It is considered best practice to learn the following basic concepts before you start development, compilation, and building:
- **Platform**
A platform is a combination of development boards and kernels.
Supported subsystems and components vary with the platform.
- **Component**
A component is a reusable software unit that contains source code, configuration files, resource files, and compilation scripts.
- **GN**
GN is short for Generate Ninja, which is used to generate Ninja files.
- **Ninja**
Ninja is a small high-speed building system.
## Working Principles<a name="section193961322175011"></a>
The compilation and building processes are as follows:
- **Parsing**: Parse the name of the product to be compiled and the compilation type \(debug or release\).
- **Running GN**: Configure toolchains and global options for the compilation based on the product name and compilation type that have been parsed.
- **Running Ninja**: Start the compilation.
- **Packaging**: Package the component compilation result of the product to create a file system image.
## Limitations and Constraints<a name="section2029921310472"></a>
You must install GN and Ninja and compilation toolchains, and download the complete code.
# Compilation and Building<a name="EN-US_TOPIC_0000001074146280"></a>
- **[Compilation and Building Overview](compilation-and-building-overview.md)**
- **[Compilation and Building Guidelines](compilation-and-building-guidelines.md)**
- **[Compilation and Building FAQ](compilation-and-building-faq.md)**
# Development Example<a name="EN-US_TOPIC_0000001061399563"></a>
For details, see the [example in the open-source project](https://gitee.com/openharmony/aafwk_frameworks_kits_ability_lite/tree/master/example).
# Development Guidelines on the featured Framework<a name="EN-US_TOPIC_0000001062713987"></a>
- [Available APIs](#section20840587473)
- [How to Develop](#section32781532131314)
- [Use Case](#section1210915266154)
The featured framework provides comprehensive DFX features. By default, logs are output to the serial port and the file in **/storage/data/log/** in debug versions.
## Available APIs<a name="section20840587473"></a>
```
HILOG_DEBUG(type, ...)
HILOG_INFO(type, ...)
HILOG_WARN(type, ...)
HILOG_ERROR(type, ...)
HILOG_FATAL(type, ...)
```
**Table 1** Parameters
<a name="table1872515171474"></a>
<table><thead align="left"><tr id="row772491734711"><th class="cellrowborder" valign="top" width="25.05%" id="mcps1.2.3.1.1"><p id="p1272431714477"><a name="p1272431714477"></a><a name="p1272431714477"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="74.95%" id="mcps1.2.3.1.2"><p id="p472451724716"><a name="p472451724716"></a><a name="p472451724716"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row15416155714297"><td class="cellrowborder" valign="top" width="25.05%" headers="mcps1.2.3.1.1 "><p id="p041617572292"><a name="p041617572292"></a><a name="p041617572292"></a>type</p>
</td>
<td class="cellrowborder" valign="top" width="74.95%" headers="mcps1.2.3.1.2 "><p id="p74161557172912"><a name="p74161557172912"></a><a name="p74161557172912"></a>Used for compatibility with the parameters in the mini framework. The featured framework ignores any value passed to this parameter.</p>
</td>
</tr>
<tr id="row19724161794719"><td class="cellrowborder" valign="top" width="25.05%" headers="mcps1.2.3.1.1 "><p id="p1072431724710"><a name="p1072431724710"></a><a name="p1072431724710"></a>domainId</p>
</td>
<td class="cellrowborder" valign="top" width="74.95%" headers="mcps1.2.3.1.2 "><p id="p14724181724719"><a name="p14724181724719"></a><a name="p14724181724719"></a>Domain ID, which is a hidden parameter and needs to be defined</p>
</td>
</tr>
<tr id="row5724131714718"><td class="cellrowborder" valign="top" width="25.05%" headers="mcps1.2.3.1.1 "><p id="p2724191724716"><a name="p2724191724716"></a><a name="p2724191724716"></a>tag</p>
</td>
<td class="cellrowborder" valign="top" width="74.95%" headers="mcps1.2.3.1.2 "><p id="p11724917114715"><a name="p11724917114715"></a><a name="p11724917114715"></a>Log tag, which is a hidden parameter and needs to be defined</p>
</td>
</tr>
<tr id="row137243177475"><td class="cellrowborder" valign="top" width="25.05%" headers="mcps1.2.3.1.1 "><p id="p1772461754718"><a name="p1772461754718"></a><a name="p1772461754718"></a>fmt</p>
</td>
<td class="cellrowborder" valign="top" width="74.95%" headers="mcps1.2.3.1.2 "><p id="p131236352304"><a name="p131236352304"></a><a name="p131236352304"></a>Format specifier</p>
<p id="p2072401710475"><a name="p2072401710475"></a><a name="p2072401710475"></a>Parameters labeled {private} are private data, and those labeled {public} are public data.</p>
</td>
</tr>
<tr id="row11725161719477"><td class="cellrowborder" valign="top" width="25.05%" headers="mcps1.2.3.1.1 "><p id="p172591734710"><a name="p172591734710"></a><a name="p172591734710"></a>args</p>
</td>
<td class="cellrowborder" valign="top" width="74.95%" headers="mcps1.2.3.1.2 "><p id="p8725617194715"><a name="p8725617194715"></a><a name="p8725617194715"></a>Parameters to be displayed using the format specifier.</p>
</td>
</tr>
</tbody>
</table>
Privacy rules \(only for logs in release mode\):
1. The format specifier is labeled \{public\} by default.
```
HILOG_INFO(0, "Hello World\n"); >> Hello World
```
2. The formatted parameter is labeled \{private\} by default.
```
HILOG_INFO(0, "Age is %d\n", 10); >> Age is <private>
```
3. Parameters labeled %\{private\} are private data.
```
HILOG_INFO(0, "Age is %{private}d\n", 10); >> Age is <private>
```
4. Parameters labeled %\{public\} are public data.
```
HILOG_INFO(0, "Age is %{public}d\n", 10); >>Age is 10
```
## How to Develop<a name="section32781532131314"></a>
1. Include the dynamic library dependencies in the **Build.gn** file.
```
public_deps = [ "//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared"]
```
2. Add the **log.h** header file to define the **TAG** and **Domain** values for the module.
```
#include<log.h>
#undef LOG_TAG
#undef LOG_DOMAIN
#define LOG_TAG "MyModule"
#define LOG_DOMAIN 0xD00000
```
3. Run the log printing code.
```
HILOG_INFO(0,"Hello World\n");
```
## Use Case<a name="section1210915266154"></a>
The following steps describe how the **samgr\_lite** module \(an example\) uses the featured framework.
1. Reference the **hilog** header file and dependency library by using dependency statements in **foundation/distributedschedule/services/samgr\_lite/samgr/source/BUILD.gn** in the source code path.
```
public_deps = [ "//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared" ]
```
2. Reference the header file in the source code file and call the **HILOG** function.
Refer to the following source code file **distributedschedule/services/samgr\_lite/samgr\_server/source/samgr\_server.c**.
```
#include<log.h>
#undef LOG_TAG
#undef LOG_DOMAIN
#define LOG_TAG "Samgr"
#define LOG_DOMAIN 0xD001800
static void InitializeRegistry(void)
{
HILOG_INFO(HILOG_MODULE_SAMGR, "Initialize Registry!");
...
}
```
As shown in the file, the header file <log.h\> or <hilog/log.h\> is included, and the domain ID and tag \(Samgr\) are added.
3. Call the **InitializeRegistry** function to print the log content, including the date, PID \(**6**\), task ID \(**23**\), level \(**I**\), domain ID \(**01800**, the least five bits of the defined value **0xD001800**\), module name \(**Samgr**\), and statement \(**Initialize Registry!**\).
**Figure 1** Information printed during system startup<a name="fig418242621511"></a>
![](figures/information-printed-during-system-startup.png "information-printed-during-system-startup")
此差异已折叠。
此差异已折叠。
# DFX<a name="EN-US_TOPIC_0000001073655967"></a>
- **[DFX](dfx-3.md)**
- **[Development Guidelines on the mini Framework](development-guidelines-on-the-mini-framework.md)**
- **[Development Guidelines on the featured Framework](development-guidelines-on-the-featured-framework.md)**
- **[FAQ](faq-4.md)**
- **[Reference](reference.md)**
# FAQ<a name="EN-US_TOPIC_0000001062423639"></a>
N/A
# FAQ<a name="EN-US_TOPIC_0000001061877724"></a>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册