Go to file
kenneth adc21052b2 fix: liteos_kernel_only=true编译内核报错
修复单独编译内核报错的问题

close #I4O204

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-25 14:10:01 +08:00
.gitee add issue and pr template 2021-04-07 14:49:54 +08:00
arch fix:fix bug of exception 2021-12-17 09:37:03 +08:00
components !442 M核posix接口fs模块用例完善 2021-12-19 08:12:27 +00:00
drivers feat(build): support Kconfig 2021-11-05 12:18:04 +08:00
figures update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
kal fix: 添加newlib对ipv6的支持 2021-12-18 19:35:10 +08:00
kernel fix:Fix spelling errors 2021-12-20 09:35:58 +08:00
targets !422 【轻量级 PR】:[fix] fix target build error 2021-11-25 02:45:17 +00:00
testsuites !474 fix: 修复L0_Emulator 门禁高概率失败的问题 2021-12-20 08:18:56 +00:00
tools feat: 新增ROM/RAM分析工具 2021-08-14 15:19:47 +08:00
utils feat: 低内存资源回收low memory killer 2021-12-13 12:07:33 +08:00
.gitignore feat(build): support Kconfig 2021-11-05 12:18:04 +08:00
BUILD.gn chore(build): set complete_static_lib false for libkernel 2021-12-08 17:53:53 +08:00
Kconfig feat: 低内存资源回收low memory killer 2021-12-13 12:07:33 +08:00
LICENSE update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
Makefile fix: liteos_kernel_only=true编译内核报错 2021-12-25 14:10:01 +08:00
NOTICE update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
OAT.xml 修复OAT.xml文件中路径错误。 2021-11-26 17:37:55 +08:00
README.md fix: ReadMe中无对动态加载模块待加载的共享库的限制说明。 2021-11-17 10:22:23 +08:00
README_zh.md fix: ReadMe中无对动态加载模块待加载的共享库的限制说明。 2021-11-17 10:22:23 +08:00
arch_spec.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
arch_spec_zh.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
liteos.gni chore(build): optimize build scripts 2021-12-05 02:29:49 +08:00

README.md

LiteOS-M Kernel

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.

Figure 1 Architecture of the OpenHarmony LiteOS-M kernel

Directory Structure

The directory structure is as follows. For more details, see arch_spec.md.

/kernel/liteos_m
├── components           # Optional components
│   ├── backtrace        # Backtrace support
│   ├── cppsupport       # C++ 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 API support
│   └── posix            # POSIX API support
├── kernel               # Minimum kernel function set
│   ├── arch             # Code of the kernel instruction architecture layer
│   │   ├── arm          # Code of the Arm32 architecture
│   │   └── include      # APIs exposed externally
│   ├── include          # APIs exposed externally
│   └── src              # Source code of the minimum kernel function set
├── targets              # Board-level projects
├── utils                # Common directory

Constraints

OpenHarmony LiteOS-M supports only C and C++.

It applies only to Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V chip architectures.

As for dynamic loading module, the shared library to be loaded needs signature verification or source restriction to ensure security.

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+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. 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.

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. 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. If you need to port the development board, see Board-Level OS Porting.

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.

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:

  • Cortex-M4:

  • Cortex-M7:

    • 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.

Repositories Involved

Kernel Subsystem

kernel_liteos_m