未验证 提交 d5711ee1 编写于 作者: O openharmony_ci 提交者: Gitee

!13161 [翻译完成】#I60PFN

Merge pull request !13161 from Annie_wang/PR10789
......@@ -24,92 +24,95 @@ The CPU architecture includes two layers: general architecture definition layer
| Header file name| los_<function>.h | los_arch_<function>.h |
| Function name| Halxxxx | Halxxxx |
LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V.
LiteOS-M supports mainstream architectures, such as RISC-V and ARM Cortex-M3, Cortex-M4, Cortex-M7, and Cortex-M33.
## Working Principles
In the **target\_config.h** file of the development board, configure the system clock and number of ticks per second, and configure the task, memory, inter-process communication (IPC), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below.
In the **target_config.h** file of the development board, configure the system clock and number of ticks per second, and configure the task, memory, inter-process communication (IPC), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below.
**Figure 2** Kernel startup process
**Figure 2** Kernel startup process<br>
![](figures/kernel-startup-process.png "kernel-startup-process")
## Directory Structure<a name="section161941989596"></a>
The directory structure is as follows.
## Directory Structure
The directory structure is as follows:
```text
/kernel/liteos_m
├── arch # Code of the kernel instruction architecture layer
│ ├── arm # Code of the ARM32 architecture
│ │ ├── arm9 # Code of the ARM9 architecture
│ │ ├── cortex-m3 # Code of the cortex-m3 architecture
│ │ ├── cortex-m33 # Code of the cortex-m33 architecture
│ │ ├── cortex-m4 # Code of the cortex-m4 architecture
│ │ ├── cortex-m7 # Code of the cortex-m7 architecture
│ │ └── include # Arm architecture public header file directory
│ ├── csky # Code of the csky architecture
│ │ └── v2 # Code of the csky v2 architecture
├── arch # Kernel instruction architecture layer directory
│ └── arm # Code of the ARM architectures
│ │ ├── arm9 # Code of ARM9
│ │ ├── cortex-m3 # Code of ARM Cortex-M3
│ │ ├── cortex-m33 # Code of ARM Cortex-M33
│ │ ├── cortex-m4 # Code of ARM Cortex-M4
│ │ ├── cortex-m55 # Code of ARM Cortex-M55
│ │ ├── cortex-m7 # code of ARM Cortex-M7
│ │ └── include # Directory of the common header files of the ARM architectures
│ ├── csky # Code of the C-SKY architecture
│ │ └── v2 # code of C-SKY v2
│ ├── include # APIs exposed externally
│ ├── risc-v # Code of the risc-v architecture
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
│ │ └── riscv32 # Code of the risc-v architecture
│ └── xtensa # Code of the xtensa architecture
│ └── lx6 # Code of the lx6 xtensa architecture
│ ├── risc-v # Code of the RISC-V architecture
│ │ ├── nuclei # Code of RISC-V for Nuclei
│ │ └── riscv32 # Code of the official RISC-V architecture
│ └── xtensa # Code of the Xtensa architecture
│ └── lx6 # Code of Xtensa LX6
├── components # Optional components
│ ├── backtrace # Backtrace support
│ ├── backtrace # Backtrace
│ ├── cppsupport # C++ support
── cpup # CPU percent (CPUP)
── cpup # CPU percent (CPUP)
│ ├── dynlink # Dynamic loading and linking
│ ├── exchook # Exception hooks
│ ├── fs # File systems
│ ├── lmk # Low memory killer functions
│ ├── lms # Lite memory sanitizer functions
│ ├── net # Networking functions
│ ├── power # Power management
│ ├── shell # Shell function
│ ├── fs # File systems
│ ├── lmk # Low memory killer mechanism
│ ├── lms # Lite memory sanitizer mechanism
│ └── net # Networking functions
│ ├── power # Power consumption management
│ ├── shell # Shell
│ └── trace # Trace tool
├── drivers # driver Kconfig
├── drivers # Driver framework Kconfig
├── kal # Kernel abstraction layer
│ ├── cmsis # CMSIS API support
│ └── posix # POSIX API support
├── kernel # Minimum kernel function set
│ ├── include # APIs exposed externally
│ └── src # Source code of the minimum kernel function set
├── testsuites # Kernel testsuites
├── testsuites # Kernel test cases
├── tools # Kernel tools
├── utils # Common directory
├── utils # Common code
```
## Constraints<a name="section119744591305"></a>
## Constraints
OpenHarmony LiteOS-M supports only C and C++.
Applicable architecture: See the directory structure for the arch layer.
OpenHarmony LiteOS-M applies only to the architectures in **arch**.
As for dynamic loading module, the shared library to be loaded needs signature verification or source restriction to ensure security.
For the shared library to be dynamically loaded, signature verification must be performed or the library source must be strictly controlled for security purposes.
## Usage<a name="section3732185231214"></a>
## Usage
The OpenHarmony LiteOS-M kernel build system is a modular build system based on Generate Ninja (GN) and Ninja. It supports module-based configuration, tailoring, and assembling, and helps you build custom products. This document describes how to build a LiteOS-M project based on GN and Ninja. For details about the methods such as GCC+gn, IAR, and Keil MDK, visit the community websites.
OpenHarmony
The OpenHarmony LiteOS-M kernel build system is a modular build system based on Generate Ninja (GN) and Ninja. It supports modular configuration, tailoring, and assembling, and helps you build custom products. This document describes how to build a LiteOS-M project based on GN and Ninja. For details about other building methods, such as GCC+gn, IAR, and Keil MDK, visit the related community websites.
### Setting Up the Environment
Before setting up the environment for a development board, you must set up the basic system environment for OpenHarmony first. The basic system environment includes the OpenHarmony build environment and development environment. For details, see [Quick Start Overview](../quick-start/quickstart-overview.md).
Before setting up the environment for a development board, you must set up the basic system environment for OpenHarmony first. The basic system environment refers to the OpenHarmony build environment and development environment. For details, see [Quick Start Overview](../quick-start/quickstart-overview.md).
### Obtaining the OpenHarmony Source Code
### Obtaining OpenHarmony Source Code
For details about how to obtain the source code, see [Source Code Acquisition](../get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
For details about how to obtain the source code, see [Obtaining Source Code](../get-code/sourcecode-acquire.md). The directory to clone is **~/openHarmony** after the OpenHarmony repository code is obtained.
### Example projects
### Supported Sample Projects
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`. For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu).
QEMU: **arm_mps2_an386**, **esp32**, **riscv32_virt**, and **SmartL_E802**. For details, see [QEMU](https://gitee.com/openharmony/device_qemu).
Bestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
bestechnic: **bes2600**. For details, see [device_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic).
### Community Porting Project Links
### Community Porting Project
The LiteOS-M kernel porting projects for specific development boards are provided by community developers. The following provides the links to these projects. If you have porting projects for more development boards, you can provide your links to share your projects.
The LiteOS-M kernel porting projects for specific development boards are provided by community developers. The following provides the links to these projects. You are also welcomed to share your porting projects.
- Cortex-M3:
......@@ -123,22 +126,22 @@ The LiteOS-M kernel porting projects for specific development boards are provide
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the STM32F429IGTb development board. The code supports build in Ninja, GCC, and IAR modes.
## Contribution<a name="section1371123476307"></a>
## Contribution
[How to involve](../../contribute/contribution-process.md)
[How To Contribute](../../contribute/how-to-contribute.md)
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
[Commit Message Specifications]((https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83))
[Liteos-M kernel coding style guide](https://gitee.com/openharmony/kernel_liteos_m/wikis/OpenHarmony%E8%BD%BB%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83)
[LiteOS-M Kernel Coding Specifications](https://gitee.com/openharmony/kernel_liteos_m/wikis/OpenHarmony%E8%BD%BB%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83)
How to contribute a chip based on Liteos-M kernel:
Contribute a chip based on LiteOS-M:
[Mini System SoC Porting Guide](../porting/porting-minichip-overview.md)
[Mini-System Chip Porting Guide](../porting/porting-minichip-overview.md)
[Mini System SoC Porting Cases](../porting/porting-bes2600w-on-minisystem-display-demo.md)
[Mini-System Devices with Screens – Bestechnic SoC Porting Case](../porting/porting-bes2600w-on-minisystem-display-demo.md)
## Repositories Involved<a name="section1371113476307"></a>
## Repositories Involved
[Kernel Subsystem](../../readme/kernel.md)
[Kernel](../../readme/kernel.md)
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m)
......@@ -122,7 +122,7 @@ You must install the software packages required for build. The command is as fol
# export PATH=~/.local/bin:$PATH
```
![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The hb tool will be installed during the installation of ohos-build. If the hb installation fails, see [Installing hb](../../device-dev/quick-start/quickstart-pkg-install-tool.md).
![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The hb tool will be installed during the installation of **ohos-build**. If hb tool fails to be installed, [install hb](../../device-dev/quick-start/quickstart-pkg-install-tool.md#hb-installation) again.
## Configuration Rules
......@@ -156,7 +156,7 @@ To ensure that chipset and product solutions are decoupled from OpenHarmony, you
gn_helpers.py*
lite/ # hb and preloader entry
misc/
├── ohos # Configuration of OpenHarmony building and packaging
├── ohos # Configuration of OpenHarmony build and packaging
│ ├── kits # Kits build and packaging templates and processing
│ ├── ndk # NDK templates and processing
│ ├── notice # Notice templates and processing
......@@ -195,34 +195,31 @@ Then, run the build commands in command line (CLI) mode or hb mode.
1. Using the CLI
- Run the following command in the root directory of the source code to build a full distribution:
- Run the following command in the root directory of the source code to build a full distribution:
Release version:
```shell
./build.sh --product-name {product_name}
```
Debug version:
```shell
./build.sh --product-name {product_name} --gn-args is_debug=true
```
>![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
>Due to the limitation of the image size, the full build for the debug version may fail to be burnt. You are advised to build the binary file for each module separately. Run the following command to build a module separately:
> ![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
> Due to the limitation of the image size, the full build for the debug version may fail to be burnt. You are advised to build the binary file for each module separately. Run the following command to build a module separately:
>
>```
>./build.sh --product-name {product_name} --gn-args is_debug=true --build-target {target_name}
>```
>
> ```
> ./build.sh --product-name {product_name} --gn-args is_debug=true --build-target {target_name}
> ```
>
**{product_name}** specifies the product platform supported by the current distribution, for example, **hispark_taurus_standard**.
The image generated is stored in the **out/{device_name}/packages/phone/images/** directory.
- The **./build.sh** command supports the following options:
- The **./build.sh** command supports the following options:
```shell
-h, --help # Display help information and exit.
......@@ -243,70 +240,64 @@ Then, run the build commands in command line (CLI) mode or hb mode.
--fast-rebuild # Specify whether to allow fast rebuild. The default value is False.
--log-level=LOG_LEVEL # Specify the log level used in the build process. The options are debug, info, and error. The default value is info.
--device-type=DEVICE_TYPE # Specify the device type. The default value is default.
--build-variant=BUILD_VARIANT #Specify the device operation mode. The default value is user.
--build-variant=BUILD_VARIANT # Specify the device operation mode. The default value is user.
```
2. Using the hb tool
**hb** is an OpenHarmony command line tool for executing build commands. Common hb commands are described as follows:
**hb set**
2. Using the hb tool
**hb** is an OpenHarmony command line tool for executing build commands. Common hb commands are described as follows:
Sets the product to build.
**hb set**
Sets the product to build.
```shell
hb set -h
usage: hb set [-h] [-root [ROOT_PATH]] [-p]
```shell
hb set -h
usage: hb set [-h] [-root [ROOT_PATH]] [-p]
optional arguments:
optional arguments:
-h, --help show this help message and exit
-root [ROOT_PATH], --root_path [ROOT_PATH]
Set OHOS root path
-p, --product Set OHOS board and kernel
```
- If you run **hb set** with no argument, the default setting process starts.
- You can run **hb set -root** *dir* to set the root directory of the source code.
- You can run **hb set -p** to set the product to build.
```
- If you run **hb set** with no argument, the default setting process starts.
**hb env**
- You can run **hb set -root** *dir* to set the root directory of the source code.
Displays current settings.
- You can run **hb set -p** to set the product to build.
```shell
hb env
[OHOS INFO] root path: xxx
[OHOS INFO] board: hispark_taurus
[OHOS INFO] kernel: liteos
[OHOS INFO] product: ipcamera
[OHOS INFO] product path: xxx/vendor/hisilicon/ipcamera
[OHOS INFO] device path: xxx/device/hisilicon/hispark_taurus/sdk_linux_4.19
```
**hb env**
Displays current settings.
```shell
hb env
[OHOS INFO] root path: xxx
[OHOS INFO] board: hispark_taurus
[OHOS INFO] kernel: liteos
[OHOS INFO] product: ipcamera
[OHOS INFO] product path: xxx/vendor/hisilicon/ipcamera
[OHOS INFO] device path: xxx/device/hisilicon/hispark_taurus/sdk_linux_4.19
```
**hb build**
**hb build**
Builds a product, component, module, or chipset solution.
Builds a product, component, module, or chipset solution.
```shell
hb build -h
usage: hb build [-h] [-b BUILD_TYPE] [-c COMPILER] [-t [TEST [TEST ...]]] [-cpu TARGET_CPU] [--dmverity] [--tee]
```shell
hb build -h
usage: hb build [-h] [-b BUILD_TYPE] [-c COMPILER] [-t [TEST [TEST ...]]] [-cpu TARGET_CPU] [--dmverity] [--tee]
[-p PRODUCT] [-f] [-n] [-T [TARGET [TARGET ...]]] [-v] [-shs] [--patch] [--compact-mode]
[--gn-args GN_ARGS] [--keep-ninja-going] [--build-only-gn] [--log-level LOG_LEVEL] [--fast-rebuild]
[--device-type DEVICE_TYPE] [--build-variant BUILD_VARIANT]
[component [component ...]]
positional arguments:
positional arguments:
component name of the component, mini/small only
optional arguments:
optional arguments:
-h, --help show this help message and exit
-b BUILD_TYPE, --build_type BUILD_TYPE
release or debug version, mini/small only
......@@ -340,34 +331,35 @@ Then, run the build commands in command line (CLI) mode or hb mode.
specifies device type
--build-variant BUILD_VARIANT
specifies device operating mode
```
```
- If you run **hb build** with no argument, the previously configured code directory, product, and options are used for the build. The **-f** option deletes all products to be built. It is equivalent to running **hb clean** and **hb build**.
- You can run **hb build** *{component_name}* to build product components separately based on the development board and kernel set for the product, for example, **hb build kv_store**.
- You can run **hb build -p ipcamera@hisilicon** to skip the setting step and build the product directly.
- If you run **hb build** with no argument, the previously configured code directory, product, and options are used for the build. The **-f** option deletes all products to be built. It is equivalent to running **hb clean** and **hb build**.
- You can run **hb build** in **device/board/device_company** to select the kernel and build an image that contains the kernel and drivers only based on the current development board and the selected kernel.
- You can run **hb build** *{component_name}* to build product components separately based on the development board and kernel set for the product, for example, **hb build kv_store**.
- You can run **hb build -p ipcamera@hisilicon** to skip the setting step and build the product directly.
- You can run **hb build** in **device/board/device_company** to select the kernel and build an image that contains the kernel and drivers only based on the current development board and the selected kernel.
**hb clean**
**hb clean**
Deletes all the files except **args.gn** and **build.log** in the **out** directory (default). To clear files in a specified directory, add the directory parameter to the command, for example, **hb clean out/board/product**.
Deletes all the files except **args.gn** and **build.log** in the **out** directory (default). To clear files in a specified directory, add the directory parameter to the command, for example, **hb clean out/board/product**.
```shell
hb clean
usage: hb clean [-h] [out_path]
```shell
hb clean
usage: hb clean [-h] [out_path]
positional arguments:
positional arguments:
out_path clean a specified path.
optional arguments:
optional arguments:
-h, --help show this help message and exit
```
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - For details about how to set up the build environment and perform the build, see the related topics in [Getting Started](../quick-start/Readme-EN.md).
> - OpenHarmony also provides the Docker environment, which spares the installation of the build tool. For details, see [Docker Environment](../get-code/gettools-acquire.md).
> **NOTE**
>
> - For details about how to set up the build environment and perform the build, see the related topics in [Getting Started](../quick-start/quickstart-overview.md)
> - OpenHarmony also provides the Docker environment, which spares the installation of the build tool. For details, see [Docker Environment](../get-code/gettools-acquire.md)
### Building Procedures
......@@ -389,3 +381,4 @@ You can add and build a product, component, chipset solution, and module. For de
- [Information Collected by the Open Source Software Notice](subsys-build-reference.md#information-collected-by-the-open-source-software-notice)
- [Parameters for Accelerating Local Build](subsys-build-reference.md#parameters-for-accelerating-local-build)
- [Viewing Ninja Build Information](subsys-build-reference.md#viewing-ninja-build-information)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册