From 2b5f52236a9a4110fa81301acdad3c11bd28ff9f Mon Sep 17 00:00:00 2001 From: annie_wangli Date: Thu, 4 Nov 2021 15:09:56 +0800 Subject: [PATCH 1/6] update docs Signed-off-by: annie_wangli --- README.md | 107 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 4044df34..ca6c7eed 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# LiteOS Cortex-M +# LiteOS-M Kernel - [Introduction](#section11660541593) - [Directory Structure](#section161941989596) @@ -8,70 +8,119 @@ ## Introduction -The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system \(OS\) for the Internet of Things \(IoT\) field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer \(HAL\) interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things \(AIoT\) field for rich hardware and compilation toolchains. [Figure1](#fig0865152210223) shows the architecture of the OpenHarmony LiteOS Cortex-M kernel. +OpenHarmony LiteOS-M is a lightweight operating system kernel designed for the Internet of Things (IoT) field. It features small footprint, low power consumption, and high performance. It has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory. The LiteOS-M kernel is divided into the hardware layer and hardware-irrelevant layers. The hardware layer provides a unified hardware abstraction layer (HAL) interface for easier hardware adaptation. A range of compilation toolchains can be used with different chip architectures to meet the expansion of diversified hardware and compilation toolchains in the Artificial Intelligence of Things (AIoT) field.**Figure1** shows the architecture of the LiteOS-M kernel. -**Figure 1** Architecture of OpenHarmony the LiteOS Cortex-M kernel -![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "architecture-of-openharmony-the-liteos-cortex-m-kernel") +**Figure 1** Architecture of the OpenHarmony LiteOS-M kernel +![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "OpenHarmony-LiteOS-M Kernel Architecture") ## Directory Structure -The directory structure is listed as below, for the detailed directories, please refer to [arch_spec.md](arch_spec.md). +The directory structure is as follows. For more details, see [arch_spec.md](arch_spec.md). ``` /kernel/liteos_m ├── components # Optional components │ ├── backtrace # Backtrace support │ ├── cppsupport # C++ support -│ ├── cpup # CPU possession (CPUP) -│ ├── dynlink # Dynamic loader & linker -│ ├── exchook # Exception hook -│ ├── fs # File system -│ └── net # Network support +│ └── cpup # CPU percent (CPUP) +│ ├── dynlink # Dynamic loading and linking +│ ├── exchook # Exception hooks +│ ├── fs # File systems +│ └── net # Networking functions ├── kal # Kernel abstraction layer -│ ├── cmsis # CMSIS-compliant API support +│ ├── cmsis # CMSIS API support │ └── posix # POSIX API support -├── kernel # Minimum function set support +├── kernel # Minimum kernel function set │ ├── arch # Code of the kernel instruction architecture layer -│ │ ├── arm # Code of the ARM32 architecture +│ │ ├── arm # Code of the Arm32 architecture │ │ └── include # APIs exposed externally │ ├── include # APIs exposed externally -│ └── src # Source code of the minimum function set of the kernel +│ └── src # Source code of the minimum kernel function set ├── targets # Board-level projects -├── utils # Common code +├── utils # Common directory ``` ## Constraints -Programming languages: C and C++ +OpenHarmony LiteOS-M supports only C and C++. -Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V +It applies only to Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V chip architectures. ## Usage -LiteOS Cortex-M provides projects for three chip architectures, which are located in the **targets** directory. The methods of compiling and using these projects are as follows: +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+Makefile, IAR, and Keil MDK, visit the 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 [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md). You need to install Python3.7+, GN, Ninja, and hb. For the LiteOS-M kernel, you also need to install the Make build tool and [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads). + +### Obtaining the OpenHarmony Source Code + +Obtain the latest OpenHarmony source code through Git clone on a Linux server. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. + +### Obtaining the Source Code of the Sample Project + +The following uses the development board Nucleo-F767Zi as an example to describe how to build and run the `OpenHarmony LiteOS-M` kernel project. In the local directory, run the following command to clone the sample code: + +``` +git clone https://gitee.com/harylee/nucleo_f767zi.git +``` + +The code is cloned to **~/nucleo_f767zi**. Run the following commands to copy the **device** and **vendor** directories in the code directory to the corresponding directories of the **openHarmony** project: + +``` +mkdir ~/openHarmony/device/st + +cp -r ~/nucleo_f767zi/device/st/nucleo_f767zi ~/openHarmony/device/st/nucleo_f767zi + +chmod +x ~/openHarmony/device/st/nucleo_f767zi/build.sh + +cp -r ~/nucleo_f767zi/vendor/st ~/openHarmony/vendor/st +``` + +For details about the directory of the sample code, see [Board-Level Directory Specifications](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-chip-board-overview.md). If you need to port the development board, see [Board-Level OS Porting](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-chip-board.md). + +### Building and Running + +Before the build, configure the **bin** directory of the cross compilation toolchain in the **PATH** environment variable or set **board_toolchain_path** in the **device/st/nucleo_f767zi/liteos_m/config.gni** file to the **bin** directory of the cross compilation toolchain. +In the **OpenHarmony** root directory, run the **hb set** command to set the product path, select **nucleo_f767zi**, and run the **hb build** command to start the build. Example: + +``` +user@dev:~/OpenHarmony$ hb set + +[OHOS INFO] Input code path: # Press Enter and select nucleo_f767zi. + +OHOS Which product do you need? nucleo_f767zi@st + +user@dev:~/OpenHarmony$ hb build +``` + +The image is generated in the **~/openHarmony/out/nucleo_f767zi/** directory. You can download the image file to the board by using the STM32 ST-LINK Utility software and run the image. + +### Community Porting Project Links + +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. - Cortex-M3: -The **kernel/liteos\_m/targets/cortex-m3\_stm32f103\_simulator\_keil** directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the **cortex-m3\_stm32f103\_simulator\_keil/project** directory and double-click the **los\_demo.uvproj** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility. + - STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil + + This repository provides the Keil project code for building the OpenHarmony LiteOS-M kernel based on the STM32F103 chip architecture. This code supports build in Keil MDK mode. - Cortex-M4: -The **kernel/liteos\_m/targets/cortex-m4\_stm32f429ig\_fire-challenger\_iar** directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the **cortex-m4\_stm32f429ig\_fire-challenger\_iar/project** directory and double-click the **los\_demo.eww** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility. + - STM32F429IGTb (https://gitee.com/harylee/stm32f429ig_firechallenger) + + 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. - Cortex-M7: -The **kernel/liteos\_m/targets/cortex-m7\_nucleo\_f767zi\_gcc** directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows: + - Nucleo-F767ZI (https://gitee.com/harylee/nucleo_f767zi) -``` -cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc -make clean; make -``` - -After the compilation is successful, the executable file **NUCLEO-F767.hex** is generated in the **cortex-m7\_nucleo\_f767zi\_gcc/build** directory. Burn the file to the corresponding board using STM32 ST-LINK Utility. + This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the Nucleo-F767ZI development board. The code supports build in Ninja, GCC, and IAR modes. ## Repositories Involved -[Kernel subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel.md) +[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) **kernel\_liteos\_m** - From 55a68dcd2d89cdaa272d68ab05eafabf2413ca26 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 4 Nov 2021 07:21:18 +0000 Subject: [PATCH 2/6] update README.md. Signed-off-by: Annie_wang --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca6c7eed..46eb3493 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,11 @@ ## Introduction -OpenHarmony LiteOS-M is a lightweight operating system kernel designed for the Internet of Things (IoT) field. It features small footprint, low power consumption, and high performance. It has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory. The LiteOS-M kernel is divided into the hardware layer and hardware-irrelevant layers. The hardware layer provides a unified hardware abstraction layer (HAL) interface for easier hardware adaptation. A range of compilation toolchains can be used with different chip architectures to meet the expansion of diversified hardware and compilation toolchains in the Artificial Intelligence of Things (AIoT) field.**Figure1** shows the architecture of the LiteOS-M kernel. +OpenHarmony LiteOS-M is a lightweight operating system kernel designed for the Internet of Things (IoT) field. It features small footprint, low power consumption, and high performance. It has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory. The LiteOS-M kernel is divided into the hardware layer and hardware-irrelevant layers. The hardware layer provides a unified hardware abstraction layer (HAL) interface for easier hardware adaptation. A range of compilation toolchains can be used with different chip architectures to meet the expansion of diversified hardware and compilation toolchains in the Artificial Intelligence of Things (AIoT) field. +**Figure1** shows the architecture of the LiteOS-M kernel. **Figure 1** Architecture of the OpenHarmony LiteOS-M kernel + ![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "OpenHarmony-LiteOS-M Kernel Architecture") ## Directory Structure @@ -56,7 +58,7 @@ Before setting up the environment for a development board, you must set up the b ### Obtaining the OpenHarmony Source Code -Obtain the latest OpenHarmony source code through Git clone on a Linux server. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. +Obtain the latest OpenHarmony source code through Git clone on a Linux server. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. ### Obtaining the Source Code of the Sample Project From 14fe10a3ff623d7f85ba762656c68e4ab0e39a4d Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 4 Nov 2021 07:28:05 +0000 Subject: [PATCH 3/6] update README.md. Signed-off-by: Annie_wang --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46eb3493..bf9f4745 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The LiteOS-M kernel porting projects for specific development boards are provide - Cortex-M3: - - STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil + - STM32F103(https://gitee.com/rtos_lover/stm32f103_simulator_keil) This repository provides the Keil project code for building the OpenHarmony LiteOS-M kernel based on the STM32F103 chip architecture. This code supports build in Keil MDK mode. @@ -123,6 +123,6 @@ The LiteOS-M kernel porting projects for specific development boards are provide ## Repositories Involved -[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) +[Kernel Subsystem](https://gitee.com/Annie_wang/docs/blob/master/en/readme/kernel-subsystem.md) **kernel\_liteos\_m** From 03941ee363401919b7991af204ab04a443315260 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 4 Nov 2021 07:31:35 +0000 Subject: [PATCH 4/6] update README.md. Signed-off-by: Annie_wang --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf9f4745..3033fd1d 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The LiteOS-M kernel porting projects for specific development boards are provide - Cortex-M3: - - STM32F103(https://gitee.com/rtos_lover/stm32f103_simulator_keil) + - STM32F103 (https://gitee.com/rtos_lover/stm32f103_simulator_keil) This repository provides the Keil project code for building the OpenHarmony LiteOS-M kernel based on the STM32F103 chip architecture. This code supports build in Keil MDK mode. @@ -123,6 +123,6 @@ The LiteOS-M kernel porting projects for specific development boards are provide ## Repositories Involved -[Kernel Subsystem](https://gitee.com/Annie_wang/docs/blob/master/en/readme/kernel-subsystem.md) +[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md) **kernel\_liteos\_m** From cfc5a0a1bac78c58466eb3d318380a18b7a207af Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 4 Nov 2021 07:34:32 +0000 Subject: [PATCH 5/6] update README.md. Signed-off-by: Annie_wang --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3033fd1d..14febac6 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,9 @@ For details about the directory of the sample code, see [Board-Level Directory S ### Building and Running Before the build, configure the **bin** directory of the cross compilation toolchain in the **PATH** environment variable or set **board_toolchain_path** in the **device/st/nucleo_f767zi/liteos_m/config.gni** file to the **bin** directory of the cross compilation toolchain. -In the **OpenHarmony** root directory, run the **hb set** command to set the product path, select **nucleo_f767zi**, and run the **hb build** command to start the build. Example: +In the **OpenHarmony** root directory, run the **hb set** command to set the product path, select **nucleo_f767zi**, and run the **hb build** command to start the build. + +Example: ``` user@dev:~/OpenHarmony$ hb set From 9f2765cfa86eed7c518deb62e9a1a06f411ea188 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Fri, 5 Nov 2021 03:43:45 +0000 Subject: [PATCH 6/6] update README.md. Signed-off-by: Annie_wang --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 14febac6..990616be 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Before setting up the environment for a development board, you must set up the b ### Obtaining the OpenHarmony Source Code -Obtain the latest OpenHarmony source code through Git clone on a Linux server. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. +Obtain the latest OpenHarmony source code through Git clone on a Linux server. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. ### Obtaining the Source Code of the Sample Project @@ -107,19 +107,19 @@ The LiteOS-M kernel porting projects for specific development boards are provide - Cortex-M3: - - STM32F103 (https://gitee.com/rtos_lover/stm32f103_simulator_keil) + - STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil This repository provides the Keil project code for building the OpenHarmony LiteOS-M kernel based on the STM32F103 chip architecture. This code supports build in Keil MDK mode. - Cortex-M4: - - STM32F429IGTb (https://gitee.com/harylee/stm32f429ig_firechallenger) + - STM32F429IGTb https://gitee.com/harylee/stm32f429ig_firechallenger 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. - Cortex-M7: - - Nucleo-F767ZI (https://gitee.com/harylee/nucleo_f767zi) + - Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the Nucleo-F767ZI development board. The code supports build in Ninja, GCC, and IAR modes.