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

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

问题描述

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

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?

推荐答案

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

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.

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

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.

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

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天全站免登陆