• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# LiteOS-A Overview
2
3## Overview
4
5The OpenHarmony lightweight kernel is a next-generation kernel that evolved from the kernel of Huawei LiteOS, a lightweight IoT operating system. The kernel comes with two patterns: LiteOS-M and LiteOS-A. The LiteOS-M kernel is designed for the mini system, which supports a Microcontroller Unit (MCU), memory of kilobytes, and Memory Protection Unit (MPU) isolation. Typical counterparts in the industry include FreeRTOS and ThreadX. The LiteOS-A kernel is ideal for the small system, which supports memory of megabytes and Memory Management Unit (MMU) isolation. Equivalent kernels include Zircon and Darwin.
6
7>![](../public_sys-resources/icon-note.gif) **NOTE:**
8>OpenHarmony provides different kernels for different systems. The small system supports LiteOS and Linux. This document applies to the LiteOS-A kernel. For details about operations related to the Linux kernel, see  [Linux Kernel Overview](kernel-standard-overview.md).
9
10To keep pace with the rapid development of the IoT industry, the OpenHarmony lightweight kernel is continuously optimized and expanded to provide application developers with friendly development experience and unified and open ecosystem capabilities. The LiteOS-A has the following new features:
11
12-   Diversified kernel mechanisms
13
14    Mechanisms such as virtual memory, system calling, multi-core, lightweight Inter-Process Communication \(IPC\), and Discretionary Access Control \(DAC\) are added to enrich kernel capabilities. To improve compatibility with software and developer experience, multiple processes are supported to isolate memory between applications and improve system robustness.
15
16-   Unified hardware driver foundation \(HDF\)
17
18    The HDF provides unified driver standards and access mode for device vendors. This simplifies porting of drivers and allows one-time development for multi-device deployment.
19
20-   1200+ standard POSIX APIs
21
22    The kernel supports more Portable Operating System Interface \(POSIX\) APIs, which facilitate software development and porting and improve developers' experience.
23
24-   Decoupling between the kernel and hardware
25
26    The lightweight kernel is highly decoupled from the hardware. New board can be added without modifying the kernel code.
27
28
29## Kernel Architecture<a name="section827143517385"></a>
30
31The lightweight kernel consists of the basic kernel, extended components, HDF, and POSIX APIs. Different from the microkernel which is running in the user mode, the extended functions, such as the file system and network protocols, of the lightweight kernel are running in the kernel address space. The direct function calling between components is much faster than inter-process communication \(IPC\) or remote procedure calls \(RPCs\).
32
33**Figure  1**  Architecture of the OpenHarmony LiteOS-A kernel<a name="fig10235830103519"></a>
34![](figures/Liteos-a-architecture.png "architecture-of-the-openharmony-liteos-a-kernel")
35
36-   The basic kernel implements basic kernel mechanisms, such as scheduling, memory management, and interrupts.
37-   Extended components include file systems, network protocols, permission management, and more.
38-   The HDF provides a unified standard framework for peripheral drivers.
39-   The POSIX APIs allow POSIX-compliant applications to be easily ported to the OpenHarmony.
40
41**Basic Kernel**
42
43The basic kernel implements the following mechanisms:
44
45-   Process management: manages processes and threads and supports task-based process implementation. Processes have independent 4 GiB address space.
46-   Multi-core scheduling: supports CPU affinity settings, allowing the binding and unbinding of a task or interrupt to one or more CPU cores.
47-   Real-time scheduling: schedules tasks based on priorities. The tasks of the same priority are scheduled by using the time slice polling.
48-   Virtual memory: supports static mapping of the kernel space to 0-1 GiB addresses, and mapping of the user space to 1-4 GiB addresses.
49-   Kernel communication: supports events, semaphores, mutexes, and queues.
50-   Time management: supports software timers and the system clock.
51
52**File systems**
53
54The LiteOS-A supports multiple file systems, such as FAT, JFFS2, NFS, ramfs, and procfs, and provides complete standard POSIX APIs. The VFS layer is used as the unified adaptation layer framework, which facilitates the porting of new file systems. Each file system can automatically use the rich functions provided by the VFS layer.
55
56The following features are supported:
57
58-   Complete POSIX API support
59-   File-level cache \(PageCache\)
60-   Disk-level cache \(Bcache\)
61-   Directory cache \(path cache\)
62-   DAC capability
63-   Nested mounting and file system stacking
64-   Feature tailoring and flexible configuration of resource usage
65
66**Network Protocols**
67
68The LiteOS-A network protocols are constructed based on the open-source lightweight IP \(lwIP\), optimizing the RAM usage while improving the transmission performance over lwIP.
69
70-   Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, and PPPoE
71-   API: socket API
72-   Extended features: IP forwarding based on multiple network ports, TCP congestion control, round-trip time \(RTT\) estimation, and fast recovery/retransmission
73-   Application programs: HTTP\(S\) service, SNTP client, SMTP\(S\) client, ping tool, NetBIOS name service, mDNS response program, MQTT client, TFTP service, DHCP client, DNS client, AutoIP/APIPA \(zero configuration\), and SNMP agent
74
75**HDF**
76
77The LiteOS-A integrates the HDF framework. The HDF framework provides a more precise and efficient development environment, aiming to realize one-time development for multi-device deployment. The HDF supports:
78
79-   Multi-kernel platform
80-   User-mode drivers
81-   Configurable component-based driver model
82-   Message-based driver interface model
83-   Object-based driver and device management
84-   Unified hardware device interface \(HDI\)
85-   Power management and plug and play \(PnP\)
86
87**Extended Components**
88
89Extended components provide optional but important mechanism for extending kernel functions.
90
91-   Dynamic linking: supports standard Executable and Linkable Format \(ELF\) execution and randomization of loading addresses.
92-   IPC: supports LiteIPC and standard mechanisms such as Mqueue, Pipe, FIFO, and Signal.
93-   System calling: supports 170+ system calls and the virtual dynamic shared object \(vDSO\) mechanism.
94-   Permission management: supports process-based privilege division and control, and file user, group, and other \(UGO\) permission configuration.
95## Directory Structure<a name="section161941989596"></a>
96
97```text
98/kernel/liteos_a
99├── apps                   # User-space init and shell application programs
100├── arch                   # System architecture, such as ARM
101│   └── arm                # Code for ARM architecture
102├── bsd                    # Code of the driver and adaptation layer module related to the FreeBSD, such as the USB module
103├── compat                 # Kernel API compatibility
104│   └── posix              # POSIX APIs
105├── drivers                # Kernel drivers
106│   └── char               # Character device
107│       ├── mem            # Driver for accessing physical input/output (I/O) devices
108│       ├── quickstart     # APIs for quick start of the system
109│       ├── random         # Driver for random number generators
110│       └── video          # Framework of the framebuffer driver
111├── fs                     # File system module, which mainly derives from the NuttX open-source project
112│   ├── fat                # FAT file system
113│   ├── jffs2              # JFFS2 file system
114│   ├── include            # Header files exposed externally
115│   ├── nfs                # NFS file system
116│   ├── proc               # proc file system
117│   ├── ramfs              # RAMFS file system
118│   └── vfs                # VFS layer
119├── kernel                 # Kernel modules including the process, memory, and IPC modules
120│   ├── base               # Basic kernel modules including the scheduling and memory modules
121│   ├── common             # Common components used by the kernel
122│   ├── extended           # Extended kernel modules including the dynamic loading, vDSO, and LiteIPC modules
123│   ├── include            # Header files exposed externally
124│   └── user               # Init process loading
125├── lib                    # Kernel library
126├── net                    # Network module, which mainly derives from the lwIP open-source project
127├── platform               # Code for supporting different systems on a chip (SOCs), such as Hi3516D V300
128│   ├── hw                 # Logic code related to clocks and interrupts
129│   ├── include            # Header files exposed externally
130│   └── uart               # Logic code related to the serial port
131├── platform               # Code for supporting different systems on a chip (SOCs), such as Hi3516D V300
132├── security               # Code related to security features, including process permission management and virtual ID mapping management
133├── syscall                # System calling
134└── tools                  # Building tools as well as related configuration and code
135```
136
137## Constraints<a name="section119744591305"></a>
138
139-   Programming languages: C and C++
140-   Applicable development boards: Hi3516D V300
141-   Hi3516D V300 uses the FAT file system by default.
142
143## Usage<a name="section741617511812"></a>
144
145OpenHarmony LiteOS Cortex-A supports the  [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-appendix-hi3516.md). You can develop and run your applications based on this development board.
146
147### Preparations<a name="section1579912573329"></a>
148
149You need to [set up the compilation environment](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-prepare.md) on Linux.
150
151
152### Source Code Acquisition<a name="section11443189655"></a>
153
154Download and decompress a set of source code on a Linux server to acquire the  [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
155
156### Compilation and Building<a name="section2081013992812"></a>
157
158For details about how to develop the first application, see:
159
160-   [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-running.md)
161
162## Repositories Involved<a name="section1371113476307"></a>
163
164[Kernel subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
165
166[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README.md)
167
168[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README.md)
169
170
171