harmony(鸿蒙)Basic Kernel Adaptation

  • 2022-08-09
  • 浏览 (707)

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_CORE_TSK_LIMIT

Maximum number of available tasks, excluding idle tasks. You can set this item based on your actual service requirements, or you can initially set it to a large value and adjust the value at a later time.

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.

你可能感兴趣的鸿蒙文章

harmony(鸿蒙)Introduction

harmony(鸿蒙)Combo Solution – ASR Chip Porting Case

harmony(鸿蒙)Mini-System Devices with Screens — Bestechnic SoC Porting Case

harmony(鸿蒙)Third-party Module Adaptation

harmony(鸿蒙)System Modules

harmony(鸿蒙)Board-Level Driver Adaptation

harmony(鸿蒙)Implementation of APIs at the HAL

harmony(鸿蒙)lwIP Module Adaptation

harmony(鸿蒙)Porting Overview

harmony(鸿蒙)XTS

0  赞