网站开发打赏功能,深圳最好的网站建设公司哪家好,西安SEO网站建设,网站维护会关闭吗开源鸿蒙中芯片与开发板对应的源码#xff08;硬件相关的部分#xff09;
作者将狼才鲸日期2024-03-20 开源鸿蒙通过芯片仓存放指定芯片和指定开发板的代码#xff0c;硬件相关的代码和纯逻辑代码是分开存放的 源码模块的组织结构在manifest这个Git仓库#xff0c;这也是拉…开源鸿蒙中芯片与开发板对应的源码硬件相关的部分
作者将狼才鲸日期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/socdevice/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_headlesshttps://gitee.com/openharmony/vendor_ohemu/tree/master/qemu_small_system_demohttps://gitee.com/openharmony/vendor_ohemu/tree/master/qemu_mini_system_demo device芯片仓的源码和配置 https://gitee.com/openharmony/device_qemu/tree/master/arm_virt/linuxhttps://gitee.com/openharmony/device_qemu/tree/master/arm_virt/liteos_ahttps://gitee.com/openharmony/device_qemu/tree/master/arm_virt/liteos_a_minihttps://gitee.com/openharmony/device_qemu/tree/master/arm_mps2_an386含上电后的初始化代码https://gitee.com/openharmony/device_qemu/tree/master/drivers 参考网址 QEMU Arm MPS2 and MPS3 boards
源码框架 以下配置文件指示了你要下载哪些Git仓库并将他们拉取到哪个子文件夹下拉取完成后才会构成完整的开源鸿蒙源码 https://gitee.com/openharmony/manifest/blob/master/default.xml 分为平台仓和芯片仓https://gitee.com/openharmony/manifest/blob/master/ohos/ohos.xml 所有与硬件无关的平台仓按group类型拉取代码是你的group则拉取不是则忽略 例如将 https://gitee.com/openharmony/kernel_liteos_m 仓库拉取到 kernel/liteos_m 目录下 https://gitee.com/openharmony/manifest/blob/master/chipsets/all.xml 所有与硬件相关的芯片仓按芯片名称分类https://gitee.com/openharmony/manifest/blob/master/chipsets/qemu.xml 选中一款芯片例如选中qemu这款虚拟芯片平台仓还是选中全量芯片仓则选中特有的https://gitee.com/openharmony/manifest/blob/master/chipsets/qemu/qemu.xml qemu这款虚拟芯片的芯片仓代码 将 https://gitee.com/openharmony/vendor_ohemu 这个仓库拉取到 vendor/ohemu 文件夹下含模块依赖关系、操作系统的配置参数、OEM-ID-密钥源码将 https://gitee.com/openharmony/device_qemu 这个仓库拉取到 device/qemu 文件夹下包含芯片相关驱动底层硬件相关部分 以ARM Cortex-M内核的arm_mps2_an386开发板为例简述源码结构 openHarmony\device\qemu\arm_mps2_an386\liteos_m\board\startup.s源码网址https://gitee.com/openharmony/device_qemu/blob/master/arm_mps2_an386/liteos_m/board/startup.s 中描述了芯片上电后的第二行代码复位中断第一行代码RAM 0地址的复位中断融合到编译器里面去了在复位中断中跳转到C语言的main函数
.global Reset_Handler.section .text
.type Reset_Handler, %function
Reset_Handler:ldr r0, __bss_startldr r1, __bss_endmov r2, #0bss_loop:str r2, [r0, #0]add r0, r0, #4subs r3, r1, r0bne bss_loopldr sp, __irq_stack_topb main
.size Reset_Handler, .-Reset_HandleropenHarmony\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函数里面启动操作系统
/*****************************************************************************Function : mainDescription : Main function entryInput : NoneOutput : NoneReturn : 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();
#endifUart0RxIrqRegister();NetInit();#if (LOSCFG_USE_SHELL 1)ret LosShellInit();if (ret ! LOS_OK) {printf(LosAppInit failed! ERROR: 0x%x\n, ret);}
#endifret 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之后会全部换成鸿蒙内核