Professional Documents
Culture Documents
Page 2 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
⚫ After completing this course, you will be able to:
Master the Huawei LiteOS architecture.
Master the basic kernel modules of Huawei LiteOS, understand the principles of
each module, and describe the functions of each module.
Page 3 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Huawei LiteOS Kernel
Page 4 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Framework
⚫ Huawei LiteOS is a lightweight IoT OS developed by Huawei. This system complies
with the BSD-3 open source license agreement and can be widely used in smart
homes, wearable devices, Internet of Vehicles (IOV), urban public services,
manufacturing and so on.
Industry applications
Security framework
Interconnection
framework consumption
IDE tools
AI JS engine
Page 5 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel
⚫ Huawei LiteOS Kernel, as the kernel of the
LiteOS, is the simplest Huawei LiteOS,
Basic kernel
which consists of basic OS components Memory
Dynamic memory
Time management
such as task management, memory System time
Static memory
synchronization
Hardware
Semaphore
management, and timer. The Huawei
Task
Hardware interrupt
Mutex
LiteOS Kernel can run independently. Exception
Page 6 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Task
⚫ A task is the minimum running unit to compete for system resources. A task can
use or wait for system resources such as Central Processing Unit (CPU) and
memory and run independently.
⚫ The Huawei LiteOS tasks have 32 priorities: 0-31. The highest priority is 0, and the
lowest is 31. A task with a higher priority can preempt a task with a lower one. A
task with a lower priority can be scheduled only after the task with a higher one is
blocked or ended.
Page 7 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Task Programming Instance
⚫ Task interface description:
⚫ Compilation result:
Page 8 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Memory Management
⚫ Memory is a very important resource in a system. Memory management, a
core function of the OS, is to initialize, allocate, and release memory
resources.
Page 9 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Dynamic Memory
⚫ A random-size of memory block in the dynamic memory pool is allocated to a user.
⚫ All memory blocks are linked together using linked lists. A TLSF has multiple linked
lists. When a memory block is released to the memory pool, the idle blocks before
and after the memory block are linked automatically. Each block starts with a
header structure for management. Allocated blocks also have this header structure.
⚫ Advantages
Allocation on demand; large blocks are cost-effective.
⚫ Disadvantages
Memory waste in case of massive small blocks due to the header for management
⚫ Advantages
High performance, compared with that of dynamic memory management
High efficiency in memory allocation and releasing, because of no header structure for
management in each block
⚫ Disadvantages
Fixed size, not allocated on demand
⚫ Compilation result:
Page 12 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Interrupt
⚫ An interrupt refers to the process in which the CPU stops to execute a new program when
necessary.
⚫ With the interrupt mechanism, the CPU can execute other tasks when the peripherals do
not require the CPU. When the peripherals require the CPU, the CPU can interrupt the
current task to respond to the interrupt request by generating the interrupt signal. In this
way, the CPU does not need to spend a lot of time in waiting and querying the peripheral
status.
⚫ An interrupt can be initialized, created, started, stopped, resumed, enabled, and masked.
Page 13 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Task Communication
⚫ The multi-task synchronization, mutual exclusion, and communication of
Huawei LiteOS are as follows:
Queue
Event
Semaphore
Mutex
Page 14 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Queue
⚫ A queue, also called message queue, is a data structure commonly used for
inter-task communication. A queue receives messages of variable lengths
from tasks or interrupts and determines whether to store messages in its
own space based on interfaces.
Page 15 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Event
⚫ An event is a mechanism for implementing communication between tasks. It can be used to
implement synchronization between tasks. However, event communication can only be
communication of event type and does not involve data transmission.
⚫ An event is not associated with a task. Events are independent of each other. A 32-bit
variable is used to identify the type of an event that occurs in a task. Each bit indicates an
event type. There are 31 event types (the 25th digitbit is reserved). The value 0 indicates
that the event does not occur, and the value 1 indicates that the event already occurs.
Sending the same event type to a task for multiple times is equivalent to sending the event type to
the task only once.
Page 16 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Semaphore
⚫ A semaphore, as a mechanism for inter-task communication, enables tasks
to access system resources synchronously or access critical resources
exclusively. Typically, a semaphore is used to coordinate a group of
competing tasks to access to critical resources.
Page 17 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Mutex
⚫ A mutex is a special binary semaphore used to exclusively process shared
resources.
When the task releases the mutex, the mutex is unlocked and the task loses the
ownership of the mutex. When a task holds a mutex, other tasks cannot unlock
or hold the mutex.
Page 18 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Time Management
⚫ Time management is based on the system clock. Time management provides all
time-related services for applications.
When the output pulse generated by a timer or counter triggers an interrupt, the system
clock is generated. The system clock is generally defined as an integer or a long integer.
The period of the output pulse is called a "Tick". The system clock is also called time
scale or Tick. The duration of a Tick can be configured statically.
The timing unit is second or millisecond, while the unit of the chip CPU timing is Tick.
When a user needs to perform an operation on the system, for example, task suspension
or delay, the user needs to input a value in second. In this case, unit conversion is
required.
Page 19 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS Kernel—Timer
⚫ Hardware timers are limited and cannot meet user requirements. Huawei
LiteOS provides the software timer function.
Page 20 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Features of Huawei LiteOS Kernel
⚫ Low power consumption, high real-time performance, and high stability
⚫ Static tailoring
Page 21 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Huawei LiteOS Kernel
Page 22 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS SDK
⚫ Huawei LiteOS software development kit (SDK) includes the device-cloud
interconnection component, JS engine, and smart sensing framework.
User applications
LwM2M MQTT
Component
Attention adapter Automatically
Enhanced
CoAP UART configured
TLS Abstract module
DTLS Device PnP
Page 23 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Device-Cloud Interconnection Component
⚫ As an independent component, the LiteOS SDK device-cloud interconnection
component does not depend on specific chip architecture or network hardware
type and can be easily integrated into various communication modules, such as
the Narrow Band Internet of Things (NB-IoT) module, enhanced Machine-Type
Communication (eMTC) module, Wi-Fi module, Global System for Mobile
Communications (GSM) module, and Ethernet hardware.
Page 24 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Software Architecture of Device-Cloud
Interconnection Component
IoT cloud
platform
IoT cloud
platform
Chip/Module/MCU
Chip/Module/MCU
Page 25 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Interconnection Framework
Page 27 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Security Framework
Device-cloud security Whitelist
Transmission
Secure ID Bidirectional device RPL
security
authentication
Terminal
security
Key management Security firmware/Application Network layer security
upgrade
Page 28 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
JS Running Engine—MapleJS
⚫ MapleJS: enables advanced IoT dynamic languages to help developers focus on application
development.
Network Optimization
library, industrial control Module-driven OS adaptation
adaptation
device capability library... programming
library
library Language check
tool
Deployment tool
MapleJS engine
Automatic
ECMA Automatic Static/dynamic Standard generation tool
language Compiler memory program library
...
features management optimization (libm/libc)
Kernel
Page 29 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
JS running Engine
⚫ High-Performance and Lightweight JS Virtual Machine (VM)
Optimized design for devices with severely limited resources
Provides independent user space and application isolation to ensure application security.
Page 30 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Huawei LiteOS Kernel
Page 31 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Huawei LiteOS API
⚫ The open API shields bottom-layer differences so that application
developers only need to focus on application development at upper layers.
Page 32 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. Which of the following functions belong to Huawei LiteOS kernel? ( )
A. Task B. Process C. Time management D. Memory management
Page 33 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Summary
⚫ Huawei LiteOS Architecture
Page 34 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Thank You
www.huawei.com