• Home
Name Date Size #Lines LOC

..--

arch/12-May-2024-71,23332,257

components/12-May-2024-26,81917,573

drivers/12-May-2024-118

figures/12-May-2024-

kal/12-May-2024-11,5017,817

kernel/12-May-2024-15,0417,319

testsuites/12-May-2024-104,73453,401

tools/12-May-2024-353296

utils/12-May-2024-2,215924

.gitignoreD12-May-2024246 2220

BUILD.gnD12-May-20245.6 KiB219185

CHANGELOG.mdD12-May-202455 KiB466423

KconfigD12-May-202414.7 KiB539433

LICENSED12-May-20241.6 KiB2923

MakefileD12-May-20244.1 KiB12370

NOTICED12-May-2024782 97

OAT.xmlD12-May-20246.3 KiB8738

README.mdD12-May-20247.4 KiB12687

README_zh.mdD12-May-20246.4 KiB12687

arch_spec.mdD12-May-20248 KiB9189

arch_spec_zh.mdD12-May-20247.7 KiB9088

bundle.jsonD12-May-20241.4 KiB6261

config.gniD12-May-20245.8 KiB211187

config_iccarm.gniD12-May-20244.2 KiB153129

liteos.gniD12-May-20246.2 KiB183167

README.md

1# LiteOS-M Kernel<a name="EN-US_TOPIC_0000001096757661"></a>
2
3-   [Introduction](#section11660541593)
4-   [Directory Structure](#section161941989596)
5-   [Constraints](#section119744591305)
6-   [Usage](#section3732185231214)
7-   [Contribution](#section1371123476307)
8-   [Repositories Involved](#section1371113476307)
9
10## Introduction<a name="section11660541593"></a>
11
12OpenHarmony 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.
13**Figure1** shows the architecture of the LiteOS-M kernel.
14
15**Figure 1** Architecture of the OpenHarmony LiteOS-M kernel<a name="fig0865152210223"></a>
16
17![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "OpenHarmony-LiteOS-M Kernel Architecture")
18
19## Directory Structure<a name="section161941989596"></a>
20
21The directory structure is as follows. For more details, see [arch_spec.md](arch_spec.md).
22
23```
24/kernel/liteos_m
25├── arch                 # Code of the kernel instruction architecture layer
26│   ├── arm              # Code of the ARM32 architecture
27│   │   ├── arm9         # Code of the ARM9 architecture
28│   │   ├── cortex-m3    # Code of the cortex-m3 architecture
29│   │   ├── cortex-m33   # Code of the cortex-m33 architecture
30│   │   ├── cortex-m4    # Code of the cortex-m4 architecture
31│   │   ├── cortex-m7    # Code of the cortex-m7 architecture
32│   │   └── include      # Arm architecture public header file directory
33│   ├── csky             # Code of the csky architecture
34│   │   └── v2           # Code of the csky v2 architecture
35│   ├── include          # APIs exposed externally
36│   ├── risc-v           # Code of the risc-v architecture
37│   │   ├── nuclei       # Code of the nuclei system technology risc-v architecture
38│   │   └── riscv32      # Code of the risc-v official common architecture
39│   └── xtensa           # Code of the xtensa architecture
40│       └── lx6          # Code of the lx6 xtensa architecture
41├── components           # Optional components
42│   ├── backtrace        # Backtrace support
43│   ├── cppsupport       # C++ support
44│   ├── cpup             # CPU percent (CPUP)
45│   ├── dynlink          # Dynamic loading and linking
46│   ├── exchook          # Exception hooks
47│   ├── fs               # File systems
48│   ├── lmk              # Low memory killer functions
49│   ├── lms              # Lite memory sanitizer functions
50│   ├── net              # Networking functions
51│   ├── power            # Power management
52│   ├── shell            # Shell function
53│   ├── fs               # File systems
54│   └── trace            # Trace tool
55├── drivers              # driver Kconfig
56├── kal                  # Kernel abstraction layer
57│   ├── cmsis            # CMSIS API support
58│   └── posix            # POSIX API support
59├── kernel               # Minimum kernel function set
60│   ├── include          # APIs exposed externally
61│   └── src              # Source code of the minimum kernel function set
62├── testsuites           # Kernel testsuites
63├── tools                # Kernel tools
64├── utils                # Common directory
65```
66
67## Constraints<a name="section119744591305"></a>
68
69OpenHarmony LiteOS-M supports only C and C++.
70
71Applicable architecture: See the directory structure for the arch layer.
72
73As for dynamic loading module, the shared library to be loaded needs signature verification or source restriction to ensure security.
74
75## Usage<a name="section3732185231214"></a>
76
77The 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.
78
79### Setting Up the Environment
80
81Before 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).
82
83### Obtaining the OpenHarmony Source Code
84
85For 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.
86
87### Example projects
88
89Qemu 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).
90
91Bestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
92
93### Community Porting Project Links
94
95The 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.
96
97-   Cortex-M3:
98
99    - STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil
100
101        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.
102
103-   Cortex-M4:
104
105    - STM32F429IGTb https://gitee.com/harylee/stm32f429ig_firechallenger
106
107        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.
108
109## Contribution<a name="section1371123476307"></a>
110
111[How to involve](https://gitee.com/openharmony/docs/blob/master/en/contribute/how-to-contribute.md)
112
113[Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
114
115[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)
116
117How to contribute a chip based on Liteos-M kernel:
118
119[Mini System SoC Porting Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/porting/Readme-EN.md)
120
121## Repositories Involved<a name="section1371113476307"></a>
122
123[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
124
125[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)
126

README_zh.md

1# LiteOS-M内核<a name="ZH-CN_TOPIC_0000001096757661"></a>
2
3-   [简介](#section11660541593)
4-   [目录](#section161941989596)
5-   [约束](#section119744591305)
6-   [使用说明](#section3732185231214)
7-   [贡献](#section1371123476307)
8-   [相关仓](#section1371113476307)
9
10## 简介<a name="section11660541593"></a>
11
12OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核,具有小体积、低功耗、高性能的特点,其代码结构简单,主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等,分为硬件相关层以及硬件无关层,硬件相关层提供统一的HAL(Hardware Abstraction Layer)接口,提升硬件易适配性,不同编译工具链和芯片架构的组合分类,满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示:
13
14**图 1**  OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
15![](figures/OpenHarmony-LiteOS-M核内核架构图.png "OpenHarmony-LiteOS-M核内核架构图")
16
17## 目录<a name="section161941989596"></a>
18
19目录结构如下,详细目录请参考[arch_spec_zh.md](arch_spec_zh.md)。
20
21```
22/kernel/liteos_m
23├── arch                 # 内核指令架构层目录
24│   ├── arm              # arm 架构代码
25│   │   ├── arm9         # arm9 架构代码
26│   │   ├── cortex-m3    # cortex-m3架构代码
27│   │   ├── cortex-m33   # cortex-m33架构代码
28│   │   ├── cortex-m4    # cortex-m4架构代码
29│   │   ├── cortex-m55   # cortex-m55架构代码
30│   │   ├── cortex-m7    # cortex-m7架构代码
31│   │   └── include      # arm架构公共头文件目录
32│   ├── csky             # csky架构代码
33│   │   └── v2           # csky v2架构代码
34│   ├── include          # 架构层对外接口存放目录
35│   ├── risc-v           # risc-v 架构
36│   │   ├── nuclei       # 芯来科技risc-v架构代码
37│   │   └── riscv32      # risc-v官方通用架构代码
38│   └── xtensa           # xtensa 架构代码
39│       └── lx6          # xtensa lx6架构代码
40├── components           # 可选组件
41│   ├── backtrace        # 栈回溯功能
42│   ├── cppsupport       # C++支持
43│   ├── cpup             # CPUP功能
44│   ├── dynlink          # 动态加载与链接
45│   ├── exchook          # 异常钩子
46│   ├── fs               # 文件系统
47│   ├── lmk              # Low memory killer 机制
48│   ├── lms              # Lite memory sanitizer 机制
49│   ├── net              # Network功能
50│   ├── power            # 低功耗管理
51│   ├── shell            # shell功能
52│   └── trace            # trace 工具
53├── drivers              # 驱动框架Kconfig
54├── kal                  # 内核抽象层
55│   ├── cmsis            # cmsis标准接口支持
56│   └── posix            # posix标准接口支持
57├── kernel               # 内核最小功能集支持
58│   ├── include          # 对外接口存放目录
59│   └── src              # 内核最小功能集源码
60├── testsuites           # 内核测试用例
61├── tools                # 内核工具
62├── utils                # 通用公共目录
63```
64
65## 约束<a name="section119744591305"></a>
66
67开发语言:C/C++;
68
69适用架构:详见目录结构arch层。
70
71动态加载模块:待加载的共享库需要验签或者限制来源,确保安全性。
72
73## 使用说明<a name="section3732185231214"></a>
74
75OpenHarmony
76LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建系统,支持按组件配置、裁剪和拼装,按需构建出定制化的产品。本文主要介绍如何基于gn和ninja编译LiteOS-M工程,GCC+gn、IAR、Keil MDK等编译方式可以参考社区爱好者贡献的站点。
77
78### 搭建系统基础环境
79
80在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md)。开发者需要根据环境搭建文档完成环境搭建。
81
82### 获取OpenHarmony源码
83
84详细的源码获取方式,请见[源码获取](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后,假设克隆目录为`~/openHarmony`。
85
86### 已支持的示例工程
87
88Qemu模拟器: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, 编译运行详见: [Qemu指导](https://gitee.com/openharmony/device_qemu)
89
90恒玄科技: `bes2600`, 编译运行详见: [恒玄开发指导](https://gitee.com/openharmony/device_soc_bestechnic)
91
92### 社区移植工程链接
93
94LiteOS-M内核移植的具体开发板的工程由社区开发者提供,可以访问社区开发者代码仓获取。如果您移植支持了更多开发板,可以提供链接给我们进行社区分享。
95
96-   cortex-m3:
97
98    - STM32F103   https://gitee.com/rtos_lover/stm32f103_simulator_keil
99
100        该仓包含OpenHarmony LiteOS-M内核基于STM32F103芯片架构构建的Keil工程,支持Keil MDK方式进行编译。
101
102-   cortex-m4:
103
104    - 野火挑战者STM32F429IGTb   https://gitee.com/harylee/stm32f429ig_firechallenger
105
106        该仓包含OpenHarmony LiteOS-M内核移植支持`野火挑战者STM32F429IGTb`开发板的工程代码,支持Ninja、GCC、IAR等方式进行编译。
107
108## 贡献<a name="section1371123476307"></a>
109
110[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
111
112[Commit message规范](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
113
114[Liteos-M 内核编码规范](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)
115
116如何基于Liteos-M内核贡献一款芯片:
117
118[轻量系统芯片移植指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/Readme-CN.md)
119
120## 相关仓<a name="section1371113476307"></a>
121
122[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
123
124[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README_zh.md)
125
126