赞
踩
作者 | 将狼才鲸 |
---|---|
日期 | 2024-03-20 |
开源鸿蒙通过芯片仓存放指定芯片和指定开发板的代码,硬件相关的代码和纯逻辑代码是分开存放的
https://gitee.com/openharmony/manifest
manifests/ohos/ohos.xml
文件中,而芯片仓都组织在manifests/chipsets/
目录下因为硬件各种各样,为了学习方便,这里选择几个ARM核的QEMU模拟器(不使用硬件,使用虚拟开发板)
https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json
https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_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
参考网址:
以下配置文件指示了你要下载哪些Git仓库,并将他们拉取到哪个子文件夹下,拉取完成后才会构成完整的开源鸿蒙源码
以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_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
https://gitee.com/openharmony/device_qemu/blob/master/arm_mps2_an386/liteos_m/board/main.c
) 中在main函数里面启动操作系统/***************************************************************************** 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"); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。