LiteOS Porting Tutorial for APM32F103

Company Profile: Geehy Semiconductor is a wholly-owned subsidiary of Apex Microelectronics, formerly known as Apex IoT Chip Division, its parent company is Ninestar Corporation (002180. SZ).

Introduction: APM32F103xDxE series MCU, based on 32-bit ARM® Cortex®-M3 core, supports an FPU floating-point unit with a maximum operating main frequency of 96MHz. Configured with an enhanced external memory controller, it supports USB and CAN interface and integrated on-chip storage, timer and data converter, and other peripheral interfaces. This series features low power consumption, large capacity, good portability, and fast Flash programming speed. It has certified IEC61508 SIL2 and passed the USB-IF test, and meets the industrial-grade high-reliability standard. It is suitable for model airplanes, handheld gimbals, barcode scanners, alarms, combination locks, electronic scales, etc.

Hardware Information

Development board: APM32ZE_MINI


Frequency: 96MHz

Flash/SRAM: 512KB/128KB

Setting Up the Environment

Hardware Environment

This experiment uses the APM32ZE_MINI development board, the USB to TTL module, and the J-LINK emulator.


Software Environment

In this experiment, you need to build the Linux environment (Make build tool, arm-none-eabi embedded toolchain) according to the LiteOS tutorial on Code Cloud. Environment building tutorial:


This experiment requires users to first download the APM32 SDK (the current version used is APM32F10x_SDK_V1.5), datasheet, burner and emulator manual, and other materials.

Download link:

Note: If you are using the keil software, you can directly follow the APM32 tutorial to test the serial port and timer implementation of the development board.

Porting Steps

1. Create Directory Structure

Add the APM32F103_Geehy directory under the targets directory, and refer to the startup process ofSTM32F103_FIRE_Arbitrary for migration.

Copy the driver library from the APM32 SDK to targets\bsp\drivers.

Copy the folders Inc, include, os_adapt, Src and the files liteos.ld, los_startup_gcc.S, Makefile to the APM32F103_Geehy directory.

Replace the files in Inc and Src; replace the stm32f1xx_hal_conf.h, stm32f1xx.h, stm32f103xe.h, system_stm32f1xx.h files in Inc directory with apm32f10x.h, system_ apm32f10x.h; replace the system_stm32f1xx.c file in src directory with system_apm32f10x.c.

Adapting to the build configuration, please refer to other development boards of the same architecture and add APM32F103’s related contents in targets\, targets\bsp\Makefile, tools\build\config, targets\Kconfig.apm32.

The final directory structure is as follows:


After completing the above steps, execute the following two commands for debugging.

Enter the command make menuconfig in the shell terminal and make sure that the menuconfig.h file is generated in the folder targets\APM32F103_Geehy\include\ and the contents of the .config file in the root directory are as configured.

Enter the command make clean && make -j in the shell terminal to ensure that the compilation options and file links are working.

2. Porting Code

Configuring the System Clock

The system clock is initialized by calling SystemInit in system_apm32f10x.c through the los_startup_gcc.S file and does not need to be implemented actively.

Configuring Serial Ports

Refer to the examples under the Examples\USART\Printf folder in the APM32 SDK to implement serial port initialization and UartControllerOps structure.

Configuring Timers

Refer to the examples under the Examples\TMR\TimeBase folder in the APM32 SDK to implement timer initialization and TimControllerOps structure.


3. Configure Burning Test

After completing the above steps, enter the command make clean && make -j in the shell terminal to compile, then the Huawei_LiteOS.bin file will be generated under out\APM32F103_Geehy\.


Download the Huawei_LiteOS.bin file to the development board via J-LINK, this experiment uses J-Flash Lite.exe to perform burning.


Open J-Flash Lite.exe

Configure to burn APM32F103ZET6

Modify the burn address to 0x08000000 (default burn address is 0x00000000)

Click Program Device to burn

Reference Link:

[1] APM32 Official Sources: