如何使用自定义外设和内存映射创建 QEMU ARM 机器? [英] How to create a QEMU ARM machine with custom peripherals and memory maps?

查看:47
本文介绍了如何使用自定义外设和内存映射创建 QEMU ARM 机器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Cortex-M3 cpu 编写代码,并且正在使用 qemu-arm 二进制文件执行单元测试.现在一切正常.但我想知道我是否能够使用 qemu-system-arm 测试整个系统?我的意思是,我想为 qemu 编写自定义机器",我将在其中定义所需的内存映射,并最终对所需的外围设备进行一些软件模仿,是否有此类模块的一些示例?我发现这方面的信息很少.我已经阅读了 qemu 源代码树中 hw 目录中的一些源代码,但几乎都没有注释,而且我仍然不确定我是否了解如何向 qemu 添加新机器以及如何将外设附加到地址空间?

解决方案

为了添加自己的机器,您至少需要创建一个源文件,其中包含您机器的参数和外围设备.之后,在 Makefile.objs 中的 qemu/hw/arm/下添加一个条目.STM32 P103机器入门.

以 Olimex STM32 P103 开发板为例:Olimex STM32P103 开发板代码.在第 105 和 106 行,我们有 flash_size 和 ram_size.在第 114 行和第 115 行,代码添加了一个 LED 连接到 GPIO A 引脚 0.在第 130 行,我们有机器描述,Olimex STM32 p103 开发板".在第 131 行,机器 init 函数:stm32_p103_init.另一个更完整的机器示例:Pebble 机器代码.

关于外设,它们在每个家族代码中被实例化,考虑到 stm32 情况.stm32f1 系列:stm32f1xx.c、stm32f2 系列:stm32f2xx.c,stm32f4 系列:stm32f4xx.c.外设本身在一个驱动程序中实现,该驱动程序通常具有一个暗示名称:stm32f2xx_adc.c、stm32f2xx_crc.c 等.添加新外设的补丁示例:向 STM32 添加 ADC.

I am writing a code for Cortex-M3 cpu and I am performing unit testing using qemu-arm binary. For now everything works just fine. But I am wondering If I am able to test whole system using qemu-system-arm? I mean, I want to write custom "machine" for qemu where I will define desired memory map and eventually some software imitation of desired peripherals, are there some examples of such module? I found very little amount of information about this. I have read some source code in hw directory in qemu source tree but it is almost all uncommented, and I am still not sure if I understand how to add new machine to the qemu and how append peripheral to the address space?

解决方案

In order to add your own machine, you need at least create one source file, containing the parameters and peripherals of your machine. After that, add a entry inside Makefile.objs, under qemu/hw/arm/. STM32 P103 machine entry.

Let's take as example Olimex STM32 P103 Development Board: Olimex STM32 P103 Development Board code. In lines 105 and 106, we have flash_size and ram_size. In lines 114 and 115 the code add a LED connect to GPIO A pin 0. In line 130 we have machine description, "Olimex STM32 p103 Dev Board". In line 131, the machine init function: stm32_p103_init. Another example of a machine more complete: Pebble machine code.

About peripherals, they are instantiated in each family code, considering stm32 case. stm32f1 family: stm32f1xx.c, stm32f2 family: stm32f2xx.c, stm32f4 family: stm32f4xx.c. The peripheral itself is implemented in a driver which typically has a suggestive name: stm32f2xx_adc.c, stm32f2xx_crc.c and so on. Example of a patch that add new peripheral: Addition of ADC to STM32.

这篇关于如何使用自定义外设和内存映射创建 QEMU ARM 机器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆