diff --git a/Readme-CN.md b/Readme-CN.md index 791d8dd8f72051d02028d185aee5353e9c23d838..9a0db53aff3625f7029455ba4cd3fcb9cb75df39 100755 --- a/Readme-CN.md +++ b/Readme-CN.md @@ -9,10 +9,11 @@ - quick-start:[快速入门](quick-start/Readme-CN.md) - get-code:[获取源码/获取工具](get-code/Readme-CN.md) - docker:[Docker镜像构建](docker/README.md) -- driver:[驱动](driver/Readme-CN.md) - kernel:[内核](kernel/Readme-CN.md) +- driver:[驱动](driver/Readme-CN.md) - subsystems:[子系统](subsystems/Readme-CN.md) - bundles:[组件开发](bundles/Readme-CN.md) +- porting:[三方库移植](porting/Readme-CN.md) - guide:[设备开发](guide/Readme-CN.md) - security:[安全](security/Readme-CN.md) - api-LinkIoT:[联接类模组API](api/api-LinkIoT/Readme-CN.md) diff --git "a/bundles/HPM\344\273\213\347\273\215.md" "b/bundles/HPM\344\273\213\347\273\215.md" new file mode 100644 index 0000000000000000000000000000000000000000..9b4daa91976492a0019ef831252eb38202ef0756 --- /dev/null +++ "b/bundles/HPM\344\273\213\347\273\215.md" @@ -0,0 +1,4 @@ +# HPM介绍 + +随着OpenHarmony正式开源,HPM包管理器也应运而生。HPM全称HarmonyOS Package Manager,是OpenHarmony组件包的管理和分发工具。HPM主要是面向设备开发者,用于获取/定制OpenHarmony源码,执行安装、编译、打包、升级等操作的工具集。本文档将向开发者介绍如何使用HPM工具进行OpenHarmony组件的安装、编译、打包等操作。 + diff --git a/bundles/Readme-CN.md b/bundles/Readme-CN.md index 9dd83ddce47aa0b788bc86d0def6d988e0cdbe46..6b1ae76002fff938ab4b3098621a85736b7756c9 100755 --- a/bundles/Readme-CN.md +++ b/bundles/Readme-CN.md @@ -13,3 +13,8 @@ - [准备工作](准备工作.md) - [组件开发](组件开发.md) +- [组件开发示例](组件开发示例.md) + - [HPM介绍](HPM介绍.md) + - [环境准备](环境准备.md) + - [操作实例](操作实例.md) + diff --git "a/bundles/\345\207\206\345\244\207\345\267\245\344\275\234.md" "b/bundles/\345\207\206\345\244\207\345\267\245\344\275\234.md" index 5d27b8dde683b07573805d99057bddc8e1eb3141..4b6484d44f8d6c557c4b82bf4736a4948c416fa4 100755 --- "a/bundles/\345\207\206\345\244\207\345\267\245\344\275\234.md" +++ "b/bundles/\345\207\206\345\244\207\345\267\245\344\275\234.md" @@ -23,9 +23,7 @@ 推荐安装 [Node.js](https://nodejs.org/) 12.x \(包含 npm 6.14.4\)或更高版本 \(推荐 12.13.0+\)。 -2. 通过Node.js自带的npm安装hpm-cli命令行工具。 - - 打开CMD,执行以下命令: +2. 通过Node.js自带的npm安装hpm-cli命令行工具。执行以下命令: ``` npm install -g @ohos/hpm-cli diff --git "a/bundles/\346\223\215\344\275\234\345\256\236\344\276\213.md" "b/bundles/\346\223\215\344\275\234\345\256\236\344\276\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..d49c4267cc6a997708e0018a61fded11f6bdb2bd --- /dev/null +++ "b/bundles/\346\223\215\344\275\234\345\256\236\344\276\213.md" @@ -0,0 +1,54 @@ +# 操作实例 + +环境准备好后,接下来本文以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 目录下会生成编译结果,开发者可以将编译结果烧录到对应的开发板上进行测试。 + diff --git "a/bundles/\347\216\257\345\242\203\345\207\206\345\244\207.md" "b/bundles/\347\216\257\345\242\203\345\207\206\345\244\207.md" new file mode 100644 index 0000000000000000000000000000000000000000..5026c7d085641e1c6e462202b3a2bc45b5df5ca4 --- /dev/null +++ "b/bundles/\347\216\257\345\242\203\345\207\206\345\244\207.md" @@ -0,0 +1,128 @@ +# 环境准备 + +- [linux服务器](#section20979554791) +- [安装Node.js](#section9954105413153) +- [安装HPM](#section15937194904819) +- [安装python环境](#section1621819180417) +- [安装文件打包工具](#section77617165913) +- [安装SCons](#section20558439191516) + +## linux服务器 + +准备一台装有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 + +推荐安装 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 + +通过 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环境 + +需使用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 +``` + +## 安装文件打包工具 + +采用以下命令进行安装: + +``` +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 + +采用下述命令安装SCons: + +``` +sudo apt-get install scons # 推荐SCons版本是3.0.4+ +``` + +>![](public_sys-resources/icon-note.gif) **说明:** +>Hi3861平台需要安装SCons,Hi3518和Hi3516两种平台不需要。 + diff --git "a/bundles/\347\273\204\344\273\266\345\274\200\345\217\221\347\244\272\344\276\213.md" "b/bundles/\347\273\204\344\273\266\345\274\200\345\217\221\347\244\272\344\276\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..790666307815946d134fd2b34e198d0ed8d9cfd7 --- /dev/null +++ "b/bundles/\347\273\204\344\273\266\345\274\200\345\217\221\347\244\272\344\276\213.md" @@ -0,0 +1,9 @@ +# 组件开发示例 + +- **[HPM介绍](HPM介绍.md)** + +- **[环境准备](环境准备.md)** + +- **[操作实例](操作实例.md)** + + diff --git a/docs-en/Readme-EN.md b/docs-en/Readme-EN.md index e1195e54df38a2992e2b9b9734f8d2f841595fe3..ee046ab3e2ff0927ae85ab33ed6d1f43881efb80 100755 --- a/docs-en/Readme-EN.md +++ b/docs-en/Readme-EN.md @@ -1,44 +1,46 @@ -# WELCOME-TO-OPEN-HARMONY -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. -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. +# WELCOME TO OPENHARMONY +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. 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 -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. [中文版本](/Readme-CN.md) ## OpenHarmony Documentation - [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)) -- [Device Development Guidelines](https://gitee.com/openharmony/docs/blob/master/docs-en/driver/Readme-EN.md) +- [Source Code Acquisition/Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.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) -- [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) - [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) - [Glossary](https://gitee.com/openharmony/docs/blob/master/docs-en/term/glossary.md) ## 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 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 -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) - [Tool Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/tool-acquisition.md) ## 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 -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 -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 -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. diff --git a/docs-en/bundles/Readme-EN.md b/docs-en/bundles/Readme-EN.md index 8b17093e4ca85e6ca66d92982cacdf2f2f5adb56..2ae8dc847c778c4cef4a191f56f5d3e107a2d1c7 100755 --- a/docs-en/bundles/Readme-EN.md +++ b/docs-en/bundles/Readme-EN.md @@ -13,3 +13,8 @@ - [Preparations](preparations.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) + diff --git a/docs-en/bundles/development-example.md b/docs-en/bundles/development-example.md new file mode 100644 index 0000000000000000000000000000000000000000..159de560311c2fe03fd03c947fbfa669c060f3fa --- /dev/null +++ b/docs-en/bundles/development-example.md @@ -0,0 +1,54 @@ +# Development Example + +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. + diff --git a/docs-en/bundles/environment-variables.md b/docs-en/bundles/environment-variables.md index 7c8691c438d84a69878d4998f21d0424d95c1dd3..933994a6818205f1a7958390a67876048369f67e 100755 --- a/docs-en/bundles/environment-variables.md +++ b/docs-en/bundles/environment-variables.md @@ -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. -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. ``` { diff --git a/docs-en/bundles/hpm-user-guide.md b/docs-en/bundles/hpm-user-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..cb465847371dc07f1f0c85c97673935185aa11d3 --- /dev/null +++ b/docs-en/bundles/hpm-user-guide.md @@ -0,0 +1,9 @@ +# HPM User Guide + +- **[Introduction](introduction.md)** + +- **[Preparations](preparations-1.md)** + +- **[Development Example](development-example.md)** + + diff --git a/docs-en/bundles/introduction.md b/docs-en/bundles/introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..a4ce85e870790e39e703212351167a84fc652166 --- /dev/null +++ b/docs-en/bundles/introduction.md @@ -0,0 +1,6 @@ +# Introduction + +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. + diff --git a/docs-en/bundles/preparations-1.md b/docs-en/bundles/preparations-1.md new file mode 100644 index 0000000000000000000000000000000000000000..dbf43fb12b2aa0aa798d25a69fe454f6fb41feaf --- /dev/null +++ b/docs-en/bundles/preparations-1.md @@ -0,0 +1,128 @@ +# Preparations + +- [Linux Server](#section20979554791) +- [Node.js](#section9954105413153) +- [HPM](#section15937194904819) +- [Python Environment](#section1621819180417) +- [File Packaging Tool](#section77617165913) +- [SCons](#section20558439191516) + +## Linux Server + +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 + +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 + +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 + +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 + +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 + +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. + diff --git a/docs-en/bundles/preparations.md b/docs-en/bundles/preparations.md index 5b196b0f945641675f6f6c0acdaf0ac5d068bd83..128d436efb84ab787656fc9c9cf1780b8d6e2564 100755 --- a/docs-en/bundles/preparations.md +++ b/docs-en/bundles/preparations.md @@ -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\). -2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. - - Start **cmd.exe** to run the following command: +2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command: ``` npm install -g @ohos/hpm-cli diff --git a/docs-en/get-code/tool-acquisition.md b/docs-en/get-code/tool-acquisition.md index 96926010684830a4477caf83fdfc76433d87d74e..ab4b46ead115a326d658ea7c0666720b0ad02d36 100755 --- a/docs-en/get-code/tool-acquisition.md +++ b/docs-en/get-code/tool-acquisition.md @@ -1,6 +1,10 @@ # Tool Acquisition -- [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) - [Tool Introduction](#section68281728193514) - [Website](#section13785205443514) @@ -10,11 +14,178 @@ - [Website](#section1572093543613) - [Usage Guidelines](#section1125615298385) -## Acquiring Compilation Toolchain +## Using Docker to Prepare the Build Environment + +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 + + + + + + + + + + + + + + +

Compatible Hardware Platform

+

Docker Image Repository

+

Tag

+

Description

+

Hi3861/Hi3516/Hi3518

+

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

+

0.0.2

+

The build environment for the OpenHarmony version has been pre-installed.

+
+ + +### HPM-based Docker + +**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 + +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 + +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

Development Board

@@ -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. - 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\) diff --git a/docs-en/guide/use-case-5.md b/docs-en/guide/use-case-5.md index 8cd8c2cb2932ed61a9fcdb741c1be47b312b0e9d..7dd76f5831a0a088ec79151121933bbdf02c9b85 100644 --- a/docs-en/guide/use-case-5.md +++ b/docs-en/guide/use-case-5.md @@ -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**. - 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:** >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. diff --git a/docs-en/guide/use-case.md b/docs-en/guide/use-case.md index ed5c84bf75250beec8e9ce7ab93084c11307c65a..4f1d7854b7465143fbd18e0ae4bd5859387ee396 100644 --- a/docs-en/guide/use-case.md +++ b/docs-en/guide/use-case.md @@ -1,8 +1,13 @@ # Use Case -- 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**. diff --git a/docs-en/porting/Readme-EN.md b/docs-en/porting/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..a9eadcea2758e5fbce172b1017711ae5dcde1475 --- /dev/null +++ b/docs-en/porting/Readme-EN.md @@ -0,0 +1,7 @@ +# 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) + diff --git a/docs-en/porting/figures/position-for-adding-the-configuration.png b/docs-en/porting/figures/position-for-adding-the-configuration.png new file mode 100644 index 0000000000000000000000000000000000000000..cf8dc4806e599451096fc899724e53a4b10137e9 Binary files /dev/null and b/docs-en/porting/figures/position-for-adding-the-configuration.png differ diff --git a/docs-en/porting/figures/successful-startup-of-openharmony.png b/docs-en/porting/figures/successful-startup-of-openharmony.png new file mode 100644 index 0000000000000000000000000000000000000000..7d0b723345d413067e0142b2035205133c907ab0 Binary files /dev/null and b/docs-en/porting/figures/successful-startup-of-openharmony.png differ diff --git a/docs-en/porting/overview.md b/docs-en/porting/overview.md new file mode 100644 index 0000000000000000000000000000000000000000..00078b050dd7af88932a12380a708465a47fbeae --- /dev/null +++ b/docs-en/porting/overview.md @@ -0,0 +1,4 @@ +# Overview + +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. + diff --git a/docs-en/porting/porting-a-library-built-using-cmake.md b/docs-en/porting/porting-a-library-built-using-cmake.md new file mode 100644 index 0000000000000000000000000000000000000000..29e888b69e26b58982e67e777454d11b14f929ad --- /dev/null +++ b/docs-en/porting/porting-a-library-built-using-cmake.md @@ -0,0 +1,465 @@ +# Porting a Library Built Using CMake + +- [Source Code Acquisition](#section1771132116245) +- [Porting Guidelines](#section9737174410328) +- [Cross-Compilation](#section38205577332) + - [Compilation Reference](#section1088111263418) + - [Cross-Compilation Settings](#section8168182883515) + +- [Library Test](#section6686144293611) +- [Adding the Compiled double-conversion Library to the Project](#section1651053153715) + +The following shows how to port the double-conversion library. + +## Source Code Acquisition + +Acquire the source code of double-conversion from [https://github.com/google/double-conversion](https://github.com/google/double-conversion). The following table lists the directory structure. + +**Table 1** Directory structure of the source code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

double-conversion/cmake/

+

Template used for building with CMake

+

double-conversion/double-conversion/

+

Directory of source files

+

double-conversion/msvc/

+

-

+

double-conversion/test/

+

Source files of the test cases

+

double-conversion/.gitignore

+

-

+

double-conversion/AUTHORS

+

-

+

double-conversion/BUILD

+

-

+

double-conversion/CMakeLists.txt

+

Top-level file used for building with CMake

+

double-conversion/COPYING

+

-

+

double-conversion/Changelog

+

-

+

double-conversion/LICENSE

+

-

+

double-conversion/Makefile

+

-

+

double-conversion/README.md

+

-

+

double-conversion/SConstruct

+

-

+

double-conversion/WORKSPACE

+

-

+
+ +## Porting Guidelines + +Cross-compile the double-conversion library by modifying the toolchain to generate executable files for the OpenHarmony platform and then add these files to the OpenHarmony project by invoking CMake via GN. + +## Cross-Compilation + +### Compilation Reference + +The **README.md** file in the code repository details the procedures for compiling the double-conversion library using CMake as well as the testing methods. This document focuses on the building, compilation, and testing of the library. If you have any questions during library porting, refer to the [README.md](https://github.com/google/double-conversion/blob/master/README.md) file. For porting of other third-party libraries that can be independently built with CMake, you can refer to the compilation guides provided by the libraries. + +### Cross-Compilation Settings + +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. + + Add configuration of the clang toolchains to the top-level file **CMakeLists.txt** listed in [Table 1](#table824211132418). + + ``` + set(CMAKE_CROSSCOMPILING TRUE) + set(CMAKE_SYSTEM_NAME Generic) + set(CMAKE_CXX_COMPILER_ID Clang) + set(CMAKE_TOOLCHAIN_PREFIX llvm-) + # Specify the C compiler (ensure that the path of the toolchain has been added to the PATH environment variable) and its flags. To perform cross-compilation using clang, the --target flag must be specified. + set(CMAKE_C_COMPILER clang) + set(CMAKE_C_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w") + # Specify the C++ compiler (ensure that the path of the toolchain has been added to the PATH environment variable) and its flags. To perform cross-compilation, the --target flag must be specified. + set(CMAKE_CXX_COMPILER clang++) + set(CMAKE_CXX_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w") + # Specify the linker and its flags. --target and --sysroot must be specified. You can specify OHOS_ROOT_PATH via the suffix parameter of the cmake command. + set(MY_LINK_FLAGS "--target=arm-liteos --sysroot=${OHOS_SYSROOT_PATH}") + set(CMAKE_LINKER clang) + set(CMAKE_CXX_LINKER clang++) + set(CMAKE_C_LINKER clang) + set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINKER} ${MY_LINK_FLAGS} -o ") + set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINKER} ${MY_LINK_FLAGS} -o ") + # Specify the path for searching chained libraries. + set(CMAKE_SYSROOT ${OHOS_SYSROOT_PATH}) + ``` + +2. Perform the compilation. + + Run a Linux command to enter the directory \(listed in [Table 1](#table824211132418)\) for storing double-conversion source files and then run the following commands: + + ``` + mkdir build && cd build + cmake .. -DBUILD_TESTING=ON -DOHOS_SYSROOT_PATH="..." + make -j + ``` + + **OHOS\_SYSROOT\_PATH** specifies the absolute path where **sysroot** is located. Taking OpenHarmony for example, set **OHOS\_SYSROOT\_PATH** to the absolute path of **openHarmony/prebuilts/lite/sysroot**. + +3. View the result. + + After step 2 is complete, a static library file and test cases are generated in the **build** directory. + + **Table 2** Directory structure of compiled files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

double-conversion/build/libdouble-conversion.a

+

Static library file

+

double-conversion/build/test/

+

Test cases and CMake cache files

+

double-conversion/build/CMakeCache.txt

+

Cache files during CMake building

+

double-conversion/build/CMakeFiles/

+

-

+

double-conversion/build/cmake_install.cmake

+

-

+

double-conversion/build/CTestTestfile.cmake

+

-

+

double-conversion/build/DartConfiguration.tcl

+

-

+

double-conversion/build/generated/

+

-

+

double-conversion/build/Makefile

+

-

+

double-conversion/build/Testing/

+

-

+
+ + +## Library Test + +1. Set up the OpenHarmony environment. + + Using Hi3518EV300 as an example, compile the OpenHarmony image and burn it to the development board. For details, see [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md). + + The following screen is displayed after a successful login to the OS. + + **Figure 1** Successful startup of OpenHarmony + ![](figures/successful-startup-of-openharmony.png "successful-startup-of-openharmony") + +2. Mount the **nfs** directory and put the executable file **cctest** into the **test** directory \(listed in [Table 2](#table1452412391911)\) to the **nfs** directory. +3. Perform the test cases. + + If the double-conversion library is not cross-compiled, you can execute the test cases by running the **make test** command and obtain the result via CMake. However, this command is not applicable to the library after cross-compilation. This way, you can perform the test cases by executing the generated test case files. + + - After the **nfs** directory is successfully mounted, run the following command to list all items in the test cases: + + ``` + cd nfs + ./cctest --list + ``` + + Some items are as follows: + + ``` + test-bignum/Assign< + test-bignum/ShiftLeft< + test-bignum/AddUInt64< + test-bignum/AddBignum< + test-bignum/SubtractBignum< + test-bignum/MultiplyUInt32< + test-bignum/MultiplyUInt64< + test-bignum/MultiplyPowerOfTen< + test-bignum/DivideModuloIntBignum< + test-bignum/Compare< + test-bignum/PlusCompare< + test-bignum/Square< + test-bignum/AssignPowerUInt16< + test-bignum-dtoa/BignumDtoaVariousDoubles< + test-bignum-dtoa/BignumDtoaShortestVariousFloats< + test-bignum-dtoa/BignumDtoaGayShortest< + test-bignum-dtoa/BignumDtoaGayShortestSingle< + test-bignum-dtoa/BignumDtoaGayFixed< + test-bignum-dtoa/BignumDtoaGayPrecision< + test-conversions/DoubleToShortest< + test-conversions/DoubleToShortestSingle< + ... + ``` + + - Run the following command to test **test-bignum**: + + ``` + ./cctest test-bignum + ``` + + The test is passed if the following information is displayed: + + ``` + Ran 13 tests. + ``` + + +## Adding the Compiled double-conversion Library to the OpenHarmony Project + +1. Copy the double-conversion library to the OpenHarmony project. + + Copy this library that can be cross-compiled to the **third\_party** directory of OpenHarmony. To avoid modifying the **BUILD.gn** file in the directory of the third-party library to be ported, add a directory to store adaptation files, including **BUILD.gn**, **build\_thirdparty.py**, and **config.gni**, for converting GN to CMake building. + + **Table 3** Directory structure of the ported library + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

openHarmony/third_party/double-conversion/BUILD.gn

+

GN file for adding the third-party library to the OpenHarmony project

+

openHarmony/third_party/double-conversion/build_thirdpaty.py

+

Script file for GN to call the shell command to convert compilation from GN to CMake.

+

openHarmony/third_party/double-conversion/config.gni

+

Third-party library compilation configuration file, which can be modified to determine whether the test cases will be used during the building

+

openHarmony/third_party/double-conversion/double-conversion/

+

Directory of the third-party library to be ported

+
+ +2. Add the GN file to the CMake adaptation file. + + - The following shows the implementation for building using the newly added **BUILD.gn** file. For other third-party libraries that can be independently compiled using CMake, you only need to change the target paths when porting them to OpenHarmony. + + ``` + import("config.gni") + group("double-conversion") { + if (ohos_build_thirdparty_migrated_from_fuchisa == true) { + deps = [":make"] + } + } + if (ohos_build_thirdparty_migrated_from_fuchisa == true) { + action("make") { + script = "//third_party/double-conversion/build_thirdparty.py" + outputs = ["$root_out_dir/log_dc.txt"] + exec_path = rebase_path(rebase_path("./double-conversion/build", root_build_dir)) + command = "rm * .* -rf && $CMAKE_TOOLS_PATH/cmake .. $CMAKE_FLAG $CMAKE_TOOLCHAIN_FLAG && make -j" + args = [ + "--path=$exec_path", + "--command=${command}" + ] + } + } + ``` + + - The newly added **config.gni** file is used to configure the library in the following example implementation. For other third-party libraries that can be independently compiled using CMake, you only need to change the configuration of **CMAKE\_FLAG** when porting them to OpenHarmony. + + ``` + #CMAKE_FLAG: config compile feature + CMAKE_FLAG = "-DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11" + + #toolchain: follow up-layer, depend on $ohos_build_compiler + if (ohos_build_compiler == "clang") { + CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + } else { + CMAKE_TOOLCHAIN_FLAG = "" + } + + #CMake tools path,no need setting if this path already joined to $PATH. + CMAKE_TOOLS_PATH = "setting CMake tools path..." + ``` + + - The following shows the implementation of the newly added **build\_thirdparty.py** file. For other third-party libraries that can be independently compiled using CMake, you can port them to OpenHarmony without modifications. + + ``` + import os + import sys + from subprocess import Popen + import argparse + import shlex + + def cmd_exec(command): + cmd = shlex.split(command) + proc = Popen(cmd) + proc.wait() + ret_code = proc.returncode + if ret_code != 0: + raise Exception("{} failed, return code is {}".format(cmd, ret_code)) + + def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--path', help='Build path.') + parser.add_argument('--command', help='Build command.') + parser.add_argument('--enable', help='enable python.', nargs='*') + args = parser.parse_args() + + if args.enable: + if args.enable[0] == 'false': + return + + if args.path: + curr_dir = os.getcwd() + os.chdir(args.path) + if args.command: + if '&&' in args.command: + command = args.command.split('&&') + for data in command: + cmd_exec(data) + else: + cmd_exec(args.command) + os.chdir(curr_dir) + + if __name__ == '__main__': + sys.exit(main()) + ``` + + - Add a configuration item in the configuration file to control compiling of the library. By default, library compilation is disabled. + + For example, add the following configuration to the **//build/lite/ohos\_var.gni** file: + + ``` + declare_args() { + ohos_build_thirdparty_migrated_from_fuchisa = false + } + ``` + +3. Add the library to the compiling configuration. + + Add the directory where the library is located to the project compiling configuration. Taking Hi3518EV300 for example, modify the **openHarmony\\build\\lite\\product\\ ipcamera\_hi3518ev300.json** file and add the following configuration to **subsystem**, as shown in [Figure 2](#fig152112412192). + + ``` + { + "name": "double-conversion", + "component": [ + { "name": "double-conversion", "dir": "//third_party/double-conversion:double-conversion", "features":[] } + ] + }, + ``` + + **Figure 2** Position for adding the configuration + ![](figures/position-for-adding-the-configuration.png "position-for-adding-the-configuration") + +4. Build the library. + + - Manual building + + Execute the following command: + + ``` + python build.py ipcamera_hi3518ev300 -T //third_party/double-conversion:double-conversion + ``` + + If the compilation is successful, a static library file and test cases will be generated in the [build](#li15717101715249) directory. + + - Automatic building with the project + + Modify the compiling configuration in the **//build/lite/ohos\_var.gni** file. + + ``` + ohos_build_thirdparty_migrated_from_fuchisa = true + ``` + + Execute the following command: + + ``` + python build.py ipcamera_hi3518ev300 -b debug + ``` + + If the compilation is successful, a static library file and test cases will be generated in the [build](#li15717101715249) directory. + + diff --git a/docs-en/porting/porting-a-library-built-using-makefile.md b/docs-en/porting/porting-a-library-built-using-makefile.md new file mode 100644 index 0000000000000000000000000000000000000000..56441e01016d4e120adeb58532eb4770da2a8178 --- /dev/null +++ b/docs-en/porting/porting-a-library-built-using-makefile.md @@ -0,0 +1,309 @@ +# Porting a Library Built Using Makefile + +- [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 + +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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

yxml/bench/

+

Benchmark-related code

+

yxml/test/

+

Input and output files as well as scripts of the test cases

+

yxml/Makefile

+

File for organizing compilation

+

yxml/.gitattributes

+

-

+

yxml/.gitignore

+

-

+

yxml/COPYING

+

-

+

yxml/yxml.c

+

-

+

yxml/yxml.c.in

+

-

+

yxml/yxml-gen.pl

+

-

+

yxml/yxml.h

+

-

+

yxml/yxml.md

+

-

+

yxml/yxml-states

+

-

+
+ +## Cross-Compilation Settings + +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 + + + + + + + + + + + + + +

Directory

+

Description

+

openHarmony/third_party/yxml/yxml/out/lib/

+

Static library file

+

openHarmony/third_party/yxml/yxml/out/test/

+

Test cases as well as the input and output files

+
+ + +## Library Test + +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 + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

openHarmony/third_party/yxml/yxml/out/test/test.sh

+

Automatic test script, which cannot be used because OpenHarmony does not support automatic script execution. However, you can refer to this script to conduct a manual test.

+

openHarmony/third_party/yxml/yxml/out/test/test

+

Executable file for testing.

+

openHarmony/third_party/yxml/yxml/out/test/*.xml

+

Input test file.

+

openHarmony/third_party/yxml/yxml/out/test/*.out

+

Expected output file.

+
+ +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**: + + ``` + + ``` + +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 + +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 + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

openHarmony/third_party/yxml/BUILD.gn

+

GN file for adding the third-party library to the OpenHarmony project

+

openHarmony/third_party/yxml/build_thirdpaty.py

+

Script file for GN to call the shell command to convert compilation from GN to Makefile.

+

openHarmony/third_party/yxml/config.gni

+

Third-party library compilation configuration file, which can be modified to determine whether the test cases will be used during the building

+

openHarmony/third_party/yxml/yxml/

+

Directory of the third-party library to be ported

+
+ diff --git a/docs-en/porting/public_sys-resources/icon-caution.gif b/docs-en/porting/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-caution.gif differ diff --git a/docs-en/porting/public_sys-resources/icon-danger.gif b/docs-en/porting/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-danger.gif differ diff --git a/docs-en/porting/public_sys-resources/icon-note.gif b/docs-en/porting/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-note.gif differ diff --git a/docs-en/porting/public_sys-resources/icon-notice.gif b/docs-en/porting/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-notice.gif differ diff --git a/docs-en/porting/public_sys-resources/icon-tip.gif b/docs-en/porting/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-tip.gif differ diff --git a/docs-en/porting/public_sys-resources/icon-warning.gif b/docs-en/porting/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/docs-en/porting/public_sys-resources/icon-warning.gif differ diff --git a/docs-en/porting/third-party-library-porting-guide.md b/docs-en/porting/third-party-library-porting-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..6fff8af56f7797c454e3ba797ac695766ba747c4 --- /dev/null +++ b/docs-en/porting/third-party-library-porting-guide.md @@ -0,0 +1,9 @@ +# Third-Party Library Porting Guide + +- **[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)** + + diff --git a/docs-en/quick-start/Readme-EN.md b/docs-en/quick-start/Readme-EN.md index c0561909dc6290d9aef4c5911f7e991830fc3454..b1478bd6eb5216d6c3a72d626e07a0242194a5ee 100755 --- a/docs-en/quick-start/Readme-EN.md +++ b/docs-en/quick-start/Readme-EN.md @@ -2,21 +2,21 @@ - [Hi3861 Development Board](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 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) - [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 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) - [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) - - [FAQs](faqs-3.md) + - [FAQ on Hi3518](faq-on-hi3518.md) diff --git a/docs-en/quick-start/developing-the-first-driver-running-on-hi3516.md b/docs-en/quick-start/developing-the-first-driver-running-on-hi3516.md index 98aadf9add1278c679433739f01c579c44870419..03d4fb6dbb1ffc2e200a4f58d3607b1fa3a6c442 100755 --- a/docs-en/quick-start/developing-the-first-driver-running-on-hi3516.md +++ b/docs-en/quick-start/developing-the-first-driver-running-on-hi3516.md @@ -427,14 +427,14 @@ The following operations take a HDF-based UART driver as an example to show how ## Compiling and Burning -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 1. Connect to a serial port. >![](public_sys-resources/icon-notice.gif) **NOTICE:** - >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faqs-1.md#section14871149155911). + >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 diff --git a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3516.md b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3516.md index bab3c62300beca3f794cbb26e7c280b28ebcadec..28d63f158ed50eb6bd765360fb77edc1c56348b4 100755 --- a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3516.md +++ b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3516.md @@ -2,7 +2,7 @@ - [Acquiring Source Code](#section215953714245) - [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb) -- [Compiling Code](#section1077671315253) +- [Building](#section1077671315253) - [Burning](#section08153912587) - [Running an Image](#section380511712615) - [Running a Program](#section5276734182615) @@ -33,36 +33,38 @@ int main(int argc, char **argv) } ``` -## Compiling Code +## Building -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 ``` +The result files are generated in the **out/ipcamera\_hi3518ev300** directory. + ## Burning The Hi3516 development board allows you to burn flash memory over the USB port, serial port, or network port. The following uses the network port burning as an example. 1. Connect the PC and the target development board through the power port, serial port, and network port. In this section, the Hi3516DV300 is used as an example. For details, please refer to [Introduction to the Hi3516 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_3516-0000001052670587). -2. Open Device Manager, then check and record the serial port number corresponding to the development board. +2. Open Device Manager, then check and record the serial port number corresponding to the development board. >![](public_sys-resources/icon-note.gif) **NOTE:** >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695). - ![](figures/en-us_image_0000001057235010.png) + ![](figures/en-us_image_0000001071792503.png) 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**. ![](figures/网口烧录-1.png) 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. - Set network connection parameters. @@ -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. - **Gateway**: gateway of the development board, which is automatically populated. - **Subnet mask**: subnet mask, which is automatically populated. - - **MAC address of board**: physical address of the development board. + - **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 information about the files to be written according to the following table. The U-Boot file is not supported for programming through the network port. - -

File Name

+ + - - - - - - - - - - - - - -

File Name

Start Address

+

Start Address

File Size

+

File Size

Enable

+

Enable

OHOS_Image.bin

+

OHOS_Image.bin

1M

+

1M

9M

+

9M

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

+

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

rootfs.img

+

rootfs.img

10M

+

10M

15M

+

15M

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

+

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

userfs.img

+

userfs.img

25M

+

25M

50M

+

50M

- ![](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. -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. 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 1. Connect to a serial port. >![](public_sys-resources/icon-notice.gif) **NOTICE:** - >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faqs-1.md#section14871149155911). + >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 diff --git a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md index dbdb960910e1b391e623201045a05af6eb75d248..d6ed76a0de092fbab2f782cad888ccf32de63aa9 100755 --- a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md +++ b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md @@ -2,7 +2,7 @@ - [Acquiring Source Code](#section1726092873119) - [Modifying a Program](#s8efc1952ebfe4d1ea717182e108c29bb) -- [Compiling Code](#section234175193114) +- [Building](#section234175193114) - [Burning](#section57955241588) - [Running an Image](#section62131033183710) - [Follow-up Learning](#section9712145420182) @@ -33,123 +33,125 @@ int main(int argc, char **argv) } ``` -## Compiling Code +## Building -On the Linux server, access the root directory of the source code package and run the following script to compile the source code package. The result files are generated in the **out/ipcamera\_hi3518ev300** directory. +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 compilation environment is installed using a software package, execute the following command to compile source code in the root directory of the source code package. ``` python build.py ipcamera_hi3518ev300 -b debug ``` +The result files are generated in the **out/ipcamera\_hi3518ev300** directory. + ## Burning The USB port is the only burning mode supported by the Hi3518 development board. 1. Connect the PC and the target development board through the serial port and USB port. In this section, the Hi3518EV300 is used as an example. For details, please refer to [Introduction to the Hi3518 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_hi3518-0000001050170473). -2. Open Device Manager, then check and record the serial port number corresponding to the development board. +2. Open Device Manager, then check and record the serial port number corresponding to the development board. >![](public_sys-resources/icon-note.gif) **NOTE:** >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695). - ![](figures/en-us_image_0000001057235010.png) + ![](figures/en-us_image_0000001071792503.png) 3. Go to **Device Tool** \> **Configure** \> **Burn**. On the displayed page, set the programming information. - ![](figures/en-us_image_0000001057194144.png) + ![](figures/en-us_image_0000001071514657.png) 4. Set **Burning Mode** to **usbport**. - ![](figures/en-us_image_0000001057392985.png) + ![](figures/en-us_image_0000001072552464.png) 5. Set the programming parameters. - - Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001057313128_li101031912111518). + - Set **Port number** to the serial port number recorded in [2](#en-us_topic_0000001072392860_li101031912111518). - Retain the default values for the baud rate and data bits, which have been adapted for the development board. - Set the memory type. For the Hi3518 series development boards, the memory type is fixed at SPI NOR. - Set the information about the files to be written according to the following table. - -

File Name

+ + - - - - - - - - - - - - - - - - - -

File Name

Start Address

+

Start Address

File Size

+

File Size

Enable

+

Enable

u-boot-development board name.bin

+

u-boot-development board name.bin

0

+

0

1M

+

1M

Select the check box.

+

Select the check box.

OHOS_Image.bin

+

OHOS_Image.bin

1M

+

1M

6M

+

6M

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

+

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

rootfs.img

+

rootfs.img

7M

+

7M

8M

+

8M

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

+

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

userfs.img

+

userfs.img

15M

+

15M

1M

+

1M

- ![](figures/en-us_image_0000001057952739.png) + ![](figures/en-us_image_0000001071634551.png) 6. When you have done, click **Save** at the bottom to save the settings. -7. Click ![](figures/en-us_image_0000001057311476.png) next to **Burn** to start programming. +7. Click ![](figures/en-us_image_0000001071984309.png) next to **Burn** to start programming. >![](public_sys-resources/icon-note.gif) **NOTE:** - >If this is the first time you program flash memory on the Hi3516 or Hi3518 board, the message "not find the Devices" may be displayed. In this case, follow the steps in [Installing the USB Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/cn/docs/ide/user-guides/usb_driver-0000001058690393) and start programming again. + >If this is the first time you program flash memory on the Hi3516 or Hi3518 board, the message "not find the Devices" may be displayed. In this case, follow the steps in [Installing the USB Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/usb_driver-0000001058690393) and start programming again. - ![](figures/en-us_image_0000001058192356.png) + ![](figures/en-us_image_0000001071904257.png) 8. Restart the development board within 15 seconds. 9. Wait until the programming is complete. If the following information is displayed on the console, it indicates that the programming is successful. ![](figures/usb烧录-6.png) -10. Use the [serial port tool](en-us_topic_0000001057649420.md) to modify the bootcmd and bootargs contents of U-Boot. For details, please refer to [Running an Image on the Hi3518](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_example-0000001051610926#EN-US_TOPIC_0000001053422339__section62131033183710). +10. 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 Hi3518](https://device.harmonyos.com/en/docs/start/introduce/oem_camera_start_example-0000001051610926#EN-US_TOPIC_0000001053422339__section62131033183710). ## Running an Image 1. Connect to a serial port. >![](public_sys-resources/icon-notice.gif) **NOTICE:** - >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faqs-3.md#en-us_topic_0000001053466255_section14871149155911). + >If the connection fails, rectify the fault by referring to [What should I do when no command output is displayed?](faq-on-hi3518.md#en-us_topic_0000001053466255_section14871149155911). **Figure 1** Serial port connection - ![](figures/chuankou1-1.png) + ![](figures/chuankou1-0.png) 1. Click **Serial port** to enable it. 2. Enter the serial port number queried in the "Burning" section \(COM11 is used in this example\) and press **Enter** until **hisillicon** is displayed. - 3. Go to step [2](#l5b42e79a33ea4d35982b78a22913b0b1) if the board is started for the first time or the startup parameters need to be modified; go to step [3](#ld26f18828aa44c36bfa36be150e60e49) otherwise. + 3. Go to [step 2](#li9441185382314) if the board is started for the first time or the startup parameters need to be modified; go to [step 3](#li6442853122312) otherwise. -2. \(Mandatory for the first burning\) Modify the **bootcmd** and **bootargs** parameters of U-boot. This step is a fixed operation and the result can be saved. However, you need to perform the following steps again if U-boot needs to be reburnt. +2. \(Mandatory for the first burning\) Modify the **bootcmd** and **bootargs** parameters of U-boot. This step is a fixed operation and the result can be saved. However, you need to perform the following steps again if U-boot needs to be reburnt. **Table 1** Parameters of the U-boot @@ -191,7 +193,7 @@ The USB port is the only burning mode supported by the Hi3518 development board. >![](public_sys-resources/icon-notice.gif) **NOTICE:** >**go 0x40000000** \(optional\) indicates that the command is fixed in the startup parameters by default and the board automatically starts after it is reset. If you want to manually start the board, press **Enter** in the countdown phase of the U-boot startup to interrupt the automatic startup. -3. If **hisilicon \#** is displayed during the startup, run the **reset** command. After the system automatically starts and **OHOS** is displayed, run the **./bin/camera\_app** command and then press **Enter**. The system is started successfully if information shown in the following figure is displayed. +3. If **hisilicon \#** is displayed during the startup, run the **reset** command. After the system automatically starts and **OHOS** is displayed, run the **./bin/camera\_app** command and then press **Enter**. The system is started successfully if information shown in the following figure is displayed. **Figure 2** Successful system startup and program execution ![](figures/successful-system-startup-and-program-execution.png "successful-system-startup-and-program-execution") diff --git a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3861.md b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3861.md index ca67662bd5bc886cdef4569e5e9ac1727c99e87a..88fa6539990044705f4f6031b954856007362798 100755 --- a/docs-en/quick-start/developing-the-first-example-program-running-on-hi3861.md +++ b/docs-en/quick-start/developing-the-first-example-program-running-on-hi3861.md @@ -1,7 +1,7 @@ # Developing the First Example Program Running on Hi3861 - [Acquiring Source Code](#section1545225464016) -- [Compiling Source Code](#section1736014117148) +- [Building](#section1736014117148) - [Burning Images](#section1610612214150) - [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 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 +## Building -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**. @@ -22,16 +24,16 @@ This section describes how to compile the WLAN module on a Linux server. ![](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 ![](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 + **Figure 3** Running the command on TERMINAL page ![](figures/en-us_image_0000001055040596.png) @@ -41,13 +43,13 @@ This section describes how to compile the WLAN module on a Linux server. **Figure 4** 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 ``` - **Figure 5** Directory for storing compilation files + **Figure 5** Directory for storing the generated files ![](figures/en-us_image_0000001055040654.png) diff --git a/docs-en/quick-start/developing-the-second-example-program-running-on-hi3861.md b/docs-en/quick-start/developing-the-second-example-program-running-on-hi3861.md index 420f628b5f78c5025e24b85678c72f6b9ee67354..09bf79e78e95032c2b92a76d5c0dee27fa1311fa 100755 --- a/docs-en/quick-start/developing-the-second-example-program-running-on-hi3861.md +++ b/docs-en/quick-start/developing-the-second-example-program-running-on-hi3861.md @@ -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. -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. ``` @@ -133,7 +133,7 @@ To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is 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) diff --git a/docs-en/quick-start/faq-on-hi3516.md b/docs-en/quick-start/faq-on-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..a5b5b8938da3c98a030fcde32ceaeb45280cd28a --- /dev/null +++ b/docs-en/quick-start/faq-on-hi3516.md @@ -0,0 +1,172 @@ +# FAQ on Hi3516 + +- [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? + +- **Symptom** + + **Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port. + + **Figure 1** Failed to open the serial port + ![](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 + ![](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 + ![](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 + + + ![](figures/changjian1.png) + + +## What should I do when Windows-based PC failed to be connected to the board? + +- **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 + ![](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 + ![](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 + ![](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 + ![](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 + ![](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? + +- **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? + +- **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? + +- **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 + ![](figures/serial-port-displayed-after-the-u-boot-is-burnt.png "serial-port-displayed-after-the-u-boot-is-burnt") + + diff --git a/docs-en/quick-start/faq-on-hi3518.md b/docs-en/quick-start/faq-on-hi3518.md new file mode 100644 index 0000000000000000000000000000000000000000..1a8ac31f832377ca4f4f67f1614bb6abf53ce1f1 --- /dev/null +++ b/docs-en/quick-start/faq-on-hi3518.md @@ -0,0 +1,174 @@ +# FAQ on Hi3518 + +- [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? + +- **Symptom** + + **Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port. + + **Figure 1** Failed to open the serial port + ![](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 + ![](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 + ![](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 + + + ![](figures/changjian1.png) + + +## What should I do when Windows-based PC failed to be connected to the board? + +- **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 + ![](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 + ![](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 + ![](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 + ![](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 + ![](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? + +- **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? + +- **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? + +- **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) + + diff --git a/docs-en/quick-start/faq-on-hi3861.md b/docs-en/quick-start/faq-on-hi3861.md new file mode 100644 index 0000000000000000000000000000000000000000..f88b70cfa7afa5e3c59b262478e0e43341d96aa5 --- /dev/null +++ b/docs-en/quick-start/faq-on-hi3861.md @@ -0,0 +1,286 @@ +# FAQ on Hi3861 + +- [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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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? + +- **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**. + + diff --git a/docs-en/quick-start/figures/chuankou1-0.png b/docs-en/quick-start/figures/chuankou1-0.png new file mode 100644 index 0000000000000000000000000000000000000000..485cb3054c0c08edd6738256f27ad629ce65e1d7 Binary files /dev/null and b/docs-en/quick-start/figures/chuankou1-0.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001058719409.png b/docs-en/quick-start/figures/en-us_image_0000001058719409.png new file mode 100644 index 0000000000000000000000000000000000000000..ad4fd618860ca9f79e9bdc39436c3b2f9cdb72de Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001058719409.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071514639.png b/docs-en/quick-start/figures/en-us_image_0000001071514639.png new file mode 100644 index 0000000000000000000000000000000000000000..381c3db41d6ef82b7074a5c9bcdfb3ad82795fb9 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071514639.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071514657.png b/docs-en/quick-start/figures/en-us_image_0000001071514657.png new file mode 100644 index 0000000000000000000000000000000000000000..5df511ab77558fa4acaa3f990190fc0ff6d9034e Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071514657.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071634537.png b/docs-en/quick-start/figures/en-us_image_0000001071634537.png new file mode 100644 index 0000000000000000000000000000000000000000..92e17f1fa91594ad5df1a07aa1bcfaf509480784 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071634537.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071634551.png b/docs-en/quick-start/figures/en-us_image_0000001071634551.png new file mode 100644 index 0000000000000000000000000000000000000000..727cdebbdf5ada0098243d7e253c4b2be11b688d Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071634551.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071792503.png b/docs-en/quick-start/figures/en-us_image_0000001071792503.png new file mode 100644 index 0000000000000000000000000000000000000000..09f33e3992c0c1d78713eea949e4b9a19f5802ec Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071792503.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071904255.png b/docs-en/quick-start/figures/en-us_image_0000001071904255.png new file mode 100644 index 0000000000000000000000000000000000000000..a8042b42e6a08be77279791dd16d3a8883b85759 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071904255.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071904257.png b/docs-en/quick-start/figures/en-us_image_0000001071904257.png new file mode 100644 index 0000000000000000000000000000000000000000..92e17f1fa91594ad5df1a07aa1bcfaf509480784 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071904257.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071984309.png b/docs-en/quick-start/figures/en-us_image_0000001071984309.png new file mode 100644 index 0000000000000000000000000000000000000000..6d3b3e755e0cb412c67d232c84823423a7e7b0a6 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071984309.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001071984311.png b/docs-en/quick-start/figures/en-us_image_0000001071984311.png new file mode 100644 index 0000000000000000000000000000000000000000..6237ab89e03d496aa9ce4b043a7bd05c37f79b36 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001071984311.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001072074632.png b/docs-en/quick-start/figures/en-us_image_0000001072074632.png new file mode 100644 index 0000000000000000000000000000000000000000..6d3b3e755e0cb412c67d232c84823423a7e7b0a6 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001072074632.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001072552464.png b/docs-en/quick-start/figures/en-us_image_0000001072552464.png new file mode 100644 index 0000000000000000000000000000000000000000..97166251067bd31ba7b1af39d35f9af86af088d1 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001072552464.png differ diff --git a/docs-en/quick-start/figures/en-us_image_0000001072552472.png b/docs-en/quick-start/figures/en-us_image_0000001072552472.png new file mode 100644 index 0000000000000000000000000000000000000000..41d999023ac3a293da559e18c204abe156a19206 Binary files /dev/null and b/docs-en/quick-start/figures/en-us_image_0000001072552472.png differ diff --git a/docs-en/quick-start/figures/hardware-connections.png b/docs-en/quick-start/figures/hardware-connections.png index 22717eff5b2344229a230d2d4fb1aa7f0dd489bb..b5dfc506b818515555959aa29a297185d816ff0b 100755 Binary files a/docs-en/quick-start/figures/hardware-connections.png and b/docs-en/quick-start/figures/hardware-connections.png differ diff --git a/docs-en/quick-start/hi3516-development-board.md b/docs-en/quick-start/hi3516-development-board.md index 84a7c72ea89a19d2bf4da280d60d8769c1fdc760..6b29f1525867ab156e4b8f53187f80bc7da8b1e0 100755 --- a/docs-en/quick-start/hi3516-development-board.md +++ b/docs-en/quick-start/hi3516-development-board.md @@ -2,12 +2,12 @@ - **[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 Driver Running on Hi3516](developing-the-first-driver-running-on-hi3516.md)** -- **[FAQs](faqs-1.md)** +- **[FAQ on Hi3516](faq-on-hi3516.md)** diff --git a/docs-en/quick-start/hi3518-development-board.md b/docs-en/quick-start/hi3518-development-board.md index 7f63f4296d23bea5ba036c7ad4253efb503421bf..2a3af060b4cca7fa7d5631a65074563cad31182d 100755 --- a/docs-en/quick-start/hi3518-development-board.md +++ b/docs-en/quick-start/hi3518-development-board.md @@ -2,10 +2,10 @@ - **[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)** -- **[FAQs](faqs-3.md)** +- **[FAQ on Hi3518](faq-on-hi3518.md)** diff --git a/docs-en/quick-start/hi3861-development-board.md b/docs-en/quick-start/hi3861-development-board.md index d15394265de7845d8adfc4b27cdb4c8352581353..1bd27bdb116e0c164991c37c75da442ddd947f43 100755 --- a/docs-en/quick-start/hi3861-development-board.md +++ b/docs-en/quick-start/hi3861-development-board.md @@ -2,12 +2,12 @@ - **[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 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)** diff --git a/docs-en/quick-start/setting-up-the-hi3516-development-environment.md b/docs-en/quick-start/setting-up-the-hi3516-development-environment.md new file mode 100644 index 0000000000000000000000000000000000000000..0ecb68e52b9a59af5824240e273401abbe989975 --- /dev/null +++ b/docs-en/quick-start/setting-up-the-hi3516-development-environment.md @@ -0,0 +1,572 @@ +# Setting Up the Hi3516 Development Environment + +- [Environment Requirements](#section179175261196) + - [Hardware Requirements](#section5840424125014) + - [Software Requirements](#section965634210501) + - [Build Tools for Linux](#section7786130185118) + - [Development Tools for Windows](#section939920316515) + +- [Using Docker to Install the Linux Environment](#section748632362420) +- [Installing the Linux Environment Using an Installation Package](#section182916865219) + - [Connecting to a Linux Server](#section14371161220386) + - [Changing Linux Shell to Bash](#section77681442174413) + - [Installing a Python Environment](#section126442079459) + - [Installing a File Packing Tool](#section8352161417450) + - [Installing gn](#section16725103716357) + - [Installing ninja](#section18469114293513) + - [Installing LLVM](#section18344103584516) + - [Installing hc-gen](#section2075110583451) + - [Installing the JVM](#section101989994613) + - [Installing the HAP Packing Tool](#section14507022124614) + - [Installing the HAP Signature Tool](#section15236123816464) + +- [Installing a Windows Development Environment](#section1995840162515) + +## Environment Requirements + +### Hardware Requirements + +- Linux server +- Windows workstation \(host computer\) +- Hi3516DV300 IoT camera development board +- USB-to-serial cable and network cable \(The Windows workstation is connected to Hi3516DV300 development board through the USB-to-serial cable and network cable.\) + +The following figure shows the hardware connections. + +**Figure 1** Hardware connections + + +![](figures/矩形备份-292.png) + +### Software Requirements + +**Table 1** Platforms required for the Hi3516DV300 development board + + + + + + + + + + + + + + + + + + + + + +

Hardware

+

Software

+

Description

+

Remarks

+

Linux compile server

+

Operating system

+

Ubuntu 16.04 64-bit or later is used for the Linux OS, and bash is used as the shell.

+
NOTE:

Common software such as samba and vim is installed in the OS by default. Adaptation is required to support Linux file sharing.

+
+

You can develop programs on the Windows workstation or on the Linux server through remote login.

+

Windows workstation

+

Operating system

+

Windows XP/Windows7/Windows10

+

USB-to-Serial adapter driver

+

http://www.hihope.org/download/AllDocuments

+

Driver name: USB-to-Serial Comm Port.exe

+
+ +### Build Tools for Linux + +The following table describes the tools required for setting up the general environment for a Linux server and how to obtain these tools. + +**Table 2** Development tools and obtaining methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

Python3.7+

+

Runs the compilation scripts.

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

bash

+

Executes commands.

+

Internet

+

gn

+

Generates ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

Executes ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+

LLVM

+

Functions as the compiler toolchain.

+

https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar

+

hc-gen

+

Configures and compiles files.

+

https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar

+

IPOP, PuTTY, or other HyperTerminal software

+

Connects to the Linux server (choose one of the terminals).

+

Internet (for example, https://www.putty.org/)

+

Java virtual machine (JVM)

+

Compiles, debugs, and runs Java programs.

+

apt-get install

+

hmos_app_packing_tool

+

HAP packing tool

+

https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar

+

hapsigntool

+

HAP signature tool

+

https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar

+
+ +### Development Tools for Windows + +**Table 3** Development tools for the Windows workstation + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

Visual Studio Code

+

Edits codes.

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

Functions as the integrated development environment (IDE) to provide code compilation, burning, and debugging. C and C++ languages are supported.

+
NOTE:

HUAWEI DevEco Device Tool is a one-stop IDE provided by OpenHarmony for smart device developers. You can customize OpenHarmony components on it as required, HUAWEI DevEco Device Tool is deployed on Visual Studio Code as a plug-in.

+
+

https://device.harmonyos.com/en/ide

+
+ +## Using Docker to Install the Linux Environment + +You can use Docker to quickly install the Linux environment. For details, see **Setting Up the Docker Environment** in [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). + +## Installing the Linux Environment Using an Installation Package + +>![](public_sys-resources/icon-notice.gif) **NOTICE:** +>- If you acquire the source code using an HPM component or HPM CLI tool, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** are not required. +>- \(Recommended\) If you obtain the source code through an image site or a code repository, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** need to be installed. When installing **gn**, **ninja**, **LLVM**, and **hc-gen**, ensure that the environment variable paths of the compilation tools are unique. + +### Connecting to a Linux Server + +Using PuTTY to log in to a Linux server from a PC running Windows + +1. Open [PuTTY](https://www.putty.org/), enter the IP address of the Linux server, and click **Open**. + + **Figure 2** PuTTY configuration + ![](figures/putty-configuration.png "putty-configuration") + +2. Click **Yes** in the PuTTY **Security Alert** dialog box. +3. Enter the account and password. + + **Figure 3** Login + ![](figures/login.png "login") + +4. The login is successful. + + **Figure 4** Successful login + ![](figures/successful-login.png "successful-login") + + +### Changing Linux Shell to Bash + +Check whether bash is used as the shell. + +``` +ls -l /bin/sh +``` + +If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. + +**Method 1:** Run the following command on the device and then click **No**. + +``` +sudo dpkg-reconfigure dash +``` + +**Method 2:** Run the first command to delete sh and then run the second command to create a new soft link. + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### Installing a Python Environment + +1. Start a Linux server. +2. Check the Python version \(Python 3.7 or later is required\). + + ``` + python3 --version + ``` + + If the Python version is earlier than 3.7, reinstall a later Python version \(for example, Python 3.8\) as follows: + + 1. Check the Ubuntu version. + + ``` + cat /etc/issue + ``` + + 1. Install Python based on the Ubuntu version. + - If the Ubuntu version is 18 or later, run the following command: + + ``` + sudo apt-get install python3.8 + ``` + + - If the Ubuntu version is 16, download the installation package and install Python. + + 1. Install Python environment dependencies \(gcc, g++, make, zlib, libffi\). + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. Obtain the [Python3.8.5 installation package](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz), save it to the Linux server, and run the following command: + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. After Python is installed, link the Python path to **/usr/bin/python**. + + Check whether Python is soft linked to Python 3.8. + + ``` + python --version + ``` + + If the command output is not **python 3.8.5**, run the following command to check the directory where Python 3.8 is stored: + + ``` + which python3.8 + ``` + + Replace **python3.8-path** in the following command with the output path of the **which python3.8** command. + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: + - **Command line:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **Installation package:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. Install setuptools. + + ``` + pip3 install setuptools + ``` + +6. Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later. + - **Command line:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **Installation package:** + 1. Download the **.whl** file \(for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**\). + + Download path: [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files) + + + 1. Install the **.whl** file. + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + + +### Installing a File Packing Tool + +1. Start a Linux server. +2. Install **dosfstools**. + + ``` + sudo apt-get install dosfstools + ``` + +3. Install **mtools**. + + ``` + sudo apt-get install mtools + ``` + +4. Install **mtd-utils**. + + ``` + sudo apt-get install mtd-utils + ``` + + +### Installing gn + +1. Start a Linux server. +2. Download [gn](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar). +3. Decompress the gn installation package to **\~/gn**. + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/gn:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing ninja + +1. Start a Linux server. +2. Download [ninja](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar). +3. Decompress the ninja installation package to **\~/ninja**. + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/ninja:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing LLVM + +1. Start a Linux server. +2. Download [LLVM](http://tools.harmonyos.com/mirrors/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar). +3. Decompress the LLVM installation package to **\~/llvm**. + + ``` + tar -xvf llvm-linux-9.0.0-34042.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing hc-gen + +1. Start a Linux server. +2. Download [hc-gen](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar). +3. Decompress the hc-gen installation package to **\~/hc-gen** on the Linux server. + + ``` + tar -xvf hc-gen-0.65-linux.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/hc-gen:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing the JVM + +1. Start a Linux server. +2. Install the Java Runtime Environment \(JRE\). + + ``` + sudo apt-get install default-jre + ``` + +3. Install the Java Development Kit \(JDK\). + + ``` + sudo apt-get install default-jdk + ``` + + +### Installing the HAP Packing Tool + +The HAP packing tool is used for packing system applications during the compilation of OpenHarmony. To install this tool, perform the following operations: + +1. Start a Linux server. +2. Install the JVM before using the HAP packing tool. +3. [Download the HAP packing tool](https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar). +4. Copy **hmos\_app\_packing\_tool.jar** to the **\~/developtools** directory on the Linux server. +5. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/developtools:$PATH + ``` + +6. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing the HAP Signature Tool + +The HAP signature tool is used for signing system applications that have been packaged during the compilation of OpenHarmony. To install this tool, perform the following operations: + +1. Start a Linux server. +2. [Download the HAP signature tool](https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar). +3. Copy **hapsigntoolv2.jar** to the **\~/developtools** directory on the Linux server. +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/developtools:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +## Installing a Windows Development Environment + +The OpenHarmony IDE Development Tool \(HUAWEI DevEco Device Tool\) integrates the capabilities of terminal tools. For details about how to install the tool, see [Preparations ](https://device.harmonyos.com/en/docs/ide/user-guides/tool_install-0000001050164976)and [Importing and Configuring a Project](https://device.harmonyos.com/en/docs/ide/user-guides/import_project-0000001050164980). + diff --git a/docs-en/quick-start/setting-up-the-hi3518-development-environment.md b/docs-en/quick-start/setting-up-the-hi3518-development-environment.md new file mode 100644 index 0000000000000000000000000000000000000000..0b481f02c982199265e1245f44963736d6c49ec5 --- /dev/null +++ b/docs-en/quick-start/setting-up-the-hi3518-development-environment.md @@ -0,0 +1,479 @@ +# Setting Up the Hi3518 Development Environment + +- [Environment Requirements](#section1724111409282) + - [Hardware Requirements](#section487353718276) + - [Software Requirements](#section44143554278) + - [Build Tools for Linux](#section17315193935817) + - [Development Tools for Windows](#section1897593723017) + +- [Using Docker to Install the Linux Environment](#section4848141175215) +- [Installing the Linux Environment Using an Installation Package](#section8831868501) + - [Connecting to a Linux Server](#section12584112413505) + - [Changing Linux Shell to Bash](#section21811833145019) + - [Installing a Python Environment](#section10807183719500) + - [Installing a File Packing Tool](#section480195453419) + - [Installing gn](#section16725103716357) + - [Installing ninja](#section156834539351) + - [Installing LLVM](#section11739111964114) + - [Installing hc-gen](#section351420104218) + +- [Installing a Windows Development Environment](#section188621583120) + +## Environment Requirements + +### Hardware Requirements + +- Linux server +- Windows workstation \(host computer\) +- Hi3518EV300 IoT camera development board +- USB-to-serial cable and network cable \(The Windows workstation is connected to the Hi3518EV300 development board through the USB-to-serial cable and network cable.\) + + The following figure shows the hardware connections. + + +**Figure 1** Hardware connections +![](figures/hardware-connections.png "hardware-connections") + +### Software Requirements + +**Table 1** Platforms required for the Hi3518EV300 development board + + + + + + + + + + + + + + + + + + + + + +

Hardware

+

Software

+

Description

+

Remarks

+

Linux compile server

+

Operating system

+

Ubuntu 16.04 64-bit or later is used for the Linux OS, and bash is used as the shell.

+
NOTE:

Common software such as samba and vim is installed in the OS by default. Adaptation is required to support Linux file sharing.

+
+

You can develop programs on the Windows workstation or on the Linux server through remote login.

+

Windows workstation

+

+

Operating system

+

Windows XP/Windows7/Windows10

+

USB-to-Serial adapter driver

+

http://www.hihope.org/download/AllDocuments

+

Driver name: USB-to-Serial Comm Port.exe

+
+ +### Build Tools for Linux + +The following table describes the tools required for setting up the general environment for a Linux server and how to obtain these tools. + +**Table 2** Development tools and obtaining methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

Python3.7+

+

Runs the compilation scripts.

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

bash

+

Executes commands.

+

Internet

+

gn

+

Generates ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

Executes ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+

LLVM

+

Functions as the compiler toolchain.

+

https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar

+

hc-gen

+

Configures and compiles files.

+

https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar

+

IPOP, PuTTY, or HyperTerminal

+

Connects to the Linux server (choose one of the terminals).

+

Public internet (for example, https://www.putty.org/)

+
+ +### Development Tools for Windows + +**Table 3** Development tools for the Windows workstation + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

Visual Studio Code

+

Edits codes.

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

Functions as the integrated development environment (IDE) to provide code compilation, burning, and debugging. C and C++ languages are supported.

+
NOTE:

HUAWEI DevEco Device Tool is a one-stop IDE provided by OpenHarmony for smart device developers. You can customize OpenHarmony components on it as required, HUAWEI DevEco Device Tool is deployed on Visual Studio Code as a plug-in.

+
+

https://device.harmonyos.com/en/ide

+
+ +## Using Docker to Install the Linux Environment + +You can use Docker to quickly install the Linux environment. For details, see **Setting Up the Docker Environment** in [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). + +## Installing the Linux Environment Using an Installation Package + +>![](public_sys-resources/icon-notice.gif) **NOTICE:** +>- If you acquire the source code using an HPM component or HPM CLI tool, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** are not required. +>- \(Recommended\) If you obtain the source code through an image site or a code repository, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** need to be installed. When installing **gn**, **ninja**, **LLVM**, and **hc-gen**, ensure that the environment variable paths of the compilation tools are unique. + +### Connecting to a Linux Server + +Using PuTTY to log in to a Linux server from a PC running Windows + +1. Open [PuTTY](https://www.putty.org/), enter the IP address of the Linux server, and click **Open**. + + **Figure 2** PuTTY configuration + ![](figures/putty-configuration.png "putty-configuration") + +2. Click **Yes** in the PuTTY **Security Alert** dialog box. +3. Enter the account and password. + + **Figure 3** Login + ![](figures/login.png "login") + +4. The login is successful. + + **Figure 4** Successful login + ![](figures/successful-login.png "successful-login") + + +### Changing Linux Shell to Bash + +Check whether bash is used as the shell. + +``` +ls -l /bin/sh +``` + +If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. + +**Method 1:** Run the following command on the device and then click **No**. + +``` +sudo dpkg-reconfigure dash +``` + +**Method 2:** Run the first command to delete sh and then run the second command to create a new soft link. + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### Installing a Python Environment + +1. Start a Linux server. +2. Check the Python version \(Python 3.7 or later is required\). + + ``` + python3 --version + ``` + + If the Python version is earlier than 3.7, reinstall a later Python version \(for example, Python 3.8\) as follows: + + 1. Check the Ubuntu version. + + ``` + cat /etc/issue + ``` + + 1. Install Python based on the Ubuntu version. + - If the Ubuntu version is 18 or later, run the following command: + + ``` + sudo apt-get install python3.8 + ``` + + - If the Ubuntu version is 16, download the installation package and install Python. + + 1. Install Python environment dependencies \(gcc, g++, make, zlib, libffi\). + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. Obtain the [Python3.8.5 installation package](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz), save it to the Linux server, and run the following command: + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. After Python is installed, link the Python path to **/usr/bin/python**. + + Check whether Python is soft linked to Python 3.8. + + ``` + python --version + ``` + + If the command output is not **python 3.8.5**, run the following command to check the directory where Python 3.8 is stored: + + ``` + which python3.8 + ``` + + Replace **python3.8-path** in the following command with the output path of the **which python3.8** command. + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: + - **Command line:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **Installation package:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. Install setuptools. + + ``` + pip3 install setuptools + ``` + +6. Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later. + - **Command line:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **Installation package:** + 1. Download the **.whl** file \(for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**\). + + Download path: [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files) + + + 1. Install the **.whl** file. + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + + +### Installing a File Packing Tool + +1. Start a Linux server. +2. Install **dosfstools**. + + ``` + sudo apt-get install dosfstools + ``` + +3. Install **mtools**. + + ``` + sudo apt-get install mtools + ``` + +4. Install **mtd-utils**. + + ``` + sudo apt-get install mtd-utils + ``` + + +### Installing gn + +1. Start a Linux server. +2. Download [gn](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar). +3. Decompress the gn installation package to **\~/gn**. + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/gn:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing ninja + +1. Start a Linux server. +2. Download [ninja](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar). +3. Decompress the ninja installation package to **\~/ninja**. + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/ninja:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing LLVM + +1. Start a Linux server. +2. Download [LLVM](http://tools.harmonyos.com/mirrors/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar). +3. Decompress the LLVM installation package to **\~/llvm**. + + ``` + tar -xvf llvm-linux-9.0.0-34042.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing hc-gen + +1. Start a Linux server. +2. Download [hc-gen](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar). +3. Decompress the hc-gen installation package to **\~/hc-gen** on the Linux server. + + ``` + tar -xvf hc-gen-0.65-linux.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/hc-gen:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +## Installing a Windows Development Environment + +The OpenHarmony IDE Development Tool \(HUAWEI DevEco Device Tool\) integrates the capabilities of terminal tools. For details about how to install the tool, see [Preparations ](https://device.harmonyos.com/en/docs/ide/user-guides/tool_install-0000001050164976)and [Importing and Configuring a Project](https://device.harmonyos.com/en/docs/ide/user-guides/import_project-0000001050164980). + diff --git a/docs-en/quick-start/setting-up-the-hi3861-development-environment.md b/docs-en/quick-start/setting-up-the-hi3861-development-environment.md new file mode 100644 index 0000000000000000000000000000000000000000..744f6b1974c41d8f794d0503a49276bada1d0011 --- /dev/null +++ b/docs-en/quick-start/setting-up-the-hi3861-development-environment.md @@ -0,0 +1,602 @@ +# Setting Up the Hi3861 Development Environment + +- [Environment Requirements](#section466851916410) + - [Software Requirements](#section1595725202314) + - [Build Tools for Linux](#section992619473117) + - [Development Tools for Windows](#section2833173411317) + +- [Using Docker to Install the Linux Environment](#section107932281315) +- [Using an Installation Package to install the Linux Environment](#section497484245614) + - [Connecting to a Linux Server](#section1565413132610) + - [Changing Linux Shell to Bash](#section1715027152617) + - [Installing a Python Environment](#section18835251192618) + - [Installing Scons](#section13515123015279) + - [Installing gn](#section0646125972716) + - [Installing ninja](#section7681117192813) + - [Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\)](#section1842910288284) + +- [Installing a Windows Development Environment](#section1995840162515) + +## Environment Requirements + +### Software Requirements + +**Table 1** Requirements on the development platform + + + + + + + + + + + + + + + + + + +

Hardware

+

Software

+

Description

+

Remarks

+

Linux compile server

+

Operating system

+

Ubuntu 16.04 64-bit server or later (Use bash as the shell.)

+

You can develop programs on the Windows workstation or Linux server via a remote login.

+

Windows workstation

+

Operating system

+

Windows XP/Windows7/Windows10

+
+ +### Build Tools for Linux + +The following table describes the tools required for setting up the general environment for a Linux server and how to obtain these tools. + +**Table 2** Development tools and obtaining methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

gcc_riscv32

+

Executes script cross compilation.

+

https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz

+

Python3.7+

+

Executes script compilation.

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

SCons3.0.4+

+

Executes script compilation.

+

Internet

+

bash

+

Executes commands.

+

Internet

+

build-essential

+

Provides basic software package for compilation.

+

Internet

+

gn

+

Generates ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

Executes ninja compilation scripts.

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+
+ +### Development Tools for Windows + +**Table 3** Development tools and obtaining methods + + + + + + + + + + + + + + + + + + + + + + + + +

Development Tool

+

Description

+

How to Obtain

+

Visual Studio Code

+

Edits code.

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

Supports code editing, compilation, burning, and debugging.

+
NOTE:

HUAWEI DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-based smart devices. It supports C and C++ languages and is installed in Visual Studio Code as a plug-in.

+
+

https://device.harmonyos.com/en/ide

+

PuTTY, or other HyperTerminal

+

Remotely connects to a Linux compile server or a serial port.

+

Internet (for example, https://www.putty.org/)

+

CH341SER.EXE

+

Identifies serial port device to transmit data.

+

http://www.wch-ic.com/downloads/CH341SER_EXE.html

+
+ +## Using Docker to Install the Linux Environment + +You can use Docker to quickly install the Linux environment. For details, see **Setting Up the Docker Environment** in [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). + +## Using an Installation Package to install the Linux Environment + +>![](public_sys-resources/icon-notice.gif) **NOTICE:** +>- If you acquire the source code using an HPM component or HPM CLI tool, compilation tools like **gn**, **ninja**, **gcc\_riscv32** are not required. +>- \(Recommended\) If you obtain the source code via the mirror site or code repository, install compilation tools such as **gn**, **ninja**, and **gcc\_riscv32**. +> When installing **gn**, **ninja**, and **gcc\_riscv32**, ensure that the environment variable paths of the compilation tools are unique. + +### Connecting to a Linux Server + +Using PuTTY to log in to a Linux server from a PC running Windows + +1. Open [PuTTY](https://www.putty.org/), enter the IP address of the Linux server, and click **Open**. + + **Figure 1** PuTTY configuration + ![](figures/putty-configuration.png "putty-configuration") + +2. Click **Yes** in the PuTTY **Security Alert** dialog box. +3. Enter the account and password. + + **Figure 2** Login + ![](figures/login.png "login") + +4. The login is successful. + + **Figure 3** Successful login + ![](figures/successful-login.png "successful-login") + + +### Changing Linux Shell to Bash + +Check whether bash is used as the shell. + +``` +ls -l /bin/sh +``` + +If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. + +**Method 1:** Run the following command on the device and then click **No**. + +``` +sudo dpkg-reconfigure dash +``` + +**Method 2:** Run the first command to delete sh and then run the second command to create a new soft link. + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### Installing a Python Environment + +1. Start a Linux server. +2. Check the Python version \(Python 3.7 or later is required\). + + ``` + python3 --version + ``` + + If the Python version is earlier than 3.7, reinstall a later Python version \(for example, Python 3.8\) as follows: + + 1. Check the Ubuntu version. + + ``` + cat /etc/issue + ``` + + 1. Install Python based on the Ubuntu version. + - If the Ubuntu version is 18 or later, run the following command: + + ``` + sudo apt-get install python3.8 + ``` + + - If the Ubuntu version is 16, download the installation package and install Python. + + 1. Install Python environment dependencies \(gcc, g++, make, zlib, libffi\). + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. Obtain the [Python3.8.5 installation package](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz), save it to the Linux server, and run the following command: + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. After Python is installed, link the Python path to **/usr/bin/python**. + + Check whether Python is soft linked to Python 3.8. + + ``` + python --version + ``` + + If the command output is not **python 3.8.5**, run the following command to check the directory where Python 3.8 is stored: + + ``` + which python3.8 + ``` + + Replace **python3.8-path** in the following command with the output path of the **which python3.8** command. + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: + - **Command line:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **Installation package:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. Install setuptools. + + ``` + pip3 install setuptools + ``` + +6. Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later. + - **Command line:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **Installation package:** + 1. Download the **.whl** file \(for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**\). + + Download path: [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files) + + + 1. Install the **.whl** file. + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + +7. Install **pycryptodome** using either of the following methods: + + Install the Python component packages on which the file signature depends, including pycryptodome, six, and ecdsa. As the installation of **ecdsa** depends on that of **six**, install **six** first. + + - **Command line:** + + ``` + sudo pip3 install pycryptodome + ``` + + - **Installation package:** + 1. Download the **.whl** file, for example, **pycryptodome-3.9.9-cp38-cp38-manylinux1\_x86\_64.whl**, from [https://pypi.org/project/pycryptodome/\#files](https://pypi.org/project/pycryptodome/#files). + + 1. Install the **.whl** file. + + ``` + sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl + ``` + + + +8. Install **six** using either of the following methods: + - **Command line:** + + ``` + sudo pip3 install six --upgrade --ignore-installed six + ``` + + + - **Installation package:** + 1. Download the **.whl** file, for example, **six-1.12.0-py2.py3-none-any.whl** from [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files). + + 1. Install the **.whl** file. + + ``` + sudo pip3 install six-1.12.0-py2.py3-none-any.whl + ``` + + + +9. Install **ecdsa** using either of the following methods: + - **Command line:** + + ``` + sudo pip3 install ecdsa + ``` + + - **Installation package:** + 1. Download the **.whl** file, for example, **ecdsa-0.14.1-py2.py3-none-any.whl** from [https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files). + + 1. Install the **.whl** file. + + ``` + sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl + ``` + + + + +### Installing Scons + +1. Start a Linux server. +2. Install the SCons installation package. + + ``` + sudo apt-get install scons -y + ``` + + If the installation package cannot be found in the software source, do as follows: + + 1. Download the source code package from [https://scons.org/pages/download.html](https://scons.org/pages/download.html). The recommended SCons version is 3.0.4 or later. + 2. Decompress the source code package to any directory, for example, scons-3.1.2. + + ``` + tar -xvf scons-3.1.2.tar.gz + ``` + + 3. Go to the source code directory and run the following command to install the source code package: + + ``` + sudo python3 setup.py install + ``` + + +3. Check whether the installation is successful. + + ``` + scons -v + ``` + + **Figure 4** Successful installation + ![](figures/successful-installation.png "successful-installation") + + +### Installing gn + +1. Start a Linux server. +2. Download [gn](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar). +3. Decompress the gn installation package to **\~/gn**. + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/gn:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing ninja + +1. Start a Linux server. +2. Download [ninja](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar). +3. Decompress the ninja installation package to **\~/ninja**. + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=~/ninja:$PATH + ``` + +5. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + + +### Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\) + +>![](public_sys-resources/icon-notice.gif) **NOTICE:** +>The Hi3861 platform supports only the static link of the libgcc library. **The dynamic link is not recommended because version 3 of the GNU General Public License \(GPLv3\) will be polluted during commercial distribution.** + +1. Start a Linux server. +2. Install the **gcc**, **g++**, **bison**, **flex**, **makeinfo** tools to ensure that the toolchain can be correctly compiled. + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install flex bison && sudo apt-get install texinfo + ``` + +3. Download the RISC-V GNU toolchain. + + ``` + git clone --recursive https://github.com/riscv/riscv-gnu-toolchain + ``` + +4. Open the **riscv-gnu-toolchain** folder and delete empty folders to prevent conflicts during the download of **newlib**, **binutils**, and **gcc**. + + ``` + cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc + ``` + +5. Download RISC-V newlib 3.0.0. + + ``` + git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git + ``` + +6. Download RISC-V binutils 2.31.1. + + ``` + git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git + ``` + +7. Download RISC-V gcc 7.3.0. + + ``` + git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc + ``` + +8. Download RISC-V gcc 7.3.0 patches. + + Copy the [89411.patch](https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2) and [86724.patch](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3), modify the line number of the corresponding code, and place the two patches in the **riscv-gcc** directory. + + ``` + cd riscv-gcc && patch -p1 < 89411.patch && patch -p1 < 86724.patch + ``` + + If problems such as **Hunk \#1 FAILED** occur during patch installation, modify the line number in the code pertaining to the patches in the **.c** file. + +9. Download, decompress, and install [GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2). + + ``` + tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install + ``` + +10. Download, decompress, and install [mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz). + + ``` + tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install + ``` + +11. Download, decompress, and install [mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz). + + ``` + tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install + ``` + +12. Open the **riscv-gnu-toolchain** folder and create a directory for toolchain output. + + ``` + cd /opt && mkdir gcc_riscv32 + ``` + +13. Build **bintutils**. + + ``` + mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install + ``` + +14. Build **newlib**. + + ``` + mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install + ``` + +15. Build **gcc**. + + ``` + mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install + ``` + +16. Set an environment variable. + + ``` + vim ~/.bashrc + ``` + + Copy the following command to the last line of the **.bashrc** file, save the file, and exit. + + ``` + export PATH=/opt/gcc_riscv32/bin:$PATH + ``` + +17. Validate the environment variable. + + ``` + source ~/.bashrc + ``` + +18. Enter the following command to check whether the compiler is successfully installed. If the compiler version number is correctly displayed, the installation is successful. + + ``` + riscv32-unknown-elf-gcc -v + ``` + + +## Installing a Windows Development Environment + +The OpenHarmony IDE Development Tool \(HUAWEI DevEco Device Tool\) integrates the capabilities of terminal tools. For details about how to install the tool, see [Preparations ](https://device.harmonyos.com/en/docs/ide/user-guides/tool_install-0000001050164976)and [Importing and Configuring a Project](https://device.harmonyos.com/en/docs/ide/user-guides/import_project-0000001050164980). + diff --git a/docs-en/subsystems/Readme-EN.md b/docs-en/subsystems/Readme-EN.md index 7125410c0a6bd3b9613ed4b319a36f34d6064619..a8765c763961840defafd90f7e62eba6b75c1604 100755 --- a/docs-en/subsystems/Readme-EN.md +++ b/docs-en/subsystems/Readme-EN.md @@ -1,21 +1,46 @@ # Subsystem Development Guidelines - [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 Layout Container Components](development-guidelines-on-layout-container-components.md) - [Development Guidelines on Common Components](development-guidelines-on-common-components.md) - [Development Guidelines on Animators](development-guidelines-on-animators.md) -- [Camera](camera.md) +- [Multimedia](multimedia.md) - [Overview](overview.md) - [Development Guidelines on Photographing](development-guidelines-on-photographing.md) - [Development Guidelines on Video Recording](development-guidelines-on-video-recording.md) - [Development Guidelines on Previewing](development-guidelines-on-previewing.md) - -- [Audio and Video](audio-and-video.md) - - [Overview](overview-0.md) + - [Overview](overview-1.md) - [Development Guidelines on Media Playback](development-guidelines-on-media-playback.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) + diff --git a/docs-en/subsystems/application-framework.md b/docs-en/subsystems/application-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..b7760483618c57cc734e89a6a3dd7a523ed2d218 --- /dev/null +++ b/docs-en/subsystems/application-framework.md @@ -0,0 +1,13 @@ +# Application Framework + +- **[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)** + + diff --git a/docs-en/subsystems/compilation-and-building-faq.md b/docs-en/subsystems/compilation-and-building-faq.md new file mode 100644 index 0000000000000000000000000000000000000000..c4a859572e60572385c3304ece6e4471e5c6bb4b --- /dev/null +++ b/docs-en/subsystems/compilation-and-building-faq.md @@ -0,0 +1,103 @@ +# Compilation and Building FAQ + +- [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 + +- **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 + +- **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 + +- **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 + +- **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 + +- **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 + +- **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** + + diff --git a/docs-en/subsystems/compilation-and-building-guidelines.md b/docs-en/subsystems/compilation-and-building-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..3ddf240946cc227875d096dd0a5690b13ba6ecf4 --- /dev/null +++ b/docs-en/subsystems/compilation-and-building-guidelines.md @@ -0,0 +1,275 @@ +# Compilation and Building Guidelines + +- [Directory Structure](#section56731811102915) +- [Compilation Commands](#section1475192018291) +- [How to Develop](#section4207112818418) + +## Directory Structure + +``` +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 + +- 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 + +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 + + + + + + + + + + + + + + + + + + + + + + + + +

Variable

+

Value Range

+

Description

+

ohos_kernel_type

+

"liteos_a", "liteos_riscv"

+

Kernel type

+

board_name

+

"hi3516dv300", "hi3518ev300", "hi3861v100"

+

Development board

+

ohos_build_compiler

+

"gcc", "clang"

+

Compilation toolchain type

+

ohos_build_type

+

"debug", "release"

+

Compilation type

+
+ + 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 + ``` + + diff --git a/docs-en/subsystems/compilation-and-building-overview.md b/docs-en/subsystems/compilation-and-building-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..8dce6bf3c2867ab726f443fb0aa0b09e8fac996b --- /dev/null +++ b/docs-en/subsystems/compilation-and-building-overview.md @@ -0,0 +1,48 @@ +# Compilation and Building Overview + +- [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 + +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 + +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 + +You must install GN and Ninja and compilation toolchains, and download the complete code. + diff --git a/docs-en/subsystems/compilation-and-building.md b/docs-en/subsystems/compilation-and-building.md new file mode 100644 index 0000000000000000000000000000000000000000..f883f16dd37741c4264f14d8d4c61e9f4ec3bd73 --- /dev/null +++ b/docs-en/subsystems/compilation-and-building.md @@ -0,0 +1,9 @@ +# Compilation and Building + +- **[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)** + + diff --git a/docs-en/subsystems/development-example.md b/docs-en/subsystems/development-example.md new file mode 100644 index 0000000000000000000000000000000000000000..f4b8026e6367aaec9b1c761bc15bbcf5dd057f30 --- /dev/null +++ b/docs-en/subsystems/development-example.md @@ -0,0 +1,4 @@ +# Development Example + +For details, see the [example in the open-source project](https://gitee.com/openharmony/aafwk_frameworks_kits_ability_lite/tree/master/example). + diff --git a/docs-en/subsystems/development-guidelines-on-the-featured-framework.md b/docs-en/subsystems/development-guidelines-on-the-featured-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..2faf21ddf58fce4f3ebaa8e2261589383f69131c --- /dev/null +++ b/docs-en/subsystems/development-guidelines-on-the-featured-framework.md @@ -0,0 +1,145 @@ +# Development Guidelines on the featured Framework + +- [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 + +``` +HILOG_DEBUG(type, ...) +HILOG_INFO(type, ...) +HILOG_WARN(type, ...) +HILOG_ERROR(type, ...) +HILOG_FATAL(type, ...) +``` + +**Table 1** Parameters + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

type

+

Used for compatibility with the parameters in the mini framework. The featured framework ignores any value passed to this parameter.

+

domainId

+

Domain ID, which is a hidden parameter and needs to be defined

+

tag

+

Log tag, which is a hidden parameter and needs to be defined

+

fmt

+

Format specifier

+

Parameters labeled {private} are private data, and those labeled {public} are public data.

+

args

+

Parameters to be displayed using the format specifier.

+
+ +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 + ``` + +3. Parameters labeled %\{private\} are private data. + + ``` + HILOG_INFO(0, "Age is %{private}d\n", 10); >> Age is + ``` + +4. Parameters labeled %\{public\} are public data. + + ``` + HILOG_INFO(0, "Age is %{public}d\n", 10); >>Age is 10 + ``` + + +## How to Develop + +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 + #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 + +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 + + #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 or 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 + ![](figures/information-printed-during-system-startup.png "information-printed-during-system-startup") + + diff --git a/docs-en/subsystems/development-guidelines-on-the-mini-framework.md b/docs-en/subsystems/development-guidelines-on-the-mini-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..61b7386bd1864abef8fc26a08d4265dae97f86ff --- /dev/null +++ b/docs-en/subsystems/development-guidelines-on-the-mini-framework.md @@ -0,0 +1,194 @@ +# Development Guidelines on the mini Framework + +- [Available APIs](#section183731439142417) +- [Use Case](#section153112047155419) + +The mini framework adopts a simple and compact DFX design that provides the logging function. + +## Available APIs + +``` +HILOG_DEBUG(mod, fmt, ...) +HILOG_INFO(mod, fmt, ...) +HILOG_WARN(mod, fmt, ...) +HILOG_ERROR(mod, fmt, ...) +HILOG_FATAL(mod, fmt, ...) +``` + +The following table lists parameters of the preceding APIs. + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Mandatory

+

Data Type

+

Description

+

mod

+

Yes

+

uint8

+

Module or service ID.

+

IDs are planned and assigned in a unified manner. A maximum of 64 IDs are supported. Third-party applications use HILOG_MODULE_APP as their module ID.

+

fmt

+

Yes

+

char *

+

Format specifier for output.

+
  1. A maximum of six variable parameters are supported. %s is not supported.
  2. The maximum length of a formatted log record is 128 bytes. If the maximum length is exceeded, the log cannot be printed.
+

Variable parameters

+

No

+

int32

+

Only numeric types are supported. A maximum of six variable parameters are allowed.

+
+ +1. Add the module ID. + + Define **HILOG\_MODULE\_A** in **HiLogModuleType** of **interfaces/kits/hilog\_lite/hiview\_log.h**. + + ``` + typedef enum { + /** DFX */ + HILOG_MODULE_HIVIEW = 0, + /** System Module A */ + HILOG_MODULE_A, + /** Maximum number of modules */ + HILOG_MODULE_MAX + } HiLogModuleType; + ``` + +2. Register the module. + + Add the following code during the module initialization to register the module with the logging framework: + + ``` + HiLogRegisterModule(HILOG_MODULE_A, "A"); + ``` + +3. Modify the static configuration of the DFX framework. + + Modify **g\_hiviewConfig** in the following file as required. By default, modification is not required and logs are output to the serial port. + + ``` + utils/lite/hiview_config.c + ``` + + + + + + + + + + + + + + + + + + + + + + +

Configuration Item

+

Description

+

outputOption

+

Log output mode. The value can be:

+
  • OUTPUT_OPTION_DEBUG: Logs are directly output to the serial port without cross-task scheduling. This value is used only for temporary debugging.
  • OUTPUT_OPTION_FLOW (default value): Logs are output as data flow to the serial port.
  • OUTPUT_OPTION_TEXT_FILE: Logs are output as text files.
+

level

+

Log level for output. Only the logs whose levels are higher than or equal to the level specified by this parameter can be output. The value can be:

+
  • HILOG_LV_DEBUG (default value)
  • HILOG_LV_INFO
  • HILOG_LV_WARN
  • HILOG_LV_ERROR
  • HILOG_LV_FATAL
+

logSwitch

+

Logging switch. This switch is turned on by default. The log component can be successfully initialized even if this switch is turned off before compilation. The value can be:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+

dumpSwitch

+

Dumping switch. This switch is turned off by default. If the default setting is retained before compilation, the DUMP component will not be initialized. The value can be:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+

eventSwitch

+

Event output switch. This switch is turned off by default. If the default setting is retained before compilation, the Event component will not be initialized. The value can be:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+
+ +4. Add the header file dependencies to the **Build.gn** file of the module. + + ``` + include_dirs = [ + "//base/hiviewdfx/interfaces/kits/hilog_lite", + ] + ``` + +5. Print logs. + + Add **\#include "log.h"** in the .c file where logs need to be printed, and then call the following function: + + ``` + HILOG_DEBUG(HILOG_MODULE_A, "log test: %d", 88); + ``` + + +## Use Case + +The following steps describe how the **samgr\_lite** module \(an example\) uses the mini framework. + +1. Add the module ID, and define **HILOG\_MODULE\_SAMGR** in the type definition structure in **base/hiviewdfx/interfaces/kits/hilog\_lite/hiview\_log.h**. + + ``` + typedef enum { + ... + HILOG_MODULE_SAMGR, + ... + } HiLogModuleType; + ``` + +2. Register the module. Specifically, add the registration code in **HiLogInit** of **base/hiviewdfx/frameworks/hilog\_lite/mini/hiview\_log.c**. + + ``` + HiLogRegisterModule(HILOG_MODULE_SAMGR, "SAMGR"); + ``` + +3. Include the header file dependencies in the **foundation/distributedschedule/services/samgr\_lite/samgr/source/BUILD.gn** file. + + ``` + include_dirs = [ + "//base/hiviewdfx/interfaces/kits/hilog_lite", + ] + ``` + +4. Reference the header file in the source code file **foundation/distributedschedule/services/samgr\_lite/samgr/source/message.c** and call the related functions. + + ``` + #include + uint32 *SAMGR_SendSharedRequest(const Identity *identity, const Request *request, uint32 *token, Handler handler) + { + ... + if (err != EC_SUCCESS) { + HILOG_ERROR(HILOG_MODULE_SAMGR, "SharedSend [%p] failed(%d)!", identity->queueId, err); + (void)FreeReference(&exchange); + } + ... + } + ``` + + diff --git a/docs-en/subsystems/development-guidelines.md b/docs-en/subsystems/development-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..c86bd7b452bef75e1eeac280e801d80e36ed0d7f --- /dev/null +++ b/docs-en/subsystems/development-guidelines.md @@ -0,0 +1,711 @@ +# Development Guidelines + +- [When to Use](#section93012287133) +- [Available APIs](#section11821047161319) +- [How to Develop](#section10514141679) + - [Creating a Service Ability](#section19921154214315) + - [Development Guidelines on Bundle Management](#section1724016743217) + - [Packing a HAP File](#section171771212328) + + +## When to Use + +- Develop Page abilities for applications that have a UI for human-machine interaction, such as news applications, video players, navigation applications, and payment applications. Most applications we use in our daily lives are such type of applications. + +- Develop Service abilities for applications so that they can run particular services in the background, such as music playing, computing, and navigation services. + +- Pack both Page and Service abilities into HarmonyOS Ability Packages \(HAPs\). All applications must be packed into HAP files before being published to the application market. Once published, users can then download the applications from the application market. + +## Available APIs + +**Table 1** APIs of the ability management framework + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function

+

Description

+

Want *WantParseUri(const char *uri)

+

Converts a specified character string into a Want object.

+

const char *WantToUri(Want want)

+

Converts a specified Want object into a character string.

+

void SetWantElement(Want *want, ElementName element);

+

Sets the element variable for a specified Want object.

+

void SetWantData(Want *want, const void *data, uint16_t dataLength)

+

Sets data to carry in a specified Want object for starting a particular ability.

+

bool SetWantSvcIdentity(Want *want, SvcIdentity sid)

+

Sets the sid member variable for a specified Want object.

+

void ClearWant(Want *want)

+

Clears the memory of a specified Want object.

+

void SetMainRoute(const std::string &entry)

+

Sets the main route for the ability.

+

void SetUIContent(RootView *rootView)

+

Sets the UI layout for the ability.

+

void OnStart(const Want& intent)

+

Called when the ability is started. This callback is invoked to handle transitions between ability lifecycle states.

+

void OnStop()

+

Called when the ability is being destroyed. This callback is invoked to handle transitions between ability lifecycle states.

+

void OnActive(const Want& intent)

+

Called when the ability is visible to users. This callback is invoked to handle transitions between ability lifecycle states.

+

void OnInactive()

+

Called when the ability is invisible to users. This callback is invoked to handle transitions between ability lifecycle states.

+

void OnBackground()

+

Called when the ability is moved to the background. This callback is invoked to handle transitions between ability lifecycle states.

+

const SvcIdentity *OnConnect(const Want &want)

+

Called when the Service ability is connected for the first time.

+

void OnDisconnect(const Want &want);

+

Called when all abilities connected to the Service ability are disconnected.

+

void MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply);

+

Handles a message sent by the client to the Service ability.

+

void Dump(const std::string &extra)

+

Prints ability information to the console.

+

void Present(AbilitySlice *abilitySlice, const Want &want)

+

Presents another ability slice.

+

void Terminate()

+

Destroys the ability slice.

+

void SetUIContent(RootView *rootView)

+

Sets the UI layout for the host ability of the ability slice.

+

void OnStart(const Want& want)

+

Called when the ability slice is started. This callback is invoked to handle transitions between ability slice lifecycle states.

+

void OnStop()

+

Called when the ability slice is being destroyed. This callback is invoked to handle transitions between ability slice lifecycle states.

+

void OnActive(const Want& want)

+

Called when the ability slice is visible to users. This callback is invoked to handle transitions between ability slice lifecycle states.

+

void OnInactive()

+

Called when the ability slice is invisible to users. This callback is invoked to handle transitions between ability slice lifecycle states.

+

void OnBackground()

+

Called when the ability slice is moved to the background. This callback is invoked to handle transitions between ability slice lifecycle states.

+

int StartAbility(const Want &want)

+

Starts an ability based on the specified Want information.

+

int StopAbility(const Want &want)

+

Stops a Service ability based on the specified Want information.

+

int TerminateAbility()

+

Destroys the ability.

+

int ConnectAbility(const Want &want, const IAbilityConnection &conn, void *data);

+

Connects to a Service ability based on the specified Want information.

+

int DisconnectAbility(const IAbilityConnection &conn)

+

Disconnects from a Service ability.

+

const char *GetBundleName()

+

Obtains the bundle name of the application to which the ability belongs.

+

const char *GetSrcPath()

+

Obtains the source code path of the ability.

+

const char *GetDataPath()

+

Obtains the data path of the ability.

+

int StartAbility(const Want *want)

+

Starts an Ability. This function does not need to be used in applications developed based on Ability.

+

int ConnectAbility(const Want *want, const IAbilityConnection *conn, void *data);

+

Connects to a Service ability based on the specified Want information. This function does not need to be used in applications developed based on Ability.

+

int DisconnectAbility(const IAbilityConnection *conn);

+

Disconnects from a Service ability. This function does not need to be used in applications developed based on Ability.

+

int StopAbility(const Want *want)

+

Stops a Service ability based on the specified Want information. This function does not need to be used in applications developed based on Ability.

+

void (*OnAbilityConnectDone)(ElementName *elementName, SvcIdentity *serviceSid, int resultCode, void *data)

+

Called when a client is connected to a Service ability.

+

void (*OnAbilityDisconnectDone)(ElementName *elementName, int resultCode, void *data)

+

Called after all connections to a Service ability are disconnected.

+

void PostTask(const Task& task)

+

Posts a task to an asynchronous thread.

+

void PostQuit()

+

Quits the event loop of the current thread.

+

static AbilityEventHandler* GetCurrentHandler()

+

Obtains the event handler of the current thread.

+

void Run()

+

Starts running the event loop of the current thread.

+

#define REGISTER_AA(className)

+

Registers the class name of an Ability child class.

+

#define REGISTER_AS(className)

+

Registers the class name of an AbilitySlice child class.

+
+ +## How to Develop + +### Creating a Service Ability + +1. Create the **MyServiceAbility** child class from **Ability** in **my\_service\_ability.h**. + + ``` + class MyServiceAbility: public Ability { + protected: + void OnStart(const Want& want); + const SvcIdentity *OnConnect(const Want &want) override; + void MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) override; + }; + ``` + +2. Call the **REGISTER\_AA** macro to register the **ServiceAbility** class with the application framework so that the framework can instantiate the **MyServiceAbility** class you have created. + + ``` + #include "my_service_ability.h" + + REGISTER_AA(ServiceAbility) + + void MyServiceAbility::OnStart(const Want& want) + { + printf("ServiceAbility::OnStart\n"); + Ability::OnStart(want); + } + + const SvcIdentity *MyServiceAbility::OnConnect(const Want &want) + { + printf("ServiceAbility::OnConnect\n"); + return Ability::OnConnect(want); + } + + void MyServiceAbility::MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) + { + printf("ServiceAbility::MsgHandle, funcId is %u\n", funcId); + int result = 0; + if (funcId == 0) { + result = IpcIoPopInt32(request) + IpcIoPopInt32(request); + } + // push data + IpcIoPushInt32(reply, result); + } + ``` + +3. Override the following lifecycle callbacks for Service abilities to implement your own logic for your Service ability. When overriding a lifecycle callback, you must call the corresponding function from the parent class. + - OnStart\(\) + + This callback is invoked when a Service ability is being created to perform Service ability initialization operations that take a short time. This callback is invoked only once in the entire lifecycle of a Service ability. + + ``` + void MyServiceAbility::OnStart(const Want& want) + { + printf("ServiceAbility::OnStart\n"); + Ability::OnStart(want); + } + ``` + + - OnConnect\(\) + + This callback is invoked when another ability is connected to the Service ability. This callback returns an **SvcIdentity** object for the other ability to interact with the Service ability. + + ``` + const SvcIdentity *MyServiceAbility::OnConnect(const Want &want) + { + printf("ServiceAbility::OnConnect\n"); + return Ability::OnConnect(want); + } + ``` + + - OnDisconnect​\(\) + + This callback is invoked when another ability is disconnected from the Service ability. + + - OnStop\(\) + + This callback is invoked when a Service ability is destroyed. You should override this callback for your Service ability to clear its resources, such as threads and registered listeners. + + +4. Override the message handling function. + + The **MsgHandle** function is used by Service abilities to handle messages sent from clients. **funcId** indicates the type of the message sent from the client, and **request** indicates the pointer to the serialized request parameters sent from the client. If you want to send the result back after the message is handled, serialize the result and write it into **reply**. + + ``` + void ServiceAbility::MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) + { + printf("ServiceAbility::MsgHandle, funcId is %d\n", funcId); + int result = 0; + if (funcId == PLUS) { + result = IpcIoPopInt32(request) + IpcIoPopInt32(request); + } + // push data + IpcIoPushInt32(reply, result); + } + ``` + +5. Register a Service ability. + + Declare your Service ability in the **config.json** file by setting its **type** attribute to **service**. + + ``` + "abilities": [{ + "name": "ServiceAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "service", + "visible": true + } + ] + ``` + +6. Start a Service ability. + - The **Ability** class provides the **StartAbility\(\)** function to start another ability. You can pass a **Want** object to this function to start a Service ability. + + You can use the **SetWantElement\(\)** function provided in the **AbilityKit** to set information about the target Service ability to start. The **element** parameter of the **SetWantElement\(\)** function indicates the **ElementName** structure that contains the bundle name and target ability name required for starting an ability. + + ``` + { + Want want = { nullptr }; + ElementName element = { nullptr }; + SetElementBundleName(&element, "com.company.appname"); + SetElementAbilityName(&element, "ServiceAbility"); + SetWantElement(&want, element); + StartAbility(want); + ClearElement(&element); + ClearWant(&want); + } + ``` + + The **StartAbility\(\)** function is executed immediately. If the Service ability is not running while the function is called, the system invokes **OnStart\(\)** first. + + - Stops a Service ability. + + Once created, the Service ability keeps running in the background. You can call **StopAbility\(\)** to stop the Service ability. + + +7. Connect to a Service ability. + - If you need to connect a Service ability to a Page ability or to a Service ability in another application, you should first create a Service ability for connection. A Service ability allows other abilities to connect to it through **ConnectAbility\(\)** by passing a **Want** object that contains information about the target Service ability to the function. You can implement callbacks in **IAbilityConnection** to be invoked when a Service ability is connected or disconnected. The **OnAbilityConnectDone\(\)** callback is invoked when an ability is connected, and **OnAbilityDisconnectDone\(\)** is invoked when an ability is disconnected. + + ``` + { + // Create an IAbilityConnection object and implement the two callbacks. + IAbilityConnection abilityConnection = new IAbilityConnection(); + abilityConnection->OnAbilityConnectDone = OnAbilityConnectDone; + abilityConnection->OnAbilityDisconnectDone = OnAbilityDisconnectDone; + + void OnAbilityConnectDone(ElementName *elementName, SvcIdentity *serviceSid, + int resultCode, void *data) + { + if (resultCode != 0) { + return; + } + // Push data. + IpcIo request; + char dataBuffer[IPC_IO_DATA_MAX]; + IpcIoInit(&request, dataBuffer, IPC_IO_DATA_MAX, 0); + IpcIoPushInt32(&request, 10); + IpcIoPushInt32(&request, 6); + + // Send and receive the reply. + IpcIo reply; + uintptr_t ptr = 0; + if (Transact(nullptr, *serviceSid, 0, &request, &reply, + LITEIPC_FLAG_DEFAULT, &ptr) != LITEIPC_OK) { + printf("transact error\n"); + return; + } + int result = IpcIoPopInt32(&reply); + printf("execute add method, result is %d\n", result); + if (ptr != 0) { + FreeBuffer(nullptr, reinterpret_cast(ptr)); + } + } + + void OnAbilityDisconnectDone(ElementName *elementName, + int resultCode, void *data) + { + printf("elementName is %s, %s\n", + elementName->bundleName, elementName->abilityName); + } + } + ``` + + - The following sample code snippet shows how to initiate ability connection and disconnection: + + ``` + { + // Connect an ability to a specified Service ability. + Want want = { nullptr }; + ElementName element = { nullptr }; + SetElementBundleName(&element, "com.company.appname"); + SetElementAbilityName(&element, "ServiceAbility"); + SetWantElement(&want, element); + ConnectAbility(want, *abilityConnection, this); + + // Disconnect from a Service ability. + DisconnectAbility(*abilityConnection); + } + ``` + + + +### Development Guidelines on Bundle Management + +**Installing an Application** + +The installation API can only be used by built-in system applications. Applications can be installed in either of the following paths: + +- Default installation directory **/storage/app/** in the system +- Particular directory on the external storage, for example, a microSD card + +You can specify the installation path when creating an **InstallParam** instance. To install the application in the **/storage/app/** directory, set the **installLocation** member variable in the **InstallParam** instance to **INSTALL\_LOCATION\_INTERNAL\_ONLY**. To install the application in the **/sdcard/app/** directory of the external storage, set **installLocation** to **INSTALL\_LOCATION\_PREFER\_EXTERNAL**. The application installation process is asynchronous, and a semaphore-like mechanism is required to ensure that the installation callback can be executed. + +The procedure for installing an application is as follows \(the system directory is used as an example\): + +1. Place the signed HAP file in a specified directory. +2. Create an **InstallParam** instance and define the semaphore. + + ``` + InstallParam installParam = { + .installLocation = INSTALL_LOCATION_INTERNAL_ONLY, // Install the application in the system directory. + .keepData = false + }; + static sem_t g_sem; + ``` + +3. Define the callback function. + + ``` + static void InstallCallback(const uint8_t resultCode, const void *resultMessage) + { + std::string strMessage = reinterpret_cast(resultMessage); + if (!strMessage.empty()) { + printf("install resultMessage is %s, %d\n", strMessage.c_str(),resultCode); + } + sem_post(&g_sem); + } + ``` + +4. Call the **Install** function. + + ``` + const uint32_t WAIT_TIMEOUT = 30; + sem_init(&g_sem, 0, 0); + std::string installPath = "/storage/bundle/demo.hap"; // Specify the path where the HAP file is stored. + bool result = Install(installPath.c_str(), &installParam, InstallCallback); + struct timespec ts = {}; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += WAIT_TIMEOUT; // Release the semaphore upon timeout. + sem_timedwait(&g_sem, &ts); + ``` + + +**Uninstalling an Application** + +When uninstalling an application, you can specify whether to retain application data using the **keepData** member variable in the created **InstallParam** instance. If **keepData** is set to **true**, the application data will be retained after the application is uninstalled. If the variable is set to **false**, the application data will be removed during application installation. + +1. Create an **InstallParam** instance and define the semaphore. + + ``` + static sem_t g_sem; + InstallParam installParam = { + .installLocation = 1, + .keepData = false // Remove application data. + }; + ``` + +2. Define the callback function. + + ``` + static void UninstallCallback(const uint8_t resultCode, const void *resultMessage) + { + std::string strMessage = reinterpret_cast(resultMessage); + if (!strMessage.empty()) { + printf("uninstall resultMessage is %s\n", strMessage.c_str()); + g_resultMessage = strMessage; + } + g_resultCode = resultCode; + sem_post(&g_sem); + } + ``` + +3. Call the **Uninstall** function. + + ``` + sem_init(&g_sem, 0, 0); + const uint32_t WAIT_TIMEOUT = 30; + std::string BUNDLE_NAME = "com.huawei.demo"; // Bundle name of the application to be uninstalled + Uninstall(BUNDLE_NAME.c_str(), &installParam, UninstallCallback); + struct timespec ts = {}; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += WAIT_TIMEOUT; + sem_timedwait(&g_sem, &ts); + ``` + + +**Querying Bundle Information About an Installed Application** + +You can use the **GetBundleInfo** function provided by **BundleManager** to query the bundle information about installed applications in the system. + +1. Create and initialize a **BundleInfo** object. + + ``` + BundleInfo bundleInfo; + (void) memset_s(&bundleInfo, sizeof(BundleInfo), 0, sizeof(BundleInfo)); + ``` + +2. Call **GetBundleInfo** to obtain bundle information about a specified application. The **bundleName** parameter indicates the pointer to the application bundle name, and the **flags** parameter specifies whether the obtained **BundleInfo** object can contain **AbilityInfo**. + + ``` + std::string BUNDLE_NAME = "com.huawei.demo"; + uint8_t ret = GetBundleInfo(BUNDLE_NAME.c_str(), 1, &bundleInfo); // When flags is set to 1, the obtained BundleInfo object contains AbilityInfo. + ``` + +3. After you finish using the obtained **BundleInfo** object, clear the memory space occupied by the object in a timely manner to prevent memory leakage. + + ``` + ClearBundleInfo(&bundleInfo); + ``` + + +### Packing a HAP File + +The packing tool is generally integrated into the development tool or IDE, and you rarely have the occasion to use it directly. This section is provided for you to have a general knowledge of the packing tool. The JAR file of the packing tool is stored in the **developtools/packing\_tool/jar** directory of the open-source code. + +- CLI command parameters for packing a HAP file + + **Table 2** Description of resource files required for packing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Command Parameter

+

Resource File

+

Description

+

Initial Value Allowed

+

--mode

+

-

+

This parameter is set to hap for packing the resource files into a HAP file.

+

No

+

--json-path

+

Configuration file config.json

+

-

+

No

+

--resources-path

+

Resource file resources

+

-

+

Yes

+

--assets-path

+

Resource file assets

+

-

+

Yes

+

--lib-path

+

Dependent library file

+

-

+

Yes

+

--shared-libs-path

+

Shared library file

+

The shared library is used by system applications in special cases.

+

Yes

+

--ability-so-path

+

SO file providing main functionality

+

-

+

Yes

+

--index-path

+

Resource index

+

The resource index file is generated by the resource generation tool and integrated by the resource pipeline.

+

Yes

+

--out-path

+

-

+

This parameter indicates the output path of the generated HAP file. The default value is the current directory.

+

Yes

+

--force

+

-

+

This parameter specifies whether to overwrite an existing file with the same name. The default value is false.

+

Yes

+
+ +- Example HAP File Structure + - Development view + + ![](figures/en-us_image_0000001062942690.png) + + - Compilation view + + ![](figures/en-us_image_0000001062334618.png) + + - Run the following commands to pack a HAP file using the packing tool. + + ![](figures/en-us_image_0000001062476933.png) + + ``` + $ java -jar hmos_app_packing_tool.jar --mode hap --json-path ./config.json --assets-path ./assets/ --ability-so-path ./libentry.so --index-path ./resources.index --out-path out/entry.hap --force true + ``` + + + diff --git a/docs-en/subsystems/dfx-3.md b/docs-en/subsystems/dfx-3.md new file mode 100644 index 0000000000000000000000000000000000000000..d373c0b91d6f10d83adfcd4314a51d6a811bbf76 --- /dev/null +++ b/docs-en/subsystems/dfx-3.md @@ -0,0 +1,37 @@ +# DFX + +The design for X \(DFX\) subsystem mainly includes design for reliability \(DFR\) and design for testability \(DFT\), providing code maintenance and testing. + +As chip resources are limited and hardware platforms are diversified, component-based and customizable DFX frameworks are required for different hardware architectures and resources. DFX provides two types of lightweight frameworks, mini and featured, for hardware platforms powered by RISC-V, Cortex-M, and Cortex-A. + +- mini: This framework is intended for hardware platforms with Cortex-M or equivalent processing capabilities. Specifically, the system memory is generally less than 512 KB, and there is only one lightweight file system that can be used in limited scenarios, or no file system at all. The mini framework complies with the Cortex Microcontroller Software Interface Standard \(CMSIS\). Related APIs are called to record logs about user tasks in buffers, and logging APIs are then asynchronously called to print the logs, as illustrated in the following figure. + +**Figure 1** mini framework architecture + + +![](figures/en-us_image_0000001064795436.png) + +- featured: This framework is intended for hardware platforms with Cortex-A or equivalent processing capabilities. Specifically, the system memory is generally greater than 512 KB, and there is a comprehensive file system for storing a large amount of data. The featured framework complies with the Portable Operating System Interface \(POSIX\) specifications. + + **Figure 2** featured framework architecture + + + ![](figures/en-us_image_0000001064187438.png) + + As shown in the figure, logs about the user-space processes or kernel tasks are written into the hilogtask and then stored in the ringbuffer. The user-space hilogcat and apphilogcat processes then output logs to the serial port and performs flushing-to-flash. + + The details are as follows: + + 1. hilogtask: kernel task for logging + - This is a driver of the kernel. It is initialized during system startup. + - Kernel-space or user-space modules call the logging APIs to transfer the formatted log content to the hilogtask and store the content in a ringbuffer. + + 2. apphilogcat: stores logs in user space + - This is a user-space process. It reads the log content from the ringbuffer of the kernel and stores the content in the log file. + + 3. hilogcat: command line tool for viewing logs + + This tool reads the log content in the ringbuffer via the kernel driver API, filters the content if required, and then outputs the content to **stdout**. + + + diff --git a/docs-en/subsystems/dfx.md b/docs-en/subsystems/dfx.md new file mode 100644 index 0000000000000000000000000000000000000000..f0303f2785fb47780577045aa0687e4231fd30d1 --- /dev/null +++ b/docs-en/subsystems/dfx.md @@ -0,0 +1,13 @@ +# DFX + +- **[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)** + + diff --git a/docs-en/subsystems/faq-4.md b/docs-en/subsystems/faq-4.md new file mode 100644 index 0000000000000000000000000000000000000000..9d65ceff0cc013da55581a3a8d487239898ce73d --- /dev/null +++ b/docs-en/subsystems/faq-4.md @@ -0,0 +1,4 @@ +# FAQ + +N/A + diff --git a/docs-en/subsystems/faq.md b/docs-en/subsystems/faq.md new file mode 100644 index 0000000000000000000000000000000000000000..fc755b99468b52f65a359114535bc0d9d632bdc8 --- /dev/null +++ b/docs-en/subsystems/faq.md @@ -0,0 +1,2 @@ +# FAQ + diff --git a/docs-en/subsystems/figures/application-startup-process.png b/docs-en/subsystems/figures/application-startup-process.png new file mode 100644 index 0000000000000000000000000000000000000000..15134bc42ee143386bf40d29d289e8a43e506f3f Binary files /dev/null and b/docs-en/subsystems/figures/application-startup-process.png differ diff --git a/docs-en/subsystems/figures/architecture-of-the-ability-management-framework.png b/docs-en/subsystems/figures/architecture-of-the-ability-management-framework.png new file mode 100644 index 0000000000000000000000000000000000000000..5c36589713f0264b5d3f87e3af9b63b05dda17d7 Binary files /dev/null and b/docs-en/subsystems/figures/architecture-of-the-ability-management-framework.png differ diff --git a/docs-en/subsystems/figures/architecture-of-the-bundle-management-framework.png b/docs-en/subsystems/figures/architecture-of-the-bundle-management-framework.png new file mode 100644 index 0000000000000000000000000000000000000000..6f7e3e730e20598be87ce8191b20af9ed33977a8 Binary files /dev/null and b/docs-en/subsystems/figures/architecture-of-the-bundle-management-framework.png differ diff --git a/docs-en/subsystems/figures/en-us_image_0000001062334618.png b/docs-en/subsystems/figures/en-us_image_0000001062334618.png new file mode 100644 index 0000000000000000000000000000000000000000..0ac7c0924e931695308a819010668327ed8a8680 Binary files /dev/null and b/docs-en/subsystems/figures/en-us_image_0000001062334618.png differ diff --git a/docs-en/subsystems/figures/en-us_image_0000001062476933.png b/docs-en/subsystems/figures/en-us_image_0000001062476933.png new file mode 100644 index 0000000000000000000000000000000000000000..7e4b608bbffd7ae3becdc918abd6ff2b041888e5 Binary files /dev/null and b/docs-en/subsystems/figures/en-us_image_0000001062476933.png differ diff --git a/docs-en/subsystems/figures/en-us_image_0000001062942690.png b/docs-en/subsystems/figures/en-us_image_0000001062942690.png new file mode 100644 index 0000000000000000000000000000000000000000..c06de34e1a7e72dc162d09b1a4fa5fcd25cefab3 Binary files /dev/null and b/docs-en/subsystems/figures/en-us_image_0000001062942690.png differ diff --git a/docs-en/subsystems/figures/en-us_image_0000001064187438.png b/docs-en/subsystems/figures/en-us_image_0000001064187438.png new file mode 100644 index 0000000000000000000000000000000000000000..16a28de6873c3d1b2d8183b9ae5ad1ad5bf9cc02 Binary files /dev/null and b/docs-en/subsystems/figures/en-us_image_0000001064187438.png differ diff --git a/docs-en/subsystems/figures/en-us_image_0000001064795436.png b/docs-en/subsystems/figures/en-us_image_0000001064795436.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f0fcc0c14ae188fc5f9860438cc924fff72978 Binary files /dev/null and b/docs-en/subsystems/figures/en-us_image_0000001064795436.png differ diff --git a/docs-en/subsystems/figures/information-printed-during-system-startup.png b/docs-en/subsystems/figures/information-printed-during-system-startup.png new file mode 100644 index 0000000000000000000000000000000000000000..b38834ea3327aaea9f6d7fdeea784456d5df3d8d Binary files /dev/null and b/docs-en/subsystems/figures/information-printed-during-system-startup.png differ diff --git a/docs-en/subsystems/figures/relationship-between-a-page-ability-and-its-ability-slices.png b/docs-en/subsystems/figures/relationship-between-a-page-ability-and-its-ability-slices.png new file mode 100644 index 0000000000000000000000000000000000000000..b73b5331d1cc078785620a8817138e86432ebe3b Binary files /dev/null and b/docs-en/subsystems/figures/relationship-between-a-page-ability-and-its-ability-slices.png differ diff --git a/docs-en/subsystems/figures/running-sequence-of-the-test-tool.png b/docs-en/subsystems/figures/running-sequence-of-the-test-tool.png new file mode 100644 index 0000000000000000000000000000000000000000..3ea41e450eb52f38716fd77bada2525fb5cf9bf3 Binary files /dev/null and b/docs-en/subsystems/figures/running-sequence-of-the-test-tool.png differ diff --git a/docs-en/subsystems/figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png b/docs-en/subsystems/figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png new file mode 100644 index 0000000000000000000000000000000000000000..5f61fa03d18b823bb86add83f86d18a28c87731a Binary files /dev/null and b/docs-en/subsystems/figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png differ diff --git a/docs-en/subsystems/figures/test-tool-architecture.png b/docs-en/subsystems/figures/test-tool-architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..bfecc4ac1906d91a59d52f0c94fdb56f3c7475c2 Binary files /dev/null and b/docs-en/subsystems/figures/test-tool-architecture.png differ diff --git a/docs-en/subsystems/figures/unnaming.png b/docs-en/subsystems/figures/unnaming.png new file mode 100644 index 0000000000000000000000000000000000000000..6350269abdc028f9b1b31d544b78f380e58d7a57 Binary files /dev/null and b/docs-en/subsystems/figures/unnaming.png differ diff --git "a/docs-en/subsystems/figures/\345\233\276\347\211\2071.png" "b/docs-en/subsystems/figures/\345\233\276\347\211\2071.png" new file mode 100644 index 0000000000000000000000000000000000000000..4f0696becdda12d63cca3b93fac1a435511280bb Binary files /dev/null and "b/docs-en/subsystems/figures/\345\233\276\347\211\2071.png" differ diff --git a/docs-en/subsystems/graphics-0.md b/docs-en/subsystems/graphics-0.md new file mode 100644 index 0000000000000000000000000000000000000000..14aa1dab9315e286319b6456f0fda3ed5b23375e --- /dev/null +++ b/docs-en/subsystems/graphics-0.md @@ -0,0 +1,47 @@ +# Graphics + +- [UI Components](#section1987017145112) +- [Layouts](#section662016231612) +- [Animators](#section73736284117) +- [Input Events](#section672194012114) +- [Rendering](#section14338859916) + +The OpenHarmony graphics subsystem provides you with basic UI and container components, including buttons, images, labels, lists, animators, scroll views, swipe views, fonts, clock, charts, canvas, sliders, and layouts. In addition, this subsystem provides the Design for X \(DFX\) capability to capture screenshots and export the component tree. It also implements features such as component rendering, animation, and input event distribution. + +## UI Components + +Contain a variety of basic components \(such as buttons, text, and progress bars\) and complex components \(such as page switching and image sequence frames\). + +## Layouts + +Implement grid layout and flexible layout \(such as centered, left-aligned, and right-aligned\). + +As each layout is a one-off, the positions of components in a specific layout are calculated each time related functions are called on the layout. However, if the position of a component changes with an operation \(dragging for example\), the positions of other associated components do not automatically change. To change them, you need to call the layout functions again. + +## Animators + +Each time the Tick event is received, the Task Manager module periodically invokes callbacks upon attribute changes and then triggers redrawing to produce the desired animation effect. + +You can call related functions to start, stop, pause, resume, create, and destroy an animator. + +## Input Events + +Include touchscreen and physical key input events. Each time the GUI engine runs, the Input Manager module reads the input of all registered hardware devices and converts the input into various events for UI components to use. + +## Rendering + +- 2D graphics rendering + + Draws lines, rectangles, triangles, and arcs. + + +- Image rendering + + Draws images of various types, such as RGB565, RGB888, ARGB8888, PNG, and JPG. + + +- Font rendering + + Draws vector fonts in real time. + + diff --git a/docs-en/subsystems/graphics.md b/docs-en/subsystems/graphics.md index 14aa1dab9315e286319b6456f0fda3ed5b23375e..4ba7d42c9ce77a809bc8f712724b94507e189c82 100755 --- a/docs-en/subsystems/graphics.md +++ b/docs-en/subsystems/graphics.md @@ -1,47 +1,13 @@ -# Graphics +# Graphics -- [UI Components](#section1987017145112) -- [Layouts](#section662016231612) -- [Animators](#section73736284117) -- [Input Events](#section672194012114) -- [Rendering](#section14338859916) +- **[Graphics](graphics-0.md)** -The OpenHarmony graphics subsystem provides you with basic UI and container components, including buttons, images, labels, lists, animators, scroll views, swipe views, fonts, clock, charts, canvas, sliders, and layouts. In addition, this subsystem provides the Design for X \(DFX\) capability to capture screenshots and export the component tree. It also implements features such as component rendering, animation, and input event distribution. +- **[Development Guidelines on Container Components](development-guidelines-on-container-components.md)** -## UI Components +- **[Development Guidelines on Layout Container Components](development-guidelines-on-layout-container-components.md)** -Contain a variety of basic components \(such as buttons, text, and progress bars\) and complex components \(such as page switching and image sequence frames\). +- **[Development Guidelines on Common Components](development-guidelines-on-common-components.md)** -## Layouts - -Implement grid layout and flexible layout \(such as centered, left-aligned, and right-aligned\). - -As each layout is a one-off, the positions of components in a specific layout are calculated each time related functions are called on the layout. However, if the position of a component changes with an operation \(dragging for example\), the positions of other associated components do not automatically change. To change them, you need to call the layout functions again. - -## Animators - -Each time the Tick event is received, the Task Manager module periodically invokes callbacks upon attribute changes and then triggers redrawing to produce the desired animation effect. - -You can call related functions to start, stop, pause, resume, create, and destroy an animator. - -## Input Events - -Include touchscreen and physical key input events. Each time the GUI engine runs, the Input Manager module reads the input of all registered hardware devices and converts the input into various events for UI components to use. - -## Rendering - -- 2D graphics rendering - - Draws lines, rectangles, triangles, and arcs. - - -- Image rendering - - Draws images of various types, such as RGB565, RGB888, ARGB8888, PNG, and JPG. - - -- Font rendering - - Draws vector fonts in real time. +- **[Development Guidelines on Animators](development-guidelines-on-animators.md)** diff --git a/docs-en/subsystems/multimedia.md b/docs-en/subsystems/multimedia.md new file mode 100644 index 0000000000000000000000000000000000000000..9e24cc81f5bd2b9c51e06ab47d9da3dd6e916686 --- /dev/null +++ b/docs-en/subsystems/multimedia.md @@ -0,0 +1,17 @@ +# Multimedia + +- **[Overview](overview.md)** + +- **[Development Guidelines on Photographing](development-guidelines-on-photographing.md)** + +- **[Development Guidelines on Video Recording](development-guidelines-on-video-recording.md)** + +- **[Development Guidelines on Previewing](development-guidelines-on-previewing.md)** + +- **[Overview](overview-1.md)** + +- **[Development Guidelines on Media Playback](development-guidelines-on-media-playback.md)** + +- **[Development Guidelines on Media Recording](development-guidelines-on-media-recording.md)** + + diff --git a/docs-en/subsystems/overview-1.md b/docs-en/subsystems/overview-1.md new file mode 100644 index 0000000000000000000000000000000000000000..98b5b4ad048a507a0a4fe21297b86ca6b158995d --- /dev/null +++ b/docs-en/subsystems/overview-1.md @@ -0,0 +1,81 @@ +# Overview + +- [Basic Concepts](#section967213571204) +- [Encoding and Decoding](#section1582020483111) + +OpenHarmony multimedia services help you to develop for audio and video playback and recording. + +- The media playback module facilitates the development of audio and video playback, including media file and stream playback, volume control, and playback progress control. +- The media recording module supports the development of audio and video recording and provides functions to set the size of captured video, encoding bit rate, encoder type, video frame rate, audio sampling rate, and output file format. + +## Basic Concepts + +It is considered good practice that you understand the following concepts before starting development: + +- Streaming media technology + + The streaming media technology refers to a process to encode continuous video and audio data and store the data on a network server. A viewer can watch and listen to the video and audio during download with no need to wait for the completion of download. + + +- Video frame rate + + The frame rate is used to measure the number of displayed frames, which is the number of images transmitted per second. The more frames per second \(FPS\), the smoother the video. + +- Bit rate + + Bit rate is the number of bits transmitted per unit of time. The commonly used unit is kbit/s. + +- Sampling rate + + The sampling rate is the number of samples per second taken from continuous signals to form discrete signals. The unit is hertz \(Hz\). + + +## Encoding and Decoding + +Available audio and video encoding and decoding capabilities vary depending on device types. The following table lists supported specifications for available development boards. + +**Table 1** Encoding and decoding specifications for different development boards + + + + + + + + + + + + + + + + + + + + + + + + +

Device Type

+

Development Board

+

Decoding

+

Encoding

+

Cameras with a screen

+

Hi3516

+
  • Audio: The MPEG-4 AAC Profile (AAC LC), mono and dual channels, and the MPEG-4 (.mp4 and .m4a) container format are supported.
  • Video: The H.265 (HEVC) and H.264 (AVC) (for streams encoded using a chip of the same type) and the MPEG-4 (.mp4) container format are supported.
+
  • Audio: AAC-LC encoding, mono and dual channels, and the MPEG-4 (.mp4) container format are supported.
  • Video: H.264 and H.265 encoding and the MPEG-4 (.mp4) container format are supported.
+

Cameras without a screen

+

Hi3518

+
  • Audio: The MPEG-4 AAC Profile (AAC LC), mono and dual channels, and the MPEG-4 (.mp4 and .m4a) container format are supported.
  • Video: none
+
  • Audio: AAC-LC encoding, mono and dual channels, and the MPEG-4 (.mp4) container format are supported.
  • Video: H.264 and H.265 encoding and the MPEG-4 (.mp4) container format are supported.
+

WLAN connecting devices

+

Hi3861

+

N/A

+

N/A

+
+ +For details about the encoding and decoding specifications of Hi3516 and Hi3518, refer to their documentation. + diff --git a/docs-en/subsystems/overview-2.md b/docs-en/subsystems/overview-2.md new file mode 100644 index 0000000000000000000000000000000000000000..fd1e28d454f7919b75810348a47f9ba9a2da0729 --- /dev/null +++ b/docs-en/subsystems/overview-2.md @@ -0,0 +1,148 @@ +# Overview + +- [Basic Concepts](#section72601941194812) +- [Ability Management Framework](#section14633111813374) +- [Bundle Management Framework](#section1341146154412) +- [Working Principles](#section94302021112717) +- [Limitations and Constraints](#section89534912527) + +The application framework is provided by OpenHarmony for you to develop OpenHarmony applications. It consists of two modules: ability management framework and bundle management framework. + +## Basic Concepts + +This section describes some basic concepts for you to better understand the OpenHarmony application framework before you start development. + +## Ability Management Framework + +The ability management framework manages running status of OpenHarmony applications. + +**Figure 1** Architecture of the ability management framework +![](figures/architecture-of-the-ability-management-framework.png "architecture-of-the-ability-management-framework") + +- **Ability** is the minimum unit for the system to schedule applications. It is a component that can implement an independent functionality. An application can contain one or more **Ability** instances. There are two types of templates that you can use to create an **Ability** instance: Page and Service. + - An **Ability using the Page template** \(Page ability for short\) provides a UI for interacting with users. + + - An **Ability using the Service template** does not have a UI and is used for running background tasks. + + + +- An **AbilitySlice** represents a single screen and its control logic. It is specific to Page abilities. A Page ability may contain one ability slice or multiple ability slices that provide highly relevant capabilities. + + **Figure 2** Relationship between a Page ability and its ability slices + ![](figures/relationship-between-a-page-ability-and-its-ability-slices.png "relationship-between-a-page-ability-and-its-ability-slices") + +- **Lifecycle** is a general term for all states of an ability, including **INITIAL**, **INACTIVE**, **ACTIVE**, and **BACKGROUND**. + + **Figure 3** Lifecycle state transition of a Page ability + + + ![](figures/图片1.png) + + - **OnStart\(\)** + + This callback is invoked when the system first creates the Page ability. After this callback is executed, the Page ability enters the **INACTIVE** state. This callback is triggered only once in the entire lifecycle of each Page ability. You must override this callback and set the default ability slice to be displayed. + + - **OnActive\(\)** + + This callback is invoked when the Page ability in the **INACTIVE** state enters the foreground. After this callback is executed, the Page ability enters the **ACTIVE** state, in which it becomes interactive. The Page ability will stay in this state unless it loses focus upon a certain event, for example, when the user touches the Back button or navigates to another Page ability. + + When such an event occurs, the Page ability returns to the **INACTIVE** state, and the system invokes the **OnInactive\(\)** callback. The Page ability may move to the **ACTIVE** state again, and the system will then invoke the **OnActive\(\)** callback again. You should implement both **OnActive\(\)** and **OnInactive\(\)** for a Page ability and use **OnActive\(\)** to obtain the resources released in **OnInactive\(\)**. + + - **OnInactive\(\)** + + This callback is invoked when the Page ability loses focus, and the Page ability then becomes **INACTIVE**. You can implement the behavior to perform after the Page ability loses focus. + + - **OnBackground\(\)** + + This callback is invoked based on the system resource status when the Page ability becomes invisible to the user. After this callback is executed, the Page ability enters the **BACKGROUND** state. You should release the resources that are no longer needed after the Page ability becomes invisible or perform time-consuming save operations in this callback. + + - **OnForeground\(\)** + + A Page ability in the **BACKGROUND** state still resides in memory. When the Page ability returns to the foreground \(for example, when the user navigates to this Page ability again\), the system first calls **OnForeground\(\)** to switch the Page ability to the **INACTIVE** state, and then calls **OnActive\(\)** to make it **ACTIVE**. You should use the **OnForeground\(\)** callback to reclaim the resources released in **OnBackground\(\)**. Currently, the **onForeground\(\)** callback is unavailable to lite devices. + + - **OnStop\(\)** + + This callback is invoked when the system is destroying a Page ability due to one of the following possible causes: + + - The user explicitly closes the Page ability using a system management feature, for example, the task manager. + - The user behavior, for example, exiting an application, triggers the **TerminateAbility\(\)** function on the Page ability. + - The system needs to temporarily destroy the Page ability and re-create it due to configuration changes. + - The system automatically destroys a Page ability in the **BACKGROUND** state due to resource management purposes. + + +- **AbilityKit** is a development kit provided by the ability management framework. You can use this kit to develop applications based on the **Ability** component. There are two types of applications developed based on the **Ability** component: JS Ability developed using the JavaScript language and Native Ability developed using the C/C++ language. The JS application development framework encapsulates JavaScript UI components on the basis of the **AbilityKit** and is used to help you quickly develop JS Ability-based applications. +- **AbilityLoader** is used to register and load **Ability** classes. After creating an **Ability** class, you should first call the registration API defined in **AbilityLoader** to register the **Ability** class name with the ability management framework so that this **Ability** can be instantiated when being started. + +- **AbilityManager** enables inter-process communication \(IPC\) between the **AbilityKit** and the Ability Manager Service. + +- **EventHandler** is provided by the **AbilityKit** to enable inter-thread communication between abilities. + +- The **Ability Manager Service** is a system service used to coordinate the running relationships and lifecycle states of **Ability** instances. It consists of the following modules: + + - The service startup module starts and registers the Ability Manager Service. + - The service interface management module manages external capabilities provided by the Ability Manager Service. + - The process management module starts and destroys processes where **Ability** instances are running, and maintains the process information. + - The ability stack management module maintains the presentation sequence of abilities in the stack. + - The lifecycle scheduling module changes an ability to a particular state based on the current operation of the system. + - The connection management module manages connections to Service abilities. + +- **AppSpawn** is a system service used to create the process for running an ability. This service has high permissions. It sets permissions for **Ability** instances and pre-loads some common modules to accelerate application startup. + + +## Bundle Management Framework + +The bundle management framework is provided by OpenHarmony for you to manage application bundles. + +**Figure 4** Architecture of the bundle management framework +![](figures/architecture-of-the-bundle-management-framework.png "architecture-of-the-bundle-management-framework") + +- **BundleKit** includes external APIs provided by the Bundle Manager Service, including the APIs for application installation and uninstallation, bundle information query, and bundle state change listeners. +- The **bundle scanning module** parses pre-installed or installed bundles on the local device and extracts information from them for the bundle management module to manage and make the information persistent for storage. +- The **bundle installation module** installs, uninstalls, and updates a bundle. The **bundle installation service** is an independent process that communicates with the Bundle Manager Service through IPC. It is used to create or delete installation directories and has high permissions. + +- The **bundle management module** manages information related to application bundles and stores persistent bundle information. + +- The **bundle security management module** verifies signatures, and grants and manages permissions. + + +## Working Principles + +The Ability Manager Service and Bundle Manager Service are the core modules of the ability management framework and bundle management framework, respectively. The two system-level services are registered and discovered by using the system service framework SAMgr, and they are used by manage abilities and bundles for other processes. The Ability Manager Service and Bundle Manager Service are provided as open APIs in the **AbilityKit** and **BundleKit**. + +**Figure 5** Startup of the Ability Manager Service and Bundle Manager Service +![](figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png "startup-of-the-ability-manager-service-and-bundle-manager-service") + +OpenHarmony applications can be installed and started after the two services are started. + +**Figure 6** Application startup process +![](figures/application-startup-process.png "application-startup-process") + +The home screen is the first OpenHarmony application started by the Ability Manager Service. After the home screen is started, the user can touch any installed OpenHarmony application on the home screen to start the particular application. The figure above shows the interaction process of starting an installed application from the home screen. + +As shown in the figure, the Ability Manager Service is responsible for displaying or hiding an ability, and the Bundle Manager Service is responsible for storing and querying ability information. + +## Limitations and Constraints + +- Language version + + - C++ 11 or later + + +- The specifications of the application framework vary depending on the System-on-a-Chip \(SoC\) and underlying OS capabilities. + + - Cortex-M RAM and ROM + + - RAM: greater than 20 KB \(recommended\) + + - ROM: greater than 300 KB \(for the JS application development framework and related subsystems, such as UIKit and engine\) + + + - Cortex-A RAM and ROM + + - RAM: greater than 2 MB \(recommended\) + + - ROM: greater than 2 MB \(for the JS application development framework and related subsystems, such as UIKit and engine\) + + + + diff --git a/docs-en/subsystems/overview.md b/docs-en/subsystems/overview.md index 57cec9bde43a47304db45239b219cf6a56d392c9..fb0bf00d194ee4abbf5589898040f388b18fd571 100755 --- a/docs-en/subsystems/overview.md +++ b/docs-en/subsystems/overview.md @@ -90,7 +90,7 @@ It is considered good practice that you understand the following concepts before Similarly, you can create a surface, implement consumer logic for it, and transfer it to the **Camera** instance. For example, transmit video streams over the network or save captured frame data as an image file. - The graphics module also obtains stream resources from the camera module through surfaces. For details, see development guidelines on [Graphic](graphics.md). + The graphics module also obtains stream resources from the camera module through surfaces. For details, see development guidelines on [Graphic](graphics-0.md). - Camera running process 1. Creating a camera diff --git a/docs-en/subsystems/reference.md b/docs-en/subsystems/reference.md new file mode 100644 index 0000000000000000000000000000000000000000..3d1b4ec6de306c0f5b97802b38cd1f9a216d1e7d --- /dev/null +++ b/docs-en/subsystems/reference.md @@ -0,0 +1,93 @@ +# Reference + +- [Directory Structure](#section5487173174316) + +## Directory Structure + +**Table 1** Directory structure of the source code for DFX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

hiviewdfx/interface

+

Stores all header files for open APIs.

+

hiviewdfx/interfaces/kits/hilog

+

Defines open APIs available for logs in the featured framework.

+

hiviewdfx/interfaces/kits/hilog_lite

+

Defines open APIs available for logs in the mini framework.

+

hiviewdfx/interfaces/innerkits/hievent_lite

+

Defines open APIs available for event printing in the mini framework.

+

hiviewdfx/services/hilogcat_lite

+

Stores services and commands related to logs.

+

hiviewdfx/services/hilogcat_lite/apphilogcat

+

Provides the log flushing-to-disk service in the featured framework.

+

hiviewdfx/services/hilogcat_lite/command

+

Provides DFX commands specific to the mini framework.

+

hiviewdfx/services/hilogcat_lite/hilogcat

+

Provides commands to output logs in the featured framework.

+

hiviewdfx/services/hiview_lite

+

Registers the DFX service specific to the mini framework.

+

hiviewdfx/frameworks/ddrdump_lite

+

Dumps Double Data Rate (DDR) memory in the mini framework.

+

hiviewdfx/frameworks/hievent_lite

+

Records event printing in the mini framework.

+

hiviewdfx/frameworks/hilog_lite

+

Defines APIs for logging.

+

hiviewdfx/frameworks/hilog_lite/featured

+

Defines APIs for logging in the featured framework.

+

hiviewdfx/frameworks/hilog_lite/mini

+

Defines APIs for logging in the mini framework.

+

hiviewdfx/utils/lite

+

Stores utils, including the configuration items of the mini framework.

+
+ diff --git a/docs-en/subsystems/setting-up-a-development-environment.md b/docs-en/subsystems/setting-up-a-development-environment.md new file mode 100644 index 0000000000000000000000000000000000000000..38ecd9721e39133d08411f02402fce11fb1e4935 --- /dev/null +++ b/docs-en/subsystems/setting-up-a-development-environment.md @@ -0,0 +1,7 @@ +# Setting Up a Development Environment + +- Development board: Hi3516D V300 + +- [Download the source code](https://device.harmonyos.com/en/docs/start/get-code/oem_sourcecode_guide-0000001050769927). +- [Compile the application framework](https://gitee.com/openharmony/docs/blob/master/docs-en/readme/application-framework.md). + diff --git a/docs-en/subsystems/testing.md b/docs-en/subsystems/testing.md new file mode 100644 index 0000000000000000000000000000000000000000..cae5a2979a37ee32cb515746f702069c6ea087ff --- /dev/null +++ b/docs-en/subsystems/testing.md @@ -0,0 +1,489 @@ +# Testing + +- [Overview](#en-us_topic_0000001059860314_section12403172115920) + - [Basic Concepts](#en-us_topic_0000001059860314_section53632272090) + - [Working Principles](#en-us_topic_0000001059860314_section2394431106) + +- [Limitations and Constraints](#en-us_topic_0000001059860314_section2029921310472) + - [Function Constraints](#en-us_topic_0000001059860314_section172441620111610) + - [Operation Constraints](#en-us_topic_0000001059860314_section201523661616) + +- [Setting Up a Test Environment](#en-us_topic_0000001059860314_section175012297491) + - [Environment Requirements](#en-us_topic_0000001059860314_section935055691014) + - [Installing the Environment](#en-us_topic_0000001059860314_section6511193210111) + - [Verifying the Test Environment](#en-us_topic_0000001059860314_section1899144517117) + +- [Development Guidelines](#en-us_topic_0000001059860314_section16741101301210) + - [When to Use](#en-us_topic_0000001059860314_section93782214124) + - [Available APIs](#en-us_topic_0000001059860314_section54131732101218) + - [How to Develop](#en-us_topic_0000001059860314_section53541946111218) + +- [Development Example](#en-us_topic_0000001059860314_section7477121918136) +- [Directory Structure](#en-us_topic_0000001059860314_section1875515364133) + +## Overview + +### Basic Concepts + +The testing subsystem provides a one-click Python-based self-test platform for developers. It also supports operations on third-party testing frameworks, including compiling, managing, scheduling and distributing, and executing test cases, collecting test results, generating test reports, creating test case templates, and managing test environments. + +Before development using the testing subsystem, you need to understand the following concepts: + +- Test case compilation + + This operation compiles the source code of test cases into binary files that can be executed on the tested device. + +- Test case scheduling & distributing + + This operation distributes test cases to different tested devices through the network port or serial port, and allocates a specific executor for each test case. + +- Test case executor + + A test case executor integrates the unit testing frameworks for different programming languages, such as Unity, and defines the execution logic of each test case, such as its pre-processing, execution, and result recording. + +- Test case template + + A test case template defines respective unified formats for test cases and for GN files. + +- Test tool kit + + The test tool kit provides common methods to be used during the running of the test tool, for example, providing the test case directory to mount the file system to a tested device, distributing test cases to the tested device, or obtaining test results from the tested device. + +- Test report generation + + This operation defines a template for generating self-test reports and converts the XML file of a report into an HTML file. + +- Test environment management + + The tested devices can be managed through the USB port or serial port, including discovering a device and querying the device status. + + +### Working Principles + +- The following figure shows the architecture of the test tool. + +**Figure 1** Test tool architecture +![](figures/test-tool-architecture.png "test-tool-architecture") + +- The following figure shows the running sequence diagram of the test tool. + +**Figure 2** Running sequence of the test tool +![](figures/running-sequence-of-the-test-tool.png "running-sequence-of-the-test-tool") + +- Working principle of the test tool + +The test tool is started using a shell script. It executes a series of testing commands entered on the command line interface \(CLI\) and prints the command output. + +## Limitations and Constraints + +### Function Constraints + +- Application scope + + Self-test tools support only code-level test case development and verification, such as unit testing and module testing. + +- Specifications + + Currently, the testing frameworks support only white-box testing. + + +### Operation Constraints + +Only one test platform can be started on a testing device. + +## Setting Up a Test Environment + +### Environment Requirements + +**Table 1** Environment requirements + + + + + + + + + + + + + + + + +

Item

+

Testing Device

+

Tested Device

+

Hardware

+
  • Memory: 8 GB or above
  • Hard disk space: 100 GB or above
  • Hardware architecture: x86 or ARM64
+

Hi3516D V300 development board

+

Hi3518E V300 development board

+

Software

+
  • OS: Windows 10 (64-bit) or Ubuntu 18.04

    System component (Linux): libreadline-dev

    +
  • Python: 3.7.5 or later
  • Python plug-ins: pySerial 3.3 or later, Paramiko 2.7.1 or later, Setuptools 40.8.0 or later, and RSA 4.0 or later
  • NFS server: haneWIN NFS Server 1.2.50 or later, or NFSv4 or later
+
  • OS: OpenHarmony 1.0 or later
  • Kernel: LiteOS Cortex-A or Linux kernel
+
+ +### Installing the Environment + +1. Go to the **test/xdevice** directory and run the **python setup.py install** command. +2. \(Optional\) If the test environment runs Linux, run the following command to install system component readline: + + ``` + sudo apt-get install libreadline-dev + ``` + +3. Install Python extension plug-ins pySerial, Setuptools, RSA, and Paramiko. + + Run the following command to install pySerial: + + ``` + pip install pyserial + ``` + + Run the following command to install Setuptools: + + ``` + pip install setuptools + ``` + + Run the following command to install RSA: + + ``` + pip install rsa + ``` + + Run the following command to install Paramiko: + + ``` + pip install paramiko + ``` + +4. Install an NFS server. + + **Windows OS** + + Download and install **haneWIN NFS Server 1.2.50** at https://www.hanewin.net/nfs-e.htm. + + **Linux OS** + + ``` + sudo apt install nfs-kernel-server + ``` + + After the environment is installed, you can conduct coding and debugging for a test tool in an integrated development environment \(IDE\) \(DevEco Studio is recommended\). + + +### Verifying the Test Environment + +**Table 2** Environment verification + + + + + + + + + + + + + + + + + + + + +

Item

+

Operation

+

Requirement

+

Check that a compliant Python version has been installed.

+

Run the python --version command.

+

The Python version must be 3.7.5 or later.

+

Check that Python extension plug-ins have been installed.

+

Access the test/xdevice directory and run run.bat or run.sh.

+

The >>> prompt is displayed.

+

Check the NFS server status.

+

Log in to the development board through the serial port and run the mount command to mount the NFS server.

+

The file directory can be mounted properly.

+
+ +## Development Guidelines + +### When to Use + +Test cases are mainly used to conduct self-tests for service code and can be used in code-level unit testing, module testing, and performance testing. + +### Available APIs + +The testing framework integrates the open-source unit testing framework and expands the macros of the test cases. For details about the framework, see the official open-source documentation. + +**Table 3** Expanded macros of the framework + + + + + + + + + + + + + + + + +

Macro

+

Description

+

HWTEST

+

This macro applies to simple tests, and its execution does not rely on the setup and teardown execution. This macro expands the test case level based on the TEST macro, for example, HWTEST(CalculatorAddTest, TestPoint_001, TestSize.Level1).

+

HWTEST_F

+

Test cases defined in this macro are independent. The macro execution relies on the setup and teardown execution. This macro expands the test case level based on the TEST_F macro, for example, HWTEST_F(CalculatorAddTest, TestPoint_001, TestSize.Level1).

+

HWTEST_P

+

This macro applies to parameterized tests. It expands the test case level based on the TEST_P macro, for example, HWTEST_P(CalculatorAddTest, TestPoint_001, TestSize.Level1).

+
+ +### How to Develop + +1. Define a test suite file based on the test case directory, for example, **test/developertest/example/cxx\_demo/test/unittest/common/calc\_subtraction\_test.cpp**. The class in this test suite should be inherited from the **testing::Test** class and named in the format of "_Tested feature_**Test**". + + ``` + #include + + using namespace std; + using namespace testing::ext; + + class CalcSubtractionTest : public testing::Test { + public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + }; + ``` + +2. Implement the preprocessing \(via the **SetUp** function\) and postprocessing \(via the **TearDown** function\) operations required by the execution of the test suite. + + ``` + void CalcSubtractionTest::SetUpTestCase(void) + { + // step 2: input testsuit setup step + } + + void CalcSubtractionTest::TearDownTestCase(void) + { + // step 2: input testsuit teardown step + } + + void CalcSubtractionTest::SetUp(void) + { + // step 3: input testcase setup step + } + + void CalcSubtractionTest::TearDown(void) + { + // step 3: input testcase teardown step + } + ``` + +3. Compile a test case based on the feature to be tested. The following code uses **HWTEST\_F** as an example: + + ``` + /* + * Feature: Calculator + * Function: Subtraction + * SubFunction: NA + * FunctionPoints: Integer Subtraction + * EnvConditions: NA + * CaseDescription: Verify the Subtraction function. + */ + HWTEST_F(CalcSubtractionTest, integer_sub_001, TestSize.Level1) + { + EXPECT_EQ(0, Subtraction(1, 0)); + } + ``` + +4. Compile the GN file of the test case, including defining the compilation target, adding compilation dependencies, and setting the source file. \(Example file path: **test/developertest/example/cxx\_demo/test/unittest/common/BUILD.gn**\) + + ``` + import("//build/lite/config/test.gni") + + unittest("CalcSubTest") { + output_extension = "bin" + sources = [ + "calc_subtraction_test.cpp" + ] + include_dirs = [] + deps = [] + } + + ``` + +5. Add the test case compilation target to the subsystem compilation configuration to ensure that the test case is compiled with the version release. \(Example file path: **test/developertest/BUILD.gn**\) + + ``` + import("//build/lite/config/test.gni") + + subsystem_test("test") { + test_components = [] + if(ohos_kernel_type == "liteos_riscv") { + features += [ + ] + }else if(ohos_kernel_type == "liteos_a") { + test_components += [ + "//test/developertest/example/cxx_demo/test/unittest/common:CalcSubTest" + ] + } + } + ``` + +6. Run the version compilation command in the root directory of the code to compile the test case. + +## Development Example + +The code repository of the testing subsystem provides complete demo cases, which are available in the **test/developertest/example/** directory. The following is an example of compiling a test case using a subtraction function: + +- The tested code is as follows: + + ``` + static int Subtraction(int a, int b) + { + return a - b; + } + ``` + +- The test case code is as follows: + + ``` + /* + * Feature: Calculator + * Function: Subtraction + * SubFunction: NA + * FunctionPoints: Integer Subtraction + * EnvConditions: NA + * CaseDescription: Verify the Subtraction function. + */ + HWTEST_F(CalcSubtractionTest, integer_sub_002, TestSize.Level1) + { + EXPECT_EQ(1, Subtraction(2, 1)); + } + ``` + + +## Directory Structure + +The source code for the test platform framework is stored in the **test/xdevice** directory. The following table describes the **xdevice** directory structure. + +**Table 4** **xdevice** directory structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory

+

Description

+

xdevice

+

Basic framework for test tools

+

xdevice/src/xdevice

+

Source code for the basic testing framework

+

xdevice/config

+

Configuration file of the basic testing framework

+

xdevice/src/xdevice/__main__.py

+

Internal entrance to the basic testing framework

+

xdevice/src/xdevice/__init__.py

+

Package and plug-in dependencies

+

xdevice/src/xdevice/variables.py

+

Global variables

+

xdevice/src/xdevice/_core/command

+

Commands entered by test cases

+

xdevice/src/xdevice/_core/config

+

Configuration management of the basic testing framework

+

xdevice/src/xdevice/_core/environment

+

Environment management of the basic testing framework, including device management

+

xdevice/src/xdevice/_core/executor

+

Scheduling and distribution of test cases

+

xdevice/src/xdevice/_core/driver

+

Test executor for the basic testing framework

+

xdevice/src/xdevice/_core/resource

+

Resource files and test report templates for the basic testing framework

+

xdevice/src/xdevice/_core/testkit

+

Common operations for the basic testing framework, including NFS mounting

+

xdevice/src/xdevice/_core/logger.py

+

Log management of the basic testing framework

+

xdevice/src/xdevice/_core/plugin.py

+

Plug-in management of the basic testing framework

+

xdevice/src/xdevice/_core/interface.py

+

Interfaces for plug-ins of the basic testing framework

+

xdevice/setup.py

+

Installation script of the basic testing framework

+

xdevice/run.bat

+

Startup script of the basic testing framework (Windows)

+

xdevice/run.sh

+

Startup script of the basic testing framework (Linux)

+
+ diff --git a/docs-en/subsystems/utils-development-guidelines.md b/docs-en/subsystems/utils-development-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..b4dd121dc28b78176c11d5517c0bd9bf34015d1c --- /dev/null +++ b/docs-en/subsystems/utils-development-guidelines.md @@ -0,0 +1,253 @@ +# Utils Development Guidelines + +- [Available APIs](#section1633115419401) +- [How to Develop](#section4207112818418) + +## Available APIs + +**Table 1** APIs for file operations + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function

+

Description

+

int UtilsFileOpen(const char* path, int oflag, int mode)

+

Opens or creates a file.

+

int UtilsFileClose(int fd)

+

Closes a file with a specified file descriptor.

+

int UtilsFileRead(int fd, char *buf, unsigned int len)

+

Reads a specified length of data from a file with the specified file descriptor and writes the data into the buffer.

+

int UtilsFileWrite(int fd, const char *buf, unsigned int len)

+

Writes a specified length of data into a file with the specified file descriptor.

+

int UtilsFileDelete(const char *path)

+

Deletes a specified file.

+

int UtilsFileStat(const char *path, unsigned int *fileSize)

+

Obtains the file size.

+

int UtilsFileSeek(int fd, int offset, unsigned int whence)

+

Adjusts the read and write position offset in a file.

+

int UtilsFileCopy(const char* src, const char* dest)

+

Copies the source file to a target file.

+

int UtilsFileMove(const char* src, const char* dest)

+

Moves the source file into a target file.

+
+ +Sample code for file operations: + +``` +// Open a file and write data. +char fileName[] = "testfile"; +static const char def[] = "utils_file_operation implement."; +int fd = UtilsFileOpen(fileName, O_RDWR_FS | O_CREAT_FS | O_TRUNC_FS, 0); +printf("file handle = %d\n", fd); +int ret = UtilsFileWrite(fd, def, strlen(def)); +printf("write ret = %d\n", ret); + +// Adjust the position offset in the file. +ret = UtilsFileSeek(fd, 5, SEEK_SET_FS); +printf("lseek ret = %d\n", ret); + +// Read data and close the file. +char buf[64] = {0}; +int readLen = UtilsFileRead(fd, buf, 64); +ret = UtilsFileClose(fd); +printf("read len = %d : buf = %s\n", readLen, buf); + +// Obtain the file size. +int fileLen = 0; +ret = UtilsFileStat(fileName, &fileLen); +printf("file size = %d\n", fileLen); + +// Delete the file. +ret = UtilsFileDelete(fileName); +printf("delete ret = %d\n", ret); +``` + +**Table 2** APIs for KV store operations + + + + + + + + + + + + + + + + +

Function

+

Description

+

int UtilsGetValue(const char* key, char* value, unsigned int len)

+

Obtains the value matching a specified key from the file system or cache.

+

int UtilsSetValue(const char* key, const char* value)

+

Adds or updates the value matching a specified key in the file system or cache.

+

int UtilsDeleteValue(const char* key)

+

Deletes the value matching a specified key from the file system or cache.

+
+ +Sample code for the KV store: + +``` +// Set the value matching the specified key. +char key[] = "rw.sys.version_100"; +char value[] = "Hello kv operation implement!"; +int ret = UtilsSetValue(key, value); +printf("UtilsSetValue set ret = %d\n", ret); + +// Obtain the value matching the specified key. +char temp[128] = {0}; +ret = UtilsGetValue(key, temp, 128); +printf("UtilsGetValue get ret = %d, temp = %s\n", ret, temp); + +// Delete the value matching the specified key. +ret = UtilsDeleteValue(key); +printf("UtilsDeleteValue delete ret = %d\n", ret); +``` + +## How to Develop + +To develop a native application for the KV store that uses the LiteOS Cortex-A kernel \(Hi3516 or Hi3518\), perform the following steps: + +1. Develop the native application for the KV store using **AbilityKit** APIs. + - Write the user program by calling the APIs provided by the KV store and compile the **libLauncher.so** file. + + ``` + // Set the value matching the specified key. + char key[] = "rw.sys.version_100"; + char value[] = "Hello kv operation implement!"; + int ret = UtilsSetValue(key, value); + printf("UtilsSetValue set ret = %d\n", ret); + + // Obtain the value matching the specified key. + char temp[128] = {0}; + ret = UtilsGetValue(key, temp, 128); + printf("UtilsGetValue get ret = %d, temp = %s\n", ret, temp); + + // Delete the value matching the specified key. + ret = UtilsDeleteValue(key); + printf("UtilsDeleteValue delete ret = %d\n", ret); + ``` + + - Edit the **config.json** file as follows: + + ``` + { + "app": { + "bundleName": "com.huawei.launcher", + "vendor": "huawei", + "version": { + "code": 1, + "name": "1.0" + } + }, + "deviceConfig": { + "default": { + "reqSdk": { + "compatible": "zsdk 1.0.0", + "target": "zsdk 1.0.1" + }, + "keepAlive": false + }, + "smartCamera": { + "reqSdk": { + "compatible": "zsdk 1.0.0", + "target": "zsdk 1.0.1" + }, + "keepAlive": false + } + }, + "module": { + "package": "com.huawei.launcher", + "name": ".MyHarmonyAbilityPackage", + "deviceType": [ + "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "Launcher", + "moduleType": "entry" + }, + "abilities": [{ + "name": "MainAbility", + "icon": "res/drawable/phone.png", + "label": "test app 1", + "launchType": "standard", + "type": "page" + }, + { + "name": "SecondAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "page" + }, + { + "name": "ServiceAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "service" + } + ] + } + } + ``` + + + - Generate a HAP file. + + - Add resource files in the **res/drawable** directory based on the following directory structure. + + ![](figures/unnaming.png) + + - Compress the **libLauncher.so**, **config.json**, and resource files into a ZIP package and change the file name extension to **.hap**, for example, **Launcher.hap**. + + +2. Connect the development board and send the command for installing the native KV store application to the board through the serial port. + + ``` + ./nfs/dev_tools/bin/bm install -p /nfs/Launcher.hap + ``` + +3. Send the command for running the native KV store application to the board through the serial port. + + ``` + ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ``` + + diff --git a/docs-en/subsystems/utils-faq.md b/docs-en/subsystems/utils-faq.md new file mode 100644 index 0000000000000000000000000000000000000000..d7840aa6e4e6d6f42fdd5170dc86c85bca7a0039 --- /dev/null +++ b/docs-en/subsystems/utils-faq.md @@ -0,0 +1,22 @@ +# Utils FAQ + +- [1. Failure in running the KV store on the LiteOS Cortex-A kernel \(Hi3516 or Hi3518\) due to incorrect path setting for the KV store](#section2041345718513) + +## 1. Failure in running the KV store on the LiteOS Cortex-A kernel \(Hi3516 or Hi3518\) due to incorrect path setting for the KV store + +**Problem** + +When the LiteOS Cortex-A kernel \(Hi3516 or Hi3518 platform\) directly calls the API provided by the KV store, the compiled executable program fails to run. + +**Possible Causes** + +The compiled executable program is run directly without being converted to an application using **AbilityKit** APIs. In this case, the Bundle Manager Service \(BMS\) cannot correctly set the path for storing application data during application installation. As a result, the KV store fails to run. + +**Solution** + +Call the **UtilsSetEnv** function of the KV store to set the data storage path. + +``` +UtilsSetEnv("/storage/com.huawei.kv"); +``` + diff --git a/docs-en/subsystems/utils-overview.md b/docs-en/subsystems/utils-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..5bb13cdf05d4f432cd03614b097ea714bef4b3bd --- /dev/null +++ b/docs-en/subsystems/utils-overview.md @@ -0,0 +1,10 @@ +# Utils Overview + +The Utils library stores common basic components of OpenHarmony. These basic components can be used by OpenHarmony service subsystems and upper-layer applications. + +The Utils library provides the following capabilities on different platforms: + +LiteOS Cortex-M \(Hi3861 platform\): KV store, file operations, and IoT peripheral control + +LiteOS Cortex-A \(Hi3516 or Hi3518 platform\): JavaScript APIs for KV store, timer, and data and file storage modules + diff --git a/docs-en/subsystems/utils.md b/docs-en/subsystems/utils.md new file mode 100644 index 0000000000000000000000000000000000000000..f58c094cbac0b1be9871a289fe61c4fae0d3801e --- /dev/null +++ b/docs-en/subsystems/utils.md @@ -0,0 +1,9 @@ +# Utils + +- **[Utils Overview](utils-overview.md)** + +- **[Utils Development Guidelines](utils-development-guidelines.md)** + +- **[Utils FAQ](utils-faq.md)** + + diff --git a/docs-en/subsystems/xts.md b/docs-en/subsystems/xts.md new file mode 100644 index 0000000000000000000000000000000000000000..318f1d88427d71f604d74f7c4fb83cb10aa557a6 --- /dev/null +++ b/docs-en/subsystems/xts.md @@ -0,0 +1,435 @@ +# XTS + +- [Overview](#en-us_topic_0000001059475030_section44931242483) +- [Directory Structure](#en-us_topic_0000001059475030_section45118915548) +- [Limitations and Constraints](#en-us_topic_0000001059475030_section115518148474) +- [Development Guidelines](#en-us_topic_0000001059475030_section99973470498) + - [ACTS Cases for the IoTLink Module](#en-us_topic_0000001059475030_section1348215596491) + - [ACTS Cases for the SmartVision Device \(IP Camera\)](#en-us_topic_0000001059475030_section11458163095019) + - [Executing ACTS Cases for the IoTLink Module](#en-us_topic_0000001059475030_section3115140115113) + - [Executing ACTS Cases for the SmartVision Device \(IP Camera\)](#en-us_topic_0000001059475030_section1759138185215) + + +## Overview + +X Test Suite is a set of OpenHarmony certification test suites, including the currently supported application compatibility test suite \(ACTS\) and the device compatibility test suite \(DCTS\) that will be supported in the future. + +The **test/xts** repository contains the **acts** directory and **tools** software package. + +- The **acts** directory stores the source code and configuration files of ACTS test cases. The ACTS helps device vendors detect the software incompatibility as early as possible and ensures that the software is compatible to OpenHarmony during the entire development process. +- The **tools** software package stores the test case development framework related to **acts**. + +## Directory Structure + +The directory structure of the **test/xts** repository is as follows: + +├── acts + +│ ├── BUILD.gn \#Compilation configuration of test cases + +│ └── subsystem\_lite \# Test case source code + +└── tools + +│ └── build \#Templates and scripts related to test cases compilation + +│ └── hcpptest \#Source code of the development framework for SmartVision device \(IP camera\) test cases + +│ └── hctest \#Source code of the development framework for IoTLink module test cases + +│ └── BUILD.gn \#Compilation configuration + +│ └── build.sh \#Compiling entry + +## Limitations and Constraints + +You must use the C language to develop IoTLink module ACTS cases, and C++ for SmartVision device \(IP camera\) ACTS cases. + +## Development Guidelines + +### ACTS Cases for the IoTLink Module + +The HCTest framework is used. + +The HCTest framework supports the C language and allows you to execute your test cases on the connecting module. The framework is enhanced and adapted based on the open-source test framework Unity. + +1. Store test cases in the **test/xts/acts** repository. + + ├── acts + + │ ├── BUILD.gn + + │ └──subsystem\_lite + + │ │ └── module\_hal + + │ │ │ └── BUILD.gn + + │ │ │ └── src + +2. Write the test case stored in the **src** directory. + + a. Import the test framework. + + ``` + #include "hctest.h" + ``` + + b. Use the **LITE\_TEST\_SUIT** macro to define names of the subsystem, module, and test suite. + + ``` + /** + * @brief register a test suit named "IntTestSuite" + * @param test subsystem name + * @param example module name + * @param IntTestSuite test suit name + */ + LITE_TEST_SUIT(test, example, IntTestSuite); + ``` + + c. Define Setup and TearDown. + + Format: test suite name+Setup, test suite name+TearDown. + + The Setup and TearDown functions must exist, but function bodies can be empty. + + d. Use the **LITE\_TEST\_CASE** macro to write the test case. + + Three parameters are involved: test suite name, test case name, and test case level. + + The case level can be one of the following: + + **Level0**, **Level1**, **Level2**, **Level3**, and **Level4**. + + ``` + LITE_TEST_CASE(IntTestSuite, TestCase001, Level0) + { + //do something + }; + ``` + + The following table describes the case levels. + + **Table 1** Case levels + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Level

+

Definition

+

Testing Scope

+

Level0

+

Smoke

+

Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable.

+

Level1

+

Basic

+

Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable.

+

Level2

+

Major

+

Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing.

+

Level3

+

Regular

+

Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions.

+

Level4

+

Rare

+

Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations.

+
+ + e. Use the **RUN\_TEST\_SUITE** macro to register the test suite. + + ``` + RUN_TEST_SUITE(IntTestSuite); + ``` + +3. Create the configuration file of the test module. + + Create a **BUILD.gn** \(example\) compilation file in each test module directory. Specify the name of the compiled static library and its dependent header file and library in the compilation file. The format is as follows: + + ``` + import("//test/xts/tools/build/suite_lite.gni") + hctest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/test_demo.c", + ] + include_dirs = [ ] + cflags = [ "-Wno-error" ] + } + ``` + +4. Add compilation options to the **BUILD.gn** file in the **acts** directory. + + You need to add the test module to the **test/xts/acts/BUILD.gn** script in the **acts** directory. + + ``` + lite_component("acts") { + ... + if(board_name == "liteos_riscv") { + features += [ + ... + "//xts/acts/subsystem_lite/module_hal:ActsDemoTest" + ] + } + } + ``` + +5. Run compilation commands. + + **python build.py wifiiot -b debug** + + **out/wifiiot** + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >The ACTS compilation middleware used for IoTLink module is a static library, which will be linked to the version image **Hi3861\_wifiiot\_app\_allinone.bin**. + + +### ACTS Cases for the SmartVision Device \(IP Camera\) + +The HCPP Test framework is enhanced and adapted based on the open-source googletest framework. + +1. Store test cases in the **test/xts/acts** repository. + + ├── acts + + │ ├── BUILD.gn + + │ └──subsystem\_lite + + │ │ └── module\_posix + + │ │ │ └── BUILD.gn + + │ │ │ └── src + +2. Write the test case stored in the **src** directory. + + a. Import the test framework. + + The following statement imports **gtest.h**. + + ``` + #include "gtest/gtest.h" + ``` + + b. Define Setup and TearDown. + + ``` + class TestSuite: public testing::Test { + protected: + // Preset action of the test suite, which is executed before the first test case + static void SetUpTestCase(void){ + } + // Test suite cleanup action, which is executed after the last test case + static void TearDownTestCase(void){ + } + // Preset action of the test case + virtual void SetUp() + { + } + // Cleanup action of the test case + virtual void TearDown() + { + } + }; + ``` + + c. Use the **HWTEST** or **HWTEST\_F** macro to write the test case. + + **HWTEST**: definition of common test cases, including the test suite name, test case name, and case marking. + + **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case marking. + + A macro definition contains three parameters: test suite name, test case name, and test case level. + + The case level can be one of the following: + + **Level0**, **Level1**, **Level2**, **Level3**, and **Level4**. + + ``` + HWTEST_F(TestSuite, TestCase_0001, Level0) { + // do something + } + ``` + + The following table describes the case levels. + + **Table 2** Case levels + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Level

+

Definition

+

Testing Scope

+

Level0

+

Smoke

+

Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable.

+

Level1

+

Basic

+

Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable.

+

Level2

+

Major

+

Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing.

+

Level3

+

Regular

+

Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions.

+

Level4

+

Rare

+

Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations.

+
+ +3. Create the configuration file of the test module. + + Create a **BUILD.gn** \(example\) compilation file in each test module directory. Specify the name of the compiled static library and its dependent header file and library in the compilation file. Each test module is independently compiled into a **.bin** executable file, which can be directly mounted to the development board for testing. + + Example: + + ``` + import("//test/xts/tools/build/suite_lite.gni") + + hcpptest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/TestDemo.cpp" + ] + + include_dirs = [ + "src", + ... + ] + deps = [ + ... + ] + cflags = [ "-Wno-error" ] + } + + ``` + +4. Add compilation options to the **BUILD.gn** file in the **acts** directory. + + Add the test module to the **test/xts/acts/BUILD.gn** script in the **acts** directory. + + ``` + lite_component("acts") { + ... + else if(board_name == "liteos_a") { + features += [ + ... + "//xts/acts/subsystem_lite/module_posix:ActsDemoTest" + ] + } + } + ``` + +5. Run compilation commands. + + - For Hi3518E V300: + + **python build.py ipcamera\_hi3518ev300 -b debug** + + **out/ipcamera\_hi3518ev300** + + - For Hi3516D V300: + + **python build.py ipcamera\_hi3518ev300 -b debug** + + **out/ipcamera\_hi3516dv300** + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >The ACTS for the SmartVision device \(IP camera\) is independently compiled to a **.bin** executable file, which can be directly mounted to the development board for testing. + + +### Executing ACTS Cases for the IoTLink Module + +**Obtaining the testing software package** + +Obtain the image from the **out\\wifiiot\\Hi3861\_wifiiot\_app\_allinone.bin** directory. + +Note: To check whether the ACTS is integrated into the current image, go to **out\\wifiiot\\Hi3861\_wifiiot\_app.map** to check whether the corresponding **.a** file is compiled. + +**Burning the image into the development board** + +**Performing testing** + +1. Use a serial port tool to log in to the development board and save information about the serial port. +2. Restart the device and view serial port logs. + +**Analyzing the test result.** + +View the serial port logs, whose format is as follows: + +The log for each test suite starts with **Start to run test suite:** and ends with **xx Tests xx Failures xx Ignored**. + +### Executing ACTS Cases for the SmartVision Device \(IP Camera\) + +Currently, test cases are shared by the NFS and mounted to the development board for execution. + +**Setting up the environment** + +1. Use a network cable or wireless network to connect the IP camera development board to your personal computer \(PC\). +2. Configure the IP address, subnet mask, and gateway for the IP camera development board. Ensure that the development board and the PC are in the same network segment. +3. Install and register the NFS server on the PC and start the NFS service. +4. Run the **mount** command for the IP camera development board to ensure that the development board can access NFS shared files on the PC. + + Format: **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_IP camera development board directory_ **nfs** + + Example: + + ``` + mount 192.168.1.10:/nfs /nfs nfs + ``` + + +**Executing test cases** + +1. View the serial port logs. +2. Run the **./**_Test module_**.bin** command to execute test cases of each test suite. + diff --git "a/get-code/\346\272\220\347\240\201\350\216\267\345\217\226.md" "b/get-code/\346\272\220\347\240\201\350\216\267\345\217\226.md" index 1e60cd9d33a3d5b070f0d74328795631a9cfb01a..63ab34576bc0c8bdfda6939fe6cc3851d20680d4 100755 --- "a/get-code/\346\272\220\347\240\201\350\216\267\345\217\226.md" +++ "b/get-code/\346\272\220\347\240\201\350\216\267\345\217\226.md" @@ -188,7 +188,7 @@ OpenHarmony是HarmonyOS的开源版,由华为捐赠给开放原子开源基金 ## 操作 -接下来将组件添加到开发项目中,假定要获取的组件名为@ohos/demo,具体操作如下: +接下来将组件添加到开发项目中,假定要获取的组件名为@ohos/demo,实际操作过程中以实际组件名为准,具体操作如下: 1. 进入开发目录,执行如下命令,采用默认模板创建一个开发项目。 diff --git "a/get-code/\350\216\267\345\217\226\345\267\245\345\205\267.md" "b/get-code/\350\216\267\345\217\226\345\267\245\345\205\267.md" index c5eb3ee2d83b0f982bc4285e302b8e6772c8548c..beef98044a486e4a7c7c0f58dad5f2629df22bcf 100755 --- "a/get-code/\350\216\267\345\217\226\345\267\245\345\205\267.md" +++ "b/get-code/\350\216\267\345\217\226\345\267\245\345\205\267.md" @@ -1,6 +1,10 @@ # 获取工具 -- [编译工具链获取路径](#zh-cn_topic_0000001055701144_section18750162432511) +- [Docker方式获取编译环境](#zh-cn_topic_0000001055701144_section107932281315) + - [基于HPM的Docker环境](#zh-cn_topic_0000001055701144_section054931895313) + - [独立Docker环境](#zh-cn_topic_0000001055701144_section980782720014) + +- [软件包方式获取编译工具链](#zh-cn_topic_0000001055701144_section18750162432511) - [获取设备开发工具(HUAWEI DevEco Device Tool)](#zh-cn_topic_0000001055701144_section12307171315108) - [工具简介](#zh-cn_topic_0000001055701144_section68281728193514) - [工具获取路径](#zh-cn_topic_0000001055701144_section13785205443514) @@ -10,11 +14,178 @@ - [工具获取路径](#zh-cn_topic_0000001055701144_section1572093543613) - [工具使用指南](#zh-cn_topic_0000001055701144_section1125615298385) -## 编译工具链获取路径 +## Docker方式获取编译环境 + +OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完成复杂的开发环境准备工作。两种Docker环境及适用场景如下: + +- 基于HPM的Docker环境:适用于使用HPM工具进行发行版编译的场景。 +- 独立Docker环境:适用于直接基于Ubuntu、Windows操作系统平台进行版本编译的场景。 + + 独立Docker环境目前容器化构建选项支持情况如下: + + **表 1** Docker镜像介绍 + + + + + + + + + + + + + + +

适配的硬件平台

+

Docker镜像仓库

+

标签

+

说明

+

Hi3861/Hi3516/Hi3518

+

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

+

0.0.2

+

已经预安装OpenHarmony版本的编译环境,支持Hi3861/Hi3516/Hi3518三种平台的版本构建

+
+ + +### 基于HPM的Docker环境 + +docker\_dist是一个[HPM](https://hpm.harmonyos.com/)系统中的模板组件,能够帮助用户快速初始化HPM工程,利用docker镜像来快速编译OpenHarmony发行版,在很大程度上简化了编译前的环境配置。开发者在配置好Ubuntu和[hpm-cli](https://device.harmonyos.com/cn/docs/develop/bundles/oem_bundle_guide_prepare-0000001050129846)开发环境后,可以通过以下步骤来使用我们提供的Docker环境。 + +**搭建Docker环境** + +1. 初始化安装模板。在任意工作目录中执行以下命令。 + + ``` + hpm init -t @ohos/docker_dist + ``` + +2. 修改publishAs。 + + 因为获取到的是模板类型的包,要把包的类型改为需要的类型。 在当前目录下打开bundle.json文件,把"publishAs"字段的值由"template"改为"distribution"。 + +3. 选择解决方案。设置解决方案发行版的环境变量。 + + 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) **说明:** + >windows下使用cmd设置需要使用如下命令 + >``` + >set solution=发行版名称 + >``` + + +**编译源码** + +执行编译。以ip\_camera\_hi3518ev300为例。 + +以下命令可以帮助用户自动安装docker, 拉取镜像,并且在容器中开始运行对应解决方案的拉取和编译。 + +``` +hpm run docker +``` + +执行成功结果如下: + +``` +...... +ohos ipcamera_hi3518 build success! +@ohos/ip_camera_hi3518ev300: distribution building completed. +``` + +>![](public_sys-resources/icon-note.gif) **说明:** +>自动安装docker只能在Ubuntu环境下执行,如果其他环境,需要用户自行安装docker,然后拉取镜像,执行编译。相关操作如下: +>``` +># 拉取镜像 +>docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2 +># linux环境下的编译 +>hpm run distWithDocker +># windows下的编译,需要配置gitbash +>hpm config set shellPath "gitbash路径" +>hpm run distWithDocker +>``` + +### 独立Docker环境 + +OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud.com/swr/?region=cn-south-1#/app/warehouse/warehouseMangeDetail/goldensir/openharmony-docker/openharmony-docker?type=ownImage)上。开发者可以通过该镜像在很大程度上简化编译前的环境配置。开发者在配置好开发环境后,通过以下步骤来使用Docker环境。本Docker支持Ubuntu/Windows平台,下文将以Ubuntu系统为例进行使用介绍。 + +**方式一:从HuaweiCloud SWR上直接获取Docker镜像进行构建:** + +1. 获取Docker镜像。 + + ``` + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2 + ``` + +2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 + + ``` + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.2 + ``` + +3. 通过如下编译脚本启动wifiiot、ipcamera\_hi3516dv300、ipcamera\_hi3518ev300不同平台的编译。 + + ``` + python build.py wifiiot/ipcamera_hi3516dv300/ipcamera_hi3518ev300 + ``` + + ``` + + ``` + + +**方式二:通过Dockerfile 构建本地Docker镜像进行构建** + +1. 获取Dockerfile脚本文件,用来构建本地Docker镜像。 + + ``` + git clone https://gitee.com/openharmony/docs.git + ``` + +2. 进入Dockerfile代码目录路径执行Docker镜像构建命令。 + + ``` + cd docs/docker + ./build.sh + ``` + +3. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 + + ``` + docker run -it -v $(pwd):/home/openharmony openharmony-docker:0.0.2 + ``` + +4. 通过如下编译脚本启动wifiiot、ipcamera\_hi3516dv300、ipcamera\_hi3518ev300不同平台的编译。 + + ``` + python build.py wifiiot/ipcamera_hi3516dv300/ipcamera_hi3518ev300 + ``` + + +## 软件包方式获取编译工具链 + +如果不使用Docker,使用软件包方式安装编译环境,请按本节要求,从镜像站点下载部分编译工具链,具体如下表所示。 -从镜像站点下载的编译工具链如下表所示。全部编译工具链的下载以及安装,请参考“快速入门”的“[Hi3861环境搭建](../quick-start/搭建环境.md)、[Hi3516环境搭建](../quick-start/搭建环境-0.md)、[Hi3518环境搭建](../quick-start/搭建环境-2.md)”部分。 +全部编译工具链的下载以及安装,请参考“快速入门”的“[Hi3861环境搭建](../quick-start/Hi3861搭建环境.md)、[Hi3516环境搭建](../quick-start/Hi3516搭建环境.md)、[Hi3518环境搭建](../quick-start/Hi3518搭建环境.md)”部分。 -**表 1** 编译工具链获取路径 +**表 2** 编译工具链获取路径

适用开发板

diff --git "a/guide/figures/\351\200\211\346\213\251\345\267\245\347\250\213\346\250\241\346\235\277.png" "b/guide/figures/\351\200\211\346\213\251\345\267\245\347\250\213\346\250\241\346\235\277.png" index 1b48acb2b9e5ac5f73c96f09f72233791289eabb..8598c1d7f4a16d229e4bf17a4ba299272a6ad322 100755 Binary files "a/guide/figures/\351\200\211\346\213\251\345\267\245\347\250\213\346\250\241\346\235\277.png" and "b/guide/figures/\351\200\211\346\213\251\345\267\245\347\250\213\346\250\241\346\235\277.png" differ diff --git "a/guide/\345\272\224\347\224\250\345\256\236\344\276\213-5.md" "b/guide/\345\272\224\347\224\250\345\256\236\344\276\213-5.md" index a2dd8d6f1253b1de99c4ff7ee10401d9ff0925dc..a47f012d6473f2876b503889d61621c2e6c2c8cc 100755 --- "a/guide/\345\272\224\347\224\250\345\256\236\344\276\213-5.md" +++ "b/guide/\345\272\224\347\224\250\345\256\236\344\276\213-5.md" @@ -11,7 +11,12 @@ - 本示例编译结果路径为“out/ipcamera\_hi3516dv300/dev\_tools/bin/camera\_sample”,为让文件能在单板中执行,可将示例文件通过读卡器复制至TF卡中,或者修改camera\_sample的编译脚本将结果文件复制至rootfs.img中。 - **修改方法:**将源码路径“applications/sample/camera/media/BUILD.gn”中第一处的output\_dir = "$root\_out\_dir/dev\_ools"语句修改为output\_dir = "$root\_out\_dir/",重新执行源码仓编译并烧写入单板后,可在单板bin目录下找到camera\_sample文件。 + 修改源码路径“applications/sample/camera/media/BUILD.gn”中第一处的output\_dir。 + + - 修改前:output\_dir = "$root\_out\_dir/dev\_ools" + - 修改后:output\_dir = "$root\_out\_dir/" + + 重新执行源码仓编译并烧写入单板后,可在单板bin目录下找到camera\_sample文件。 >![](public_sys-resources/icon-notice.gif) **须知:** >实例运行拍照和录像功能需要插入TF卡\(最大容量支持128GB\),系统启动后自动将TF卡挂载至/sdcard目录,如果在启动后插入则需要手动挂载。查看拍照和录像内容可将TF卡中内容复制到电脑中进行查看,预览功能无需TF卡。 diff --git "a/guide/\345\272\224\347\224\250\345\256\236\344\276\213.md" "b/guide/\345\272\224\347\224\250\345\256\236\344\276\213.md" index fb79281bdcf26b6666963281aa260fb5daae78c9..718764fe6fad69470c74717a79893c246b965f8c 100755 --- "a/guide/\345\272\224\347\224\250\345\256\236\344\276\213.md" +++ "b/guide/\345\272\224\347\224\250\345\256\236\344\276\213.md" @@ -2,7 +2,12 @@ - 开发板介绍及编译烧录、运行镜像基本流程参考对应开发板快速入门手册:[Hi3518快速入门](../quick-start/Hi3518开发板介绍.md),编译结果包含示例,结果文件为out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample,可将文件通过读卡器复制至TF卡中,或者修改camera\_sample的编译脚本将结果文件复制至rootfs.img中。 - **修改方法**:将`applications/sample/camera/media/BUILD.gn`中的`output_dir = "$root_out_dir/dev_tools"`语句修改为`output_dir = "$root_out_dir/"`,重新执行源码仓编译并烧写入单板后,可在单板bin目录下找到`camera_sample`文件。 + 修改applications/sample/camera/media/BUILD.gn中的output\_dir。 + + - 修改前:output\_dir = "$root\_out\_dir/dev\_tools" + - 修改后:output\_dir = "$root\_out\_d_i_r/" + + 重新执行源码仓编译并烧写入单板后,可在单板bin目录下找到camera\_sample文件。 - 相机示例代码为applications/sample/camera/media/camera\_sample.cpp。 diff --git "a/guide/\345\274\200\345\217\221\345\207\206\345\244\207.md" "b/guide/\345\274\200\345\217\221\345\207\206\345\244\207.md" index 295710db31a9ade593c1d38392ed61636dfe3e51..fe6693aebc2a2242c2e395cf7e2b92748fec662b 100755 --- "a/guide/\345\274\200\345\217\221\345\207\206\345\244\207.md" +++ "b/guide/\345\274\200\345\217\221\345\207\206\345\244\207.md" @@ -9,41 +9,12 @@ ## 创建项目 -DevEco Studio配置完成后,请根据如下步骤创建项目(暂不支持直接创建“smartVision”类型项目)。 +DevEco Studio配置完成后,请根据如下步骤创建项目。 ->![](public_sys-resources/icon-note.gif) **说明:** ->当前的DevEco Studio提供基本的开发功能,至于模拟器界面预览、代码调测将在下个版本提供,敬请期待。 - -1. 运行DevEco Studio,点击**File \> Project**,选择“Lite Wearable”下的“Empty Feature Ability”模板。 +1. 运行DevEco Studio,点击**File \> Project**,选择“Smart Vision”下的“Empty Feature Ability”模板。 **图 1** 选择工程模板 ![](figures/选择工程模板.png "选择工程模板") -2. 创建成功后,修改**entry \> src \> main**目录下的config.json文件。 - 1. 将“deviceType”的取值修改为"smartVision"。 - 2. 在abilities数组内新增“visible”属性,取值设置为“true”。 - - ``` - "deviceConfig": {}, - "module": { - "deviceType": [ - "smartVision" //将deviceType 改为"smartVision" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - {"name": - "default","icon": - "$media:icon", - "label": "airquality", - "visible": true, //新增“visible”属性,值为“true” - "type": "page" - } - ], - ``` - - +2. 点击Next,配置项目名称和路径等信息后点击Finish按钮即完成项目创建。 diff --git "a/guide/\351\252\214\350\257\201.md" "b/guide/\351\252\214\350\257\201.md" index d3239ead0ccc47ffc8326765d5e69080ba17e529..18f3edafb9acfae29ed17d57f983a92d6ee4adba 100755 --- "a/guide/\351\252\214\350\257\201.md" +++ "b/guide/\351\252\214\350\257\201.md" @@ -1,6 +1,6 @@ # 验证 -编译过程请参考《[Hi3861快速入门-源码编译](../quick-start/Hi3861开发板第一个示例程序.md)》,烧录过程请参考《[Hi3861快速入门-镜像烧录](../quick-start/Hi3861开发板第一个示例程序.md)》。 +编译过程请参考《[Hi3861快速入门-源码编译](../quick-start/开发Hi3861第一个示例程序.md)》,烧录过程请参考《[Hi3861快速入门-镜像烧录](../quick-start/开发Hi3861第一个示例程序.md)》。 完成以上两步后,按下RST键复位模组,可发现LED在周期性闪烁,与预期相符,验证完毕。 diff --git "a/porting/CMake\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" "b/porting/CMake\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" new file mode 100644 index 0000000000000000000000000000000000000000..9fa96a610b13c43215380b1e518d02bdbb74c9d9 --- /dev/null +++ "b/porting/CMake\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" @@ -0,0 +1,465 @@ +# CMake方式组织编译的库移植 + +- [源码获取](#section1771132116245) +- [移植思路](#section9737174410328) +- [交叉编译](#section38205577332) + - [编译参考](#section1088111263418) + - [设置执行交叉编译](#section8168182883515) + +- [测试](#section6686144293611) +- [将该库编译添加到工程中](#section1651053153715) + +以double-conversion库为例,其移植过程如下文所示 + +## 源码获取 + +从仓库[获取double-conversion源码](https://github.com/google/double-conversion),其目录结构如下表: + +**表 1** 源码目录结构 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

double-conversion/cmake/

+

CMake组织编译使用到的模板

+

double-conversion/double-conversion/

+

源文件目录

+

double-conversion/msvc/

+

-

+

double-conversion/test/

+

测试用例源文件

+

double-conversion/.gitignore

+

-

+

double-conversion/AUTHORS

+

-

+

double-conversion/BUILD

+

-

+

double-conversion/CMakeLists.txt

+

CMake方式顶层编译组织文件

+

double-conversion/COPYING

+

-

+

double-conversion/Changelog

+

-

+

double-conversion/LICENSE

+

-

+

double-conversion/Makefile

+

-

+

double-conversion/README.md

+

-

+

double-conversion/SConstruct

+

-

+

double-conversion/WORKSPACE

+

-

+
+ +## 移植思路 + +移植思路:通过修改工具链,交叉编译该三方库,生成OpenHarmony平台的可执行文件,最后再通过GN调用CMake的方式添加到OpenHarmony工程中。 + +## 交叉编译 + +### 编译参考 + +代码仓库的README.md中详细介绍了使用CMake编译double-conversion库的步骤,以及测试方法。本文参考该指导设置该库的编译配置,并完成测试。若开发人员在移植过程中对该库的编译选项配置有疑惑的地方,[可参考该指导](https://github.com/google/double-conversion/blob/master/README.md)。对于其他使用CMake可独立编译的三方库,在移植时可以参考其自带的编译指导。 + +### 设置执行交叉编译 + +CMake方式可通过指定工具链进行交叉编译,修改并编译该库,生成OpenHarmony平台的可执行文件,步骤如下: + +1. 设置工具链 + + 将下列clang工具链配置添加到该工程的顶层CMakeLists.txt(即[表1中的该文件](#table824211132418))中即可。 + + ``` + set(CMAKE_CROSSCOMPILING TRUE) + set(CMAKE_SYSTEM_NAME Generic) + set(CMAKE_CXX_COMPILER_ID Clang) + set(CMAKE_TOOLCHAIN_PREFIX llvm-) + #指定c编译工具(确保工具链所在路径已经添加到了PATH环境变量中)和编译标志,使用clang编译时标志中必须指定--target,否则无法交叉编译。 + set(CMAKE_C_COMPILER clang) + set(CMAKE_C_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w") + #指定c++编译工具(确保工具链所在路径已经添加到了PATH环境变量中)和编译标志,必须指定--target,否则无法交叉编译。 + set(CMAKE_CXX_COMPILER clang++) + set(CMAKE_CXX_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w") + #指定链接工具和链接标志,必须指定--target和--sysroot,其中OHOS_ROOT_PATH可通过cmake命令后缀参数来指定。 + set(MY_LINK_FLAGS "--target=arm-liteos --sysroot=${OHOS_SYSROOT_PATH}") + set(CMAKE_LINKER clang) + set(CMAKE_CXX_LINKER clang++) + set(CMAKE_C_LINKER clang) + set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINKER} ${MY_LINK_FLAGS} -o ") + set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINKER} ${MY_LINK_FLAGS} -o ") + #指定链接库的查找路径。 + set(CMAKE_SYSROOT ${OHOS_SYSROOT_PATH}) + ``` + +2. 执行编译 + + linux命令行中进入double-conversion的源文件目录(即[表1所示目录](#table824211132418)),执行下列命令: + + ``` + mkdir build && cd build + cmake .. -DBUILD_TESTING=ON -DOHOS_SYSROOT_PATH="..." + make -j + ``` + + 其中OHOS\_SYSROOT\_PATH需用绝对路径指定出sysroot目录的位置,以OpenHarmony为例即目录openHarmony/prebuilts/lite/sysroot的绝对路径。 + +3. 查看结果 + + 步骤2操作完成后,build目录下会生成静态库文件和测试用例: + + **表 2** 编译生成文件目录结构 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

double-conversion/build/libdouble-conversion.a

+

生成的静态库文件

+

double-conversion/build/test/

+

目录下存放生成的测试用例和相关CMake缓存文件

+

double-conversion/build/CMakeCache.txt

+

CMake构建过程中的缓存文件

+

double-conversion/build/CMakeFiles/

+

-

+

double-conversion/build/cmake_install.cmake

+

-

+

double-conversion/build/CTestTestfile.cmake

+

-

+

double-conversion/build/DartConfiguration.tcl

+

-

+

double-conversion/build/generated/

+

-

+

double-conversion/build/Makefile

+

-

+

double-conversion/build/Testing/

+

-

+
+ + +## 测试 + +1. 搭建OpenHarmony环境 + + 以hi3518ev300为例,编译出OpenHarmony镜像,烧写到开发板,参考[开发Hi3518第一个示例程序.md](https://gitee.com/openharmony/docs/blob/master/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md)。 + + 进入系统如下所示: + + **图 1** OpenHarmony启动成功界面 + ![](figures/OpenHarmony启动成功界面.png "OpenHarmony启动成功界面") + +2. 挂载nfs目录,将[表2](#table1452412391911)中test目录下cctest可执行文件放入nfs目录 +3. 执行用例 + + 该库采用非交叉编译时用例是通过make test执行,CMake会有相关的执行结果统计;交叉编译时无法使用该方法,因此可直接执行生成的测试文件完成测试。 + + - 挂载成功后执行下列命令可列出用例所有条目: + + ``` + cd nfs + ./cctest --list + ``` + + 上述命令执行结果部分展示: + + ``` + test-bignum/Assign< + test-bignum/ShiftLeft< + test-bignum/AddUInt64< + test-bignum/AddBignum< + test-bignum/SubtractBignum< + test-bignum/MultiplyUInt32< + test-bignum/MultiplyUInt64< + test-bignum/MultiplyPowerOfTen< + test-bignum/DivideModuloIntBignum< + test-bignum/Compare< + test-bignum/PlusCompare< + test-bignum/Square< + test-bignum/AssignPowerUInt16< + test-bignum-dtoa/BignumDtoaVariousDoubles< + test-bignum-dtoa/BignumDtoaShortestVariousFloats< + test-bignum-dtoa/BignumDtoaGayShortest< + test-bignum-dtoa/BignumDtoaGayShortestSingle< + test-bignum-dtoa/BignumDtoaGayFixed< + test-bignum-dtoa/BignumDtoaGayPrecision< + test-conversions/DoubleToShortest< + test-conversions/DoubleToShortestSingle< + ... + ``` + + - 以test-bignum条目为例,执行下列命令开始测试: + + ``` + ./cctest test-bignum + ``` + + 测试结果如下则表示通过: + + ``` + Ran 13 tests. + ``` + + +## 将该库编译添加到OpenHarmony工程中 + +1. 复制库到OpenHarmony工程中 + + 拷贝已经能够成功交叉编译的库到OpenHarmony的third\_party目录,为了不修改要移植的三方库目录下的BUILD.gn文件,再添加一层目录放置新增的gn转CMake编译适配文件,新增的文件有BUILD.gn、build\_thirdparty.py、 config.gni,新增后的目录结构如下所示。 + + **表 3** 添加到工程后的目录结构 + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

openHarmony/third_party/double-conversion/BUILD.gn

+

将三方库加入工程的gn适配文件

+

openHarmony/third_party/double-conversion/build_thirdpaty.py

+

GN调用shell命令脚本文件,由上面GN文件将相关命令传入,实现GN转CMake

+

openHarmony/third_party/double-conversion/config.gni

+

三方库编译配置文件,可修改该文件来配置用例是否参与构建等

+

openHarmony/third_party/double-conversion/double-conversion/

+

要移植的三方库目录

+
+ +2. 添加gn到CMake适配文件 + + - **新增的BUILD.gn文件实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony平台时只需修改路径即可**。 + + ``` + import("config.gni") + group("double-conversion") { + if (ohos_build_thirdparty_migrated_from_fuchisa == true) { + deps = [":make"] + } + } + if (ohos_build_thirdparty_migrated_from_fuchisa == true) { + action("make") { + script = "//third_party/double-conversion/build_thirdparty.py" + outputs = ["$root_out_dir/log_dc.txt"] + exec_path = rebase_path(rebase_path("./double-conversion/build", root_build_dir)) + command = "rm * .* -rf && $CMAKE_TOOLS_PATH/cmake .. $CMAKE_FLAG $CMAKE_TOOLCHAIN_FLAG && make -j" + args = [ + "--path=$exec_path", + "--command=${command}" + ] + } + } + ``` + + - **新增的config.gni用于配置该库,实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时只需修改CMAKE\_FLAG的配置即可。** + + ``` + #CMAKE_FLAG: config compile feature + CMAKE_FLAG = "-DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11" + + #toolchain:follow up-layer,depend on $ohos_build_compiler + if (ohos_build_compiler == "clang") { + CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + } else { + CMAKE_TOOLCHAIN_FLAG = "" + } + + #CMake tools path,no need setting if this path already joined to $PATH. + CMAKE_TOOLS_PATH = "setting CMake tools path..." + ``` + + - **新增的build\_thirdparty.py实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时无需修改即可使用。** + + ``` + import os + import sys + from subprocess import Popen + import argparse + import shlex + + def cmd_exec(command): + cmd = shlex.split(command) + proc = Popen(cmd) + proc.wait() + ret_code = proc.returncode + if ret_code != 0: + raise Exception("{} failed, return code is {}".format(cmd, ret_code)) + + def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--path', help='Build path.') + parser.add_argument('--command', help='Build command.') + parser.add_argument('--enable', help='enable python.', nargs='*') + args = parser.parse_args() + + if args.enable: + if args.enable[0] == 'false': + return + + if args.path: + curr_dir = os.getcwd() + os.chdir(args.path) + if args.command: + if '&&' in args.command: + command = args.command.split('&&') + for data in command: + cmd_exec(data) + else: + cmd_exec(args.command) + os.chdir(curr_dir) + + if __name__ == '__main__': + sys.exit(main()) + ``` + + - 在配置文件中添加开关控制该库编译,默认设为关闭 + + 在//build/lite/ohos\_var.gni文件中添加下列配置: + + ``` + declare_args() { + ohos_build_thirdparty_migrated_from_fuchisa = false + } + ``` + +3. 将库加入构建配置 + + 将该库所在目录添加到整个工程的构建配置中,以hi3518ev300为例修改文件openHarmony\\build\\lite\\product\\ ipcamera\_hi3518ev300.json,添加下列配置到“subsystem”下,如[图2所示](#fig152112412192): + + ``` + { + "name": "double-conversion", + "component": [ + { "name": "double-conversion", "dir": "//third_party/double-conversion:double-conversion", "features":[] } + ] + }, + ``` + + **图 2** 添加位置示意图 + ![](figures/添加位置示意图.png "添加位置示意图") + +4. 编译构建 + + - 手动单独构建: + + 执行下列命令 + + ``` + python build.py ipcamera_hi3518ev300 -T //third_party/double-conversion:double-conversion + ``` + + 编译成功则[build](#li15717101715249)目录下会生成静态库文件和测试用例 + + - 跟随工程自动构建: + + 修改文件//build/lite/ohos\_var.gni中的控制开关 + + ``` + ohos_build_thirdparty_migrated_from_fuchisa = true + ``` + + 执行下列命令 + + ``` + python build.py ipcamera_hi3518ev300 -b debug + ``` + + 编译成功则[build](#li15717101715249)目录下会生成静态库文件和测试用例 + + diff --git "a/porting/Makefile\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" "b/porting/Makefile\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" new file mode 100644 index 0000000000000000000000000000000000000000..26773794bacf7b133187bbf0d3bf54ca717653eb --- /dev/null +++ "b/porting/Makefile\346\226\271\345\274\217\347\273\204\347\273\207\347\274\226\350\257\221\347\232\204\345\272\223\347\247\273\346\244\215.md" @@ -0,0 +1,309 @@ +# Makefile方式组织编译的库移植 + +- [源码获取](#section114115321416) +- [设置交叉编译](#section81263255384) +- [测试](#section1830015913391) +- [将该库编译添加到工程中](#section1898016213406) + +以yxml库为例,其移植过程如下文所示 + +## 源码获取 + +从仓库[获取yxml源码](https://github.com/getdnsapi/yxml),其目录结构如下表: + +**表 1** 源码目录结构 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

yxml/bench/

+

benchmark相关代码

+

yxml/test/

+

测试输入输出文件,及测试脚本

+

yxml/Makefile

+

编译组织文件

+

yxml/.gitattributes

+

-

+

yxml/.gitignore

+

-

+

yxml/COPYING

+

-

+

yxml/yxml.c

+

-

+

yxml/yxml.c.in

+

-

+

yxml/yxml-gen.pl

+

-

+

yxml/yxml.h

+

-

+

yxml/yxml.md

+

-

+

yxml/yxml-states

+

-

+
+ +## 设置交叉编译 + +设置Makefile的交叉编译工具链,修改并编译该库,生成OpenHarmony平台的可执行文件,步骤如下: + +1. 设置工具链 + + 将下列clang工具链配置替换掉yxml库根目录的MakeFile(即[表1中的文件](#table16520154171813))中的原有配置。 + + clang工具链配置 + + ``` + #设置交叉编译工具链,确保工具链所在路径已经添加到了PATH环境变量中 + CC:=clang + AR:=llvm-ar + #cflags中必须要添加--target及--sysroot选项 + CFLAGS:=-Wall -Wextra -Wno-unused-parameter -O2 -g --target=arm-liteos -march=armv7-a --sysroot=$(OHOS_ROOT_PATH)prebuilts/lite/sysroot + ``` + + 原有配置 + + ``` + CC:=gcc + AR:=ar + CFLAGS:=-Wall -Wextra -Wno-unused-parameter -O2 -g + ``` + +2. 执行编译 + + linux命令行中进入yxml的源文件目录(即图1所示目录),执行下列命令: + + ``` + make test OHOS_SYSROOT_PATH=... + ``` + + 其中OHOS\_SYSROOT\_PATH需用绝对路径指定出sysroot所在目录,以OpenHarmony为例即源码根目录prebuilts/lite/sysroot/所在的绝对路径。 + +3. 查看结果 + + 步骤2操作完成后,yxml下会生成out目录,里面有静态库文件和测试用例: + + **表 2** yxml编译生成目录 + + + + + + + + + + + + + +

名称

+

描述

+

openHarmony/third_party/yxml/yxml/out/lib/

+

编译生成的静态库的存放目录

+

openHarmony/third_party/yxml/yxml/out/test/

+

编译生成的测试用例及其输入输出等文件的存放目录

+
+ + +## 测试 + +yxml库测试步骤与double-conversion库基本一致,可参考[2.4节](CMake方式组织编译的库移植.md#section6686144293611)的测试过程,以下内容介绍yxml库测试用例的使用方法: + +**表 3** 生成的test目录结构示意 + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

openHarmony/third_party/yxml/yxml/out/test/test.sh

+

自动化测试脚本,由于OpenHarmony不支持脚本运行,因此无法使用,可参考其内容手动测试

+

openHarmony/third_party/yxml/yxml/out/test/test

+

用于测试的可执行文件

+

openHarmony/third_party/yxml/yxml/out/test/*.xml

+

测试输入文件

+

openHarmony/third_party/yxml/yxml/out/test/*.out

+

期望的输出文件

+
+ +test.sh内容如下所示: + +``` +#!/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." +``` + +由于OpenHarmony的shell中暂不支持输入输出重定向(<和\>),所以测试时需要将输入\*.xml文件内容直接复制进shell后回车,输出内容会直接展示在shell窗口。过程如下: + +下列操作假定已按照2.4节的步骤搭建OpenHarmony,挂载并进入nfs目录: + +1. 执行下列命令 + + ``` + ./test + ``` + +2. 复制\*.xml内容到shell + + 以[test目录](#table115941423164318)下pi01.xml为例,内容如下,输入到shell并回车: + + ``` + + ``` + +3. 比较shell中输出的内容与[test目录](#table115941423164318)中对应的\*.out文件是否一致 + + 输出结果如下: + + ``` + pistart SomePI + picontent abc + piend + elemstart a + elemend + ok + ``` + + 经比较与[test目录](#table115941423164318)下pi01.out内容一致,测试通过。 + + +## 将该库编译添加到OpenHarmony工程中 + +yxml库添加的过程除了适配文件build.gn和config.gni有些许变化外,其他和double-conversion库完全一致,参考[2.5 节](CMake方式组织编译的库移植.md#section1651053153715)的配置过程。要修改的适配文件及添加后的目录结构如下: + +- yxml库新增的BUILD.gn实现如下: + +``` +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}" + ] + } +} +``` + +- yxml库新增的config.gni配置如下: + +``` +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/" +} +``` + +- 添加完成后目录结构示意: + +**表 4** 添加到工程后的目录结构 + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

openHarmony/third_party/yxml/BUILD.gn

+

将三方库加入工程的gn适配文件

+

openHarmony/third_party/yxml/build_thirdpaty.py

+

GN调用shell命令脚本文件,由上面GN文件将相关命令传入,实现GN转Makefile

+

openHarmony/third_party/yxml/config.gni

+

三方库编译配置文件,可修改该文件来配置用例是否参与构建等

+

openHarmony/third_party/yxml/yxml/

+

要移植的三方库目录

+
+ diff --git a/porting/Readme-CN.md b/porting/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..72d385e1fee9c1d665075f55a0259afd5baa92c0 --- /dev/null +++ b/porting/Readme-CN.md @@ -0,0 +1,6 @@ +# 三方库移植指南 + +- [概述](概述.md) +- [CMake方式组织编译的库移植](CMake方式组织编译的库移植.md) +- [Makefile方式组织编译的库移植](Makefile方式组织编译的库移植.md) + diff --git "a/porting/figures/OpenHarmony\345\220\257\345\212\250\346\210\220\345\212\237\347\225\214\351\235\242.png" "b/porting/figures/OpenHarmony\345\220\257\345\212\250\346\210\220\345\212\237\347\225\214\351\235\242.png" new file mode 100644 index 0000000000000000000000000000000000000000..7d0b723345d413067e0142b2035205133c907ab0 Binary files /dev/null and "b/porting/figures/OpenHarmony\345\220\257\345\212\250\346\210\220\345\212\237\347\225\214\351\235\242.png" differ diff --git "a/porting/figures/\346\267\273\345\212\240\344\275\215\347\275\256\347\244\272\346\204\217\345\233\276.png" "b/porting/figures/\346\267\273\345\212\240\344\275\215\347\275\256\347\244\272\346\204\217\345\233\276.png" new file mode 100644 index 0000000000000000000000000000000000000000..cf8dc4806e599451096fc899724e53a4b10137e9 Binary files /dev/null and "b/porting/figures/\346\267\273\345\212\240\344\275\215\347\275\256\347\244\272\346\204\217\345\233\276.png" differ diff --git a/porting/public_sys-resources/icon-caution.gif b/porting/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/porting/public_sys-resources/icon-caution.gif differ diff --git a/porting/public_sys-resources/icon-danger.gif b/porting/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/porting/public_sys-resources/icon-danger.gif differ diff --git a/porting/public_sys-resources/icon-note.gif b/porting/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/porting/public_sys-resources/icon-note.gif differ diff --git a/porting/public_sys-resources/icon-notice.gif b/porting/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/porting/public_sys-resources/icon-notice.gif differ diff --git a/porting/public_sys-resources/icon-tip.gif b/porting/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/porting/public_sys-resources/icon-tip.gif differ diff --git a/porting/public_sys-resources/icon-warning.gif b/porting/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/porting/public_sys-resources/icon-warning.gif differ diff --git "a/porting/\346\246\202\350\277\260.md" "b/porting/\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..9b230dfd42f3f25faa73c09cb41993003e4618c8 --- /dev/null +++ "b/porting/\346\246\202\350\277\260.md" @@ -0,0 +1,4 @@ +# 概述 + +本文为OpenHarmony开发者提供一些组织编译形式比较常见(CMakeLists、Makefile)的三方库的移植指南,该指南当前仅适用于Hi3516DV300和Hi3518EV300两个平台,文中着重介绍各编译组织方式下工具链的设置方法以及如何将该库的编译添加到OpenHarmony整个工程的构建中。 + diff --git "a/quick-start/Hi3516\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/quick-start/Hi3516\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..f00e0055d4a28ea5cfa484bf9f7b44de9ff01501 --- /dev/null +++ "b/quick-start/Hi3516\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,175 @@ +# Hi3516常见问题 + +- [烧写选择串口后提示失败](#section627268185113) +- [Windows电脑与单板网络连接失败](#section195391036568) +- [烧写失败](#section571164016565) +- [编译构建过程中,提示找不到“python”](#section1039835245619) +- [串口无回显](#section14871149155911) + +## 烧写选择串口后提示失败 + +- **现象描述** + + 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 + + **图 1** 打开串口失败图 + ![](figures/打开串口失败图.png "打开串口失败图") + +- **可能原因** + + 串口已经被占用。 + +- **解决办法** + +1. 按图依次选择下拉框,查找带有serial-xx的终端 + + **图 2** 查找是否存在占用串口的终端 + ![](figures/查找是否存在占用串口的终端.png "查找是否存在占用串口的终端") + +2. 点击标号中的垃圾桶图标,关闭串口。 + + **图 3** 关闭串口终端 + ![](figures/关闭串口终端.png "关闭串口终端") + +3. 重新点击烧写,选择串口并开始烧写程序 + + **图 4** 重新启动烧写任务 + + + ![](figures/changjian1.png) + + +## Windows电脑与单板网络连接失败 + +- **现象描述** + + 点击烧写并选择串口后,无法获取文件。 + + **图 5** 网络不通,单板无法获取文件图 + ![](figures/网络不通-单板无法获取文件图.png "网络不通-单板无法获取文件图") + +- **可能原因** + + 单板网络与Windows电脑不联通。 + + Windows电脑防火墙未允许Visual Studio Code联网。 + +- **解决方法** + +1. 检查网线是否连接。 +2. 点击Windows防火墙。 + + **图 6** 网络防火墙设置图 + ![](figures/网络防火墙设置图.png "网络防火墙设置图") + +3. 点击“允许应用通过防火墙”。 + + **图 7** 防火墙和网络保护界面图 + ![](figures/防火墙和网络保护界面图.png "防火墙和网络保护界面图") + +4. 查找Visual Studio Code应用。 + + **图 8** 查找Visual Studio Code应用图 + ![](figures/查找Visual-Studio-Code应用图.png "查找Visual-Studio-Code应用图") + +5. 勾选Visual Studio Code的专用和公用网络的访问权限。 + + **图 9** 允许Visual Studio Code应用访问网络 + ![](figures/允许Visual-Studio-Code应用访问网络.png "允许Visual-Studio-Code应用访问网络") + + +## 烧写失败 + +- **现象描述** + + 点击烧写并选择串口后,出现无法烧写的情况。 + +- **可能原因** + + 安装IDE插件DevEco后未重启。 + +- **解决方法** + + 重启IDE。 + + +## 编译构建过程中,提示找不到“python” + +- **现象描述** + + ![](figures/zh-cn_image_0000001055035538.png) + + +- **可能原因1** + + 没有装python。 + +- **解决办法** + + 请按照[安装Python环境](Hi3516搭建环境.md#section126442079459)安装python。 + +- **可能原因2** + + ![](figures/zh-cn_image_0000001054475589.png) + +- **解决办法** + + usr/bin目录下没有python软链接,请运行以下命令: + + ``` + # cd /usr/bin/ + # which python3 + # ln -s /usr/local/bin/python3 python + # python --version + ``` + + 例: + + ![](figures/zh-cn_image_0000001054875562.png) + + +## 串口无回显 + +- **现象描述** + + 串口显示已连接,重启单板后,回车无任何回显。 + +- **可能原因1** + + 串口连接错误。 + +- **解决办法** + + 修改串口号。 + + 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按镜像运行内[步骤1](开发Hi3516第一个应用程序示例.md#l177d08e77bd441d38991da9be4572a74)修改串口号。 + + +- **可能原因2** + + 单板U-boot被损坏。 + +- **解决办法** + + 烧写U-boot。 + + 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 + + +1. 获取引导文件U-boot。 + + >![](public_sys-resources/icon-notice.gif) **须知:** + >单板的U-boot文件请在开源包中获取: + >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. 根据USB烧写步骤烧写U-boot文件。 + + 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3518_upload-0000001057313128)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 + +3. 烧写完成后,登录串口如下图所示。 + + **图 10** U-boot烧写完成串口显示图 + ![](figures/U-boot烧写完成串口显示图.png "U-boot烧写完成串口显示图") + + diff --git "a/quick-start/Hi3516\345\274\200\345\217\221\346\235\277.md" "b/quick-start/Hi3516\345\274\200\345\217\221\346\235\277.md" index df8f265354a43363308d871b7c7d28e8faa9f0db..647d7ebfa8a46a76bd48870e4622e6801ed67150 100755 --- "a/quick-start/Hi3516\345\274\200\345\217\221\346\235\277.md" +++ "b/quick-start/Hi3516\345\274\200\345\217\221\346\235\277.md" @@ -2,12 +2,12 @@ - **[Hi3516开发板介绍](Hi3516开发板介绍.md)** -- **[搭建环境](搭建环境-0.md)** +- **[Hi3516搭建环境](Hi3516搭建环境.md)** - **[开发Hi3516第一个应用程序示例](开发Hi3516第一个应用程序示例.md)** - **[开发Hi3516第一个驱动程序示例](开发Hi3516第一个驱动程序示例.md)** -- **[常见问题](常见问题-1.md)** +- **[Hi3516常见问题](Hi3516常见问题.md)** diff --git "a/quick-start/Hi3516\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" "b/quick-start/Hi3516\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" index b9324de431c16f95db09521e53b759acb3a59a4c..8c78bd646c8946b6704122f14c89335e5b83d2ad 100755 --- "a/quick-start/Hi3516\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" +++ "b/quick-start/Hi3516\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" @@ -5,7 +5,7 @@ ## 开发板简介 -Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP、业界最新的H.265视频压缩编码器,同时集成高性能NNIE引擎,使得Hi3516DV300在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 +Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP、H.265视频压缩编码器,同时集成高性能NNIE引擎,使得Hi3516DV300在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 **图 1** Hi3516单板正面外观图 diff --git "a/quick-start/Hi3516\346\220\255\345\273\272\347\216\257\345\242\203.md" "b/quick-start/Hi3516\346\220\255\345\273\272\347\216\257\345\242\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..fadc32dfe8cd6364f6fe1c0bd57d62e217855a1b --- /dev/null +++ "b/quick-start/Hi3516\346\220\255\345\273\272\347\216\257\345\242\203.md" @@ -0,0 +1,572 @@ +# Hi3516搭建环境 + +- [环境要求](#section179175261196) + - [硬件要求](#section5840424125014) + - [软件系统要求](#section965634210501) + - [Linux构建工具要求](#section7786130185118) + - [Windows开发工具要求](#section939920316515) + +- [安装Linux编译环境(方法一:Docker方式)](#section748632362420) +- [安装Linux编译环境(方法二:安装包方式)](#section182916865219) + - [连接Linux服务器](#section14371161220386) + - [将Linux shell改为bash](#section77681442174413) + - [安装Python环境](#section126442079459) + - [安装文件打包工具](#section8352161417450) + - [安装gn](#section16725103716357) + - [安装ninja](#section18469114293513) + - [安装LLVM](#section18344103584516) + - [安装hc-gen](#section2075110583451) + - [安装Java 虚拟机环境](#section101989994613) + - [安装hap打包工具](#section14507022124614) + - [安装hap签名工具](#section15236123816464) + +- [安装Windows开发环境](#section1995840162515) + +## 环境要求 + +### 硬件要求 + +- Linux服务器 +- Windows工作台(主机电脑) +- Hi3516DV300 IoT Camera开发板 +- USB转串口线、网线(Windows工作台通过USB转串口线、网线与Hi3516DV300 开发板连接) + +各硬件连接关系如下图所示。 + +**图 1** 硬件连线图 + + +![](figures/矩形备份-292.png) + +### 软件系统要求 + +**表 1** Hi3516DV300开发板开发平台要求 + + + + + + + + + + + + + + + + + + + + + +

硬件

+

软件

+

描述

+

备注

+

Linux编译服务器

+

操作系统

+

Ubuntu16.04及以上64位系统版本,Shell使用bash。

+
说明:

通常系统默认安装samba、vim等常用软件,需要做适当适配以支持linux文件共享。

+
+

开发人员可以在Windows工作台中进行程序开发,或者远程登录到Linux服务器进行程序开发。

+

Windows工作台

+

操作系统

+

Windows XP/Windows7/Windows10

+

USB转串口驱动

+

http://www.hihope.org/download/AllDocuments

+

驱动软件名:USB-to-Serial Comm Port.exe

+
+ +### Linux构建工具要求 + +Linux服务器通用环境配置需要的工具及其获取途径如下表所示。 + +**表 2** Linux服务器开发工具及获取途径 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

Python3.7+

+

执行编译脚本工具

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

bash

+

执行命令行工具

+

通过互联网获取

+

gn

+

产生ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

执行ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+

LLVM

+

编译工具链

+

https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar

+

hc-gen

+

驱动配置编译工具

+

https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar

+

IPOP、PuTTY或其他超级终端

+

连接Linux服务器工具(任选其一)

+

通过互联网获取(如:https://www.putty.org/

+

Java 虚拟机环境

+

编译、调试和运行Java程序

+

通过apt-get install安装

+

hmos_app_packing_tool

+

hap打包工具

+

https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar

+

hapsigntool

+

hap签名工具

+

https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar

+
+ +### Windows开发工具要求 + +**表 3** Windows工作台开发工具及获取途径 + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

Visual Studio Code

+

代码编辑工具

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

IDE开发工具,Visual Studio Code插件,支持代码编译、烧录和调试等功能,支持C/C++语言

+
说明:

HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持代码编辑、编译、烧录、调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上。

+
+

https://device.harmonyos.com/cn/ide

+
+ +## 安装Linux编译环境(方法一:Docker方式) + +Linux编译环境可以通过Docker方式快速安装,具体请参见[Docker方式获取编译环境](../get-code/获取工具.md)的“搭建Docker环境”。 + +## 安装Linux编译环境(方法二:安装包方式) + +>![](public_sys-resources/icon-notice.gif) **须知:** +>- 如果后续通过“HPM组件方式”或“HPM包管理器命令行工具方式”获取源码,不需要安装gn、ninja、LLVM、hc-gen编译工具。 +>- (推荐)如果后续通过“镜像站点方式”或“代码仓库方式”获取源码,需要安装gn、ninja、LLVM、hc-gen编译工具。安装gn、ninja、LLVM、hc-gen编译工具时,请确保编译工具的环境变量路径唯一。 + +### 连接Linux服务器 + +使用Windows远程登录Linux,以PUTTY工具为例: + +1. 打开[PuTTY工具](https://www.putty.org/),输入Linux服务器IP地址,后点击“open”,打开连接。 + + **图 2** PuTTY界面示例图 + ![](figures/PuTTY界面示例图.png "PuTTY界面示例图") + +2. 弹框告警选择“是\(Y\)”。 +3. 弹出界面中输入帐号并按回车键,继续输入密码并回车键。 + + **图 3** 登录界面图 + ![](figures/登录界面图.png "登录界面图") + +4. 登录成功。 + + **图 4** 登录成功界面 + ![](figures/登录成功界面.png "登录成功界面") + + +### 将Linux shell改为bash + +查看shell是否为bash,在终端运行如下命令 + +``` +ls -l /bin/sh +``` + +如果显示为“/bin/sh -\> bash”则为正常,否则请按以下方式修改: + +**方法一**:在终端运行如下命令,然后选择 no。 + +``` +sudo dpkg-reconfigure dash +``` + +**方法二**:先删除sh,再创建软链接。 + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### 安装Python环境 + +1. 打开Linux编译服务器终端。 +2. 输入如下命令,查看python版本号,需使用python3.7以上版本。 + + ``` + python3 --version + ``` + + 如果低于python3.7版本,不建议直接升级,请按照如下步骤重新安装。以python3.8为例,按照以下步骤安装python。 + + 1. 运行如下命令,查看Ubuntu版本: + + ``` + cat /etc/issue + ``` + + 1. 根据Ubuntu不同版本,安装python。 + - 如果Ubuntu 版本为18+,运行如下命令。 + + ``` + sudo apt-get install python3.8 + ``` + + - 如果Ubuntu版本为16,请以下载包的方式安装python。 + + 1. python安装环境依赖\(gcc, g++, make, zlib, libffi\)请运行如下命令: + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. 获取[python3.8.5安装包](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz),将其放至linux服务器中,运行如下命令 : + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. 确定python安装好后,将python路径链接到"/usr/bin/python"。 + + 输入如下命令,查看python是否正确软链接到python3.8。 + + ``` + python --version + ``` + + 如果回显不是python 3.8.5,则运行如下命令,查看python3.8所在目录: + + ``` + which python3.8 + ``` + + 将以下命令中的 "python3.8-path" 替换为 "which python3.8" 命令执行后的回显路径 + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. 安装并升级Python包管理工具(pip3),任选如下一种方式。 + - **命令行方式:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **安装包方式:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. 运行如下命令,安装python模块setuptools。 + + ``` + pip3 install setuptools + ``` + +6. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 + - **命令行方式:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **安装包方式:** + 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 + + 下载路径:“[https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files)” + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + + +### 安装文件打包工具 + +1. 打开Linux编译服务器终端。 +2. 运行如下命令,安装dosfstools。 + + ``` + sudo apt-get install dosfstools + ``` + +3. 运行如下命令,安装mtools。 + + ``` + sudo apt-get install mtools + ``` + +4. 运行如下命令,安装mtd-utils。 + + ``` + sudo apt-get install mtd-utils + ``` + + +### 安装gn + +1. 打开Linux编译服务器终端。 +2. [下载gn工具](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar)。 +3. 解压gn安装包至\~/gn路径下。 + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/gn:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装ninja + +1. 打开Linux编译服务器终端。 +2. [下载ninja工具](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar)。 +3. 解压ninja安装包至\~/ninja路径下。 + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/ninja:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装LLVM + +1. 打开Linux编译服务器终端。 +2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar)。 +3. 解压LLVM安装包至\~/llvm路径下。 + + ``` + tar -xvf llvm-linux-9.0.0-34042.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装hc-gen + +1. 打开Linux编译服务器终端。 +2. [下载hc-gen工具](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar)。 +3. 解压hc-gen安装包到Linux服务器\~/hc-gen路径下。 + + ``` + tar -xvf hc-gen-0.65-linux.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/hc-gen:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装Java 虚拟机环境 + +1. 打开Linux编译服务器终端。 +2. 安装Java运行时环境(JRE)。 + + ``` + sudo apt-get install default-jre + ``` + +3. 安装Java sdk开发工具包。 + + ``` + sudo apt-get install default-jdk + ``` + + +### 安装hap打包工具 + +编译OpenHarmony时,该工具用于打包系统应用。安装步骤如下: + +1. 打开Linux编译服务器终端。 +2. 打包工具使用Java开发,使用前请先安装Java 虚拟机环境。 +3. [下载hap打包工具](https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar)。 +4. 拷贝hmos\_app\_packing\_tool.jar到Linux服务器\~/developtools路径下。 +5. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/developtools:$PATH + ``` + +6. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装hap签名工具 + +编译OpenHarmony时,在系统应用打包完成后,编译脚本会调用hap签名工具对其签名。安装步骤如下: + +1. 打开Linux编译服务器终端。 +2. [下载hap签名工具](https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar)。 +3. 拷贝hapsigntoolv2.jar到Linux服务器\~/developtools路径下。 +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/developtools:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +## 安装Windows开发环境 + +OpenHarmony IDE工具DevEco Device Tool集成了终端工具的能力,工具的安装步骤请参考[DevEco Device Tool环境搭建](https://device.harmonyos.com/cn/docs/ide/user-guides/tool_install-0000001050164976)、[导入和配置工程](https://device.harmonyos.com/cn/docs/ide/user-guides/import_project-0000001050164980)完成。 + diff --git "a/quick-start/Hi3518\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/quick-start/Hi3518\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..f42f31cd7f1cbf6ea693f60bf45daedc9935bc16 --- /dev/null +++ "b/quick-start/Hi3518\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,174 @@ +# Hi3518常见问题 + +- [烧写选择串口后提示失败](#section1498892119619) +- [Windows电脑与单板网络连接失败](#section8512971816) +- [烧写失败](#section1767804111198) +- [编译构建过程中,提示找不到“python”](#zh-cn_topic_0000001053466255_section1039835245619) +- [串口无回显](#zh-cn_topic_0000001053466255_section14871149155911) + +## 烧写选择串口后提示失败 + +- **现象描述** + + 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 + + **图 1** 打开串口失败图 + ![](figures/打开串口失败图.png "打开串口失败图") + +- **可能原因** + + 串口已经被占用。 + +- **解决办法** + +1. 按图依次选择下拉框,查找带有serial-xx的终端 + + **图 2** 查找是否存在占用串口的终端 + ![](figures/查找是否存在占用串口的终端.png "查找是否存在占用串口的终端") + +2. 点击标号中的垃圾桶图标,关闭串口。 + + **图 3** 关闭串口终端 + ![](figures/关闭串口终端.png "关闭串口终端") + +3. 重新点击烧写,选择串口并开始烧写程序 + + **图 4** 重新启动烧写任务 + + + ![](figures/changjian1.png) + + +## Windows电脑与单板网络连接失败 + +- **现象描述** + + 点击烧写并选择串口后,无法获取文件。 + + **图 5** 网络不通,单板无法获取文件图 + ![](figures/网络不通-单板无法获取文件图.png "网络不通-单板无法获取文件图") + +- **可能原因** + + 单板网络与Windows电脑不联通。 + + Windows电脑防火墙未允许Visual Studio Code联网。 + +- **解决方法** + +1. 检查网线是否连接。 +2. 点击Windows防火墙。 + + **图 6** 网络防火墙设置图 + ![](figures/网络防火墙设置图.png "网络防火墙设置图") + +3. 点击“允许应用通过防火墙”。 + + **图 7** 防火墙和网络保护界面图 + ![](figures/防火墙和网络保护界面图.png "防火墙和网络保护界面图") + +4. 查找Visual Studio Code应用。 + + **图 8** 查找Visual Studio Code应用图 + ![](figures/查找Visual-Studio-Code应用图.png "查找Visual-Studio-Code应用图") + +5. 勾选Visual Studio Code的专用和公用网络的访问权限。 + + **图 9** 允许Visual Studio Code应用访问网络 + ![](figures/允许Visual-Studio-Code应用访问网络.png "允许Visual-Studio-Code应用访问网络") + + +## 烧写失败 + +- **现象描述** + + 点击烧写并选择串口后,出现无法烧写的情况。 + +- **可能原因** + + 安装IDE插件DevEco后未重启。 + +- **解决方法** + + 重启IDE。 + + +## 编译构建过程中,提示找不到“python” + +- **现象描述** + + ![](figures/zh-cn_image_0000001058781525.png) + + +- **可能原因1** + + 没有装python。 + +- **解决办法** + + 请按照[安装Python环境](Hi3518搭建环境.md#section10807183719500)安装python。 + +- **可能原因2** + + ![](figures/zh-cn_image_0000001058939672.png) + +- **解决办法** + + usr/bin目录下没有python软链接,请运行以下命令: + + ``` + # cd /usr/bin/ + # which python3 + # ln -s /usr/local/bin/python3 python + # python --version + ``` + + 例: + + ![](figures/zh-cn_image_0000001058781464.png) + + +## 串口无回显 + +- **现象描述** + + 串口显示已连接,重启单板后,回车无任何回显。 + +- **可能原因1** + + 串口连接错误。 + +- **解决办法** + + 修改串口号。 + + 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按镜像运行内[步骤1](开发Hi3518第一个示例程序.md#li744118533233)修改串口号。 + + +- **可能原因2** + + 单板U-boot被损坏。 + +- **解决办法** + + 烧写U-boot。 + + 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 + + +1. 获取引导文件U-boot。 + + >![](public_sys-resources/icon-notice.gif) **须知:** + >单板的U-boot文件请在开源包中获取: + >- 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. 根据USB烧写步骤烧写U-boot文件。 + + 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3518_upload-0000001057313128)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 + +3. 烧写完成后,登录串口如下图所示。 + + ![](figures/zh-cn_image_0000001058719409.png) + + diff --git "a/quick-start/Hi3518\345\274\200\345\217\221\346\235\277.md" "b/quick-start/Hi3518\345\274\200\345\217\221\346\235\277.md" index 724898a9ec600902c4bcf21c022524d32b694d97..6bd48ddd929f8201f704e3bdb725251a51876904 100755 --- "a/quick-start/Hi3518\345\274\200\345\217\221\346\235\277.md" +++ "b/quick-start/Hi3518\345\274\200\345\217\221\346\235\277.md" @@ -2,10 +2,10 @@ - **[Hi3518开发板介绍](Hi3518开发板介绍.md)** -- **[搭建环境](搭建环境-2.md)** +- **[Hi3518搭建环境](Hi3518搭建环境.md)** - **[开发Hi3518第一个示例程序](开发Hi3518第一个示例程序.md)** -- **[常见问题](常见问题-3.md)** +- **[Hi3518常见问题](Hi3518常见问题.md)** diff --git "a/quick-start/Hi3518\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" "b/quick-start/Hi3518\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" index fb77a968a78317073a2b72b97d13545c0905d930..f0221a553428bdf34918905d31bdd5478c9c31eb 100755 --- "a/quick-start/Hi3518\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" +++ "b/quick-start/Hi3518\345\274\200\345\217\221\346\235\277\344\273\213\347\273\215.md" @@ -5,7 +5,7 @@ ## 开发板简介 -Hi3518EV300作为新一代智慧视觉处理SOC,集成新一代ISP\(Image Signal Processor\)以及业界最新的H.265视频压缩编码器,同时采用先进低功耗工艺和低功耗架构设计,使其在低码率、高画质、低功耗等方面引领行业水平。 +Hi3518EV300作为新一代智慧视觉处理SOC,集成新一代ISP\(Image Signal Processor\)以及H.265视频压缩编码器,同时采用先进低功耗工艺和低功耗架构设计,使其在低码率、高画质、低功耗等方面引领行业水平。 **图 1** Hi3518EV300单板正面外观图 ![](figures/Hi3518EV300单板正面外观图.png "Hi3518EV300单板正面外观图") diff --git "a/quick-start/Hi3518\346\220\255\345\273\272\347\216\257\345\242\203.md" "b/quick-start/Hi3518\346\220\255\345\273\272\347\216\257\345\242\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..ce41c099b6f59e09df3e639e8cad05805c12f67f --- /dev/null +++ "b/quick-start/Hi3518\346\220\255\345\273\272\347\216\257\345\242\203.md" @@ -0,0 +1,479 @@ +# Hi3518搭建环境 + +- [环境要求](#section1724111409282) + - [硬件要求](#section487353718276) + - [软件系统要求](#section44143554278) + - [Linux构建工具要求](#section17315193935817) + - [Windows开发工具要求](#section1897593723017) + +- [安装Linux编译环境(方法一:Docker方式)](#section4848141175215) +- [安装Linux编译环境(方法二:安装包方式)](#section8831868501) + - [连接Linux服务器](#section12584112413505) + - [将Linux shell改为bash](#section21811833145019) + - [安装Python环境](#section10807183719500) + - [安装文件打包工具](#section480195453419) + - [安装gn](#section16725103716357) + - [安装ninja](#section156834539351) + - [安装LLVM](#section11739111964114) + - [安装hc-gen](#section351420104218) + +- [安装Windows开发环境](#section188621583120) + +## 环境要求 + +### 硬件要求 + +- Linux服务器 +- Windows工作台(主机电脑) +- Hi3518EV300 IoT Camera开发板 +- USB转串口线、网线(Windows工作台通过USB转串口线、网线与开发板连接) + + 各硬件连接关系如下图所示。 + + +**图 1** 硬件连线图 +![](figures/硬件连线图.png "硬件连线图") + +### 软件系统要求 + +**表 1** 开发板开发平台要求 + + + + + + + + + + + + + + + + + + + + + +

硬件

+

软件

+

描述

+

备注

+

Linux编译服务器

+

操作系统

+

Ubuntu16.04及以上64位系统版本,Shell使用bash。

+
说明:

通常系统默认安装samba、vim等常用软件,需要做适当适配以支持linux文件共享。

+
+

开发人员可以在Windows工作台中进行程序开发,或者远程登录到Linux服务器进行程序开发。

+

Windows工作台

+

+

操作系统

+

Windows XP/Windows7/Windows10

+

USB转串口驱动

+

http://www.hihope.org/download/AllDocuments

+

驱动软件名:USB-to-Serial Comm Port.exe

+
+ +### Linux构建工具要求 + +Linux服务器通用环境配置需要的工具及其获取途径如下表所示。 + +**表 2** Linux服务器开发工具及获取途径 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

Python3.7+

+

执行编译脚本工具

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

bash

+

执行命令行工具

+

通过互联网获取

+

gn

+

产生ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

执行ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+

LLVM

+

编译工具链

+

https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar

+

hc-gen

+

驱动配置编译工具

+

https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar

+

IPOP、PuTTY或其他超级终端

+

连接Linux服务器工具(任选其一)

+

通过互联网获取(如:https://www.putty.org/

+
+ +### Windows开发工具要求 + +**表 3** Windows工作台开发工具及获取途径 + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

Visual Studio Code

+

代码编辑工具

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

IDE开发工具,Visual Studio Code插件,支持代码编译、烧录和调试等功能,支持C/C++语言

+
说明:

HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持代码编辑、编译、烧录、调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上。

+
+

https://device.harmonyos.com/cn/ide

+
+ +## 安装Linux编译环境(方法一:Docker方式) + +Linux编译环境可以通过Docker方式快速安装,具体请参见[Docker方式获取编译环境](../get-code/获取工具.md)的“搭建Docker环境”。 + +## 安装Linux编译环境(方法二:安装包方式) + +>![](public_sys-resources/icon-notice.gif) **须知:** +>- 如果后续通过“HPM组件方式”或“HPM包管理器命令行工具方式”获取源码,不需要安装gn、ninja、LLVM、hc-gen编译工具。 +>- (推荐)如果后续通过“镜像站点方式”或“代码仓库方式”获取源码,需要安装gn、ninja、LLVM、hc-gen编译工具。安装gn、ninja、LLVM、hc-gen编译工具时,请确保编译工具的环境变量路径唯一。 + +### 连接Linux服务器 + +使用Windows远程登录Linux,以PUTTY工具为例: + +1. 打开[PuTTY工具](https://www.putty.org/),输入Linux服务器IP地址,后点击“open”,打开连接。 + + **图 2** PuTTY界面示例图 + ![](figures/PuTTY界面示例图.png "PuTTY界面示例图") + +2. 弹框告警选择“是\(Y\)”。 +3. 弹出界面中输入帐号并按回车键,继续输入密码并回车键。 + + **图 3** 登录界面图 + ![](figures/登录界面图.png "登录界面图") + +4. 登录成功。 + + **图 4** 登录成功界面 + ![](figures/登录成功界面.png "登录成功界面") + + +### 将Linux shell改为bash + +查看shell是否为bash,在终端运行如下命令 + +``` +ls -l /bin/sh +``` + +如果显示为“/bin/sh -\> bash”则为正常,否则请按以下方式修改: + +**方法一**:在终端运行如下命令,然后选择 no。 + +``` +sudo dpkg-reconfigure dash +``` + +**方法二**:先删除sh,再创建软链接。 + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### 安装Python环境 + +1. 打开Linux编译服务器终端。 +2. 输入如下命令,查看python版本号,需使用python3.7以上版本。 + + ``` + python3 --version + ``` + + 如果低于python3.7版本,不建议直接升级,请按照如下步骤重新安装。以python3.8为例,按照以下步骤安装python。 + + 1. 运行如下命令,查看Ubuntu版本: + + ``` + cat /etc/issue + ``` + + 1. 根据Ubuntu不同版本,安装python。 + - 如果Ubuntu 版本为18+,运行如下命令。 + + ``` + sudo apt-get install python3.8 + ``` + + - 如果Ubuntu版本为16,请以下载包的方式安装python。 + + 1. python安装环境依赖\(gcc, g++, make, zlib, libffi\)请运行如下命令: + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. 获取[python3.8.5安装包](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz),将其放至linux服务器中,运行如下命令 : + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. 确定python安装好后,将python路径链接到"/usr/bin/python"。 + + 输入如下命令,查看python是否正确软链接到python3.8。 + + ``` + python --version + ``` + + 如果回显不是python 3.8.5,则运行如下命令,查看python3.8所在目录: + + ``` + which python3.8 + ``` + + 将以下命令中的 "python3.8-path" 替换为 "which python3.8" 命令执行后的回显路径 + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. 安装并升级Python包管理工具(pip3),任选如下一种方式。 + - **命令行方式:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **安装包方式:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. 运行如下命令,安装python模块setuptools。 + + ``` + pip3 install setuptools + ``` + +6. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 + - **命令行方式:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **安装包方式:** + 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 + + 下载路径:“[https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files)” + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + + +### 安装文件打包工具 + +1. 打开Linux编译服务器终端。 +2. 运行如下命令,安装dosfstools。 + + ``` + sudo apt-get install dosfstools + ``` + +3. 运行如下命令,安装mtools。 + + ``` + sudo apt-get install mtools + ``` + +4. 运行如下命令,安装mtd-utils。 + + ``` + sudo apt-get install mtd-utils + ``` + + +### 安装gn + +1. 打开Linux编译服务器终端。 +2. [下载gn工具](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar)。 +3. 解压gn安装包至\~/gn路径下。 + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/gn:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装ninja + +1. 打开Linux编译服务器终端。 +2. [下载ninja工具](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar)。 +3. 解压ninja安装包至\~/ninja路径下。 + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/ninja:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装LLVM + +1. 打开Linux编译服务器终端。 +2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar)。 +3. 解压LLVM安装包至\~/llvm路径下。 + + ``` + tar -xvf llvm-linux-9.0.0-34042.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装hc-gen + +1. 打开Linux编译服务器终端。 +2. [下载hc-gen工具](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar)。 +3. 解压hc-gen安装包到Linux服务器\~/hc-gen路径下。 + + ``` + tar -xvf hc-gen-0.65-linux.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/hc-gen:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +## 安装Windows开发环境 + +OpenHarmony IDE工具DevEco Device Tool集成了终端工具的能力,工具的安装步骤请参考[DevEco Device Tool环境搭建](https://device.harmonyos.com/cn/docs/ide/user-guides/tool_install-0000001050164976)、[导入和配置工程](https://device.harmonyos.com/cn/docs/ide/user-guides/import_project-0000001050164980)完成。 + diff --git "a/quick-start/Hi3861\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/quick-start/Hi3861\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..abe07bda7cbed066753ff7140e2c0fb2e63263c7 --- /dev/null +++ "b/quick-start/Hi3861\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,292 @@ +# Hi3861常见问题 + +- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](#section1221016541119) +- [安装python3过程中,提示“-bash: make: command not found”](#section1913477181213) +- [安装python3过程中,提示“zlib not available”](#section108211415131210) +- [安装python3过程中,提示“No module named '\_ctypes'”](#section2062268124) +- [编译构建过程中,提示“No module named 'Crypto'”](#section982315398121) +- [编译构建过程中,提示“No module named 'ecdsa'”](#section102035451216) +- [编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”](#section4498158162320) +- [编译构建过程中,提示找不到“-lgcc”](#section11181036112615) +- [编译构建过程中,提示找不到“python”](#section1571810194619) +- [安装 kconfiglib时,遇到lsb\_release错误](#section691681635814) + +## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” + +- **现象描述** + + 安装python3过程中出现以下错误: + + ``` + configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details + ``` + +- **可能原因** + + 环境中未安装“gcc”。 + +- **解决办法** + + 1、通过命令“apt-get install gcc”在线安装。 + + 2、完成后,重新安装python3。 + + +## 安装python3过程中,提示“-bash: make: command not found” + +- **现象描述** + + 安装python3过程中出现以下错误: + + ``` + -bash: make: command not found + ``` + +- **可能原因** + + 环境中未安装“make”。 + +- **解决办法** + + 1、通过命令“apt-get install make”在线安装。 + + 2、完成后,重新安装python3。 + + +## 安装python3过程中,提示“zlib not available” + +- **现象描述** + + 安装python3过程中出现以下错误: + + ``` + zipimport.ZipImportError: can't decompress data; zlib not avaliable + ``` + +- **可能原因** + + 环境中未安装“zlib”。 + +- **解决办法** + + 方法1:通过命令“apt-get install zlib”在线安装。 + + 方法2:如果软件源中没有该软件,请从“www.zlib.net”下载版本代码,并离线安装。 + + ![](figures/10.png) + + 完成下载后,通过以下命令安装: + + ``` + # tar xvf zlib-1.2.11.tar.gz + # cd zlib-1.2.11 + # ./configure + # make && make install + ``` + + 完成后,重新安装python3。 + + +## 安装python3过程中,提示“No module named '\_ctypes'” + +- **现象描述** + + 安装python3过程中出现以下错误: + + ``` + ModuleNotFoundError:No module named ‘_ctypes’ + ``` + + +- **可能原因** + + 环境中未安装“libffi”和“libffi-devel”。 + + +- **解决办法** + + 1、通过命令“apt-get install libffi\* -y”,在线安装。 + + 2、完成后,重新安装python3。 + + +## 编译构建过程中,提示“No module named 'Crypto'” + +- **现象描述** + + 编译构建过程中出现以下错误: + + ``` + ModuleNotFoundError: No module named 'Crypto' + ``` + + +- **可能原因** + + 环境中未安装“Crypto”。 + + +- **解决办法** + + 方法1:通过命令“pip3 install Crypto”,在线安装。 + + 方法2:离线安装 + + 通过网页[https://pypi.org/project/pycrypto/\#files](https://pypi.org/project/pycrypto/#files),下载源码。 + + ![](figures/zh-cn_image_0000001053462612.png) + + 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 + + 完成上述安装后,重新构建。 + + +## 编译构建过程中,提示“No module named 'ecdsa'” + +- **现象描述** + + 编译构建过程中出现以下错误: + + ``` + ModuleNotFoundError:No module named 'ecdsa' + ``` + + +- **可能原因** + + 环境中未安装“ecdsa”。 + + +- **解决办法** + + 方法1:通过命令“pip3 install ecdsa”,在线安装。 + + 方法2:离线安装 + + 通过网页[https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files),下载安装包。 + + ![](figures/zh-cn_image_0000001053022609.png) + + 将安装包放置Linux服务器中,并安装“pip3 install ecdsa-0.15-py2.py3-none-any.whl”。 + + 完成上述安装后,重新构建。 + + +## 编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0” + +- **现象描述** + + 编译构建过程中出现以下错误: + + ``` + Could not find a version that satisfies the requirment six>=1.9.0 + ``` + + +- **可能原因** + + 环境中未安装合适的“six”。 + + +- **解决办法** + + 方法1:通过命令“pip3 install six”,在线安装。 + + 方法2:离线安装 + + 通过网页[https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files),下载安装包。 + + ![](figures/zh-cn_image_0000001052742629.png) + + 将源码放置在Linux服务器中,并安装“pip3 install six-1.14.0-py2.py3-none-any.whl”。 + + 完成上述安装后,重新构建。 + + +## 编译构建过程中,提示找不到“-lgcc” + +- **现象描述** + + 编译构建过程中出现以下错误: + + ``` + riscv32-unknown-elf-ld: cannot find -lgcc + ``` + + +- **可能原因** + + 交叉编译器gcc\_riscv32的PATH添加错误,如下,在"bin"后多添加了一个“/”,应该删除。 + + ``` + ~/gcc_riscv32/bin/:/data/toolchain/ + ``` + + +- **解决办法** + + 重新修改gcc\_riscv32的PATH,将多余的“/”删除。 + + ``` + ~/gcc_riscv32/bin:/data/toolchain/ + ``` + + +## 编译构建过程中,提示找不到“python” + +- **现象描述** + + 编译构建过程中出现以下错误: + + ``` + -bash: /usr/bin/python: No such file or directory + ``` + + +- **可能原因**1 + + 没有装python。 + +- **解决办法** + + 请按照[安装Python环境](Hi3861搭建环境.md#section18835251192618)安装python。 + +- **可能原因2** + + ![](figures/zh-cn_image_0000001055372855.png) + +- **解决办法** + + usr/bin目录下没有python软链接,请运行以下命令添加软链接: + + ``` + # cd /usr/bin/ + # which python3 + # ln -s /usr/local/bin/python3 python + # python --version + ``` + + 例: + + ![](figures/zh-cn_image_0000001055012855.png) + + +## 安装 kconfiglib时,遇到lsb\_release错误 + +- **现象描述** + + 安装kconfiglib过程中遇到如下错误打印: + + ``` + subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. + ``` + +- **可能原因** + + lsb\_release模块基于的python版本与现有python版本不一致 + +- **解决办法** + + 执行"find / -name lsb\_release",找到lsb\_release位置并删除,如:"sudo rm -rf /usr/bin/lsb\_release" + + diff --git "a/quick-start/Hi3861\345\274\200\345\217\221\346\235\277.md" "b/quick-start/Hi3861\345\274\200\345\217\221\346\235\277.md" index 22900c442797f93477a06e1a80fb0fcf5bd325f4..0b44a4a940f078634a2654995b1a9230d191c58e 100755 --- "a/quick-start/Hi3861\345\274\200\345\217\221\346\235\277.md" +++ "b/quick-start/Hi3861\345\274\200\345\217\221\346\235\277.md" @@ -2,12 +2,12 @@ - **[Hi3861开发板介绍](Hi3861开发板介绍.md)** -- **[搭建环境](搭建环境.md)** +- **[Hi3861搭建环境](Hi3861搭建环境.md)** -- **[Hi3861开发板第一个示例程序](Hi3861开发板第一个示例程序.md)** +- **[开发Hi3861第一个示例程序](开发Hi3861第一个示例程序.md)** -- **[Hi3861开发板第二个示例程序](Hi3861开发板第二个示例程序.md)** +- **[开发Hi3861第二个示例程序](开发Hi3861第二个示例程序.md)** -- **[常见问题](常见问题.md)** +- **[Hi3861常见问题](Hi3861常见问题.md)** diff --git "a/quick-start/Hi3861\346\220\255\345\273\272\347\216\257\345\242\203.md" "b/quick-start/Hi3861\346\220\255\345\273\272\347\216\257\345\242\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..3d87c424a2b671c7e084ed3baf3d4b1e40554fb4 --- /dev/null +++ "b/quick-start/Hi3861\346\220\255\345\273\272\347\216\257\345\242\203.md" @@ -0,0 +1,611 @@ +# Hi3861搭建环境 + +- [环境要求](#section466851916410) + - [软件系统要求](#section1595725202314) + - [Linux构建工具要求](#section992619473117) + - [Windows开发工具要求](#section2833173411317) + +- [安装Linux编译环境(方法一:Docker方式)](#section107932281315) +- [安装Linux编译环境(方法二:安装包方式)](#section497484245614) + - [连接Linux服务器](#section1565413132610) + - [将Linux shell改为bash](#section1715027152617) + - [安装Python环境](#section18835251192618) + - [安装Scons](#section13515123015279) + - [安装gn](#section0646125972716) + - [安装ninja](#section7681117192813) + - [安装gcc\_riscv32(WLAN模组类编译工具链)](#section1842910288284) + +- [安装Windows开发环境](#section1995840162515) + +## 环境要求 + +### 软件系统要求 + +**表 1** Hi3861 WLAN模組开发平台要求 + + + + + + + + + + + + + + + + + + +

硬件

+

软件

+

描述

+

备注

+

Linux编译服务器

+

操作系统

+

Ubuntu16.04及以上64位系统版本,Shell使用bash

+

开发人员可以在Windows工作台中进行程序开发,或者远程登录到Linux服务器进行程序开发。

+

Windows工作台

+

操作系统

+

Windows XP/Windows7/Windows10

+
+ +### Linux构建工具要求 + +Linux服务器通用环境配置需要的工具及其获取途径如下表所示。 + +**表 2** Linux服务器开发工具及获取途径 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

交叉编译器gcc_riscv32

+

交叉编译工具

+

https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz

+

Python3.7+

+

编译构建工具

+

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

+

SCons3.0.4+

+

编译构建工具

+

通过互联网获取

+

bash

+

命令处理器

+

通过互联网获取

+

build-essential

+

编译依赖的基础软件包

+

通过互联网获取

+

gn

+

产生ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

+

ninja

+

执行ninja编译脚本

+

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

+
+ +### Windows开发工具要求 + +**表 3** Windows工作台开发工具及获取途径 + + + + + + + + + + + + + + + + + + + + + + + + +

开发工具

+

用途

+

获取途径

+

Visual Studio Code

+

代码编辑工具。

+

https://code.visualstudio.com/

+

HUAWEI DevEco Device Tool

+

IDE开发工具,支持WLAN模组的代码编写、远程编译、版本烧录、串口调试等功能。

+
说明:

HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持C/C++语言,以插件的形式部署在Visual Studio Code上。

+
+

https://device.harmonyos.com/cn/ide

+

PuTTY或其他超级终端(选其一)

+

远程连接Linux编译服务器,连接模组串口工具。

+

通过互联网获取(如:https://www.putty.org/

+

CH341SER.EXE

+

USB转串口驱动。

+

http://www.wch.cn/search?q=ch340g&t=downloads

+
+ +## 安装Linux编译环境(方法一:Docker方式) + +Linux编译环境可以通过Docker方式快速安装,具体请参见[Docker方式获取编译环境](../get-code/获取工具.md)的“搭建Docker环境”。 + +## 安装Linux编译环境(方法二:安装包方式) + +>![](public_sys-resources/icon-notice.gif) **须知:** +>- 如果后续通过“HPM组件方式”或“HPM包管理器命令行工具方式”获取源码,不需要安装gn、ninja、gcc\_riscv32编译工具。 +>- (推荐)如果后续通过“镜像站点方式”或“代码仓库方式”获取源码,需要安装gn、ninja、gcc\_riscv32编译工具。 +> 安装gn、ninja、gcc\_riscv32编译工具时,请确保编译工具的环境变量路径唯一。 + +### 连接Linux服务器 + +使用Windows远程登录Linux,以PUTTY工具为例: + +1. 打开[PuTTY工具](https://www.putty.org/),输入Linux服务器IP地址,后点击“open”,打开连接。 + + **图 1** PuTTY界面示例图 + ![](figures/PuTTY界面示例图.png "PuTTY界面示例图") + +2. 弹框告警选择“是\(Y\)”。 +3. 弹出界面中输入帐号并按回车键,继续输入密码并回车键。 + + **图 2** 登录界面图 + ![](figures/登录界面图.png "登录界面图") + +4. 登录成功。 + + **图 3** 登录成功界面 + ![](figures/登录成功界面.png "登录成功界面") + + +### 将Linux shell改为bash + +查看shell是否为bash,在终端运行如下命令 + +``` +ls -l /bin/sh +``` + +如果显示为“/bin/sh -\> bash”则为正常,否则请按以下方式修改: + +**方法一**:在终端运行如下命令,然后选择 no。 + +``` +sudo dpkg-reconfigure dash +``` + +**方法二**:先删除sh,再创建软链接。 + +``` +sudo rm -rf /bin/sh +sudo ln -s /bin/bash /bin/sh +``` + +### 安装Python环境 + +1. 打开Linux编译服务器终端。 +2. 输入如下命令,查看python版本号,需使用python3.7以上版本。 + + ``` + python3 --version + ``` + + 如果低于python3.7版本,不建议直接升级,请按照如下步骤重新安装。以python3.8为例,按照以下步骤安装python。 + + 1. 运行如下命令,查看Ubuntu版本: + + ``` + cat /etc/issue + ``` + + 1. 根据Ubuntu不同版本,安装python。 + - 如果Ubuntu 版本为18+,运行如下命令。 + + ``` + sudo apt-get install python3.8 + ``` + + - 如果Ubuntu版本为16,请以下载包的方式安装python。 + + 1. python安装环境依赖\(gcc, g++, make, zlib, libffi\)请运行如下命令: + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev + ``` + + 1. 获取[python3.8.5安装包](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz),将其放至linux服务器中,运行如下命令 : + + ``` + tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install + ``` + + + +3. 确定python安装好后,将python路径链接到"/usr/bin/python"。 + + 输入如下命令,查看python是否正确软链接到python3.8。 + + ``` + python --version + ``` + + 如果回显不是python 3.8.5,则运行如下命令,查看python3.8所在目录: + + ``` + which python3.8 + ``` + + 将以下命令中的 "python3.8-path" 替换为 "which python3.8" 命令执行后的回显路径 + + ``` + cd /usr/bin && sudo rm python && sudo rm python3 && sudo ln -s python3.8-path python && sudo ln -s python3.8-path python3 && python3 --version && python --version + ``` + +4. 安装并升级Python包管理工具(pip3),任选如下一种方式。 + - **命令行方式:** + + ``` + sudo apt-get install python3-setuptools python3-pip -y + sudo pip3 install --upgrade pip + ``` + + - **安装包方式:** + + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +5. 运行如下命令,安装python模块setuptools。 + + ``` + pip3 install setuptools + ``` + +6. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 + - **命令行方式:** + + ``` + sudo pip3 install kconfiglib + ``` + + + - **安装包方式:** + 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 + + 下载路径:“[https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files)” + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` + + + +7. 安装pycryptodome,任选如下一种方式。 + + 安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。 + + - **命令行方式:** + + ``` + sudo pip3 install pycryptodome + ``` + + - **安装包方式:** + 1. 下载.whl文件(例如:pycryptodome-3.9.9-cp38-cp38-manylinux1\_x86\_64.whl)。 + + 下载路径:“[https://pypi.org/project/pycryptodome/\#files](https://pypi.org/project/pycryptodome/#files)”。 + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl + ``` + + + +8. 安装six,任选如下一种方式。 + - **命令行方式:** + + ``` + sudo pip3 install six --upgrade --ignore-installed six + ``` + + + - **安装包方式:** + 1. 下载.whl文件(例如:six-1.12.0-py2.py3-none-any.whl)。 + + 下载路径:“[https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files)” + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install six-1.12.0-py2.py3-none-any.whl + ``` + + + +9. 安装ecdsa,任选如下一种方式。 + - **命令行方式:** + + ``` + sudo pip3 install ecdsa + ``` + + - **安装包方式:** + 1. 下载.whl文件(例如:ecdsa-0.14.1-py2.py3-none-any.whl)。 + + 下载路径:“[https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files)” + + + 1. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl + ``` + + + + +### 安装Scons + +1. 打开Linux编译服务器终端。 +2. 运行如下命令,安装SCons安装包。 + + ``` + sudo apt-get install scons -y + ``` + + 如果软件源中无法找到安装包,请按以下步骤处理: + + 1. 下载源码包(下载路径:“ [https://scons.org/pages/download.html](https://scons.org/pages/download.html) ”,推荐SCons版本是3.0.4+)。 + 2. 解压源码包到任意目录(以scons-3.1.2为例)。 + + ``` + tar -xvf scons-3.1.2.tar.gz + ``` + + 3. 安装源码包:进入解压目录,运行如下命令: + + ``` + sudo python3 setup.py install + ``` + + +3. 运行如下命令,查看是否安装成功。如果安装成功,查询结果下图所示。 + + ``` + scons -v + ``` + + **图 4** SCons安装成功界面 + ![](figures/SCons安装成功界面.png "SCons安装成功界面") + + +### 安装gn + +1. 打开Linux编译服务器终端。 +2. [下载gn工具](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar)。 +3. 解压gn安装包至\~/gn路径下。 + + ``` + tar -xvf gn.1523.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/gn:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装ninja + +1. 打开Linux编译服务器终端。 +2. [下载ninja工具](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar)。 +3. 解压ninja安装包至\~/ninja路径下。 + + ``` + tar -xvf ninja.1.9.0.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/ninja:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + + +### 安装gcc\_riscv32(WLAN模组类编译工具链) + +>![](public_sys-resources/icon-notice.gif) **须知:** +>Hi3861平台仅支持使用libgcc运行时库的静态链接,**不建议开发者使用libgcc运行时库的动态链接,会导致商业分发时被GPL V3污染。** + +1. 打开Linux编译服务器终端。 +2. 环境准备,请安装"gcc, g++, bison, flex, makeinfo"软件,确保工具链能正确编译。 + + ``` + sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install flex bison && sudo apt-get install texinfo + ``` + +3. 下载riscv-gnu-toolchain交叉编译工具链。 + + ``` + git clone --recursive https://github.com/riscv/riscv-gnu-toolchain + ``` + +4. 打开文件夹riscv-gnu-toolchain,先删除空文件夹,以防止下载newlib,binutils,gcc时冲突。 + + ``` + cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc + ``` + +5. 下载riscv-newlib-3.0.0。 + + ``` + git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git + ``` + +6. 下载riscv-binutils-2.31.1。 + + ``` + git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git + ``` + +7. 下载riscv-gcc-7.3.0。 + + ``` + git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc + ``` + +8. 下载riscv-gcc-7.3.0补丁。 + + 拷贝gcc官方[89411.patch](https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2),拷贝gcc官方[86724.patch](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3),并对应代码做一定的行数号修改,将两个patch放入 riscv-gcc目录 + + ``` + cd riscv-gcc && patch -p1 < 89411.patch && patch -p1 < 86724.patch + ``` + + patch过程中如遇到Hunk \#1 FAILED等问题,请对应到相应.c文件,修改patch代码所在行数 + +9. 下载[GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2),并解压安装。 + + ``` + tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install + ``` + +10. 下载[mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz),并解压安装。 + + ``` + tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install + ``` + +11. 下载[mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz) ,并解压安装。 + + ``` + tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install + ``` + +12. 打开文件夹riscv-gnu-toolchain,新建工具链输出目录。 + + ``` + cd /opt && mkdir gcc_riscv32 + ``` + +13. 编译bintutils。 + + ``` + mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install + ``` + +14. 编译newlib。 + + ``` + mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install + ``` + +15. 编译gcc。 + + ``` + mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install + ``` + +16. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=/opt/gcc_riscv32/bin:$PATH + ``` + +17. 生效环境变量。 + + ``` + source ~/.bashrc + ``` + +18. Shell命令行中输入如下命令,如果能正确显示编译器版本号,表明编译器安装成功。 + + ``` + riscv32-unknown-elf-gcc -v + ``` + + +## 安装Windows开发环境 + +OpenHarmony IDE工具DevEco Device Tool集成了终端工具的能力,工具的安装步骤请参考[DevEco Device Tool环境搭建](https://device.harmonyos.com/cn/docs/ide/user-guides/tool_install-0000001050164976)、[导入和配置工程](https://device.harmonyos.com/cn/docs/ide/user-guides/import_project-0000001050164980)完成。 + diff --git a/quick-start/Readme-CN.md b/quick-start/Readme-CN.md index 2865b3a54105314239f88f322511320ca1e8364f..a39cf859ddce22f3addc4ce5f078852b4e498240 100755 --- a/quick-start/Readme-CN.md +++ b/quick-start/Readme-CN.md @@ -2,21 +2,21 @@ - [Hi3861开发板](Hi3861开发板.md) - [Hi3861开发板介绍](Hi3861开发板介绍.md) - - [搭建环境](搭建环境.md) - - [Hi3861开发板第一个示例程序](Hi3861开发板第一个示例程序.md) - - [Hi3861开发板第二个示例程序](Hi3861开发板第二个示例程序.md) - - [常见问题](常见问题.md) + - [Hi3861搭建环境](Hi3861搭建环境.md) + - [开发Hi3861第一个示例程序](开发Hi3861第一个示例程序.md) + - [开发Hi3861第二个示例程序](开发Hi3861第二个示例程序.md) + - [Hi3861常见问题](Hi3861常见问题.md) - [Hi3516开发板](Hi3516开发板.md) - [Hi3516开发板介绍](Hi3516开发板介绍.md) - - [搭建环境](搭建环境-0.md) + - [Hi3516搭建环境](Hi3516搭建环境.md) - [开发Hi3516第一个应用程序示例](开发Hi3516第一个应用程序示例.md) - [开发Hi3516第一个驱动程序示例](开发Hi3516第一个驱动程序示例.md) - - [常见问题](常见问题-1.md) + - [Hi3516常见问题](Hi3516常见问题.md) - [Hi3518开发板](Hi3518开发板.md) - [Hi3518开发板介绍](Hi3518开发板介绍.md) - - [搭建环境](搭建环境-2.md) + - [Hi3518搭建环境](Hi3518搭建环境.md) - [开发Hi3518第一个示例程序](开发Hi3518第一个示例程序.md) - - [常见问题](常见问题-3.md) + - [Hi3518常见问题](Hi3518常见问题.md) diff --git a/quick-start/figures/chuankou1-0.png b/quick-start/figures/chuankou1-0.png new file mode 100644 index 0000000000000000000000000000000000000000..485cb3054c0c08edd6738256f27ad629ce65e1d7 Binary files /dev/null and b/quick-start/figures/chuankou1-0.png differ diff --git a/quick-start/figures/zh-cn_image_0000001058719409.png b/quick-start/figures/zh-cn_image_0000001058719409.png new file mode 100644 index 0000000000000000000000000000000000000000..ad4fd618860ca9f79e9bdc39436c3b2f9cdb72de Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001058719409.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071514639.png b/quick-start/figures/zh-cn_image_0000001071514639.png new file mode 100644 index 0000000000000000000000000000000000000000..381c3db41d6ef82b7074a5c9bcdfb3ad82795fb9 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071514639.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071514657.png b/quick-start/figures/zh-cn_image_0000001071514657.png new file mode 100644 index 0000000000000000000000000000000000000000..5df511ab77558fa4acaa3f990190fc0ff6d9034e Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071514657.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071634537.png b/quick-start/figures/zh-cn_image_0000001071634537.png new file mode 100644 index 0000000000000000000000000000000000000000..92e17f1fa91594ad5df1a07aa1bcfaf509480784 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071634537.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071634551.png b/quick-start/figures/zh-cn_image_0000001071634551.png new file mode 100644 index 0000000000000000000000000000000000000000..727cdebbdf5ada0098243d7e253c4b2be11b688d Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071634551.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071792503.png b/quick-start/figures/zh-cn_image_0000001071792503.png new file mode 100644 index 0000000000000000000000000000000000000000..09f33e3992c0c1d78713eea949e4b9a19f5802ec Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071792503.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071904255.png b/quick-start/figures/zh-cn_image_0000001071904255.png new file mode 100644 index 0000000000000000000000000000000000000000..a8042b42e6a08be77279791dd16d3a8883b85759 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071904255.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071904257.png b/quick-start/figures/zh-cn_image_0000001071904257.png new file mode 100644 index 0000000000000000000000000000000000000000..92e17f1fa91594ad5df1a07aa1bcfaf509480784 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071904257.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071984309.png b/quick-start/figures/zh-cn_image_0000001071984309.png new file mode 100644 index 0000000000000000000000000000000000000000..6d3b3e755e0cb412c67d232c84823423a7e7b0a6 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071984309.png differ diff --git a/quick-start/figures/zh-cn_image_0000001071984311.png b/quick-start/figures/zh-cn_image_0000001071984311.png new file mode 100644 index 0000000000000000000000000000000000000000..6237ab89e03d496aa9ce4b043a7bd05c37f79b36 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001071984311.png differ diff --git a/quick-start/figures/zh-cn_image_0000001072074632.png b/quick-start/figures/zh-cn_image_0000001072074632.png new file mode 100644 index 0000000000000000000000000000000000000000..6d3b3e755e0cb412c67d232c84823423a7e7b0a6 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001072074632.png differ diff --git a/quick-start/figures/zh-cn_image_0000001072552464.png b/quick-start/figures/zh-cn_image_0000001072552464.png new file mode 100644 index 0000000000000000000000000000000000000000..97166251067bd31ba7b1af39d35f9af86af088d1 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001072552464.png differ diff --git a/quick-start/figures/zh-cn_image_0000001072552472.png b/quick-start/figures/zh-cn_image_0000001072552472.png new file mode 100644 index 0000000000000000000000000000000000000000..41d999023ac3a293da559e18c204abe156a19206 Binary files /dev/null and b/quick-start/figures/zh-cn_image_0000001072552472.png differ diff --git "a/quick-start/figures/\347\241\254\344\273\266\350\277\236\347\272\277\345\233\276.png" "b/quick-start/figures/\347\241\254\344\273\266\350\277\236\347\272\277\345\233\276.png" index 22717eff5b2344229a230d2d4fb1aa7f0dd489bb..b5dfc506b818515555959aa29a297185d816ff0b 100755 Binary files "a/quick-start/figures/\347\241\254\344\273\266\350\277\236\347\272\277\345\233\276.png" and "b/quick-start/figures/\347\241\254\344\273\266\350\277\236\347\272\277\345\233\276.png" differ diff --git "a/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\345\272\224\347\224\250\347\250\213\345\272\217\347\244\272\344\276\213.md" "b/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\345\272\224\347\224\250\347\250\213\345\272\217\347\244\272\344\276\213.md" index afd6598fa8eb9163e26255622bfffaf55eb9640a..2343744a98561d951820fbccc7c9a73b410b1909 100755 --- "a/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\345\272\224\347\224\250\347\250\213\345\272\217\347\244\272\344\276\213.md" +++ "b/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\345\272\224\347\224\250\347\250\213\345\272\217\347\244\272\344\276\213.md" @@ -35,34 +35,36 @@ int main(int argc, char **argv) ## 编译 -在linux服务器上,进入源码包根目录,目录内存放有build.py编译脚本,执行如下脚本编译源码包。结果文件生成在out/ipcamera\_hi3516dv300目录下。 +如果Linux编译环境通过Docker方式安装,具体编译过程请参见[Docker方式获取编译环境](../get-code/获取工具.md)的编译操作。如果Linux编译环境通过软件包方式安装,请进入源码根目录,执行如下命令进行编译: ``` python build.py ipcamera_hi3516dv300 -b debug ``` +结果文件生成在out/ipcamera\_hi3516dv300目录下。 + ## 烧录 Hi3516开发板的代码烧录支持USB烧录、网口烧录和串口烧录三种方式。此处仅以网口烧录为例进行说明。 1. 请连接好电脑和待烧录开发板,以Hi3516DV300为例,需要同时连接串口、网口和电源,具体可参考[Hi3516开发板介绍](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_3516-0000001052670587)。 -2. 打开电脑的设备管理器,查看并记录对应的串口号。 +2. 打开电脑的设备管理器,查看并记录对应的串口号。 >![](public_sys-resources/icon-note.gif) **说明:** >如果对应的串口异常,请根据[Hi3516/Hi3518系列开发板串口驱动安装](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 - ![](figures/zh-cn_image_0000001057235010.png) + ![](figures/zh-cn_image_0000001071792503.png) 3. 点击“Configure \> Burn“,进入烧录配置界面,设置ARM系列芯片烧录信息。 - ![](figures/zh-cn_image_0000001057354060.png) + ![](figures/zh-cn_image_0000001071904255.png) 4. 选择烧录方式(Burning Mode),固定选择“network“。 ![](figures/网口烧录-1.png) 5. 设置网口烧录方式的烧录参数。 - - 设置Port number,请选择[2](#zh-cn_topic_0000001056443961_li142386399535)中查询的串口号。 + - 设置Port number,请选择[2](#zh-cn_topic_0000001071634529_li142386399535)中查询的串口号。 - 设置Baud rate和Data bits参数,已根据开发板进行适配,保持默认值即可。 - 设置网络连接信息: @@ -70,73 +72,73 @@ Hi3516开发板的代码烧录支持USB烧录、网口烧录和串口烧录三 - Remote IP address:设置开发板的IP地址,工具自动设置。 - Gateway:对应开发板的网关,工具自动设置。 - Subnet mask:子网验码,工具自动设置。 - - MAC address of board:开发板的物理地址,请手动设置。 + - MAC address of board:开发板的物理地址,请使用默认值即可。 - ![](figures/zh-cn_image_0000001057543065.png) + ![](figures/zh-cn_image_0000001072552472.png) - 设置器件类型(Memory Type),包括spi nor、spi nand和emmc,具体设置规则与硬件接收类型相关,请查阅随硬件发货的硬件说明书。例如Hi3516DV300固定设置为emmc。 - 设置烧录文件信息:请根据如下表格设置烧录文件,网口烧录方式,不支持烧录U-Boot文件。 - -

待烧录文件(File Name)

+ + - - - - - - - - - - - - - -

待烧录文件(File Name)

开始地址(Start Address)

+

开始地址(Start Address)

Flash地址块大小(File Size)

+

Flash地址块大小(File Size)

是否烧录(Enable)

+

是否烧录(Enable)

OHOS_Image.bin

+

OHOS_Image.bin

1M

+

1M

9M

+

9M

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果修改了内核和驱动相关内容,才需要烧录。

+

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果修改了内核和驱动相关内容,才需要烧录。

rootfs.img

+

rootfs.img

10M

+

10M

15M

+

15M

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果这两个文件未做修改,可以不烧录。建议每次烧录时,都烧录这两个文件。

+

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果这两个文件未做修改,可以不烧录。建议每次烧录时,都烧录这两个文件。

userfs.img

+

userfs.img

25M

+

25M

50M

+

50M

- ![](figures/zh-cn_image_0000001057621705.png) + ![](figures/zh-cn_image_0000001071514639.png) 6. 修改了相关配置后,请点击最下方的“Save“进行保存。 -7. 在DevEco Device Tool中,点击Burn后的![](figures/zh-cn_image_0000001057097113.png)按钮开始烧录。 +7. 在DevEco Device Tool中,点击Burn后的![](figures/zh-cn_image_0000001072074632.png)按钮开始烧录。 - ![](figures/zh-cn_image_0000001057911116.png) + ![](figures/zh-cn_image_0000001071634537.png) 8. 请在15秒内手动重启开发板\(下电再上电\)。 9. 等待烧录完成,当控制台输出如下信息时,表示烧录成功。 - ![](figures/zh-cn_image_0000001056648688.png) + ![](figures/zh-cn_image_0000001071984311.png) -10. 如果第一次使用开发板,需要使用[串口工具](zh-cn_topic_0000001057649420.md)修改U-boot的bootcmd及bootargs内容,具体可参考[Hi3516开发板镜像运行](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_first_example-0000001051610926#ZH-CN_TOPIC_0000001052906247__section380511712615)。 +10. 如果第一次使用开发板,需要使用[串口工具](https://device.harmonyos.com/cn/docs/ide/user-guides/serial_port-0000001057649420)修改U-boot的bootcmd及bootargs内容,具体可参考[Hi3516开发板镜像运行](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_first_example-0000001051610926#ZH-CN_TOPIC_0000001052906247__section380511712615)。 ## 镜像运行 1. 连接串口。 >![](public_sys-resources/icon-notice.gif) **须知:** - >若无法连接串口,请参考[常见问题](常见问题-1.md#section14871149155911)进行排查。 + >若无法连接串口,请参考[常见问题](Hi3516常见问题.md#section14871149155911)进行排查。 **图 1** 连接串口图 diff --git "a/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\351\251\261\345\212\250\347\250\213\345\272\217\347\244\272\344\276\213.md" "b/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\351\251\261\345\212\250\347\250\213\345\272\217\347\244\272\344\276\213.md" index 53dfa65609fedac5f1e4ce3a77cc5e44e75f2db6..02f8f6a4d65eade9c6c2fc9fce19acb54dd7dc2f 100755 --- "a/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\351\251\261\345\212\250\347\250\213\345\272\217\347\244\272\344\276\213.md" +++ "b/quick-start/\345\274\200\345\217\221Hi3516\347\254\254\344\270\200\344\270\252\351\251\261\345\212\250\347\250\213\345\272\217\347\244\272\344\276\213.md" @@ -434,7 +434,7 @@ 1. 连接串口。 >![](public_sys-resources/icon-notice.gif) **须知:** - >若无法连接串口,请参考[常见问题](常见问题-1.md#section14871149155911)进行排查。 + >若无法连接串口,请参考[常见问题](Hi3516常见问题.md#section14871149155911)进行排查。 **图 1** 连接串口图 diff --git "a/quick-start/\345\274\200\345\217\221Hi3518\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" "b/quick-start/\345\274\200\345\217\221Hi3518\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" index db83ac79fde3ee3a4a984b8ac5358214a8ea9b1a..22e9bd4438c1bc7412cfb7cdc9f6a3a677d8b776 100755 --- "a/quick-start/\345\274\200\345\217\221Hi3518\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" +++ "b/quick-start/\345\274\200\345\217\221Hi3518\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" @@ -35,121 +35,123 @@ int main(int argc, char **argv) ## 编译 -在Linux服务器上,进入源码包根目录,执行如下脚本编译源码包。结果文件生成在out/ipcamera\_hi3518ev300目录下。 +如果Linux编译环境通过Docker方式安装,具体编译过程请参见[Docker方式获取编译环境](../get-code/获取工具.md)的编译操作。如果Linux编译环境通过软件包方式安装,进入源码根目录,执行如下命令进行编译: ``` python build.py ipcamera_hi3518ev300 -b debug ``` +结果文件生成在out/ipcamera\_hi3518ev300目录下。 + ## 烧录 Hi3518开发板的代码烧录仅支持USB烧录方式。 1. 请连接好电脑和待烧录开发板,以Hi3518EV300为例,需要同时连接串口和USB口,具体可参考[Hi3518开发板介绍](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_hi3518-0000001050170473)。 -2. 打开电脑的设备管理器,查看并记录对应的串口号。 +2. 打开电脑的设备管理器,查看并记录对应的串口号。 >![](public_sys-resources/icon-note.gif) **说明:** >如果对应的串口异常,请根据[Hi3516/Hi3518系列开发板串口驱动安装](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 - ![](figures/zh-cn_image_0000001057235010.png) + ![](figures/zh-cn_image_0000001071792503.png) 3. 点击“Device Tool \> Configure \> Burn”进入烧录配置界面,设置Hi3518系列开发板烧录信息。 - ![](figures/zh-cn_image_0000001057194144.png) + ![](figures/zh-cn_image_0000001071514657.png) 4. 选择烧录方式(Burning Mode),固定选择“usbport”。 - ![](figures/zh-cn_image_0000001057392985.png) + ![](figures/zh-cn_image_0000001072552464.png) 5. 设置USB烧录的烧录参数。 - - 设置Port number,请选择[2](#zh-cn_topic_0000001057313128_li101031912111518)中查询的串口号。 + - 设置Port number,请选择[2](#zh-cn_topic_0000001072392860_li101031912111518)中查询的串口号。 - 设置Baud Rate和Data Bits参数,已根据开发板进行适配,保持默认值即可。 - 设置器件类型(Memory Type),Hi3518系列开发板固定设置为spi nor。 - 设置烧录文件信息:请根据如下表格设置烧录文件。 - -

待烧录文件(File Name)

+ + - - - - - - - - - - - - - - - - - -

待烧录文件(File Name)

开始地址(Start Address)

+

开始地址(Start Address)

Flash地址块大小(File Size)

+

Flash地址块大小(File Size)

是否烧录(Enable)

+

是否烧录(Enable)

u-boot-开发板名称.bin

+

u-boot-开发板名称.bin

0

+

0

1M

+

1M

+

OHOS_Image.bin

+

OHOS_Image.bin

1M

+

1M

6M

+

6M

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果修改了内核和驱动相关内容,才需要烧录。

+

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果修改了内核和驱动相关内容,才需要烧录。

rootfs.img

+

rootfs.img

7M

+

7M

8M

+

8M

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果这两个文件未做修改,可以不烧录。建议每次烧录时,都烧录这两个文件。

+

第一次使用开发板烧录时,必须同时烧录;在后续烧录过程中,如果这两个文件未做修改,可以不烧录。建议每次烧录时,都烧录这两个文件。

userfs.img

+

userfs.img

15M

+

15M

1M

+

1M

- ![](figures/zh-cn_image_0000001057952739.png) + ![](figures/zh-cn_image_0000001071634551.png) 6. 修改了相关配置后,请点击最下方的“Save”进行保存。 -7. 在DevEco Device Tool中,点击Burn后的![](figures/zh-cn_image_0000001057311476.png)按钮开始烧录。 +7. 在DevEco Device Tool中,点击Burn后的![](figures/zh-cn_image_0000001071984309.png)按钮开始烧录。 >![](public_sys-resources/icon-note.gif) **说明:** >如果您是第一次在工作台烧录Hi3516/Hi3518系列开发板,可能烧录失败,提示“not find the Devices”,请根据[Hi3516/Hi3518系列开发板USB驱动安装](https://device.harmonyos.com/cn/docs/ide/user-guides/usb_driver-0000001058690393)进行处理后再重新烧录。 - ![](figures/zh-cn_image_0000001058192356.png) + ![](figures/zh-cn_image_0000001071904257.png) 8. 请在15秒内手动重启开发板\(下电再上电\)。 9. 等待烧录完成,当控制台输出如下信息时,表示烧录成功。 ![](figures/USB烧录-6.png) -10. 每次烧录U-boot后,需要使用[串口工具](zh-cn_topic_0000001057649420.md)修改U-boot的bootcmd及bootargs内容,具体可参考[Hi3518开发板镜像运行](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_example-0000001051610926#ZH-CN_TOPIC_0000001053422339__section62131033183710)。 +10. 每次烧录U-boot后,需要使用[串口工具](https://device.harmonyos.com/cn/docs/ide/user-guides/serial_port-0000001057649420)修改U-boot的bootcmd及bootargs内容,具体可参考[Hi3518开发板镜像运行](https://device.harmonyos.com/cn/docs/start/introduce/oem_camera_start_example-0000001051610926#ZH-CN_TOPIC_0000001053422339__section62131033183710)。 ## 镜像运行 1. 连接串口。 >![](public_sys-resources/icon-notice.gif) **须知:** - >若无法连接串口,请参考[常见问题](常见问题-3.md#zh-cn_topic_0000001053466255_section14871149155911)进行排查。 + >若无法连接串口,请参考[常见问题](Hi3518常见问题.md#zh-cn_topic_0000001053466255_section14871149155911)进行排查。 **图 1** 连接串口图 - ![](figures/chuankou1-1.png) + ![](figures/chuankou1-0.png) 1. 单击**Serial port**打开串口。 2. 输入串口编号\(按照烧录步骤中查询的串口号,此处以com11举例\),并连续输入回车直到串口显示"hisillicon"。 - 3. 单板初次启动或修改启动参数,请进入[步骤2](#l5b42e79a33ea4d35982b78a22913b0b1),否则进入[步骤3](#ld26f18828aa44c36bfa36be150e60e49)。 + 3. 单板初次启动或修改启动参数,请进入[步骤2](#li9441185382314),否则进入[步骤3](#li6442853122312)。 -2. (初次烧写必选)修改U-boot的bootcmd及bootargs内容:该步骤为固化操作,可保存执行结果,但U-boot重新烧入,则需要再次执行下述步骤。 +2. (初次烧写必选)修改U-boot的bootcmd及bootargs内容:该步骤为固化操作,可保存执行结果,但U-boot重新烧入,则需要再次执行下述步骤。 **表 1** U-boot修改命令 @@ -191,7 +193,7 @@ Hi3518开发板的代码烧录仅支持USB烧录方式。 >![](public_sys-resources/icon-notice.gif) **须知:** >**“go 0x40000000”**为可选指令,默认配置已将该指令固化在启动参数中,单板复位后可自动启动。若想切换为手动启动,可在U-boot启动倒数阶段使用"回车"打断自动启动。 -3. 若启动时显示**"hisilicon \#**字样,请输入**“reset”**指令,等待系统自启动进入系统,系统启动后,显示**“OHOS”**字样,输入**”./bin/camera\_app”**并回车,显示成功结果如下图所示。 +3. 若启动时显示**"hisilicon \#**字样,请输入**“reset”**指令,等待系统自启动进入系统,系统启动后,显示**“OHOS”**字样,输入**”./bin/camera\_app”**并回车,显示成功结果如下图所示。 **图 2** 启动成功并执行应用程序图 ![](figures/启动成功并执行应用程序图.png "启动成功并执行应用程序图") diff --git "a/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" "b/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" new file mode 100644 index 0000000000000000000000000000000000000000..5b3cd0b0cea13bbe17c54904dba10e7bad8916ce --- /dev/null +++ "b/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\270\200\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" @@ -0,0 +1,153 @@ +# 开发Hi3861第一个示例程序 + +- [源码获取](#section1545225464016) +- [源码编译](#section1736014117148) +- [镜像烧录](#section1610612214150) +- [WLAN模组联网](#section168257461059) + +本示例将演示如何通过AT命令完成WLAN模组与网关联网。 + +## 源码获取 + +开发者需要在Linux服务器上下载并解压一套源代码,获取Hi3861源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz))。更多源码获取方式,请见[源码获取](../get-code/源码获取.md)。 + +## 源码编译 + +本节描述如何在Linux服务器上进行WLAN模组版本的编译。 + +如果Linux编译环境通过Docker方式安装,具体编译过程请参见[Docker方式获取编译环境](../get-code/获取工具.md)的编译操作。如果Linux编译环境通过软件包方式安装,请参考如下步骤。 + +1. 打开DevEco Device Tool工具,点击“View \> Terminal”,进入终端界面。 + + **图 1** IDE终端工具打开方法 + + + ![](figures/zh-cn_image_0000001055040538.png) + + 在终端界面使用ssh命令连接linux服务器,如“ssh _user_@_ipaddr_”。 + + **图 2** 终端界面示意图 + + + ![](figures/zh-cn_image_0000001054599199.png) + +2. 进入代码根路径,并在终端窗口,执行编译脚本命令启动编译“python build.py wifiiot”。 + + **图 3** 在终端界面执行编译命令示意图 + + + ![](figures/zh-cn_image_0000001055040596.png) + +3. 编译结束后,如果出现“BUILD SUCCESS”字样,则证明构建成功,如下图所示。 + + **图 4** 编译成功示意图 + ![](figures/编译成功示意图.png "编译成功示意图") + +4. 构建成功后,会在./out/wifiiot/路径中生成以下文件,使用如下命令可以查看,至此编译构建流程结束。 + + ``` + ls -l out/wifiiot + ``` + + **图 5** 编译文件存放目录示意图 + + + ![](figures/zh-cn_image_0000001055040654.png) + + +## 镜像烧录 + +Hi3861 WLAN模组的镜像烧录可以通过OpenHarmony IDE工具DevEco完成,工具的基本使用请参考[DevEco Device Tool使用指南](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905),烧录过程包含如下步骤。 + +1. 使用USB线连接Windows工作台和WLAN模组。 +2. [下载USB转串口驱动](http://www.wch.cn/downloads/CH341SER_EXE.html),安装USB转串口驱动。 +3. 查询设备管理器上的COM口,如CH340\(COM11\)。该串口集成了烧录、日志打印、AT命令等功能。 + + **图 6** 设备管理器的COM口示意图 + ![](figures/设备管理器的COM口示意图.png "设备管理器的COM口示意图") + +4. 进入IDE烧录配置界面。 + + **图 7** 烧录基础配置示意图 + + + ![](figures/zh-cn_image_0000001054877726.png) + +5. 基础参数配置如下。 + + 1. 在Baud rate中选择合适的波特率,波特率越高烧写速度越快,此处建议使用默认值921600。 + 2. 在Data bit中选择数据位,WLAN模组使用默认值8。 + 3. 选择版本包路径“./out/wifiiot/Hi3861\_wifiiot\_app\_allinone.bin”,选择Mode为“Hiburn”。 + 4. 点击“Save”保存配置。 + + **图 8** 波特率和数据位配置示意图 + ![](figures/波特率和数据位配置示意图.png "波特率和数据位配置示意图") + + **图 9** 烧录包路径示意图 + + + ![](figures/zh-cn_image_0000001055427138.png) + +6. 在DevEco工具界面中单击“烧录”按钮![](figures/zh-cn_image_0000001054443694.png),然后选择烧录串口“COM11”。 + + **图 10** 烧录启动示意图 + ![](figures/烧录启动示意图.png "烧录启动示意图") + +7. 选择串口后,IDE的TERMINAL对话框中出现“Connecting, please reset device...”的字样,模组进入待烧录状态。 + + **图 11** 烧录进行中示意图 + ![](figures/烧录进行中示意图.png "烧录进行中示意图") + +8. 按下模组上的复位按键,开始烧写版本,等待TERMINAL对话框中出现“Execution Successful”字样,即烧录完成。 + + **图 12** 烧录完成示意图 + + + ![](figures/zh-cn_image_0000001054802306.png) + + +## WLAN模组联网 + +完成版本构建及烧录后,下面开始介绍如何在串口终端上执行AT命令,使WLAN模组联网。 + +1. 保持Windows工作台和WLAN模组的连接状态,在DevEco工具最下方,点击“Serial port”按钮,弹出串口终端的配置界面。 + + **图 13** 打开DevEco串口终端示意图 + ![](figures/打开DevEco串口终端示意图.png "打开DevEco串口终端示意图") + +2. 选择串口,并完成参数配置。根据实际情况输入串口号,此处为“COM11”;波特率、数据位、停止位使用默认值;由于AT命令输入需要以“\\r\\n”结尾,否则输入无效,所以结束符处输入“1”。 + + **图 14** 串口参数配置示意图 + ![](figures/串口参数配置示意图.png "串口参数配置示意图") + +3. 复位WLAN模组,终端界面显示“ready to OS start”,则启动成功。 + + **图 15** WLAN复位成功示意图 + + + ![](figures/3.png) + +4. 在DevEco的串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 + + ``` + AT+STARTSTA - 启动STA模式 + AT+SCAN - 扫描周边AP + AT+SCANRESULT - 显示扫描结果 + AT+CONN="SSID",,2,"PASSWORD" - 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 + AT+STASTAT - 查看连接结果 + AT+DHCP=wlan0,1 - 通过DHCP向AP请求wlan0的IP地址 + ``` + +5. 查看WLAN模组与网关联通是否正常,如下图所示。 + + ``` + AT+IFCFG - 查看模组接口IP + AT+PING=X.X.X.X - 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 + ``` + + **图 16** WLAN模组联网成功示意图 + + + ![](figures/4.png) + + diff --git "a/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\272\214\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" "b/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\272\214\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" new file mode 100644 index 0000000000000000000000000000000000000000..5561e1d8ca5b0720dec64abe33f1c69a8c787429 --- /dev/null +++ "b/quick-start/\345\274\200\345\217\221Hi3861\347\254\254\344\272\214\344\270\252\347\244\272\344\276\213\347\250\213\345\272\217.md" @@ -0,0 +1,158 @@ +# 开发Hi3861第二个示例程序 + +- [修改源码](#section9360141181414) +- [调测验证](#section1621064881419) +- [printf打印](#section1246911301217) +- [根据asm文件进行问题定位](#section197271353219) +- [运行结果](#section18115713118) +- [下一步学习](#section9712145420182) + +本示例将演示如何编写简单业务,输出“Hello World”,初步了解OpenHarmony 如何运行在开发板上。 + +## 修改源码 + +bugfix和新增业务两种情况,涉及源码修改。下面以新增业务(my\_first\_app)为例,向开发者介绍如何进行源码修改。 + +1. 确定目录结构。 + + 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 + + 例如:在app下新增业务my\_first\_app,其中hello\_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: + + ``` + . + └── applications + └── sample + └── wifi-iot + └── app + │── my_first_app + │ │── hello_world.c + │ └── BUILD.gn + └── BUILD.gn + ``` + +2. 编写业务代码。 + + 新建./applications/sample/wifi-iot/app/my\_first\_app下的hello\_world.c文件,在hello\_world.c中新建业务入口函数HelloWorld,并实现业务逻辑。并在代码最下方,使用OpenHarmony启动恢复模块接口SYS\_RUN\(\)启动业务。(SYS\_RUN定义在ohos\_init.h文件中) + + ``` + #include + #include "ohos_init.h" + #include "ohos_types.h" + + void HelloWorld(void) + { + printf("[DEMO] Hello world.\n"); + } + SYS_RUN(HelloWorld); + ``` + +3. 编写用于将业务构建成静态库的BUILD.gn文件。 + + 新建./applications/sample/wifi-iot/app/my\_first\_app下的BUILD.gn文件,并完成如下配置。 + + 如[步骤1](#li5479332115116)所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。。 + + ``` + static_library("myapp") { + sources = [ + "hello_world.c" + ] + include_dirs = [ + "//utils/native/lite/include" + ] + } + ``` + + - static\_library中指定业务模块的编译结果,为静态库文件libmyapp.a,开发者根据实际情况完成填写。 + - sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//"则表示绝对路径(此处为代码根路径),若不包含"//"则表示相对路径。 + - include\_dirs中指定source所需要依赖的.h文件路径。 + +4. 编写模块BUILD.gn文件,指定需参与构建的特性模块。 + + 配置./applications/sample/wifi-iot/app/BUILD.gn文件,在features字段中增加索引,使目标模块参与编译。features字段指定业务模块的路径和目标,以my\_first\_app举例,features字段配置如下。 + + ``` + import("//build/lite/config/component/lite_component.gni") + + lite_component("app") { + features = [ + "my_first_app:myapp", + ] + } + ``` + + - my\_first\_app是相对路径,指向./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn。 + - myapp是目标,指向./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn中的static\_library\("myapp"\)。 + + +## 调测验证 + +目前调试验证的方法有两种,分别为通过printf打印日志、通过asm文件定位panic问题,开发者可以根据具体业务情况选择。 + +由于本示例业务简单,采用printf打印日志的调试方式即可。下面开始介绍这两种调试手段的使用方法。 + +## printf打印 + +代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示。 + +``` +void HelloWorld(void) +{ + printf("[DEMO] Hello world.\n"); +} +``` + +## 根据asm文件进行问题定位 + +系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 + +``` +=======KERNEL PANIC======= +**********************Call Stack********************* +Call Stack 0 -- 4860d8 addr:f784c +Call Stack 1 -- 47b2b2 addr:f788c +Call Stack 2 -- 3e562c addr:f789c +Call Stack 3 -- 4101de addr:f78ac +Call Stack 4 -- 3e5f32 addr:f78cc +Call Stack 5 -- 3f78c0 addr:f78ec +Call Stack 6 -- 3f5e24 addr:f78fc +********************Call Stack end******************* +``` + +为解析上述调用栈信息,需要使用到Hi3861\_wifiiot\_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本大包一同构建输出,存放在./out/wifiiot/路径下。 + +1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) +2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名 信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 + + ``` + Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB + Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data + Call Stack 2 -- 3e562c addr:f789c + Call Stack 3 -- 4101de addr:f78ac + Call Stack 4 -- 3e5f32 addr:f78cc + Call Stack 5 -- 3f78c0 addr:f78ec + Call Stack 6 -- 3f5e24 addr:f78fc + ``` + +3. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 + + ![](figures/zh-cn_image_0000001054763554.png) + +4. 完成代码排查及修改。 + +## 运行结果 + +示例代码编译、烧录、运行、调测后,在串口界面会显示如下结果: + +``` +ready to OS start +FileSystem mount ok. +wifi init success! +[DEMO] Hello world. +``` + +## 下一步学习 + +恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入[WLAN产品开发](../guide/概述.md)的学习 。 + diff --git a/subsystems/DFX.md b/subsystems/DFX.md new file mode 100644 index 0000000000000000000000000000000000000000..810e5b91ccf132b4ca5eb5e41786016a4f298349 --- /dev/null +++ b/subsystems/DFX.md @@ -0,0 +1,13 @@ +# DFX + +- **[DFX子系统概述](DFX子系统概述.md)** + +- **[使用mini框架开发](使用mini框架开发.md)** + +- **[使用featured框架开发](使用featured框架开发.md)** + +- **[常见问题](常见问题-0.md)** + +- **[参考](参考.md)** + + diff --git "a/subsystems/DFX\345\255\220\347\263\273\347\273\237\346\246\202\350\277\260.md" "b/subsystems/DFX\345\255\220\347\263\273\347\273\237\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..e9d1725ad202f2cac61b3f2ba70be37c5edd1dcc --- /dev/null +++ "b/subsystems/DFX\345\255\220\347\263\273\347\273\237\346\246\202\350\277\260.md" @@ -0,0 +1,37 @@ +# DFX子系统概述 + +DFX子系统主要包含DFR(Design for Reliability,可靠性)和DFT(Design for Testability,可测试性)特性,为开发者提供代码维测信息。 + +由于芯片平台资源有限,且硬件平台多样,因此需要针对不同硬件架构和资源提供组件化且可定制的DFX框架。根据RISC-V、Cortex-M、Cortex-A不同硬件平台,提供两种不同的轻量级DFX框架,以下简称mini、featured框架。 + +- mini框架:针对处理架构为Cortex-M或同等处理能力的硬件平台,系统内存一般低于512KB,无文件系统或者仅提供一个可有限使用的轻量级文件系统,遵循CMSIS接口规范。用户Task通过API接口,将日志记录在缓存中,异步调用输出接口打印日志,如下图所示。 + +**图 1** mini框架架构 + + +![](figures/zh-cn_image_0000001064795436.png) + +- featured框架:处理架构为Cortex-A或同等处理能力的硬件平台,内存资源一般大于512KB,文件系统完善,可存储大量数据,遵循POSIX接口规范。 + + **图 2** featured框架架构 + + + ![](figures/zh-cn_image_0000001064187438.png) + + **图解:**用户态Process或内核Task写日志至hilogtask,hilogtask将日志内容存入ringbuffer中,用户态的hilogcat及apphilogcat进程负责日志的串口输出和flash落盘。 + + 下述主要任务的详细内容: + + 1. hilogtask流水日志的内核任务。 + - 此功能是一个内核的驱动,在系统启动时初始化。 + - 当内核或者用户态模块调用日志接口,将格式化好的日志内容传输给该任务,并将其存储在一个环形缓冲区中 。 + + 2. apphilogcat用户态日志存储服务。 + - 用户态进程,负责将内核的Ringbuffer读取出来,存储到日志文件中。 + + 3. hilogcat日志查看命令行工具。 + + 从内核驱动接口读取ringbuffer内容,输出到标准输出,可支持日志过滤。 + + + diff --git a/subsystems/Readme-CN.md b/subsystems/Readme-CN.md index db3cfea4de384ee90822eb49d1079141570135a6..4ae9ca2b413ab295d4e7d183a85ac34d0aa27938 100755 --- a/subsystems/Readme-CN.md +++ b/subsystems/Readme-CN.md @@ -8,14 +8,39 @@ - [普通组件开发指导](普通组件开发指导.md) - [动画开发指导](动画开发指导.md) -- [相机](相机.md) +- [媒体](媒体.md) - [相机开发概述](相机开发概述.md) - [拍照开发指导](拍照开发指导.md) - [录像开发指导](录像开发指导.md) - [预览开发指导](预览开发指导.md) - -- [音视频](音视频.md) - [音视频开发概述](音视频开发概述.md) - [音视频播放开发指导](音视频播放开发指导.md) - [音视频录制开发指导](音视频录制开发指导.md) +- [公共基础](公共基础.md) + - [公共基础库概述](公共基础库概述.md) + - [公共基础库开发指导](公共基础库开发指导.md) + - [公共基础库常见问题](公共基础库常见问题.md) + +- [用户程序框架](用户程序框架.md) + - [概述](概述.md) + - [搭建环境](搭建环境.md) + - [开发指导](开发指导.md) + - [开发实例](开发实例.md) + - [常见问题](常见问题.md) + +- [编译构建](编译构建.md) + - [编译构建概述](编译构建概述.md) + - [编译构建使用指导](编译构建使用指导.md) + - [编译构建常见问题](编译构建常见问题.md) + +- [测试](测试.md) +- [DFX](DFX.md) + - [DFX子系统概述](DFX子系统概述.md) + - [使用mini框架开发](使用mini框架开发.md) + - [使用featured框架开发](使用featured框架开发.md) + - [常见问题](常见问题-0.md) + - [参考](参考.md) + +- [XTS认证](XTS认证.md) + diff --git "a/subsystems/XTS\350\256\244\350\257\201.md" "b/subsystems/XTS\350\256\244\350\257\201.md" new file mode 100644 index 0000000000000000000000000000000000000000..a7eeb7d6dd7ef21b7366568935e533983dee076b --- /dev/null +++ "b/subsystems/XTS\350\256\244\350\257\201.md" @@ -0,0 +1,436 @@ +# XTS认证 + +- [概述](#zh-cn_topic_0000001059475030_section44931242483) +- [目录结构](#zh-cn_topic_0000001059475030_section45118915548) +- [约束与限制](#zh-cn_topic_0000001059475030_section115518148474) +- [开发指导](#zh-cn_topic_0000001059475030_section99973470498) + - [编写联接类模组acts测试用例](#zh-cn_topic_0000001059475030_section1348215596491) + - [编写智慧视觉类设备(Ipcamera)acts测试用例](#zh-cn_topic_0000001059475030_section11458163095019) + - [执行联接类模组acts测试用例](#zh-cn_topic_0000001059475030_section3115140115113) + - [执行智慧视觉类设备(Ipcamera)acts测试用例](#zh-cn_topic_0000001059475030_section1759138185215) + + +## 概述 + +XTS是OpenHarmony生态认证测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套,后续会拓展dcts(device compatibility test suite)设备兼容性测试套等。 + +test/xts仓当前包括acts与tools软件包: + +- acts,存放acts相关测试用例源码与配置文件,其目的是帮助终端设备厂商尽早发现软件与OpenHarmony的不兼容性,确保软件在整个开发过程中满足OpenHarmony的兼容性要求。 +- tools,存放acts相关测试用例开发框架。 + +## 目录结构 + +test/xts源代码目录结构: + +├── acts + +│ ├── BUILD.gn 测试用例编译配置 + +│ └── subsystem\_lite 子系统测试用例源码 + +└── tools + +│ └── build 测试用例编译相关的模板与脚本 + +│ └── hcpptest 智慧视觉类设备(Ipcamera)测试用例开发框架源码 + +│ └── hctest 联接类模组测试用例开发框架源码 + +│ └── BUILD.gn 编译配置 + +│ └── build.sh 编译入口 + +## 约束与限制 + +联接类模组acts用例开发语言是C,智慧视觉类设备(Ipcamera)acts用例开发语言是C++。 + +## 开发指导 + +### 编写联接类模组acts测试用例 + +当前使用的测试框架是hctest。 + +hctest测试框架支持使用C语言编写测试用例,在联接类模组上执行,是在开源测试框架unity的基础上进行增强和适配。 + +1. 规范用例目录:测试用例存储test/xts/acts仓中。 + + ├── acts + + │ ├── BUILD.gn + + │ └──subsystem\_lite + + │ │ └── module\_hal + + │ │ │ └── BUILD.gn + + │ │ │ └── src + +2. src目录下用例编写样例。 + + a. 引用测试框架 + + ``` + #include "hctest.h" + ``` + + b. 使用宏定义LITE\_TEST\_SUIT定义子系统、模块、测试套件名称 + + ``` + /** + * @brief register a test suit named "IntTestSuite" + * @param test subsystem name + * @param example module name + * @param IntTestSuite test suit name + */ + LITE_TEST_SUIT(test, example, IntTestSuite); + ``` + + c. 定义Setup与TearDown + + 命名方式:测试套件名称+Setup,测试套件名称+TearDown。 + + Setup与TearDown必须存在,可以为空函数。 + + d. 使用宏定义LITE\_TEST\_CASE写测试用例 + + 包括三个参数:测试套件名称,测试用例名称,用例级别。 + + 用例级别取值为如下内容之一: + + “Level0”,“Level1”,“Level2”,“Level3”,“Level4”。 + + ``` + LITE_TEST_CASE(IntTestSuite, TestCase001, Level0) + { + //do something + }; + ``` + + 用例级别说明如下表所示。 + + **表 1** 用例级别说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

级别名称

+

基本定义

+

测试范围

+

Level0

+

冒烟

+

验证关键功能点基本功能/最基本DFX属性在最常见输入下的表现,通过表示功能基本可运行。

+

Level1

+

基本

+

验证各功能点基本功能/基本DFX属性在常见输入下的表现,通过表示功能基本可测试。

+

Level2

+

重要

+

验证各功能点的基本功能/基本DFX属性在常规输入/常见异常情况下的表现,通过表示功能基本正常可用,可开展Beta。

+

Level3

+

一般

+

验证各功能点的全部功能/全部DFX属性在各种常规/非常规输入组合下,或各种正常/异常预置条件组合下的表现。

+

Level4

+

生僻

+

验证关键功能点在极端异常预置条件下、用户难以触及的异常输入组合下的表现。

+
+ + e. 使用宏定义 RUN\_TEST\_SUITE注册测试套件。 + + ``` + RUN_TEST_SUITE(IntTestSuite); + ``` + +3. 测试模块的配置文件样例:(BUILD.gn)。 + + 每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后静态库的名称、依赖的头文件、依赖的库等;具体写法如下: + + ``` + import("//test/xts/tools/build/suite_lite.gni") + hctest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/test_demo.c", + ] + include_dirs = [ ] + cflags = [ "-Wno-error" ] + } + ``` + +4. acts下BUILD.gn增加编译选项。 + + 需要将测试模块加入到acts目录下的编译脚本中,编译脚本路径:test/xts/acts/BUILD.gn。 + + ``` + lite_component("acts") { + ... + if(board_name == "liteos_riscv") { + features += [ + ... + "//xts/acts/subsystem_lite/module_hal:ActsDemoTest" + ] + } + } + ``` + +5. 测试套件编译命令。 + + **命令:**python build.py wifiiot -b debug + + **输出:**out/wifiiot + + >![](public_sys-resources/icon-note.gif) **说明:** + >联接类模组acts测试编译中间件为静态库,最终会链接到版本镜像中 :Hi3861\_wifiiot\_app\_allinone.bin。 + + +### 编写智慧视觉类设备(Ipcamera)acts测试用例 + +hcpptest测试框架是在开源的googletest测试框架的基础上进行的增强和适配。 + +1. 规范用例目录:测试用例存储到test/xts/acts仓中。 + + ├── acts + + │ ├── BUILD.gn + + │ └──subsystem\_lite + + │ │ └── module\_posix + + │ │ │ └── BUILD.gn + + │ │ │ └── src + +2. 测试模块src下用例编写样例。 + + a. 引用测试框架: + + 需要引用gtest.h 如:\#include "gtest/gtest.h" + + ``` + #include "gtest/gtest.h" + ``` + + b. 定义Setup与TearDown + + ``` + class TestSuite: public testing::Test { + protected: + // Preset action of the test suite, which is executed before the first test case + static void SetUpTestCase(void){ + } + // Test suite cleanup action, which is executed after the last test case + static void TearDownTestCase(void){ + } + // Preset action of the test case + virtual void SetUp() + { + } + // Cleanup action of the test case + virtual void TearDown() + { + } + }; + ``` + + c. 使用宏定义HWTEST或HWTEST\_F写测试用例 + + 普通测试用例的定义:HWTEST(测试套名称, 测试用例名称, 用例标注)。 + + 包含SetUp和TearDown的测试用例的定义 :HWTEST\_F(测试套名称, 测试用例名称,用例标注)。 + + 宏定义包括三个参数:测试套件名称,测试用例名称,用例级别。 + + 用例级别取值为如下内容之一: + + “Level0”,“Level1”,“Level2”,“Level3”,“Level4”。 + + ``` + HWTEST_F(TestSuite, TestCase_0001, Level0) { + // do something + } + ``` + + 用例级别说明如下表所示。 + + **表 2** 用例级别说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

级别名称

+

基本定义

+

测试范围

+

Level0

+

冒烟

+

验证关键功能点基本功能/最基本DFX属性在最常见输入下的表现,通过表示功能基本可运行。

+

Level1

+

基本

+

验证各功能点基本功能/基本DFX属性在常见输入下的表现,通过表示功能基本可测试。

+

Level2

+

重要

+

验证各功能点的基本功能/基本DFX属性在常规输入/常见异常情况下的表现,通过表示功能基本正常可用,可开展Beta。

+

Level3

+

一般

+

验证各功能点的全部功能/全部DFX属性在各种常规/非常规输入组合下,或各种正常/异常预置条件组合下的表现。

+

Level4

+

生僻

+

验证关键功能点在极端异常预置条件下、用户难以触及的异常输入组合下的表现。

+
+ +3. 测试模块下用例配置文件样例:(BUILD.gn)。 + + 每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后可执行文件的名称、依赖的头文件、依赖的库等;具体写法如下。每个测试模块将独立编译成.bin可执行文件, 该文件可直接mount到单板上进行测试。 + + 举例: + + ``` + import("//test/xts/tools/build/suite_lite.gni") + + hcpptest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/TestDemo.cpp" + ] + + include_dirs = [ + "src", + ... + ] + deps = [ + ... + ] + cflags = [ "-Wno-error" ] + } + + ``` + +4. acts目录下增加编译选项(BUILD.gn)。 + + 将测试模块加入到acts目录下的编译脚本中,编译脚本为:test/xts/acts/BUILD.gn。 + + ``` + lite_component("acts") { + ... + else if(board_name == "liteos_a") { + features += [ + ... + "//xts/acts/subsystem_lite/module_posix:ActsDemoTest" + ] + } + } + ``` + +5. 测试套件编译命令。 + + - **hi3518ev300** + + **命令**:python build.py ipcamera\_hi3518ev300 -b debug + + **输出**:out/ipcamera\_hi3518ev300 + + - **hi3516dv300** + + **命令**:python build.py ipcamera\_hi3516dv300 -b debug + + **输出**:out/ipcamera\_hi3516dv300 + + >![](public_sys-resources/icon-note.gif) **说明:** + >智慧视觉类设备(Ipcamera)acts独立编译成.bin可执行文件, 该文件可直接mount到单板上进行测试。 + + +### 执行联接类模组acts测试用例 + +**获取测试大包** + +请在如下目录获取版本镜像,归档目录:out\\wifiiot\\Hi3861\_wifiiot\_app\_allinone.bin。 + +备注:判断当前版本镜像是否集成acts测试套件方法:在map文件中查看对应.a是否被编译即可,out\\wifiiot\\Hi3861\_wifiiot\_app.map。 + +**版本镜像烧录进开发板** + +**测试步骤** + +1. 使用串口工具登录开发板,并保存串口打印信息。 +2. 重启设备,查看串口日志。 + +**测试结果分析指导** + +基于串口打印日志进行分析; + +每个测试套件执行以:Start to run test suite:开始,以xx Tests xx Failures xx Ignored结束。 + +### 执行智慧视觉类设备(Ipcamera)acts测试用例 + +目前的用例执行采用nfs共享的方式,mount到单板去执行; + +**环境搭建** + +1. 使用有限网线或无线将Ipcamera开发板与PC进行连接。 +2. Ipcamera开发板配置IP、子网掩码、网关,确保Ipcamera开发板与PC处于同一个网段。 +3. PC安装nfs服务器并完成注册,启动nfs服务。 +4. Ipcamera开发板配置mount命令,确保Ipcamera开发板可以访问PC端的nfs共享文件。 + + 格式:mount \[nfs服务器IP\]:\[/nfs共享目录\] \[/Ipcamera开发板目录\] nfs + + 举例: + + ``` + mount 192.168.1.10:/nfs /nfs nfs + ``` + + +**用例执行** + +基于串口打印日志进行分析。 + +每个测试套件执行以./测试模块.bin 触发用例执行。 + diff --git "a/subsystems/figures/Ability\344\270\216AbilitySlice\347\232\204\345\205\263\347\263\273\345\233\276.png" "b/subsystems/figures/Ability\344\270\216AbilitySlice\347\232\204\345\205\263\347\263\273\345\233\276.png" new file mode 100644 index 0000000000000000000000000000000000000000..d75201bb385d4a02d05c38174a5be216953da9c6 Binary files /dev/null and "b/subsystems/figures/Ability\344\270\216AbilitySlice\347\232\204\345\205\263\347\263\273\345\233\276.png" differ diff --git "a/subsystems/figures/Ability\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" "b/subsystems/figures/Ability\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" new file mode 100644 index 0000000000000000000000000000000000000000..a7335c79e316dcefaa91de546cf1604644e471df Binary files /dev/null and "b/subsystems/figures/Ability\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" differ diff --git "a/subsystems/figures/Ability\347\256\241\347\220\206\346\234\215\345\212\241\345\222\214\345\214\205\347\256\241\347\220\206\346\234\215\345\212\241\345\220\257\345\212\250.png" "b/subsystems/figures/Ability\347\256\241\347\220\206\346\234\215\345\212\241\345\222\214\345\214\205\347\256\241\347\220\206\346\234\215\345\212\241\345\220\257\345\212\250.png" new file mode 100644 index 0000000000000000000000000000000000000000..b84f177a7d26094ea96ad7e28b9872217fe79ab8 Binary files /dev/null and "b/subsystems/figures/Ability\347\256\241\347\220\206\346\234\215\345\212\241\345\222\214\345\214\205\347\256\241\347\220\206\346\234\215\345\212\241\345\220\257\345\212\250.png" differ diff --git a/subsystems/figures/unnaming.png b/subsystems/figures/unnaming.png new file mode 100644 index 0000000000000000000000000000000000000000..6350269abdc028f9b1b31d544b78f380e58d7a57 Binary files /dev/null and b/subsystems/figures/unnaming.png differ diff --git a/subsystems/figures/zh-cn_image_0000001062334618.png b/subsystems/figures/zh-cn_image_0000001062334618.png new file mode 100644 index 0000000000000000000000000000000000000000..0ac7c0924e931695308a819010668327ed8a8680 Binary files /dev/null and b/subsystems/figures/zh-cn_image_0000001062334618.png differ diff --git a/subsystems/figures/zh-cn_image_0000001062476933.png b/subsystems/figures/zh-cn_image_0000001062476933.png new file mode 100644 index 0000000000000000000000000000000000000000..7e4b608bbffd7ae3becdc918abd6ff2b041888e5 Binary files /dev/null and b/subsystems/figures/zh-cn_image_0000001062476933.png differ diff --git a/subsystems/figures/zh-cn_image_0000001062942690.png b/subsystems/figures/zh-cn_image_0000001062942690.png new file mode 100644 index 0000000000000000000000000000000000000000..c06de34e1a7e72dc162d09b1a4fa5fcd25cefab3 Binary files /dev/null and b/subsystems/figures/zh-cn_image_0000001062942690.png differ diff --git a/subsystems/figures/zh-cn_image_0000001064187438.png b/subsystems/figures/zh-cn_image_0000001064187438.png new file mode 100644 index 0000000000000000000000000000000000000000..0e4830197efdfafe19853a06b1888340cc91c4c1 Binary files /dev/null and b/subsystems/figures/zh-cn_image_0000001064187438.png differ diff --git a/subsystems/figures/zh-cn_image_0000001064795436.png b/subsystems/figures/zh-cn_image_0000001064795436.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f0fcc0c14ae188fc5f9860438cc924fff72978 Binary files /dev/null and b/subsystems/figures/zh-cn_image_0000001064795436.png differ diff --git "a/subsystems/figures/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" "b/subsystems/figures/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" new file mode 100644 index 0000000000000000000000000000000000000000..594c3e1d9db95b3149ee3da9c11d9cea350d4d1d Binary files /dev/null and "b/subsystems/figures/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237\346\241\206\346\236\266\345\233\276.png" differ diff --git "a/subsystems/figures/\345\220\257\345\212\250\351\230\266\346\256\265\346\211\223\345\215\260\345\233\276\347\244\272.png" "b/subsystems/figures/\345\220\257\345\212\250\351\230\266\346\256\265\346\211\223\345\215\260\345\233\276\347\244\272.png" new file mode 100644 index 0000000000000000000000000000000000000000..b38834ea3327aaea9f6d7fdeea784456d5df3d8d Binary files /dev/null and "b/subsystems/figures/\345\220\257\345\212\250\351\230\266\346\256\265\346\211\223\345\215\260\345\233\276\347\244\272.png" differ diff --git "a/subsystems/figures/\345\233\276\347\211\2071.png" "b/subsystems/figures/\345\233\276\347\211\2071.png" new file mode 100644 index 0000000000000000000000000000000000000000..c9e74aefe365e0c103fbb6c128f731850d8258a4 Binary files /dev/null and "b/subsystems/figures/\345\233\276\347\211\2071.png" differ diff --git "a/subsystems/figures/\345\272\224\347\224\250\345\220\257\345\212\250\346\265\201\347\250\213.png" "b/subsystems/figures/\345\272\224\347\224\250\345\220\257\345\212\250\346\265\201\347\250\213.png" new file mode 100644 index 0000000000000000000000000000000000000000..2111dd19967c6f8d960a4e93891ddde7f8825225 Binary files /dev/null and "b/subsystems/figures/\345\272\224\347\224\250\345\220\257\345\212\250\346\265\201\347\250\213.png" differ diff --git "a/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\346\236\266\346\236\204.png" "b/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\346\236\266\346\236\204.png" new file mode 100644 index 0000000000000000000000000000000000000000..2fe0cd71ea0d976cf03ccb73ecc0904fc1f68d03 Binary files /dev/null and "b/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\346\236\266\346\236\204.png" differ diff --git "a/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\350\277\220\350\241\214\346\227\266\345\272\217.png" "b/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\350\277\220\350\241\214\346\227\266\345\272\217.png" new file mode 100644 index 0000000000000000000000000000000000000000..284d36dcb0633694c6414b96c05910f91a1ee455 Binary files /dev/null and "b/subsystems/figures/\346\265\213\350\257\225\345\267\245\345\205\267\350\277\220\350\241\214\346\227\266\345\272\217.png" differ diff --git "a/subsystems/\344\275\277\347\224\250featured\346\241\206\346\236\266\345\274\200\345\217\221.md" "b/subsystems/\344\275\277\347\224\250featured\346\241\206\346\236\266\345\274\200\345\217\221.md" new file mode 100644 index 0000000000000000000000000000000000000000..a27c95fe172a1eb72310a8ee4012c2c17818ab7f --- /dev/null +++ "b/subsystems/\344\275\277\347\224\250featured\346\241\206\346\236\266\345\274\200\345\217\221.md" @@ -0,0 +1,145 @@ +# 使用featured框架开发 + +- [接口说明](#section20840587473) +- [开发步骤](#section32781532131314) +- [使用featured框架实例](#section1210915266154) + +featured框架提供完整的DFX特性,debug版本默认输出到串口及文件,保存路径为“/storage/data/log/“。 + +## 接口说明 + +``` +HILOG_DEBUG(type, ...) +HILOG_INFO(type, ...) +HILOG_WARN(type, ...) +HILOG_ERROR(type, ...) +HILOG_FATAL(type, ...) +``` + +**表 1** 接口参数介绍 + + + + + + + + + + + + + + + + + + + + + + +

参数名字

+

参数含义

+

type

+

兼容mini框架的参数,featured框架忽略传入值。

+

domainId

+

领域标识ID,隐藏参数,需要用户自定义。

+

tag

+

日志tag,隐藏参数,需要用户自定义。

+

fmt

+

格式化字符串,

+

支持标识格式化字符串fmt是否是隐私,是{private}时fmt会被认为是隐私,{public}时被认为是公开。

+

args

+

格式化字符串参数。

+
+ +接口隐私规则介绍(该功能仅在release版本中有效): + +1. 格式化字符串默认是非隐私 + + ``` + HILOG_INFO(0, "Hello World\n"); >> Hello World + ``` + +2. 格式化参数默认是隐私 + + ``` + HILOG_INFO(0, "Age is %d\n", 10); >> Age is + ``` + +3. %\{private\}标识的参数是隐私 + + ``` + HILOG_INFO(0, "Age is %{private}d\n", 10); >> Age is + ``` + +4. %\{public\}标识的参数是非隐私 + + ``` + HILOG_INFO(0, "Age is %{public}d\n", 10); >>Age is 10 + ``` + + +## 开发步骤 + +1. 在Build.gn文件中添加动态库依赖。 + + ``` + public_deps = [ "//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared"] + ``` + +2. 增加头文件,定义模块TAG及Domain数值。 + + ``` + #include + #undef LOG_TAG + #undef LOG_DOMAIN + #define LOG_TAG "MyModule" + #define LOG_DOMAIN 0xD00000 + ``` + +3. 添加日志打印代码。 + + ``` + HILOG_INFO(0,"Hello World\n"); + ``` + + +## 使用featured框架实例 + +以引用samgr\_lite模块使用featured框架作为实例。 + +1. 源码路径中foundation/distributedschedule/services/samgr\_lite/samgr/source/BUILD.gn中通过依赖语句引用hilog的头文件及依赖库。 + + ``` + public_deps = [ "//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared" ] + ``` + +2. 源码文件中引用头文件并使用HILOG接口。 + + 参考源码文件distributedschedule/services/samgr\_lite/samgr\_server/source/samgr\_server.c。 + + ``` + #include + + #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!"); + ... + } + ``` + + 文件内引用头文件或者,增加模块类别的编号及TAG标识(Samgr)。 + +3. InitializeRegistry函数被调用时,打印输出日志内容,内容包括日期,PID(6),taskID(23),级别(I),领域标识ID(01800,取定义值0xD001800的低5位),模块名(Samgr),语句内容(Initialize Registry!)。 + + **图 1** 启动阶段打印图示 + ![](figures/启动阶段打印图示.png "启动阶段打印图示") + + diff --git "a/subsystems/\344\275\277\347\224\250mini\346\241\206\346\236\266\345\274\200\345\217\221.md" "b/subsystems/\344\275\277\347\224\250mini\346\241\206\346\236\266\345\274\200\345\217\221.md" new file mode 100644 index 0000000000000000000000000000000000000000..8beeb2db9146ad02706c1622ac07a129823af6ef --- /dev/null +++ "b/subsystems/\344\275\277\347\224\250mini\346\241\206\346\236\266\345\274\200\345\217\221.md" @@ -0,0 +1,194 @@ +# 使用mini框架开发 + +- [接口说明](#section183731439142417) +- [使用mini框架实例](#section153112047155419) + +mini框架是一套简单小巧的DFX设计,对外提供日志记录功能。 + +## 接口说明 + +``` +HILOG_DEBUG(mod, fmt, ...) +HILOG_INFO(mod, fmt, ...) +HILOG_WARN(mod, fmt, ...) +HILOG_ERROR(mod, fmt, ...) +HILOG_FATAL(mod, fmt, ...) +``` + +接口参数说明: + + + + + + + + + + + + + + + + + + + + + + + + +

参数名

+

是否必填

+

参数类型

+

参数说明

+

mod

+

+

uint8

+

模块/服务的ID。

+

统一规划分配,最大支持64个,其中第三方APP统一使用HILOG_MODULE_APP作为模块ID。

+

fmt

+

+

char *

+

格式化输出字符串。

+
  1. 最大支持6个可变参数,不支持%s。
  2. 格式化后的单条日志最大长度128字节,超过将无法打印。
+

可变参

+

+

int32

+

仅支持数字类型,最大支持6个变参。

+
+ +1. 添加模块ID + + 在interfaces/kits/hilog\_lite/hiview\_log.h的HiLogModuleType中添加HILOG\_MODULE\_A定义。 + + ``` + typedef enum { + /** DFX */ + HILOG_MODULE_HIVIEW = 0, + /** System Module A */ + HILOG_MODULE_A, + /** Maximum number of modules */ + HILOG_MODULE_MAX + } HiLogModuleType; + ``` + +2. 注册模块 + + 在模块的初始化流程中添加如下代码,注册模块到日志框架中: + + ``` + HiLogRegisterModule(HILOG_MODULE_A, "A"); + ``` + +3. 调整DFX框架静态配置 + + 根据需要调整如下文件的g\_hiviewConfig全局参数配置。默认情况下不用修改,日志默认输出到串口。 + + ``` + utils/lite/hiview_config.c + ``` + + + + + + + + + + + + + + + + + + + + + + +

配置项

+

取值及含义

+

outputOption

+

日志的输出方式。取值如下:

+
  • OUTPUT_OPTION_DEBUG日志不进行跨任务调度直接输出到串口,仅适合临时调测使用。
  • OUTPUT_OPTION_FLOW日志流式输出到串口(默认设置)。
  • OUTPUT_OPTION_TEXT_FILE 日志输出为文本文件。
+

level

+

日志的输出级别,仅输出大于等于该级别的日志。取值如下:

+
  • HILOG_LV_DEBUG(默认设置)
  • HILOG_LV_INFO
  • HILOG_LV_WARN
  • HILOG_LV_ERROR
  • HILOG_LV_FATAL
+

logSwitch

+

流水日志功能开关。编译前关闭不影响log组件初始化,默认打开。取值如下:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+

dumpSwitch

+

dump功能开关。编译前关闭则不再初始化DUMP组件,默认关闭。取值如下:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+

eventSwitch

+

事件功能开关。编译前关闭则不再初始化Event组件,默认关闭。取值如下:

+
  • HIVIEW_FEATURE_ON
  • HIVIEW_FEATURE_OFF
+
+ +4. 在模块的Build.gn文件中添加头文件依赖 + + ``` + include_dirs = [ + "//base/hiviewdfx/interfaces/kits/hilog_lite", + ] + ``` + +5. 日志打印 + + 在需要打印日志的.c文件中增加头文件依赖\#include "log.h",并调用如下接口: + + ``` + HILOG_DEBUG(HILOG_MODULE_A, "log test: %d", 88); + ``` + + +## 使用mini框架实例 + +以下引用samgr\_lite模块使用mini框架作为实例。 + +1. 添加模块ID,在base/hiviewdfx/interfaces/kits/hilog\_lite/hiview\_log.h的类型定义结构体中添加HILOG\_MODULE\_SAMGR定义。 + + ``` + typedef enum { + ... + HILOG_MODULE_SAMGR, + ... + } HiLogModuleType; + ``` + +2. 注册模块,在base/hiviewdfx/frameworks/hilog\_lite/mini/hiview\_log.c的HiLogInit函数中添加注册代码。 + + ``` + HiLogRegisterModule(HILOG_MODULE_SAMGR, "SAMGR"); + ``` + +3. 在GN文件中添加头文件依赖,文件路径为:foundation/distributedschedule/services/samgr\_lite/samgr/source/BUILD.gn + + ``` + include_dirs = [ + "//base/hiviewdfx/interfaces/kits/hilog_lite", + ] + ``` + +4. 源文件foundation/distributedschedule/services/samgr\_lite/samgr/source/message.c中引用头文件并调用接口。 + + ``` + #include + uint32 *SAMGR_SendSharedRequest(const Identity *identity, const Request *request, uint32 *token, Handler handler) + { + ... + if (err != EC_SUCCESS) { + HILOG_ERROR(HILOG_MODULE_SAMGR, "SharedSend [%p] failed(%d)!", identity->queueId, err); + (void)FreeReference(&exchange); + } + ... + } + ``` + + diff --git "a/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200.md" "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200.md" new file mode 100644 index 0000000000000000000000000000000000000000..fce34cb73073a0a33ecd3a79ce8c420c05f2c595 --- /dev/null +++ "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200.md" @@ -0,0 +1,9 @@ +# 公共基础 + +- **[公共基础库概述](公共基础库概述.md)** + +- **[公共基础库开发指导](公共基础库开发指导.md)** + +- **[公共基础库常见问题](公共基础库常见问题.md)** + + diff --git "a/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..c991e43c15fe5dd550c7d42c9707d738c4b44673 --- /dev/null +++ "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,22 @@ +# 公共基础库常见问题 + +- [1.LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败](#section2041345718513) + +## 1.LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败 + +**现象描述** + +LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各参数正常的情况下,编译可执行程序运行失败。 + +**可能原因** + +直接运行编译出的可执行文件,没有将程序基于AbilityKit转换成应用,不能由BMS在应用安装时正确设置应用数据存储路径,导致KV存储运行失败。 + +**解决办法** + +显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 + +``` +UtilsSetEnv("/storage/com.huawei.kv"); +``` + diff --git "a/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\274\200\345\217\221\346\214\207\345\257\274.md" "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\274\200\345\217\221\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..516887de7a57bc2d31377208ffcec8d995c982b5 --- /dev/null +++ "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\345\274\200\345\217\221\346\214\207\345\257\274.md" @@ -0,0 +1,258 @@ +# 公共基础库开发指导 + +- [接口说明](#section1633115419401) +- [开发步骤](#section4207112818418) + +## 接口说明 + +**表 1** 文件操作接口说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

接口名

+

描述

+

int UtilsFileOpen(const char* path, int oflag, int mode)

+

打开或创建文件

+

int UtilsFileClose(int fd)

+

关闭文件

+

int UtilsFileRead(int fd, char *buf, unsigned int len)

+

读取特定长度的文件数据

+

int UtilsFileWrite(int fd, const char *buf, unsigned int len)

+

向文件写入特定大小的数据

+

int UtilsFileDelete(const char *path)

+

删除指定文件

+

int UtilsFileStat(const char *path, unsigned int *fileSize)

+

获取文件大小

+

int UtilsFileSeek(int fd, int offset, unsigned int whence)

+

重新定位文件读/写偏移量

+

int UtilsFileCopy(const char* src, const char* dest)

+

将源文件复制一份并存储到目标文件

+

int UtilsFileMove(const char* src, const char* dest)

+

将源文件移动到指定目标文件

+
+ +文件操作使用示例: + +``` +// open && write +char fileName[] = "testfile"; +static const char def[] = "utils_file_operation implement."; +int fd = UtilsFileOpen(fileName, O_RDWR_FS | O_CREAT_FS | O_TRUNC_FS, 0); +printf("file handle = %d\n", fd); +int ret = UtilsFileWrite(fd, def, strlen(def)); +printf("write ret = %d\n", ret); + +// seek +ret = UtilsFileSeek(fd, 5, SEEK_SET_FS); +printf("lseek ret = %d\n", ret); + +// read && close +char buf[64] = {0}; +int readLen = UtilsFileRead(fd, buf, 64); +ret = UtilsFileClose(fd); +printf("read len = %d : buf = %s\n", readLen, buf); + +// stat +int fileLen = 0; +ret = UtilsFileStat(fileName, &fileLen); +printf("file size = %d\n", fileLen); + +// delete +ret = UtilsFileDelete(fileName); +printf("delete ret = %d\n", ret); +``` + +**表 2** KV存储接口说明 + + + + + + + + + + + + + + + + +

接口名

+

描述

+

int UtilsGetValue(const char* key, char* value, unsigned int len)

+

提供给上层应用根据key获取对应数据项

+

int UtilsSetValue(const char* key, const char* value)

+

提供给上层应用用于存储/更新key对应数据项

+

int UtilsDeleteValue(const char* key)

+

提供给上层应用删除key对应数据项

+
+ +KV存储使用示例: + +``` +// set +char key[] = "rw.sys.version_100"; +char value[] = "Hello kv operation implement!"; +int ret = UtilsSetValue(key, value); +printf("UtilsSetValue set ret = %d\n", ret); + +// get +char temp[128] = {0}; +ret = UtilsGetValue(key, temp, 128); +printf("UtilsGetValue get ret = %d, temp = %s\n", ret, temp); + +// delete +ret = UtilsDeleteValue(key); +printf("UtilsDeleteValue delete ret = %d\n", ret); +``` + +## 开发步骤 + + + + +
+ +LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储的native应用开发步骤: + +1. 基于AbilityKit开发KV存储的native应用。 + - 基于KV存储提供的接口编写用户程序,并编译出so(libLauncher.so)文件。 + + ``` + // set + char key[] = "rw.sys.version_100"; + char value[] = "Hello kv operation implement!"; + int ret = UtilsSetValue(key, value); + printf("UtilsSetValue set ret = %d\n", ret); + + // get + char temp[128] = {0}; + ret = UtilsGetValue(key, temp, 128); + printf("UtilsGetValue get ret = %d, temp = %s\n", ret, temp); + + // delete + ret = UtilsDeleteValue(key); + printf("UtilsDeleteValue delete ret = %d\n", ret); + ``` + + - 编写config.json文件,内容如下: + + ``` + { + "app": { + "bundleName": "com.huawei.launcher", + "vendor": "huawei", + "version": { + "code": 1, + "name": "1.0" + } + }, + "deviceConfig": { + "default": { + "reqSdk": { + "compatible": "zsdk 1.0.0", + "target": "zsdk 1.0.1" + }, + "keepAlive": false + }, + "smartCamera": { + "reqSdk": { + "compatible": "zsdk 1.0.0", + "target": "zsdk 1.0.1" + }, + "keepAlive": false + } + }, + "module": { + "package": "com.huawei.launcher", + "name": ".MyHarmonyAbilityPackage", + "deviceType": [ + "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "Launcher", + "moduleType": "entry" + }, + "abilities": [{ + "name": "MainAbility", + "icon": "res/drawable/phone.png", + "label": "test app 1", + "launchType": "standard", + "type": "page" + }, + { + "name": "SecondAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "page" + }, + { + "name": "ServiceAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "service" + } + ] + } + } + ``` + + + - 生成hap包。 + + - 按照如下目录结构存放文件,res/drawable下面放置资源文件: + + ![](figures/unnaming.png) + + - 将上述文件打包生成zip包,修改后缀为.hap,例如Launcher.hap + + +2. 连接单板,通过串口向单板发送安装KV存储native应用的命令。 + + ``` + ./nfs/dev_tools/bin/bm install -p /nfs/Launcher.hap + ``` + +3. 通过串口向单板发送运行KV存储native应用的命令。 + + ``` + ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ``` + + diff --git "a/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\346\246\202\350\277\260.md" "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..ca3297d6432cd6805ceb5d3e4cbbdfe533f96fc9 --- /dev/null +++ "b/subsystems/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223\346\246\202\350\277\260.md" @@ -0,0 +1,10 @@ +# 公共基础库概述 + +公共基础库存放OpenHarmony通用的基础组件。这些基础组件可被OpenHarmony各业务子系统及上层应用所使用。 + +公共基础库在不同平台上提供的能力: + +LiteOS-M内核\(Hi3861平台\):KV存储、文件操作、IoT外设控制。 + +LiteOS-A内核\(Hi3516、Hi3518平台\):KV存储、定时器、数据和文件存储的JS API。 + diff --git "a/subsystems/\345\210\206\345\270\203\345\274\217\350\277\234\347\250\213\345\220\257\345\212\250.md" "b/subsystems/\345\210\206\345\270\203\345\274\217\350\277\234\347\250\213\345\220\257\345\212\250.md" index 742cff8b7c25039aa8a17673bedeb5f561b119e3..9d456643d321650e42b869ab992d76f617c48022 100755 --- "a/subsystems/\345\210\206\345\270\203\345\274\217\350\277\234\347\250\213\345\220\257\345\212\250.md" +++ "b/subsystems/\345\210\206\345\270\203\345\274\217\350\277\234\347\250\213\345\220\257\345\212\250.md" @@ -1,22 +1,22 @@ -# 分布式远程启动 +# 分布式远程启动 -- [概述](#zh-cn_topic_0000001052698169_zh-cn_topic_0000001051071561_section186634310418) -- [基本概念](#zh-cn_topic_0000001052698169_zh-cn_topic_0000001051071561_section982651246) -- [接口说明](#zh-cn_topic_0000001052698169_zh-cn_topic_0000001051071561_section125479541744) -- [约束与限制](#zh-cn_topic_0000001052698169_zh-cn_topic_0000001051071561_section1165911177314) -- [开发步骤](#zh-cn_topic_0000001052698169_zh-cn_topic_0000001051071561_section34171333656) +- [概述](#section186634310418) +- [基本概念](#section982651246) +- [接口说明](#section125479541744) +- [约束与限制](#section1165911177314) +- [开发步骤](#section34171333656) -## 概述 +## 概述 -分布式任务调度模块,通过主从设备服务代理机制,在HarmonyOS操作系统上建立起分布式服务平台,支持主设备\(搭载HarmonyOS的智慧屏设备\)启动从设备\(IP Camera、运动手表等小内存HarmonyOS设备\)FA的能力。 +分布式任务调度模块,通过主从设备服务代理机制,在OpenHarmony操作系统上建立起分布式服务平台,支持主设备\(搭载OpenHarmony的智慧屏设备\)启动从设备\(IP Camera、运动手表等小内存OpenHarmony设备\)FA的能力。 以智慧屏节目开播提醒为例,智慧屏上在喜欢的节目菜单中,点击“开播后提醒我”按钮,等节目开播后,智慧屏会拉起运动手表上的节目开播提醒FA。通过该FA用户可以快速知道喜欢的节目已经开始,达到协同互助的作用。 -## 基本概念 +## 基本概念 - FA - Feature Ability代表有界面的元能力,用于与用户进行交互。 + Feature Ability代表有界面的Ability,用于与用户进行交互。 - 远程启动 @@ -24,22 +24,22 @@ 即跨设备启动FA,与本地启动FA相对应。 -## 接口说明 +## 接口说明 -智慧屏端分布式开放能力如下表,包含在AbilitySlice类中,具体的API接口详见HarmonyOS应用接入接口文档: +智慧屏端分布式开放能力如下表,包含在AbilitySlice类中,具体的API接口详见OpenHarmony应用接入接口文档: **表 1** 分布式远程启动FA的API接口功能介绍 - -

接口名

+ + - - - @@ -47,32 +47,32 @@ **表 2** 参数Want功能介绍 - -

接口名

描述

+

描述

void startAbility(Want want)

+

void startAbility(Want want)

远程启动FA,Want参数命名以实际开发平台API为准。

+

远程启动FA,Want参数命名以实际开发平台API为准。

参数名

+ + - - - - -

参数名

类型

+

类型

说明

+

说明

want

+

want

ohos.aafwk.content.Want

+

ohos.aafwk.content.Want

当开发者需要调用该接口启动远程FA时,需要显式指定待启动FA的设备id、bundleName和abilityName。

+

当开发者需要调用该接口启动远程FA时,需要显式指定待启动FA的设备id、bundleName和abilityName。

-## 约束与限制 +## 约束与限制 - 支持主设备侧远程启动从设备侧FA,不支持从设备远程启动主设备FA。 -- 远程启动前必须确保HarmonyOS设备间分布式组网成功(需要在同一网段内,可互相ping通),否则无法远程启动。 +- 远程启动前必须确保OpenHarmony设备间分布式组网成功(需要在同一网段内,可互相ping通),否则无法远程启动。 - 当前只支持拥有共同公钥信息的主从设备间FA(即主从设备的FA使用相同华为证书)的拉起。 -## 开发步骤 +## 开发步骤 智慧屏侧通过如下操作启动从设备侧FA,从设备侧FA默认已开发。 @@ -93,7 +93,7 @@ } ``` -3. 构造want,首先使用ElementName类表明需要启动的远端设备ID,包名,元能力类名,传入want中,然后设置want中的分布式标志位Want.FLAG\_ABILITYSLICE\_MULTI\_DEVICE表示需要远程启动。 +3. 构造want,首先使用ElementName类表明需要启动的远端设备ID,包名,Ability类名,传入want中,然后设置want中的分布式标志位Want.FLAG\_ABILITYSLICE\_MULTI\_DEVICE表示需要远程启动。 ``` // 引入相关头文件 diff --git "a/subsystems/\345\217\202\350\200\203.md" "b/subsystems/\345\217\202\350\200\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..07ad8e70645d093d5e3b6d6503b0cbd5583127f4 --- /dev/null +++ "b/subsystems/\345\217\202\350\200\203.md" @@ -0,0 +1,93 @@ +# 参考 + +- [包结构说明](#section5487173174316) + +## 包结构说明 + +**表 1** 轻量级DFX子系统源代码目录结构 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

描述

+

hiviewdfx/interface

+

存放所有对外接口定义头文件

+

hiviewdfx/interfaces/kits/hilog

+

featured框架流水日志对外接口定义

+

hiviewdfx/interfaces/kits/hilog_lite

+

mini框架流水日志对外接口定义

+

hiviewdfx/interfaces/innerkits/hievent_lite

+

mini框架事件打点对外接口定义

+

hiviewdfx/services/hilogcat_lite

+

流水日志相关服务和命令

+

hiviewdfx/services/hilogcat_lite/apphilogcat

+

featured框架流水日志落盘服务

+

hiviewdfx/services/hilogcat_lite/command

+

mini框架DFX命令

+

hiviewdfx/services/hilogcat_lite/hilogcat

+

featured框架流水日志输出命令

+

hiviewdfx/services/hiview_lite

+

DFX mini框架服务化注册

+

hiviewdfx/frameworks/ddrdump_lite

+

mini框架ddrdump信息转储

+

hiviewdfx/frameworks/hievent_lite

+

mini框架事件打点记录实现

+

hiviewdfx/frameworks/hilog_lite

+

流水日志接口实现

+

hiviewdfx/frameworks/hilog_lite/featured

+

featured框架流水日志接口实现

+

hiviewdfx/frameworks/hilog_lite/mini

+

mini框架流水日志接口实现

+

hiviewdfx/utils/lite

+

公共基础操作定义实现。包含了mini框架的config配置

+
+ diff --git "a/subsystems/\345\252\222\344\275\223.md" "b/subsystems/\345\252\222\344\275\223.md" new file mode 100644 index 0000000000000000000000000000000000000000..2e29522bf23fdf433408796f8a2e9162c68c7837 --- /dev/null +++ "b/subsystems/\345\252\222\344\275\223.md" @@ -0,0 +1,17 @@ +# 媒体 + +- **[相机开发概述](相机开发概述.md)** + +- **[拍照开发指导](拍照开发指导.md)** + +- **[录像开发指导](录像开发指导.md)** + +- **[预览开发指导](预览开发指导.md)** + +- **[音视频开发概述](音视频开发概述.md)** + +- **[音视频播放开发指导](音视频播放开发指导.md)** + +- **[音视频录制开发指导](音视频录制开发指导.md)** + + diff --git "a/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230-0.md" "b/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230-0.md" new file mode 100644 index 0000000000000000000000000000000000000000..37405d3f479c810ba20f9174223922cfdf3b4e43 --- /dev/null +++ "b/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230-0.md" @@ -0,0 +1,4 @@ +# 常见问题 + +无 + diff --git "a/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..0530d1ef8bfa36c263f73d009ea34c55f86ba62d --- /dev/null +++ "b/subsystems/\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,2 @@ +# 常见问题 + diff --git "a/subsystems/\345\274\200\345\217\221\345\256\236\344\276\213.md" "b/subsystems/\345\274\200\345\217\221\345\256\236\344\276\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..4785d1a776f8134db9450682b510e9471d211133 --- /dev/null +++ "b/subsystems/\345\274\200\345\217\221\345\256\236\344\276\213.md" @@ -0,0 +1,4 @@ +# 开发实例 + +开发实例可参考[开源项目中的示例](https://gitee.com/openharmony/aafwk_frameworks_kits_ability_lite/tree/master/example) + diff --git "a/subsystems/\345\274\200\345\217\221\346\214\207\345\257\274.md" "b/subsystems/\345\274\200\345\217\221\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..6a68dfe23f9f81c975fab1807c63bc9fbe6a15f4 --- /dev/null +++ "b/subsystems/\345\274\200\345\217\221\346\214\207\345\257\274.md" @@ -0,0 +1,711 @@ +# 开发指导 + +- [场景介绍](#section93012287133) +- [接口说明](#section11821047161319) +- [开发步骤](#section10514141679) + - [创建Service类型的Ability](#section19921154214315) + - [包管理接口使用指导](#section1724016743217) + - [Hap包打包](#section171771212328) + + +## 场景介绍 + +- 带界面的Ability的应用,比如:新闻类的应用、视频类的应用、导航类的应用、支付类的应用等等,目前我们看到的大部分应用都是带有界面的用于人机交互的应用。 + +- 不带界面的Ability应用,比如:音乐播放器能在后台播放音乐、后台提供计算服务、导航服务的各类应用等。 + +- 不管是带界面的Ability应用还是不带界面的Ability应用,都要打包成Hap包,最终发布到应用市场,用户通过应用市场下载安装相应的应用。 + +## 接口说明 + +**表 1** Ability子系统的对外接口 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

接口名称

+

接口描述

+

Want *WantParseUri(const char *uri)

+

反序列化接口,由字符串生成Want对象。

+

const char *WantToUri(Want want)

+

序列化,把Want对象生成字符串。

+

void SetWantElement(Want *want, ElementName element);

+

设置ElementName对象。

+

void SetWantData(Want *want, const void *data, uint16_t dataLength)

+

设置数据。

+

bool SetWantSvcIdentity(Want *want, SvcIdentity sid)

+

设置SvcIdentity。

+

void ClearWant(Want *want)

+

清除Want的内部内存数据。

+

void SetMainRoute(const std::string &entry)

+

设置AbilitySlice主路由。

+

void SetUIContent(RootView *rootView)

+

设置布局资源。

+

void OnStart(const Want& intent)

+

Ability生命周期状态回调,Ability启动时被回调。

+

void OnStop()

+

Ability生命周期状态回调,Ability销毁时被回调。

+

void OnActive(const Want& intent)

+

Ability生命周期状态回调,Ability显示时被回调。

+

void OnInactive()

+

Ability生命周期状态回调,Ability隐藏时被回调。

+

void OnBackground()

+

Ability生命周期状态回调,Ability退到后台时被回调。

+

const SvcIdentity *OnConnect(const Want &want)

+

Service类型Ability第一次连接时被回调。

+

void OnDisconnect(const Want &want);

+

Service类型Ability断开连接被回调。

+

void MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply);

+

Service类型Ability接收消息处理。

+

void Dump(const std::string &extra)

+

dump Ability信息。

+

void Present(AbilitySlice *abilitySlice, const Want &want)

+

发起AbilitySlice跳转。

+

void Terminate()

+

退出当前AbilitySlice。

+

void SetUIContent(RootView *rootView)

+

设置当前AbilitySlice所在Ability的布局资源。

+

void OnStart(const Want& want)

+

AbilitySlice生命周期状态回调,AbilitySlice启动时被回调。

+

void OnStop()

+

AbilitySlice生命周期状态回调,AbilitySlice销毁时被回调。

+

void OnActive(const Want& want)

+

AbilitySlice生命周期状态回调,AbilitySlice显示时被回调。

+

void OnInactive()

+

AbilitySlice生命周期状态回调,AbilitySlice隐藏时被回调。

+

void OnBackground()

+

AbilitySlice生命周期状态回调,AbilitySlice退到后台时被回调。

+

int StartAbility(const Want &want)

+

启动Ability。

+

int StopAbility(const Want &want)

+

停止Service类型的Ability。

+

int TerminateAbility()

+

销毁当前的Ability。

+

int ConnectAbility(const Want &want, const IAbilityConnection &conn, void *data);

+

绑定Service类型的Ability。

+

int DisconnectAbility(const IAbilityConnection &conn)

+

解绑Service类型的Ability。

+

const char *GetBundleName()

+

获取当前ability的对应应用的包名。

+

const char *GetSrcPath()

+

获取当前ability的对应应用的安装路径。

+

const char *GetDataPath()

+

获取当前ability的对应应用的数据路径。

+

int StartAbility(const Want *want)

+

启动Ability,该接口可以不需要在基于Ability开发的应用中使用。

+

int ConnectAbility(const Want *want, const IAbilityConnection *conn, void *data);

+

绑定Service类型的Ability,该接口可以不需要在基于Ability开发的应用中使用。

+

int DisconnectAbility(const IAbilityConnection *conn);

+

解绑Service类型的Ability,该接口可以不需要在基于Ability开发的应用中使用。

+

int StopAbility(const Want *want)

+

停止Service类型的Ability,该接口可以不需要在基于Ability开发的应用中使用。

+

void (*OnAbilityConnectDone)(ElementName *elementName, SvcIdentity *serviceSid, int resultCode, void *data)

+

绑定Service Ability的回调。

+

void (*OnAbilityDisconnectDone)(ElementName *elementName, int resultCode, void *data)

+

解绑Service Ability的回调。

+

void PostTask(const Task& task)

+

投递任务到异步线程进行处理。

+

void PostQuit()

+

退出当前线程的消息循环。

+

static AbilityEventHandler* GetCurrentHandler()

+

获取当前线程的事件处理器。

+

void Run()

+

执行当前线程的消息循环。

+

#define REGISTER_AA(className)

+

注册开发者的Ability到框架中。

+

#define REGISTER_AS(className)

+

注册开发者的AbilitySlice到框架中。

+
+ +## 开发步骤 + +### 创建Service类型的Ability + +1. 在my\_service\_ability.h中创建Ability的子类MyServiceAbility。 + + ``` + class MyServiceAbility: public Ability { + protected: + void OnStart(const Want& want); + const SvcIdentity *OnConnect(const Want &want) override; + void MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) override; + }; + ``` + +2. 调用REGISTER\_AA宏将ServiceAbility注册到应用框架中,以便应用框架实例化开发者的MyServiceAbility。 + + ``` + #include "my_service_ability.h" + + REGISTER_AA(ServiceAbility) + + void MyServiceAbility::OnStart(const Want& want) + { + printf("ServiceAbility::OnStart\n"); + Ability::OnStart(want); + } + + const SvcIdentity *MyServiceAbility::OnConnect(const Want &want) + { + printf("ServiceAbility::OnConnect\n"); + return Ability::OnConnect(want); + } + + void MyServiceAbility::MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) + { + printf("ServiceAbility::MsgHandle, funcId is %u\n", funcId); + int result = 0; + if (funcId == 0) { + result = IpcIoPopInt32(request) + IpcIoPopInt32(request); + } + // push data + IpcIoPushInt32(reply, result); + } + ``` + +3. 实现Service相关的生命周期方法。Service也是一种Ability,Ability为服务提供了以下生命周期方法,用户可以重写这些方法来添加自己的处理。用户在重写的方法里,需要调用父类对应的方法。 + - OnStart\(\) + + 该方法在创建Service的时候调用,用于做一些Service初始化且耗时较短的工作,在Service的整个生命周期只会调用一次。 + + ``` + void MyServiceAbility::OnStart(const Want& want) + { + printf("ServiceAbility::OnStart\n"); + Ability::OnStart(want); + } + ``` + + - OnConnect​\(\) + + 在组件和服务连接时调用,该方法返回SvcIdentity,组件可以通过它,与服务交互。 + + ``` + const SvcIdentity *MyServiceAbility::OnConnect(const Want &want) + { + printf("ServiceAbility::OnConnect\n"); + return Ability::OnConnect(want); + } + ``` + + - OnDisconnect​\(\) + + 在组件与绑定的Service断开连接时调用。 + + - OnStop\(\) + + 在Service销毁时调用。Service应通过实现此方法来清理任何资源,如关闭线程、注册的侦听器等。 + + +4. 重写消息处理方法。 + + MsgHandle是Service用来处理客户端消息的方法。其中funcId是客户端传过来的消息类型,request是客户端传过来的序列化请求参数。如果用户在处理完成之后想要把结果传回去,需要把结果序列化后写入reply中。 + + ``` + void ServiceAbility::MsgHandle(uint32_t funcId, IpcIo *request, IpcIo *reply) + { + printf("ServiceAbility::MsgHandle, funcId is %d\n", funcId); + int result = 0; + if (funcId == PLUS) { + result = IpcIoPopInt32(request) + IpcIoPopInt32(request); + } + // push data + IpcIoPushInt32(reply, result); + } + ``` + +5. 注册Service。 + + Service也需要在应用清单文件config.json中进行注册,注册类型type需要设置为service。 + + ``` + "abilities": [{ + "name": "ServiceAbility", + "icon": "res/drawable/phone.png", + "label": "test app 2", + "launchType": "standard", + "type": "service", + "visible": true + } + ] + ``` + +6. 启动Service。 + - Ability为用户提供了StartAbility\(\)方法来启动另外一个Ability,因为Service也是Ability的一种,开发者同样可以通过将Want传递给该方法来启动Service。 + + 开发者可以通过Want的SetWantElement \(\)来设置目标服务信息。ElementName结构体的两个主要参数:第一个参数为包名称;第二个参数为目标Ability。 + + ``` + { + Want want = { nullptr }; + ElementName element = { nullptr }; + SetElementBundleName(&element, "com.company.appname"); + SetElementAbilityName(&element, "ServiceAbility"); + SetWantElement(&want, element); + StartAbility(want); + ClearElement(&element); + ClearWant(&want); + } + ``` + + StartAbility\(\) 方法会立即执行,如果Service尚未运行,则系统首先会调用OnStart\(\)。 + + - 停止Service。 + + Service一旦创建就会一直保持在后台运行,开发者可以通过调用StopAbility\(\)来停止Service。 + + +7. 连接Service。 + - 如果Service需要与Page Ability或其他应用组件中的Service进行交互,则应创建用于连接的Service。Service支持其他Ability通过ConnectAbility\(\)与其进行连接,ConnectAbility\(\)需要传入目标Service的Want,以及IAbilityConnection的实例来处理回调。IAbilityConnection提供了两个方法供用户实现,OnAbilityConnectDone\(\)用来处理连接的回调,OnAbilityDisconnectDone\(\)用来处理断开连接的回调。 + + ``` + { + // ability创建IAbilityConnection对象和定义IAbilityConnection的两个方法实现 + IAbilityConnection abilityConnection = new IAbilityConnection(); + abilityConnection->OnAbilityConnectDone = OnAbilityConnectDone; + abilityConnection->OnAbilityDisconnectDone = OnAbilityDisconnectDone; + + void OnAbilityConnectDone(ElementName *elementName, SvcIdentity *serviceSid, + int resultCode, void *data) + { + if (resultCode != 0) { + return; + } + // push data + IpcIo request; + char dataBuffer[IPC_IO_DATA_MAX]; + IpcIoInit(&request, dataBuffer, IPC_IO_DATA_MAX, 0); + IpcIoPushInt32(&request, 10); + IpcIoPushInt32(&request, 6); + + // send and getReply + IpcIo reply; + uintptr_t ptr = 0; + if (Transact(nullptr, *serviceSid, 0, &request, &reply, + LITEIPC_FLAG_DEFAULT, &ptr) != LITEIPC_OK) { + printf("transact error\n"); + return; + } + int result = IpcIoPopInt32(&reply); + printf("execute add method, result is %d\n", result); + if (ptr != 0) { + FreeBuffer(nullptr, reinterpret_cast(ptr)); + } + } + + void OnAbilityDisconnectDone(ElementName *elementName, + int resultCode, void *data) + { + printf("elementName is %s, %s\n", + elementName->bundleName, elementName->abilityName); + } + } + ``` + + - 发起connect和disconnect。 + + ``` + { + // ability发起connect + Want want = { nullptr }; + ElementName element = { nullptr }; + SetElementBundleName(&element, "com.company.appname"); + SetElementAbilityName(&element, "ServiceAbility"); + SetWantElement(&want, element); + ConnectAbility(want, *abilityConnection, this); + + // ability发起disconnect + DisconnectAbility(*abilityConnection); + } + ``` + + + +### 包管理接口使用指导 + +**安装应用** + +安装接口只能给内置的系统应用使用。根据应用的安装路径,可以在安装应用时进行选择: + +- 将应用安装到系统默认的文件目录/storage/app/。 +- 将应用安装到系统外挂的存储介质中,例如micro sdcard。 + +这两种选择可以在创建InstallParam实例的时候指定,当InstallParam的成员变量installLocation为 INSTALL\_LOCATION\_INTERNAL\_ONLY时,意味着应用将会被安装到/storage/app/目录下;当InstallParam的成员变量installLocation为INSTALL\_LOCATION\_PREFER\_EXTERNAL时,意味着应用将被安装到存储介质,其安装目录是/sdcard/app/。由于安装应用的过程是异步的,所以需要使用类似信号量的机制来确保安装的回调可以被执行。 + +安装应用的步骤如下(示例代码以安装到系统目录为例): + +1. 将经过安全签名的应用放置于指定的目录下。 +2. 创建InstallParam实例和信号量。 + + ``` + InstallParam installParam = { + .installLocation = INSTALL_LOCATION_INTERNAL_ONLY, // 安装到系统目录 + .keepData = false + }; + static sem_t g_sem; + ``` + +3. 定义回调函数。 + + ``` + static void InstallCallback(const uint8_t resultCode, const void *resultMessage) + { + std::string strMessage = reinterpret_cast(resultMessage); + if (!strMessage.empty()) { + printf("install resultMessage is %s, %d\n", strMessage.c_str(),resultCode); + } + sem_post(&g_sem); + } + ``` + +4. 调用Install接口。 + + ``` + const uint32_t WAIT_TIMEOUT = 30; + sem_init(&g_sem, 0, 0); + std::string installPath = “/storage/bundle/demo.hap”; // hap包的存储路径 + bool result = Install(installPath.c_str(), &installParam, InstallCallback); + struct timespec ts = {}; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += WAIT_TIMEOUT; // 超时即释放信号量 + sem_timedwait(&g_sem, &ts); + ``` + + +**卸载应用** + +卸载应用的时候可以选择是否保留应用的数据,开发者可以通过创建的InstallParam实例的成员变量keepData来确定。当keepData为true, 卸载应用之后将保留应用的数据,当keepData为false时,卸载应用之后将不会保留应用的数据。 + +1. 创建InstallParam实例和信号量。 + + ``` + static sem_t g_sem; + InstallParam installParam = { + .installLocation = 1, + .keepData = false // 不保留应用数据 + }; + ``` + +2. 定义回调函数。 + + ``` + static void UninstallCallback(const uint8_t resultCode, const void *resultMessage) + { + std::string strMessage = reinterpret_cast(resultMessage); + if (!strMessage.empty()) { + printf("uninstall resultMessage is %s\n", strMessage.c_str()); + g_resultMessage = strMessage; + } + g_resultCode = resultCode; + sem_post(&g_sem); + } + ``` + +3. 调用Uninstall接口。 + + ``` + sem_init(&g_sem, 0, 0); + const uint32_t WAIT_TIMEOUT = 30; + std::string BUNDLE_NAME = “com.huawei.demo”; // 卸载应用的包名 + Uninstall(BUNDLE_NAME.c_str(), &installParam, UninstallCallback); + struct timespec ts = {}; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += WAIT_TIMEOUT; + sem_timedwait(&g_sem, &ts); + ``` + + +**查询已安装应用的包信息** + +开发者可以利用BundleManager提供的接口GetBundleInfo来查询系统内已安装应用的包信息。 + +1. 创建以及初始化BundleInfo。 + + ``` + BundleInfo bundleInfo; + (void) memset_s(&bundleInfo, sizeof(BundleInfo), 0, sizeof(BundleInfo)); + ``` + +2. 调用GetBundleInfo接口,指定查询应用的包名,同时指定flag来确定获取的BundleInfo中是否含有元能力信息(实例代码以含有元能力信息为例)。 + + ``` + std::string BUNDLE_NAME = "com.huawei.demo"; + uint8_t ret = GetBundleInfo(BUNDLE_NAME.c_str(), 1, &bundleInfo); // flags = 1,获取包信息中含有元能力信息 + ``` + +3. 使用完获取的BundleInfo之后,要及时清理掉其内部所占用的内存空间避免内存泄漏。 + + ``` + ClearBundleInfo(&bundleInfo); + ``` + + +### Hap包打包 + +打包工具一般集成到开发工具或者ide中,开发者一般不涉及直接使用该工具,下面的介绍开发者可以作为了解。打包工具的jar包在开源代码中的位置:developtools/packing\_tool/jar。 + +- 打包命令行参数 + + **表 2** 打包所需要的资源文件描述 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

命令参数

+

对应的资源文件

+

说明

+

是否可缺省

+

--mode

+

-

+

为“hap”字段,打包生成hap

+

+

--json-path

+

清单文件config.json

+

-

+

+

--resources-path

+

资源文件resources

+

-

+

+

--assets-path

+

资源文件assets

+

-

+

+

--lib-path

+

依赖库文件

+

-

+

+

--shared-libs-path

+

共享库文件

+

针对系统应用的共享库,特殊情况下使用

+

+

--ability-so-path

+

主功能so文件

+

-

+

+

--index-path

+

资源索引

+

资源索引文件由资源生成工具生成,由资源流水线会集成该工具

+

+

--out-path

+

-

+

生成的hap包输出路径,默认为当前目录

+

+

--force

+

-

+

是否覆盖原有同名文件,默认为false

+

+
+ +- 打包示例 + - 开发视图 + + ![](figures/zh-cn_image_0000001062942690.png) + + - 编译视图 + + ![](figures/zh-cn_image_0000001062334618.png) + + - 使用打包工具执行以下命令打包: + + ![](figures/zh-cn_image_0000001062476933.png) + + ``` + $ java -jar hmos_app_packing_tool.jar --mode hap --json-path ./config.json --assets-path ./assets/ --ability-so-path ./libentry.so --index-path ./resources.index --out-path out/entry.hap --force true + ``` + + + diff --git "a/subsystems/\346\220\255\345\273\272\347\216\257\345\242\203.md" "b/subsystems/\346\220\255\345\273\272\347\216\257\345\242\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..5b318e33d389a677fe25badcfc3904e853297d60 --- /dev/null +++ "b/subsystems/\346\220\255\345\273\272\347\216\257\345\242\203.md" @@ -0,0 +1,7 @@ +# 搭建环境 + +- 开发板:Hi3516DV300 + +- [下载源码](https://device.harmonyos.com/cn/docs/start/get-code/oem_sourcecode_guide-0000001050769927) +- [编译用户程序框架](https://gitee.com/openharmony/docs/blob/master/readme/用户程序框架子系统README.md) + diff --git "a/subsystems/\346\246\202\350\277\260.md" "b/subsystems/\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..9dc5255c09efb9903a91898971919c4c17688bd6 --- /dev/null +++ "b/subsystems/\346\246\202\350\277\260.md" @@ -0,0 +1,141 @@ +# 概述 + +- [基本概念](#section72601941194812) +- [Ability子系统](#section14633111813374) +- [包管理子系统](#section1341146154412) +- [运作机制](#section94302021112717) +- [约束与限制](#section89534912527) + +用户程序框架是OpenHarmony为开发者提供开发OpenHarmony应用的开发框架,包含两个模块:Ability子系统和包管理子系统。 + +## 基本概念 + +开发者在开发前需要先了解以下基本概念,方便开发者更好的理解OpenHarmony用户程序框架。 + +## Ability子系统 + +Ability子系统是管理OpenHarmony应用运行状态的开发框架。 + +**图 1** Ability子系统框架图 +![](figures/Ability子系统框架图.png "Ability子系统框架图") + +- **Ability**:系统调度应用的最小单元,是能够完成一个独立功能的组件,一个应用可以包含一个或多个Ability。Ability分为两种类型:Page类型的Ability和Service类型的Ability。 + - **Page类型的Ability**:带有界面,为用户提供人机交互的能力。 + + - **Service类型的Ability**:不带界面,为用户提供后台任务机制。 + + + +- **AbilitySlice**:单个页面及其控制逻辑的总和,是Page类型Ability特有的组件,一个Page类型的Ability可以包含多个AbilitySlice,此时,这些页面提供的业务能力应当是高度相关的。 + + **图 2** Ability与AbilitySlice的关系图 + ![](figures/Ability与AbilitySlice的关系图.png "Ability与AbilitySlice的关系图") + +- **生命周期**:Ability被调度到启动、激活、隐藏和退出等各个状态的统称。 + + **图 3** Ability生命周期流转 + + + ![](figures/图片1.png) + + - **OnStart\(\)** + + 系统首次创建Page实例时触发该回调。对于一个Page实例,该回调在其生命周期过程中仅触发一次,Page在该逻辑后进入INACTIVE状态。开发者必须重写该方法,并在此配置默认展示的AbilitySlice。 + + - **OnActive\(\)** + + Page会在进入INACTIVE状态后来到前台,然后系统调用此回调。Page在此之后进入ACTIVE状态,该状态是应用与用户交互的状态。Page将保持在此状态,除非某类事件发生导致Page失去焦点,比如用户点击返回键或导航到其他Page。 + + 当此类事件发生时,会触发Page回到INACTIVE状态,系统将调用OnInactive\(\)回调。此后,Page可能重新回到ACTIVE状态,系统将再次调用OnActive\(\)回调。因此,开发者通常需要成对实现OnActive\(\)和OnInactive\(\),并在OnActive\(\)中获取在OnInactive\(\)中被释放的资源。 + + - **OnInactive\(\)** + + 当Page失去焦点时,系统将调用此回调,此后Page进入INACTIVE状态。开发者可以在此回调中实现Page失去焦点时应表现的恰当行为。 + + - **OnBackground\(\)** + + 如果Page不再对用户可见,系统将可能根据资源状况调用此回调,此后Page进入BACKGROUND状态。开发者应该在此回调中释放Page不可见时无用的资源,或在此回调中执行较为耗时的状态保存操作。 + + - **OnForeground\(\)** + + 处于BACKGROUND状态的Page仍然驻留在内存中,当重新回到前台时(比如用户重新导航到此Page),系统将先调用OnForeground\(\)回调使Page回到INACTIVE状态,然后调用OnActive\(\)回调使Page回到ACTIVE状态。开发者应当在此回调中重新申请在OnBackground\(\)中释放的资源。轻量化设备目前不支持该接口。 + + - **OnStop\(\)** + + 此回调表示系统正在销毁Page。销毁Page的可能原因包括: + + - 用户通过系统管理能力显式关闭Page,例如使用任务管理器关闭Page。 + - 用户行为触发Page的TerminateAbility\(\)方法调用,例如使用应用的退出功能。 + - 配置变更导致系统暂时销毁Page并重建。 + - 系统出于资源管理目的,自动触发对处于BACKGROUND状态Page的销毁。 + + +- **AbilityKit**:Ability框架提供给开发者的开发包,开发者基于该开发包可以开发出基于Ability组件的应用。基于Ability组件开发的应用有两种类型:基于Javascript语言开发的Ability(JS Ability)和基于C/C++语言开发的Ability(Native Ability)。JS应用开发框架是开发者开发JS Ability所用到框架,是在AbilityKit基础封装的包含js UI组件的一套方便开发者能够迅速开发Ability应用的框架。 +- **AbilityLoader**:负责注册和加载开发者Ability的模块。开发者开发的Ability先要调用AbilityLoader的注册接口注册到框架中,接着Ability启动时会被实例化。 + +- **AbilityManager:**负责AbilityKit和Ability管理服务进行IPC的通信。 + +- **EventHandler**:AbilityKit提供给开发者的用于在Ability中实现线程间通信的一个模块。 + +- **AbilityManagerService**:元能力运行管理服务。该服务用于协调各Ability运行关系、及生命周期进行调度的系统服务。其中,服务启动模块负责Ability管理服务的启动、注册等。服务接口管理模块负责Ability管理服务对外能力的管理。进程管理模块负责Ability应用所在进程的启动和销毁、及其进程信息维护等功能。Ability栈管理模块负责维护各个Ability之间跳转的先后关系。生命周期调度模块是Ability管理服务根据系统当前的操作调度Ability进入相应的状态的模块。连接管理模块是Ability管理服务对Service类型Ability连接管理的模块 + +- **AppSpawn**:负责创建Ability应用所在进程的系统服务,该服务有较高的权限,为Ability应用设置相应的权限,并预加载一些通用的模块,加速应用的启动。 + + +## 包管理子系统 + +包管理子系统是OpenHarmony为开发者提供的安装包管理框架。 + +**图 4** 包管理子系统框架图 +![](figures/包管理子系统框架图.png "包管理子系统框架图") + +- **BundleKit**:是包管理服务对外提供的接口,有安装/卸载接口、包信息查询接口、包状态变化监听接口。 +- **包扫描器**:用来解析本地预制或者安装的安装包,提取里面的各种信息,供管理子模块进行管理,持久化。 +- **包安装子模块**:安装,卸载,升级一个包;包安装服务是一个单独进程和包管理服务通过IPC进行通信,该服务用于创建、删除安装目录和数据目录等,具有较高的权限。 + +- **包管理子模块**:管理安装包相关的信息,存储持久化包信息。 + +- **包安全管理子模块**:签名检查、权限授予、权限管理。 + + +## 运作机制 + +Ability子系统的核心模块是Ability管理服务、包管理子系统的核心模块是包管理服务,这两个服务是系统级服务,借助系统服务框架Samgr实现服务的注册与发现,并对其他进程提供Ability管理服务和包管理服务。Ability管理服务和包管理服务通过AbilityKit和BundleKit以接口的形式向外提供服务。 + +**图 5** Ability管理服务和包管理服务启动 +![](figures/Ability管理服务和包管理服务启动.png "Ability管理服务和包管理服务启动") + +Ability管理服务和包管理服务启动后,就可以安装OpenHarmony应用和启动运行OpenHarmony应用。 + +**图 6** 应用启动流程 +![](figures/应用启动流程.png "应用启动流程") + +桌面为Ability管理服务启动的第一个OpenHarmony应用。桌面启动后,用户可以在桌面上点击安装的OpenHarmony应用并启动该应用。上图6为从桌面启动一个已安装应用的交互流程。 + +从图中可知,Ability管理服务负责协调Ability之间的显示隐藏,包管理服务负责Ability信息的存储查询。 + +## 约束与限制 + +- 语言版本 + + - C++11版本或以上 + + +- 框架针对不同的芯片平台和底层OS能力,规格有所区别 + + - Cortex-M RAM/ROM: + + - RAM:建议大于20K + + - ROM: \> 300K (包含JS应用开发框架,UIKit及引擎等强相关子系统) + + + - Cortex-A RAM/ROM: + + - RAM:建议大于2M + + - ROM:\> 2M (包含JS应用开发框架,UIKit及引擎等强相关子系统) + + + + diff --git "a/subsystems/\346\265\213\350\257\225.md" "b/subsystems/\346\265\213\350\257\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..0bc1efc0c636a04511ffe5e3f4d1eef7344ac9d6 --- /dev/null +++ "b/subsystems/\346\265\213\350\257\225.md" @@ -0,0 +1,489 @@ +# 测试 + +- [概述](#zh-cn_topic_0000001059860314_section12403172115920) + - [基本概念](#zh-cn_topic_0000001059860314_section53632272090) + - [运作机制](#zh-cn_topic_0000001059860314_section2394431106) + +- [约束与限制](#zh-cn_topic_0000001059860314_section2029921310472) + - [功能限制](#zh-cn_topic_0000001059860314_section172441620111610) + - [操作限制](#zh-cn_topic_0000001059860314_section201523661616) + +- [搭建环境](#zh-cn_topic_0000001059860314_section175012297491) + - [环境要求](#zh-cn_topic_0000001059860314_section935055691014) + - [安装环境](#zh-cn_topic_0000001059860314_section6511193210111) + - [检验环境是否搭建成功](#zh-cn_topic_0000001059860314_section1899144517117) + +- [开发指导](#zh-cn_topic_0000001059860314_section16741101301210) + - [场景介绍](#zh-cn_topic_0000001059860314_section93782214124) + - [接口说明](#zh-cn_topic_0000001059860314_section54131732101218) + - [开发步骤](#zh-cn_topic_0000001059860314_section53541946111218) + +- [开发实例](#zh-cn_topic_0000001059860314_section7477121918136) +- [包结构说明](#zh-cn_topic_0000001059860314_section1875515364133) + +## 概述 + +### 基本概念 + +测试子系统提供基于python开发的一键式的开发者自测试平台,支持三方测试框架拓展,主要包括测试用例编译、测试用例管理、测试用例调度分发、测试用例执行、测试结果收集、测试报告生成、测试用例模板、测试环境管理。 + +在测试子系统开发前,开发者应先了解以下概念: + +- 测试用例编译 + + 支持将测试用例源代码编译成可在被测设备侧执行的二进制文件。 + +- 测试用例调度分发 + + 支持将测试用例通过网口通道或者串口通道分发到不同的被测设备上,并且为每一个测试用例分配特定的测试用例执行器。 + +- 测试用例执行器 + + 集成不同语言的单元测试框架,如unity等,定义每一个测试用例的预处理,用例执行,结果记录等执行逻辑。 + +- 测试用例模板 + + 定义测试用例统一格式,以及测试用例编译配置GN文件的统一格式。 + +- 测试工具kit + + 测试工具运行过程中公共方法,如提供测试用例目录向被测设备挂载文件系统,测试用例推送到被测设备,或者从被测设备获取测试结果等操作。 + +- 测试报告生成 + + 定义开发者自测试报告模板,支持将测试用例的xml结果通过html方式展示。 + +- 测试环境管理 + + 支持通过USB、串口等方式管理被测设备,功能包括设备发现,设备状态查询等。 + + +### 运作机制 + +- 测试工具架构图如下: + +**图 1** 测试工具架构 +![](figures/测试工具架构.png "测试工具架构") + +- 测试工具运行时序图如下: + +**图 2** 测试工具运行时序 +![](figures/测试工具运行时序.png "测试工具运行时序") + +- 测试工具运行原理 + +测试工具通过shell脚本启动,以命令行方式支持一系列的测试指令执行,通过命令行输出测试结果。 + +## 约束与限制 + +### 功能限制 + +- 功能使用范围 + + 开发自测试工具仅支持代码级的测试用例开发和验证,如单元测试,模块测试。 + +- 规格限制 + + 当前测试框架的适用范围仅支持白盒测试。 + + +### 操作限制 + +一台测试设备上仅支持启动单个测试平台。 + +## 搭建环境 + +### 环境要求 + +**表 1** **环境要求** + + + + + + + + + + + + + + + + +

项目

+

测试设备

+

被测设备

+

硬件

+
  • 内存:8G及以上
  • 硬盘:100G及以上
  • 硬件架构:X86或ARM64
+

HI3516DV300开发板

+

HI3518EV300开发板

+

软件

+
  • 操作系统:Windows 10 64位 或 Ubuntu 18.04

    系统组件(Linux): libreadline-dev

    +
  • Python:3.7.5及以上
  • Python插件:pyserial3.3及以上、paramiko2.7.1及以上、setuptools40.8.0及以上,rsa4.0及以上
  • NFS Server:haneWIN NFS Server1.2.50及以上或者 NFSv4及以上
+
  • 系统软件:版本不低于OpenHarmony 1.0
  • 内核类型:LiteOS-A或者Linux
+
+ +### 安装环境 + +1. 打开test/xdevice目录,执行python setup.py install。 +2. 如测试环境为Linux,需要安装系统组件readline,命令如下: + + ``` + sudo apt-get install libreadline-dev + ``` + +3. 安装Python扩展组件pyserial、paramiko、setuptools以及rsa,命令如下: + + 安装pyserial + + ``` + pip install pyserial + ``` + + 安装setuptools + + ``` + pip install setuptools + ``` + + 安装rsa + + ``` + pip install rsa + ``` + + 安装Paramiko + + ``` + pip install paramiko + ``` + +4. 安装NFS server。 + + **Windows环境安装** + + 下载并安装haneWIN NFS Server1.2.50,地址:https://www.hanewin.net/nfs-e.htm + + **Linux环境下安装** + + ``` + sudo apt install nfs-kernel-server + ``` + + 所有环境配置安装完成,即可在IDE中进行测试工具代码开发调试,推荐的IDE为 DevEco Studio。 + + +### 检验环境是否搭建成功 + +**表 2** **检验环境** + + + + + + + + + + + + + + + + + + + + +

检查项

+

操作

+

满足条件

+

检查python安装与否,版本是否满足要求。

+

命令行窗口执行命令:python --version。

+

版本不小于3.7.5即可。

+

检查python扩展插件安装与否。

+

打开test/xdevice目录,执行run.bat或run.sh。

+

可进入提示符“>>>”界面即可。

+

检查NFS Server启动状态。

+

通过串口登录开发板,执行mount命令挂载NFS。

+

可正常挂载文件目录即可。

+
+ +## 开发指导 + +### 场景介绍 + +开发者测试用例主要用于对开发业务代码进行自验证,支持代码级别的单元测试、模块测试、性能测试。 + +### 接口说明 + +测试框架集成了开源的单元测试框架,并对测试用例的宏定义做了扩展,具体框架说明详见开源官方文档。 + +**表 3** 测试框架扩展宏定义说明 + + + + + + + + + + + + + + + + +

宏定义

+

描述

+

HWTEST

+

适合做简单测试,执行不依赖Setup&Teardown,对TEST扩展了用例级别,例如HWTEST(CalculatorAddTest, TestPoint_001, TestSize.Level1)。

+

HWTEST_F

+

用例具备独立性,执行依赖Setup&Teardown,对TEST_F扩展了用例级别,例如HWTEST_F(CalculatorAddTest, TestPoint_001, TestSize.Level1)。

+

HWTEST_P

+

参数化测试,对TEST_P扩展了用例级别,例如HWTEST_P(CalculatorAddTest, TestPoint_001, TestSize.Level1)。

+
+ +### 开发步骤 + +1. 按照开发者测试用例目录规划定义测试套文件,需要继承testing::Test类,命名以被测特性+Test命名,示例代码路径:test/developertest/example/cxx\_demo/test/unittest/common/calc\_subtraction\_test.cpp + + ``` + #include + + using namespace std; + using namespace testing::ext; + + class CalcSubtractionTest : public testing::Test { + public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + }; + ``` + +2. 实现测试套执行过程需要的预处理操作和后处理操作,即实现SetUp和TearDown方法。 + + ``` + void CalcSubtractionTest::SetUpTestCase(void) + { + // step 2: input testsuit setup step + } + + void CalcSubtractionTest::TearDownTestCase(void) + { + // step 2: input testsuit teardown step + } + + void CalcSubtractionTest::SetUp(void) + { + // step 3: input testcase setup step + } + + void CalcSubtractionTest::TearDown(void) + { + // step 3: input testcase teardown step + } + ``` + +3. 针对被测对象的特性编写测试用例,以使用HWTEST\_F为例说明。 + + ``` + /* + * Feature: Calculator + * Function: Subtraction + * SubFunction: NA + * FunctionPoints: Integer Subtraction + * EnvConditions: NA + * CaseDescription: Verify the Subtraction function. + */ + HWTEST_F(CalcSubtractionTest, integer_sub_001, TestSize.Level1) + { + EXPECT_EQ(0, Subtraction(1, 0)); + } + ``` + +4. 编写用例编译GN文件,其中包括定义用例编译目标,添加编译配置依赖,源文件等,举例说明(示例文件路径:test/developertest/example/cxx\_demo/test/unittest/common/BUILD.gn)。 + + ``` + import("//build/lite/config/test.gni") + + unittest("CalcSubTest") { + output_extension = "bin" + sources = [ + "calc_subtraction_test.cpp" + ] + include_dirs = [] + deps = [] + } + + ``` + +5. 将用例编译目标添加到子系统编译配置中,保证用例随版本一起编译,举例说明(示例文件路径:test/developertest/BUILD.gn)。 + + ``` + import("//build/lite/config/test.gni") + + subsystem_test("test") { + test_components = [] + if(ohos_kernel_type == "liteos_riscv") { + features += [ + ] + }else if(ohos_kernel_type == "liteos_a") { + test_components += [ + "//test/developertest/example/cxx_demo/test/unittest/common:CalcSubTest" + ] + } + } + ``` + +6. 在代码根路径下执行版本编译命令,即可编译测试用例。 + +## 开发实例 + +测试子系统代码仓提供了完整demo用例,demo用例路径:test/developertest/example/。以一个减法运算方法编写测试用例举例说明: + +- 被测代码如下: + + ``` + static int Subtraction(int a, int b) + { + return a - b; + } + ``` + +- 测试用例代码如下: + + ``` + /* + * Feature: Calculator + * Function: Subtraction + * SubFunction: NA + * FunctionPoints: Integer Subtraction + * EnvConditions: NA + * CaseDescription: Verify the Subtraction function. + */ + HWTEST_F(CalcSubtractionTest, integer_sub_002, TestSize.Level1) + { + EXPECT_EQ(1, Subtraction(2, 1)); + } + ``` + + +## 包结构说明 + +开发者测试平台基础框架xdevice包结构说明,代码目录test/xdevice,详见下表所示: + +**表 4** 基础框架xdevice包结构说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

功能描述

+

xdevice

+

测试工具基础框架。

+

xdevice/src/xdevice

+

基础测试框架源码。

+

xdevice/config

+

基础测试框架配置文件定义。

+

xdevice/src/xdevice/__main__.py

+

基础测试框架内部入口。

+

xdevice/src/xdevice/__init__.py

+

包依赖定义,插件依赖。

+

xdevice/src/xdevice/variables.py

+

全局变量定义。

+

xdevice/src/xdevice/_core/command

+

用例输入的命令行处理。

+

xdevice/src/xdevice/_core/config

+

基础测试框架的配置管理。

+

xdevice/src/xdevice/_core/environment

+

基础测试框架的环境管理,包括设备管理。

+

xdevice/src/xdevice/_core/executor

+

基础测试框架用例调度和分发。

+

xdevice/src/xdevice/_core/driver

+

基础测试框架测试执行器。

+

xdevice/src/xdevice/_core/resource

+

基础测试框架资源文件以及测试报告模板。

+

xdevice/src/xdevice/_core/testkit

+

基础测试框架公共操作,包括NFS文件系统挂载等。

+

xdevice/src/xdevice/_core/logger.py

+

基础测试框架日志管理。

+

xdevice/src/xdevice/_core/plugin.py

+

基础测试框架插件管理。

+

xdevice/src/xdevice/_core/interface.py

+

基础测试框架插件接口定义。

+

xdevice/setup.py

+

基础测试框架的安装脚本。

+

xdevice/run.bat

+

基础测试框架启动脚本(Windows)。

+

xdevice/run.sh

+

基础测试框架启动脚本(Linux)。

+
+ diff --git "a/subsystems/\347\224\250\346\210\267\347\250\213\345\272\217\346\241\206\346\236\266.md" "b/subsystems/\347\224\250\346\210\267\347\250\213\345\272\217\346\241\206\346\236\266.md" new file mode 100644 index 0000000000000000000000000000000000000000..6443d609fd6714540da7886576e8419e8e57f431 --- /dev/null +++ "b/subsystems/\347\224\250\346\210\267\347\250\213\345\272\217\346\241\206\346\236\266.md" @@ -0,0 +1,13 @@ +# 用户程序框架 + +- **[概述](概述.md)** + +- **[搭建环境](搭建环境.md)** + +- **[开发指导](开发指导.md)** + +- **[开发实例](开发实例.md)** + +- **[常见问题](常见问题.md)** + + diff --git "a/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272.md" "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272.md" new file mode 100644 index 0000000000000000000000000000000000000000..af87279326d8c684aac2aa870652683ad96d13b1 --- /dev/null +++ "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272.md" @@ -0,0 +1,9 @@ +# 编译构建 + +- **[编译构建概述](编译构建概述.md)** + +- **[编译构建使用指导](编译构建使用指导.md)** + +- **[编译构建常见问题](编译构建常见问题.md)** + + diff --git "a/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\344\275\277\347\224\250\346\214\207\345\257\274.md" "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\344\275\277\347\224\250\346\214\207\345\257\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..79221d7e79504204223b9a344ee36d43672da2c8 --- /dev/null +++ "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\344\275\277\347\224\250\346\214\207\345\257\274.md" @@ -0,0 +1,275 @@ +# 编译构建使用指导 + +- [目录结构](#section56731811102915) +- [编译命令](#section1475192018291) +- [开发步骤](#section4207112818418) + +## 目录结构 + +``` +build/lite # 编译构建主目录 +├── config # 编译相关的配置项 +│ ├── boards # 开发板相关的变量定义。包括:开发板名、目标架构、目标CPU等 +│ ├── component # OpenHarmony组件相关的模板定义。包括:静态库、动态库、扩展组件、模拟器库等 +│ ├── kernel # OpenHarmony内核的编译变量定义与配置参数 +│ └── subsystem # OpenHarmony子系统列表 +├── ndk # NDK相关编译脚本与配置参数 +├── platform # 平台相关的配置文件 +│ ├── hi3516dv300_liteos_a # hi3516dv300, liteos_a平台。包括:平台全量配置表,启动文件。 +│ ├── hi3518ev300_liteos_a # hi3518ev300, liteos_a平台。包括:平台全量配置表,启动文件。 +│ └── hi3861v100_liteos_riscv # hi3861v100, liteos_riscv平台。包括:平台全量配置表,启动文件。 +├── product # 产品全量配置表。包括:配置单元、子系统列表、编译器等。 +├── toolchain # 编译工具链相关。包括:编译器路径、编译选项、链接选项等。 +└── tools # 编译构建依赖的工具。包括:mkfs等。 +``` + +## 编译命令 + +- 使用方法: + + ``` + python build.py product [options] + ``` + + product为build/lite/produc/xxx.json, product名称和json配置文件中的组件均可自定义。默认json文件中的组件为对应平台支持的全集。 + +- 编译选项: + + -b, --build\_type Debug or release + + -t, --test Build with test suit + + -T, --target Build single target + +- 编译输出: 代码根目录/out/product + + +## 开发步骤 + +1. 添加组件 + + 本节以添加一个自定义的组件为例,描述了如何编译组件、编译库、编译可执行文件。 + + 示例组件example由两个功能feature1和feature2组成。feture1的目标为一个动态库,feature2的目标为一个可执行文件。示例组件example的完整目录结构如下: + + ``` + example # 自定义组件 + ├── BUILD.gn # 自定义组件gn脚本,BUILD.gn为固定名称 + ├── feature1 # 自定义单元1 + │ ├── BUILD.gn # 自定义单元1的gn脚本,BUILD.gn为固定名称 + │ ├── include # 头文件文件夹 + │ │ └── helloworld1.h # 头文件1 + │ └── src # 源文件文件夹 + │ └── helloworld1.c # 源文件1 + ├── feature2 # 自定义单元2 + │ ├── BUILD.gn # 自定义单元2的gn脚本,BUILD.gn为固定名称 + │ ├── include # 头文件文件夹 + │ │ └── helloworld2.h # 头文件2 + │ └── src # 源文件文件夹 + │ └── helloworld2.c # 源文件2 + ├── build.sh # 自定义组件build.sh脚本,非必要 + └── Makefile # 自定义组件Makefile脚本,非必要 + ``` + + 示例1:编写动态库gn脚本example/feature1/BUILD.gn,示例如下: + + ``` + # helloworld动态库编译示例 + # helloworld的Build.gn文件 + shared_library("helloworld_lib") { + sources = [ + "src/helloworld1.c" + ] + include_dirs = [ + "include", + "../feature2_example/include" #(可选)如果依赖 feature2_example 可以加入该include + ] + } + ``` + + 示例2:编写可执行文件gn脚本example/feature2/BUILD.gn,示例如下: + + 内置函数executable,可编译出可执行文件。示例如下: + + ``` + #编译可执行.bin文件 + executable("hello_world_bin") { + sources = [ + "src/helloworld2.c" + ] + include_dirs = [ + "include", + "../feature2_example/include" #(可选)如果依赖 feature2_example 可以加入该include + ] + #(可选)如果依赖 feature1_example 可以加入该deps + deps = [ + "../feature1_example:helloworld1" + ] + } + ``` + + 示例3,编译组件脚本example/BUILD.gn: + + ``` + import("//build/lite/config/component/lite_component.gni") + lite_component("example_gn") { + features = [ + "feature_example1:helloworld_lib", + "feature_example2:hello_world_bin", + ] + } + ``` + + 示例4,三方开源软件的build.sh或Makefile工程, 可用gn脚本调用混合编译: + + ``` + 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" + } + ``` + + 全局可引用的变量定义在:build/lite/ohos\_var.gni + + 用户常用变量说明见表1: + + **表 1** 用户常用变量 + + + + + + + + + + + + + + + + + + + + + + + + +

变量

+

取值范围

+

说明

+

ohos_kernel_type

+

"liteos_a", "liteos_riscv"

+

内核类型

+

board_name

+

"hi3516dv300", "hi3518ev300", "hi3861v100"

+

开发板类型

+

ohos_build_compiler

+

"gcc", "clang"

+

编译工具链类型

+

ohos_build_type

+

"debug", "release"

+

编译类型

+
+ + 举例:ohos\_kernel\_type的使用方式,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. 编译产品解决方案 + + 产品解决方案的配置在build/lite/product 目录下,如ipcamera\_hi3516dv300.json,构建时会读取该文件包含所有用户自定义子系统、组件等配置。以编译ipcamera\_hi3516dv30为例,编译命令如下: + + ``` + python build.py ipcamera_hi3516dv30 + ``` + +3. 编译输出 + + 编译所生产的文件都归档在out目录下,例如在代码所在目录下,运行"python build.py wifiiot -b debug",编译wifiiot完成后,会有如下结果生成: + + ``` + out/ + └── wifiiot # 产品名 + ├── args.gn # gn编译,用户自定义变量 + ├── build.log # 编译日志 + ├── build.ninja + ├── build.ninja.d + ├── gen + ├── Hi3861_boot_signed_B.bin # 带签名的bootloader备份文件 + ├── Hi3861_boot_signed.bin # 带签名的bootloader文件 + ├── Hi3861_loader_signed.bin # 烧写工具使用的加载文件 + ├── Hi3861_wifiiot_app_allinone.bin # 产线工装烧写文件(已经包含独立烧写程序和loader程序) + ├── Hi3861_wifiiot_app.asm # Kernel asm文件 + ├── Hi3861_wifiiot_app_burn.bin # 烧写文件 + ├── Hi3861_wifiiot_app_flash_boot_ota.bin # Flash Boot升级文件 + ├── Hi3861_wifiiot_app.map # Kernel map文件 + ├── Hi3861_wifiiot_app_ota.bin # Kernel 升级文件 + ├── Hi3861_wifiiot_app.out # Kernel 输出文件 + ├── Hi3861_wifiiot_app_vercfg.bin # 安全启动配置boot和kernel版本号,防版本回滚 + ├── libs # 库文件夹 + ├── NOTICE_FILE + ├── obj + ├── suites + └── toolchain.ninja + ``` + + 注:烧写文件,烧写程序建议使用"Hi3861\_wifiiot\_app\_allinone.bin"。 + + 运行"python build.py ipcamera\_hi3518ev300 -b debug",编译ipcamera\_hi3518ev300完成后,会有如下结果生成\(同ipcamera\_hi3516dv300\): + + ``` + out/ + └── ipcamera_hi3518ev300 # 产品名 + ├── args.gn # gn编译,用户自定义变量 + ├── bin # 链接bin所在文件夹 + ├── bm_tool.map # map文件 + ├── build.log # 编译日志 + ├── build.ninja + ├── build.ninja.d + ├── bundle_daemon_tool.map # map文件 + ├── data # 媒体camera依赖底层资源配置文件 + ├── dev_tools # 研发自测试 + ├── foundation.map # map文件 + ├── gen + ├── libaudio_api.so + ├── libs # 镜像包含库文件 + ├── liteos.bin # liteos基础内核bin文件 + ├── media_server.map # map文件 + ├── NOTICE_FILE + ├── obj # 二进制文件,编译结果文件夹 + ├── OHOS_Image # liteos整包bin文件,未strip + ├── OHOS_Image.asm # 汇编代码 + ├── OHOS_Image.bin # liteos整包烧录bin文件 + ├── OHOS_Image.map # map文件 + ├── rootfs.img # 编译出的库和app的镜像 + ├── rootfs.tar # rootfs的压缩 + ├── suites # xts编译结果 + ├── test # 测试用例编译结果 + ├── toolchain.ninja + ├── userfs # 用户可读写的分区 + ├── userfs.img # img格式的用户可读写的分区,对应启动之后的/storage目录 + └── vendor # 芯片的Firmware文件及配置文件 + ``` + + diff --git "a/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\345\270\270\350\247\201\351\227\256\351\242\230.md" "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\345\270\270\350\247\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..3091007aca95441a17bbb9b76305ae359d269e10 --- /dev/null +++ "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\345\270\270\350\247\201\351\227\256\351\242\230.md" @@ -0,0 +1,101 @@ +# 编译构建常见问题 + +- [由于ninja版本问题导致编译失败](#section1019152312222) +- [由于ncurses库缺失导致编译失败](#section21449422618) +- [由于未安装mcopy导致编译失败](#section12477184992615) +- [由于权限问题导致编译失败](#section178451337202716) +- [由于未安装Crypto导致编译失败](#section1241481172819) +- [由于编译环境为shell导致编译失败](#section3691222152919) + +## 由于ninja版本问题导致编译失败 + +- **现象描述:** + + 编译失败,提示"usr/sbin/ninja: invalid option -- w"。 + +- **可能原因:** + + 编译环境中ninja版本太低,不支持--w选项。 + +- **解决办法:** + + 卸载环境中ninja和gn,按照HarmonyOS官网[获取工具](../get-code/获取工具.md)。 + + +## 由于ncurses库缺失导致编译失败 + +- **现象描述:** + + 编译失败,提示“/usr/bin/ld: cannot find -lncurses”。 + +- **可能原因:** + + 编译环境ncurses库缺失。 + +- **解决办法:** + + sudo apt-get install lib32ncurses5-dev。 + + +## 由于未安装mcopy导致编译失败 + +- **现象描述:** + + ​编译失败,提示“line 77: mcopy: command not found”。 + +- **可能原因:** + + 编译环境未安装mcopy。 + +- **解决办法:** + + ​sudo apt-get install dosfstools mtools。 + + +## 由于权限问题导致编译失败 + +- **现象描述:** + + 编译失败,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”。 + +- ​**可能原因:** + + 当前用户对riscv编译器路径下的文件访问权限不够。 + +- ​**解决办法:** + + 输入命令\`which riscv32-unknown-elf-gcc\`, 对其hcc\_riscv32所在的目录,使用chmod 755修改权限。 + + +## 由于未安装Crypto导致编译失败 + +- **现象描述:** + + 编译失败,提示“No module named 'Crypto'”。 + +- **可能原因:** + + python3未安装Crypto。 + +- **解决办法:** + + 输入命令\`python3 --version\`,查看Python版本号。需使用python3.7以上版本,再输入\`sudo pip3 install pycryptodome\`。 + + +## 由于编译环境为shell导致编译失败 + +- **现象描述:** + + 编译失败:“xx.sh \[: xx upexpected operator”。 + +- **可能原因:** + + 编译环境shell不是bash。 + +- **解决办法:** + + sudo rm -rf /bin/sh + + sudo ln -s /bin/bash /bin/sh + + diff --git "a/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\346\246\202\350\277\260.md" "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\346\246\202\350\277\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..cfcbc67840884a6d82e23e60a6b015002b375196 --- /dev/null +++ "b/subsystems/\347\274\226\350\257\221\346\236\204\345\273\272\346\246\202\350\277\260.md" @@ -0,0 +1,46 @@ +# 编译构建概述 + +- [基本概念](#section175012297491) +- [运作机制](#section193961322175011) +- [约束与限制](#section2029921310472) + +编译构建提供了一个基于gn和ninja的编译构建框架。主要提供以下功能: + +- 构建不同芯片平台的产品。如:Hi3518EV300平台的IPcamera产品,Hi3516DV300平台的IPcamera产品,Hi3861平台的WLAN模组产品。 + +- 构建HPM包管理配置生成的自定义产品。 + +## 基本概念 + +在开发编译构建前,应了解如下基本概念: + +- 平台 + + 开发板和内核的组合,不同平台支持的子系统和组件不同。 + +- 组件 + + 可复用的软件单元,它包含源码、配置文件、资源文件和编译脚本等。 + +- gn + + Generate ninja的缩写,用于产生ninja文件。 + +- ninja + + ninja是一个专注于速度的小型构建系统。 + + +## 运作机制 + +编译构建流程主要包括编译命令行解析,调用gn, 执行ninja和系统镜像打包。 + +- 命令行解析:解析待编译的产品名称,编译类型(debug/release)。 +- 调用gn: 根据命令行解析的产品名称和编译类型配置编译工具链和全局的编译选项。 +- 执行ninja:启动编译。 +- 系统镜像打包:将组件编译产物打包,制作文件系统镜像。 + +## 约束与限制 + +开发者需预装gn、ninja构建工具和编译工具链,并下载完整代码。 +