1 Star 0 Fork 5K

黄承耿 / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
basic-kernel-adaptation.md 8.23 KB
一键复制 编辑 原始数据 按行查看 历史
NEEN 提交于 2021-03-12 17:59 . !197 Docs Update version 1.0.1

Basic Kernel Adaptation

The LiteOS Cortex-M kernel provides the system initialization process and customized configuration options required for system running. During kernel porting, you must pay attention to the functions related to hardware configuration in the initialization process and understand the kernel configuration options so that the minimum kernel that matches the board can be tailored.

Adaptation Process

Basic adaptation consists of the following steps:

  1. Modify the code in the startup.S and corresponding link configuration files.
  2. Initialize the serial port and register the handler function for the tick interrupt response in the main.c file

Figure 1 Startup process

In the startup.S file, you must ensure that the entry function (for example, reset_vector) of the interrupt vector table is stored in the RAM start address specified by the link configuration files. The link configuration files of IAR, Keil, and GCC projects are xxx.icf, xxx.sct, and xxx.ld, respectively. The startup file provided by the vendor does not need to be modified if the startup.S file has initialized the system clock and returned to the main function. Otherwise, the preceding functions need to be implemented.

In the main.c file, you need to register the UartInit function used for initializing the serial port and the handler function used for the system tick.

  • The UartInit function initializes the board serial port, and the function name can be defined based on the board. This function is optional. You can determine whether to call it based on whether the board supports the serial port. If the board supports the serial port, this function must enable TX and RX channels of the serial port and set the baud rate.
  • You can call HalTickStart to set the OsTickHandler function for the tick interrupt response.

For the chip whose interrupt vector table cannot be redirected, you need to disable the LOSCFG_PLATFORM_HWI macro, and add the OsTickHandler function for the tick interrupt response in the startup.S file.

Feature Configuration

The los_config.h file defines both complete configuration and default configuration of liteos_m. All configuration items in this file can be customized for different boards as required.

You can define configuration items in the device/xxxx/target_config.h file of the corresponding board. For other undefined configuration items, default values in the los_config.h file will be used.

The following table shows some typical configuration items:

Table 1 Typical configuration items

Item

Description

LOSCFG_BASE_CORE_SWTMR

Switch of the software timer. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_BASE_CORE_SWTMR_ALIGN

Switch of the time alignment feature, which depends on the switch status of the software timer. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_BASE_IPC_MUX

Switch of the mux feature. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_BASE_IPC_QUEUE

Switch of the queue feature. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_BASE_IPC_SEM

Switch of the semaphore feature. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_PLATFORM_EXC

Switch of the exception feature. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

LOSCFG_KERNEL_PRINTF

Switch of the print feature. The values 1 and 0 indicate that the switch is turned on and turned off, respectively.

1
https://gitee.com/hcg-96/docs.git
git@gitee.com:hcg-96/docs.git
hcg-96
docs
docs
master

搜索帮助