一、背景
OpenHarmony系统移植最核心的步骤是内核的移植,内核的稳定是一切子系统稳定的基础,上一篇我们讲述了内核启动原理,以及vendor、board的开发配置,本文将介绍SoC层级的移植适配流程。
二、SoC适配
SoC配置芯片层级编译依赖库,包括CMSIS、HAL(硬件抽象层)等,这里包含操作总线、串口、时钟、寄存等库函数。
1.创建对应的文件目录结构
目录名称按照芯片厂家、芯片型号来创建,比如st公司下的stm32f4xx系列芯片。
配置文件内容如下:
device/soc/st/stm32f4xx/Kconfig.liteos_m.defconfig.series
if SOC_SERIES_STM32F4xx
rsource "Kconfig.liteos_m.defconfig.stm32f4xx"
config SOC_SERIES
string
default "stm32f4xx"
endif
device/soc/st/stm32f4xx/Kconfig.liteos_m.defconfig.stm32f4xx
config SOC
string
default "stm32f4xx"
depends on SOC_STM32F4xx
device/soc/st/stm32f4xx/Kconfig.liteos_m.series
config SOC_SERIES_STM32F4xx
bool "STMicroelectronics STM32F4xx series"
select ARCH_ARM
select SOC_COMPANY_STMICROELECTRONICS
select CPU_CORTEX_M4
help
Enable support for STMicroelectronics STM32F4xx series
device/soc/st/stm32f4xx/Kconfig.liteos_m.soc
choice
prompt "STMicroelectronics STM32F4xx series SoC"
depends on SOC_SERIES_STM32F4xx
config SOC_STM32F407
bool "SoC STM32F407"
Endchoice
device/soc/st/Kconfig.liteos_m.defconfig
rsource "*/Kconfig.liteos_m.defconfig.series"
device/soc/st/Kconfig.liteos_m.defconfig
rsource "*/Kconfig.liteos_m.series"
device/soc/st/Kconfig.liteos_m.soc
config SOC_COMPANY_STMICROELECTRONICS
bool
if SOC_COMPANY_STMICROELECTRONICS
config SOC_COMPANY
default "st"
rsource "*/Kconfig.liteos_m.soc"
endif # SOC_COMPANY_STMICROELECTRONICS
device/soc/st/BUILD.gn
if (ohos_kernel_type == "liteos_m") {
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name"