Learning notes for the introduction to LiteOS - environment construction

Posted by volant on Wed, 02 Feb 2022 17:42:34 +0100


Taking time to study and compare several RTOS, such as RT thread, FreeRTOS, LiteOS, etc., we found that LiteOS is also quite good.

So download the source code, view the documents, configure the development environment, and start the learning journey of LiteOS.


Environment construction

The development of embedded software requires the configuration of software and hardware development environment. Otherwise, it is difficult to understand and be familiar with the working logic of the kernel and even master the basic use method of the kernel by simply looking at the code without real machine debugging.

Therefore, build a PC software development environment, prepare the development board and debug the real machine.

At present, the LiteOS version is [LiteOS kernel version: 5.1.0]. The supported MCU models are not complete. STM32F103 series and [STM32F103ZE] series are supported at present.

Keil MDK5 does not support the development IDE temporarily. There is a VS Code based development IDE: [Huawei liteos studio], and the compilation environment is gcc cross compilation.


Download [Huawei liteos studio]

Download address: https://gitee.com/LiteOS/LiteOS_Studio/releases/V1.45.8



After downloading, click Install to finish.


Configuring the compilation environment

After installation: after Huawei liteos studio, the compilation tool is not downloaded and needs to be downloaded manually. The download method can be seen in the official documents.

HUAWEI LiteOS Studio installation

Here are the main downloads:

Install arm none EABI software

Install Make build software

Install JLink emulator software



Construction of the project

Open Huawei liteos studio and build a new project. I have the development board of [STM32F103VE], so I choose the BSP of STM32F103 series. Note that the pins of STM32F103ZE and VE are different, but there is little difference in Flash, SRAM and other resources. This BSP can be used directly in theory.



Project configuration: the gcc compilation path does not need to be changed by default



Burn path:

That is, the path of the generated bin file, which is generally: \ out\STM32F103_FIRE_Arbitrary\Huawei_LiteOS.bin


Configuration debugging:

J-Link is used here. Note that the installed version of J-Link is too high, which will affect the [domestic] J-Link. I use v4 90 J-Link drive.


Compilation and download:

If the above configuration is correct, the compilation will succeed and the download will succeed. Note: the program does not execute after downloading. You need to reset the development board or power on manually.


LiteOS running:

LiteOS, with Shell enabled by default, is similar to RT thread MSH. The operation effect is as follows:


********Hello Huawei LiteOS********

LiteOS Kernel Version : 5.1.0
build data : Jun 12 2021 17:24:57

cpu 0 entering scheduler
Hello, welcome to liteos!
Hello, welcome to liteos demo!

Huawei LiteOS # 
Huawei LiteOS # 
Huawei LiteOS # help
*******************shell commands:*************************

date          free          help          hwi           memcheck      swtmr         systeminfo    task          
uname         watch         

Huawei LiteOS # 


View system information:

Huawei LiteOS # systeminfo

   Module    Used      Total
   Task      5         12        
   Sem       0         20        
   Mutex     3         20        
   Queue     2         10        
   SwTmr     0         16        

Huawei LiteOS # task

Name                   TaskEntryAddr       TID    Priority   Status       StackSize    WaterLine      StackPoint   TopOfStack   SemID        EventMask   MEMUSE
----                   -------------       ---    --------   --------     ---------    ----------     ----------   ----------   ----------   ---------   ------
Swt_Task               0x0800181d          0x0    0          Pend         0x320        0xd8           0x20003d0c   0x20003ac0   0xffffffff   0x0         0          
IdleCore000            0x08002ff1          0x1    31         Ready        0x190        0x158          0x20003f74   0x20003e40   0xffffffff   0x0         0          
LedTask                0x08007c55          0x3    5          Delay        0x320        0x78           0x200045bc   0x20004310   0xffffffff   0x0         0          
SerialShellTask        0x08007721          0x4    9          Running      0x1000       0x594          0x200059c4   0x20004a90   0xffffffff   0xfff       1492       
SerialEntryTask        0x08007321          0x5    9          Pend         0x600        0x490          0x20005fc4   0x20005aa0   0xffffffff   0x0         132        

Huawei LiteOS # uname
Huawei LiteOS

Huawei LiteOS # 


LED flashing light


Through checking, there is a program for LED flashing, but the LED control pin of the driver configuration is inconsistent with that on my development board. Please change it manually.

After configuring the LED pin, compile and download it to the development board. It is found that the LED of the development board flashes normally.


The LiteOS development environment, based on Huawei LiteOS studio, has been successfully built.



The development of domestic RTOS is inseparable from your efforts. I hope you can use it more and improve it continuously. Domestic RTOS will be continuously robust.

Through research and comparison of some excellent RTOS kernel codes, it is a better way to study the operating system and RTOS.

Embedded software needs to get rid of the problem of "high vision and low hand". The code is debugged, not seen.






Topics: liteos RTOS