鸿蒙NEXT开发实战往期必看文章:
一分钟了解”纯血版!鸿蒙HarmonyOS Next应用开发!
“非常详细的” 鸿蒙HarmonyOS Next应用开发学习路线!(从零基础入门到精通)
HarmonyOS NEXT应用开发案例实践总结合(持续更新......)
HarmonyOS NEXT应用开发性能优化实践总结(持续更新......)
本方案基于OpenHarmony LiteOS-M内核,使用联盛德W800芯片的润和软件海王星系列Neptune100开发板,进行开发移植。移植架构采用Board
与SoC
分离方案,支持通过Kconfig图形化配置编译选项,增加玄铁ck804ef
架构移植,实现了HDF
、XTS
等子系统及组件的适配。
适配准备
准备ubuntu20.04系统环境,安装csky-abiv2-elf-gcc交叉编译工具链。
编译构建
目录规划
本方案的目录结构使用Board和Soc解耦的思路:
芯片适配目录规划为:
device
├── board --- 单板厂商目录
│ └── hihope --- 单板厂商名字:HiHope
│ └── neptune100 --- 单板名:Neptune100
└── soc --- SoC厂商目录
└── winnermicro --- SoC厂商名字:联盛德
└── wm800 --- SoC Series名:w800系列芯片
产品样例目录规划为:
vendor
└── hihope --- 开发产品样例厂商目录,润和软件的产品样例
├── neptune_iotlink_demo --- 产品名字:Neptune100产品样例代码
└── ...
产品定义
vendor/hihope/neptune_iotlink_demo/config.json
文件下,描述了产品使用的内核、单板、子系统等信息。其中,内核、单板型号、单板厂商需提前规划好,是预编译指令hb set
关注的。例如:
{
"product_name": "neptune_iotlink_demo", --- 产品名
"ohos_version": "OpenHarmony 3.1", --- 使用的OS版本
"type":"mini", --- 系统类型: mini
"version": "3.0", --- 系统版本: 3.0
"device_company": "hihope", --- 单板厂商:hihope
"board": "neptune100", --- 单板名:neptune100
"kernel_type": "liteos_m", --- 内核类型:liteos_m
"kernel_version": "3.0.0", --- 内核版本:3.0.0
"subsystems": [] --- 子系统
}
填入的信息与规划的目录相对应,其中device_company
和board
用于关联出device/board/<device_company>/
目录。
单板配置
关联到的目录下,在device/board/hihope/neptune100/liteos_m
目录下放置config.gni
文件,该配置文件用于描述该单板信息,包括CPU型号、交叉编译工具链及全局编译、链接参数等重要信息:
# Kernel type, e.g. "linux", "liteos_a", "liteos_m".
kernel_type = "liteos_m"
# Kernel version.
kernel_version = "3.0.0"
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = "ck804ef"
# Board arch, e.g. "armv7-a", "rv32imac".
board_arch = "ck803"
# Toolchain name used for system compiling.
# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf.
# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toolchain.
board_toolchain = "csky-elfabiv2-gcc"
#use_board_toolchain = true
# The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc.
board_toolchain_path = ""
# Compiler prefix.
board_toolchain_prefix = "csky-elfabiv2-"
# Compiler type, "gcc" or "clang".
board_toolchain_type = "gcc"
# config.json parse
if (product_path != "") {
product_conf = read_file("${product_path}/config.json", "json")
product_name = product_conf.product_name
bin_list = product_conf.bin_list
}
# Board related common compile flags.
board_cflags &