Skip to content
Jinhui-Lin edited this page Apr 7, 2019 · 7 revisions

HomePage

Tutorial

Images

Usage Step on macOS

  1. 按照官方的建议方式安装即可:brew install qemu
➜  qemu-img  --version
qemu-img version 3.0.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
  1. 这里拿 qemu 来进行 ARM 的学习,所以需要安装 GNU Arm Embedded Toolchain,手动下载二进制安装包即可(注:macOS 下解压是二进制文件,需要手动在环境变量中添加路径)
➜  arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 8-2018-q4-major) 8.2.1 20181213 (release) [gcc-8-branch revision 267074]
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

➜  which arm-none-eabi-gcc
/Users/jinhuilin/workspace/qemu-arm/cortex-m/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc
➜  
  1. 按照 Embedded Programming with the GNU Toolchain 步骤即可使用 qemu 来仿真 ARM Cortex-M3 的裸机环境
➜  cat add.s
        .thumb
        .syntax unified

sp:     .word 0x200
reset:  .word start+1



start:
        mov r0, #4
        mov r1, #5
        add r2, r1, r0

stop:   b stop
➜  arm-none-eabi-as -mcpu=cortex-m3 add.s -o add.o
➜  arm-none-eabi-ld -Ttext=0x0 -o add.elf add.o
arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000000000
➜  arm-none-eabi-objcopy -O binary add.elf add.bin
➜  ls
Building_bare-metal_ARM_with_GNU.pdf add.o
Simba.pdf                            add.s
add.bin                              gcc-arm-none-eabi-8-2018-q4-major
add.elf
➜  qemu-system-arm -M lm3s811evb -kernel add.bin -monitor stdio
QEMU 3.0.0 monitor - type 'help' for more information
(qemu) info registers
R00=00000004 R01=00000005 R02=00000009 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000200 R14=ffffffff R15=00000014
XPSR=41000000 -Z-- T priv-thread
FPSCR: 00000000
(qemu)