How to create a QEMU ARM machine with custom peripherals and memory cards?

I am writing code for Cortex-M3 cpu and I am doing unit testing using qemu-arm binary code. So far, everything is working fine. But I wonder if I can check the whole system using qemu-system-arm ? I want to say that I want to write a custom β€œmachine” for qemu, where I define the desired memory card and, ultimately, some software simulation of the desired peripherals, are there some examples of such a module? I have found very little information about this. I read some source code in the hw directory in the qemu source tree, but it is almost all uncommented, and I'm still not sure if I understand how to add a new machine to qemu and how to add peripherals to the address space?

+8
arm qemu cortex-m
source share
1 answer

To add your own computer, you need to at least create one source file containing the parameters and peripherals of your device. After that, add an entry inside Makefile.objs, under qemu / hw / arm /. Recording Machine STM32 P103 .

Take Olimex STM32 P103 Development Board as an example: Olimex STM32 P103 Developer Board Code . In lines 105 and 106 we have flash_size and ram_size. On lines 114 and 115, the code adds an LED to pin GPIO A 0. On line 130 we give a description of the machine "Olimex STM32 p103 Dev Board". On line 131, the machine initialization function: stm32_p103_init. Another example of a machine is more complete: pebble machine code .

On peripheral devices, they are created in each family code, taking into account the case of stm32. Family stm32f1: stm32f1xx.c , stm32f2 family: stm32f2xx.c, stm32f4 family: stm32f4xx.c. The periphery itself is implemented in the driver, which usually has a suggestive name: stm32f2xx_adc.c, stm32f2xx_crc.c and so on. An example of a patch that adds a new peripheral device: Adding ADC to STM32 .

+11
source share

All Articles