13d8536b4Sopenharmony_ci# LiteOS-M Kernel<a name="EN-US_TOPIC_0000001096757661"></a>
23d8536b4Sopenharmony_ci
33d8536b4Sopenharmony_ci-   [Introduction](#section11660541593)
43d8536b4Sopenharmony_ci-   [Directory Structure](#section161941989596)
53d8536b4Sopenharmony_ci-   [Constraints](#section119744591305)
63d8536b4Sopenharmony_ci-   [Usage](#section3732185231214)
73d8536b4Sopenharmony_ci-   [Contribution](#section1371123476307)
83d8536b4Sopenharmony_ci-   [Repositories Involved](#section1371113476307)
93d8536b4Sopenharmony_ci
103d8536b4Sopenharmony_ci## Introduction<a name="section11660541593"></a>
113d8536b4Sopenharmony_ci
123d8536b4Sopenharmony_ciOpenHarmony 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.
133d8536b4Sopenharmony_ci**Figure1** shows the architecture of the LiteOS-M kernel.
143d8536b4Sopenharmony_ci
153d8536b4Sopenharmony_ci**Figure 1** Architecture of the OpenHarmony LiteOS-M kernel<a name="fig0865152210223"></a>
163d8536b4Sopenharmony_ci
173d8536b4Sopenharmony_ci![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "OpenHarmony-LiteOS-M Kernel Architecture")
183d8536b4Sopenharmony_ci
193d8536b4Sopenharmony_ci## Directory Structure<a name="section161941989596"></a>
203d8536b4Sopenharmony_ci
213d8536b4Sopenharmony_ciThe directory structure is as follows. For more details, see [arch_spec.md](arch_spec.md).
223d8536b4Sopenharmony_ci
233d8536b4Sopenharmony_ci```
243d8536b4Sopenharmony_ci/kernel/liteos_m
253d8536b4Sopenharmony_ci├── arch                 # Code of the kernel instruction architecture layer
263d8536b4Sopenharmony_ci│   ├── arm              # Code of the ARM32 architecture
273d8536b4Sopenharmony_ci│   │   ├── arm9         # Code of the ARM9 architecture
283d8536b4Sopenharmony_ci│   │   ├── cortex-m3    # Code of the cortex-m3 architecture
293d8536b4Sopenharmony_ci│   │   ├── cortex-m33   # Code of the cortex-m33 architecture
303d8536b4Sopenharmony_ci│   │   ├── cortex-m4    # Code of the cortex-m4 architecture
313d8536b4Sopenharmony_ci│   │   ├── cortex-m7    # Code of the cortex-m7 architecture
323d8536b4Sopenharmony_ci│   │   └── include      # Arm architecture public header file directory
333d8536b4Sopenharmony_ci│   ├── csky             # Code of the csky architecture
343d8536b4Sopenharmony_ci│   │   └── v2           # Code of the csky v2 architecture
353d8536b4Sopenharmony_ci│   ├── include          # APIs exposed externally
363d8536b4Sopenharmony_ci│   ├── risc-v           # Code of the risc-v architecture
373d8536b4Sopenharmony_ci│   │   ├── nuclei       # Code of the nuclei system technology risc-v architecture
383d8536b4Sopenharmony_ci│   │   └── riscv32      # Code of the risc-v official common architecture
393d8536b4Sopenharmony_ci│   └── xtensa           # Code of the xtensa architecture
403d8536b4Sopenharmony_ci│       └── lx6          # Code of the lx6 xtensa architecture
413d8536b4Sopenharmony_ci├── components           # Optional components
423d8536b4Sopenharmony_ci│   ├── backtrace        # Backtrace support
433d8536b4Sopenharmony_ci│   ├── cppsupport       # C++ support
443d8536b4Sopenharmony_ci│   ├── cpup             # CPU percent (CPUP)
453d8536b4Sopenharmony_ci│   ├── dynlink          # Dynamic loading and linking
463d8536b4Sopenharmony_ci│   ├── exchook          # Exception hooks
473d8536b4Sopenharmony_ci│   ├── fs               # File systems
483d8536b4Sopenharmony_ci│   ├── lmk              # Low memory killer functions
493d8536b4Sopenharmony_ci│   ├── lms              # Lite memory sanitizer functions
503d8536b4Sopenharmony_ci│   ├── net              # Networking functions
513d8536b4Sopenharmony_ci│   ├── power            # Power management
523d8536b4Sopenharmony_ci│   ├── shell            # Shell function
533d8536b4Sopenharmony_ci│   ├── fs               # File systems
543d8536b4Sopenharmony_ci│   └── trace            # Trace tool
553d8536b4Sopenharmony_ci├── drivers              # driver Kconfig
563d8536b4Sopenharmony_ci├── kal                  # Kernel abstraction layer
573d8536b4Sopenharmony_ci│   ├── cmsis            # CMSIS API support
583d8536b4Sopenharmony_ci│   └── posix            # POSIX API support
593d8536b4Sopenharmony_ci├── kernel               # Minimum kernel function set
603d8536b4Sopenharmony_ci│   ├── include          # APIs exposed externally
613d8536b4Sopenharmony_ci│   └── src              # Source code of the minimum kernel function set
623d8536b4Sopenharmony_ci├── testsuites           # Kernel testsuites
633d8536b4Sopenharmony_ci├── tools                # Kernel tools
643d8536b4Sopenharmony_ci├── utils                # Common directory
653d8536b4Sopenharmony_ci```
663d8536b4Sopenharmony_ci
673d8536b4Sopenharmony_ci## Constraints<a name="section119744591305"></a>
683d8536b4Sopenharmony_ci
693d8536b4Sopenharmony_ciOpenHarmony LiteOS-M supports only C and C++.
703d8536b4Sopenharmony_ci
713d8536b4Sopenharmony_ciApplicable architecture: See the directory structure for the arch layer.
723d8536b4Sopenharmony_ci
733d8536b4Sopenharmony_ciAs for dynamic loading module, the shared library to be loaded needs signature verification or source restriction to ensure security.
743d8536b4Sopenharmony_ci
753d8536b4Sopenharmony_ci## Usage<a name="section3732185231214"></a>
763d8536b4Sopenharmony_ci
773d8536b4Sopenharmony_ciThe 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.
783d8536b4Sopenharmony_ci
793d8536b4Sopenharmony_ci### Setting Up the Environment
803d8536b4Sopenharmony_ci
813d8536b4Sopenharmony_ciBefore 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 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md).
823d8536b4Sopenharmony_ci
833d8536b4Sopenharmony_ci### Obtaining the OpenHarmony Source Code
843d8536b4Sopenharmony_ci
853d8536b4Sopenharmony_ciFor 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.
863d8536b4Sopenharmony_ci
873d8536b4Sopenharmony_ci### Example projects
883d8536b4Sopenharmony_ci
893d8536b4Sopenharmony_ciQemu 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).
903d8536b4Sopenharmony_ci
913d8536b4Sopenharmony_ciBestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
923d8536b4Sopenharmony_ci
933d8536b4Sopenharmony_ci### Community Porting Project Links
943d8536b4Sopenharmony_ci
953d8536b4Sopenharmony_ciThe 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.
963d8536b4Sopenharmony_ci
973d8536b4Sopenharmony_ci-   Cortex-M3:
983d8536b4Sopenharmony_ci
993d8536b4Sopenharmony_ci    - STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil
1003d8536b4Sopenharmony_ci
1013d8536b4Sopenharmony_ci        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.
1023d8536b4Sopenharmony_ci
1033d8536b4Sopenharmony_ci-   Cortex-M4:
1043d8536b4Sopenharmony_ci
1053d8536b4Sopenharmony_ci    - STM32F429IGTb https://gitee.com/harylee/stm32f429ig_firechallenger
1063d8536b4Sopenharmony_ci
1073d8536b4Sopenharmony_ci        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.
1083d8536b4Sopenharmony_ci
1093d8536b4Sopenharmony_ci## Contribution<a name="section1371123476307"></a>
1103d8536b4Sopenharmony_ci
1113d8536b4Sopenharmony_ci[How to involve](https://gitee.com/openharmony/docs/blob/master/en/contribute/how-to-contribute.md)
1123d8536b4Sopenharmony_ci
1133d8536b4Sopenharmony_ci[Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
1143d8536b4Sopenharmony_ci
1153d8536b4Sopenharmony_ci[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)
1163d8536b4Sopenharmony_ci
1173d8536b4Sopenharmony_ciHow to contribute a chip based on Liteos-M kernel:
1183d8536b4Sopenharmony_ci
1193d8536b4Sopenharmony_ci[Mini System SoC Porting Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/porting/Readme-EN.md)
1203d8536b4Sopenharmony_ci
1213d8536b4Sopenharmony_ci## Repositories Involved<a name="section1371113476307"></a>
1223d8536b4Sopenharmony_ci
1233d8536b4Sopenharmony_ci[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
1243d8536b4Sopenharmony_ci
1253d8536b4Sopenharmony_ci[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)
126