阅读量:2
在QEMU硬件模拟器中运行开源鸿蒙OpenHarmony4.1的操作系统,无需实体开发板
作者 | 将狼才鲸 |
---|---|
日期 | 2024-03-01 |
先下载源码和编译程序:
我准备在QEMU模拟器中运行ARM Cortex-M4的轻型开源鸿蒙系统
- 官方支持的开发板和模拟器种类-编译形态整体说明
- 已支持的示例工程,Qemu模拟器: arm_mps2_an386、esp32、riscv32_virt、SmartL_E802
- Qemu Arm Cortex-m4 mps2-an386 教程
在电脑上安装QEMU模拟器软件,可以在Windows下安装,也可以在Linux发行版下安装
- Qemu安装-QEMU Quick Emulator QEMU在Ubuntu下的安装流程;是下载源码后再编译,编译速度很慢,可以make只编译ARM部分的,这样编译速度会快很多
- …/configure --target-list=arm-softmmu,arm-linux-user
- make -j4
- sudo make install
- 在Windows下的安装流程更简单
- Windows的所有安装包 安装6.2.0及以上的版本都可以
- 官网下载很慢,可以用国内网站下载 https://www.mydown.com/soft/172/726002172.shtml
- Windows下安装后手动配置好QEMU的环境变量,或者进入到D:\Program Files\qemu的目录下打开CMD命令行界面
- Qemu安装-QEMU Quick Emulator QEMU在Ubuntu下的安装流程;是下载源码后再编译,编译速度很慢,可以make只编译ARM部分的,这样编译速度会快很多
Ubuntu回到OpenHarmony源码根目录下,使用命令行用QEMU模拟器运行开源鸿蒙系统
- ./qemu-run --help
- ./qemu-run -e out/arm_mps2_an386/qemu_mini_system_demo/OHOS_Image
- qemu-run是个脚本,可以用文本文件打开,它里面也是调用的qemu-system-arm,并且传入了需要的参数
这是开源鸿蒙在QEMU硬件模拟器中运行的结果,在网口时程序跑飞了,可能源码中对QEMU Cortex-M4的适配有点问题,你也可以再尝试一下别的QEMU开发板,步骤和上述流程一样的:
jim@ubuntu:~/openHarmony$ ./qemu-run -e out/arm_mps2_an386/qemu_mini_system_demo/OHOS_Image board: arm_mps2_an386 Enter to start qemu[y/n]:entering kernel init... LfsLowLevelInit: DiskPartition succeed LfsLowLevelInit: PartitionFormat succeed LfsLowLevelInit: mount fs on '/littlefs' succeed LfsLowLevelInit: mkdir '/littlefs' succeed tcpip_init start *************Exception Information************** Type = 11 ThrdPid = 25 Phase = exc in task FaultAddr = 0xabababab Current task info: Task name = (null) Task ID = 25 Task SP = (nil) Task ST = 0x0 Task SS = 0x0 Exception reg dump: PC = 0x2100e62a LR = 0x2101b045 SP = 0x210b18e0 R0 = 0x210a725c R1 = 0x200 R2 = 0x210a725c R3 = 0x2108a9b3 R4 = 0x0 R5 = 0x0 R6 = 0x0 R7 = 0x210b18e8 R8 = 0x0 R9 = 0x0 R10 = 0x0 R11 = 0x0 R12 = 0xc8000000 PriMask = 0x0 xPSR = 0x610f0000 ----- backtrace start ----- backtrace 0 -- lr = 0x21015178 backtrace 1 -- lr = 0x2101b044 backtrace 2 -- lr = 0x210235da backtrace 3 -- lr = 0x210235e2 backtrace 4 -- lr = 0x2102379a ----- backtrace end ----- qemu: fatal: Lockup: can't escalate 3 to HardFault (current priority -1) R00=210b2ad0 R01=2109fa3f R02=210a18f8 R03=6c0da998 R04=00000000 R05=00000060 R06=00000018 R07=210b1708 R08=00000019 R09=000003e8 R10=218ba1e8 R11=00000000 R12=00000000 R13=210b1708 R14=210011db R15=21000fcc XPSR=21030006 --C- T handler s00=00000000 s01=00000000 d00=0000000000000000 s02=00000000 s03=00000000 d01=0000000000000000 s04=00000000 s05=00000000 d02=0000000000000000 s06=00000000 s07=00000000 d03=0000000000000000 s08=00000000 s09=00000000 d04=0000000000000000 s10=00000000 s11=00000000 d05=0000000000000000 s12=00000000 s13=00000000 d06=0000000000000000 s14=00000000 s15=00000000 d07=0000000000000000 s16=00000000 s17=00000000 d08=0000000000000000 s18=00000000 s19=00000000 d09=0000000000000000 s20=00000000 s21=00000000 d10=0000000000000000 s22=00000000 s23=00000000 d11=0000000000000000 s24=00000000 s25=00000000 d12=0000000000000000 s26=00000000 s27=00000000 d13=0000000000000000 s28=00000000 s29=00000000 d14=0000000000000000 s30=00000000 s31=00000000 d15=0000000000000000 FPSCR: 00000000 /home/jim/openHarmony/vendor/ohemu/qemu_mini_system_demo/qemu_run.sh: line 95: 50440 Aborted (core dumped) qemu-system-arm -M mps2-an386 -m 16M -kernel $elf_file $qemu_option -append "root=dev/vda or console=ttyS0" -nographic jim@ubuntu:~/openHarmony$
- 在Windows的QEMU下可以用这个命令
- qemu-system-arm -M mps2-an386 -cpu cortex-m4 -kernel OHOS_Image -serial stdio -nodefaults -nographic
- 另外一个可供你参考的命令 qemu-system-arm -machine versatileab -cpu cortex-a9 -nographic -monitor null -semihosting -append ‘some program arguments’ -kernel program.axf
D:\Program Files\qemu>qemu-system-arm -M mps2-an386 -cpu cortex-m4 -kernel OHOS_Image -serial stdio -nodefaults -nographic qemu-system-arm: warning: nic lan9118.0 has no peer entering kernel init... LfsLowLevelInit: DiskPartition succeed LfsLowLevelInit: PartitionFormat succeed LfsLowLevelInit: mount fs on '/littlefs' succeed LfsLowLevelInit: mkdir '/littlefs' succeed tcpip_init start *************Exception Information************** Type = 11 ThrdPid = 25 Phase = exc in task FaultAddr = 0xabababab Current task info: Task name = (null) Task ID = 25 Task SP = (nil) Task ST = 0x0 Task SS = 0x0 Exception reg dump: PC = 0x2100e62a LR = 0x2101b045 SP = 0x210b18e0 R0 = 0x210a725c R1 = 0x200 R2 = 0x210a725c R3 = 0x2108a9b3 R4 = 0x0 R5 = 0x0 R6 = 0x0 R7 = 0x210b18e8 R8 = 0x0 R9 = 0x0 R10 = 0x0 R11 = 0x0 R12 = 0xc8000000 PriMask = 0x0 xPSR = 0x610f0000 ----- backtrace start ----- backtrace 0 -- lr = 0x21015178 backtrace 1 -- lr = 0x2101b044 backtrace 2 -- lr = 0x210235da backtrace 3 -- lr = 0x210235e2 backtrace 4 -- lr = 0x2102379a ----- backtrace end ----- qemu: fatal: Lockup: can't escalate 3 to HardFault (current priority -1) R00=210b2ad0 R01=2109fa3f R02=210a18f8 R03=6c0da998 R04=00000000 R05=00000060 R06=00000018 R07=210b1708 R08=00000019 R09=000003e8 R10=218ba1e8 R11=00000000 R12=00000000 R13=210b1708 R14=210011db R15=21000fcc XPSR=21030006 --C- T handler s00=00000000 s01=00000000 d00=0000000000000000 s02=00000000 s03=00000000 d01=0000000000000000 s04=00000000 s05=00000000 d02=0000000000000000 s06=00000000 s07=00000000 d03=0000000000000000 s08=00000000 s09=00000000 d04=0000000000000000 s10=00000000 s11=00000000 d05=0000000000000000 s12=00000000 s13=00000000 d06=0000000000000000 s14=00000000 s15=00000000 d07=0000000000000000 s16=00000000 s17=00000000 d08=0000000000000000 s18=00000000 s19=00000000 d09=0000000000000000 s20=00000000 s21=00000000 d10=0000000000000000 s22=00000000 s23=00000000 d11=0000000000000000 s24=00000000 s25=00000000 d12=0000000000000000 s26=00000000 s27=00000000 d13=0000000000000000 s28=00000000 s29=00000000 d14=0000000000000000 s30=00000000 s31=00000000 d15=0000000000000000 FPSCR: 00000000 D:\Program Files\qemu>