10 开源鸿蒙中芯片与开发板对应的源码(硬件相关的部分)

开源鸿蒙中芯片与开发板对应的源码(硬件相关的部分)

作者 将狼才鲸
日期 2024-03-20

  • 开源鸿蒙通过芯片仓存放指定芯片和指定开发板的代码,硬件相关的代码和纯逻辑代码是分开存放的

    • 源码模块的组织结构在manifest这个Git仓库,这也是拉取源码时的顶层仓库:https://gitee.com/openharmony/manifest
    • 平台仓都组织在manifests/ohos/ohos.xml文件中,而芯片仓都组织在manifests/chipsets/目录下
    • 每个芯片平台会在device和vendor目录下创建相应的仓,把这类仓称为芯片仓,其它的仓称为平台仓,芯片仓可能会随着硬件的演进而逐渐废弃,生命周期相对较短
    • default.xml由ohos/ohos.xml和chipsets/all.xml组成,是所有平台仓和芯片仓的集合;可以通过缺省参数下载所有代码仓(全量代码)
    • chipsets/chipsetN/chipsetN-detail.xml是单个芯片平台所引入的仓集合
    • 每个开发板的chipsets/chipsetN/chipsetN-detail.xml里主要包括device/soc,device/board以及vendor相关仓
    • 官方支持的开发板和模拟器种类-编译形态整体说明
  • 因为硬件各种各样,为了学习方便,这里选择几个ARM核的QEMU模拟器(不使用硬件,使用虚拟开发板)

    • 编译参数(产品名):qemu_arm_linux_headless,开发板名称:qemu-arm-linux,芯片名称:qemu,芯片内核:ARM Cortex-A,系统类型:标准,系统内核:linux,开发板参数:https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json
    • 编译参数(产品名):qemu_small_system_demo,开发板名称:arm_virt,芯片名称:qemu,芯片内核:ARM Cortex-A,系统类型:小型,系统内核:liteos_a,开发板参数:https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json
    • 编译参数(产品名):qemu_mini_system_demo,开发板名称:arm_mps2_an386,芯片名称:qemu,芯片内核:ARM Cortex-M4,系统类型:轻型,系统内核:liteos_m,开发板参数:https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json
  • verdor芯片仓的开发板配置

    • https://gitee.com/openharmony/vendor_ohemu/tree/master/qemu_arm_linux_headless
    • https://gitee.com/openharmony/vendor_ohemu/tree/master/qemu_small_system_demo
    • https://gitee.com/openharmony/vendor_ohemu/tree/master/qemu_mini_system_demo
  • device芯片仓的源码和配置

    • https://gitee.com/openharmony/device_qemu/tree/master/arm_virt/linux
    • https://gitee.com/openharmony/device_qemu/tree/master/arm_virt/liteos_a
    • https://gitee.com/openharmony/device_qemu/tree/master/arm_virt/liteos_a_mini
    • https://gitee.com/openharmony/device_qemu/tree/master/arm_mps2_an386含上电后的初始化代码
    • https://gitee.com/openharmony/device_qemu/tree/master/drivers
  • 参考网址:

源码框架

shell 复制代码
.global Reset_Handler

.section .text
.type  Reset_Handler, %function
Reset_Handler:
    ldr  r0, =__bss_start
    ldr  r1, =__bss_end
    mov  r2, #0

bss_loop:
    str  r2, [r0, #0]
    add  r0, r0, #4
    subs r3, r1, r0
    bne  bss_loop

    ldr  sp, =__irq_stack_top
    b    main
.size  Reset_Handler, .-Reset_Handler
  • openHarmony\device\qemu\arm_mps2_an386\liteos_m\board\main.c(源码网址https://gitee.com/openharmony/device_qemu/blob/master/arm_mps2_an386/liteos_m/board/main.c) 中在main函数里面启动操作系统
c 复制代码
/*****************************************************************************
 Function    : main
 Description : Main function entry
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
LITE_OS_SEC_TEXT_INIT int main(void)
{
    unsigned int ret;

    UartInit();

    ret = LOS_KernelInit();
    if (ret != LOS_OK) {
        printf("LiteOS kernel init failed! ERROR: 0x%x\n", ret);
        goto EXIT;
    }
#if (LOSCFG_SUPPORT_LITTLEFS == 1)
    LfsLowLevelInit();
#endif

    Uart0RxIrqRegister();

    NetInit();

#if (LOSCFG_USE_SHELL == 1)
    ret = LosShellInit();
    if (ret != LOS_OK) {
        printf("LosAppInit failed! ERROR: 0x%x\n", ret);
    }
#endif

    ret = LosAppInit();
    if (ret != LOS_OK) {
        printf("LosAppInit failed! ERROR: 0x%x\n", ret);
    }

    LOS_Start();

EXIT:
    while (1) {
        __asm volatile("wfi");
    }
}
  • openHarmony\device\qemu\arm_mps2_an386\liteos_m\board\driver 包含了芯片的底层驱动代码
  • 接下来就是理解操作系统内核模块,当前时LiteOS-M、LiteOS-A和Linux,之后会全部换成鸿蒙内核
相关推荐
Despacito0o2 小时前
STM32 I2C通信完整教程:从协议原理到硬件实现
stm32·单片机·嵌入式硬件
你好,奋斗者!3 小时前
小电流驱动大电流:原理、实现方式与应用前景
stm32·单片机·嵌入式硬件·电路设计
猫猫的小茶馆6 小时前
【STM32】FreeRTOS 任务的删除(三)
java·linux·stm32·单片机·嵌入式硬件·mcu·51单片机
学不动CV了6 小时前
单片机ADC采集机理层面详细分析(二)
c语言·arm开发·stm32·单片机·嵌入式硬件·开源·51单片机
学不动CV了6 小时前
51核和ARM核单片机OTA实战解析(二)
c语言·arm开发·stm32·单片机·嵌入式硬件·51单片机
Yuroo zhou7 小时前
IMU的精度对无人机姿态控制意味着什么?
单片机·嵌入式硬件·算法·无人机·嵌入式实时数据库
嵌入式小白牙9 小时前
ARM-I2C硬实现
arm开发·单片机·嵌入式硬件
knight_202412 小时前
嵌入式学习日志————对射式红外传感器计次
stm32·单片机·嵌入式硬件·学习
深圳安凯星单片机开发方案公司12 小时前
用单片机怎么控制转速
单片机·51单片机
Ronin-Lotus12 小时前
嵌入式硬件篇---驱动板
单片机·嵌入式硬件·esp32·驱动板