qemu · February 22, 2026·

QEMU Custom Basic Machine

Disclaimer: A Note on QEMU Version Coverage and Timeliness

This blog post was initiated based on observations of QEMU version v10.2.1. Please be aware that the information presented here may not align with updates in more recent or future releases in the official QEMU repository. Due to the fast-moving nature of technology and aggressive software development cycles, I find it necessary to provide this disclaimer to prevent any potential misinformation going forward.


Overview

QEMU is a powerful and flexible virtualization platform that allows users to run virtual machines or embedded devices on their host machines. One of the key features of QEMU is the ability to create custom virtual machines, which can be used to run a wide range of operating systems and applications.

In this blog post, I will be creating an ARM Cortex-M4 based custom basic QEMU machine with armv7m architecture, including UART, GPIO, timer and interrupt controller. I will be using the qemu-system-arm binary to create the custom basic machine. I will be writing a simple bare-metal program to run on the custom basic machine. I will be using the arm-none-eabi toolchain to compile the bare-metal program.

I will be using a Raspberry Pi 5 (64-bit | Raspberry Pi OS) as my host machine to compile the QEMU source code and create an ARM Cortex-M4 bare-metal example. If you are using a different platform as your host machine (Windows-x86_64, Linux-x86_64, macOS-Apple Silicon, etc.), there is no need to panic; all you need to do is download the appropriate toolchain for your system from: ARM GNU Toolchain Downloads.

After providing information about device modules in subsequent blog posts, I plan to create another custom machines with more detailed peripherals and features in an upcoming blog posts series.

Last but not least, I will assume that you have already read the previous blog posts in this series and have a basic understanding of QEMU and its features.


Toolchain Setup

# Create a directory for the toolchain(optional)
$ cd
$ mkdir -p programs/toolchain
$ cd programs/toolchain

# Download the toolchain
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/15.2.rel1/binrel/arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-eabi.tar.xz

# Extract the toolchain
$ tar -xvf arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-eabi.tar.xz

# Add the toolchain to the PATH
$ export PATH="$PWD/arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-eabi/bin:$PATH"

CAVEAT: Permanently adding this toolchain to your environment PATH may cause conflicts in the future if you require different toolchain versions, and you might need to reconfigure your PATH variable. Therefore, I recommend temporarily modifying the PATH in your current terminal session using export each time. If you prefer not to use export every time and are certain that you will use only this single toolchain version, you can permanently modify the environment PATH variable with the following command:

# Add the toolchain to the PATH permanently(Not Recommended)
echo 'export PATH="$PATH:/path/to/toolchain/bin"' >> ~/.bashrc && source ~/.bashrc
# Verify the toolchain
$ arm-none-eabi-gcc --version

You should see the following output:

...
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.1 20251203 (Arm GNU Toolchain 15.2.Rel1 (Build arm-15.86)) 

Create a new file for custom basic machine in QEMU source code

I have already downloaded the QEMU source code and extracted it to the current directory. Now I will create a new file for custom basic machine in QEMU source code.

# Go to the QEMU source code directory(You can change it to your own directory)
$ cd $HOME/codes/qemu

# Create a new file for custom basic machine
$ touch hw/arm/ugur_m4.c
$ touch include/hw/arm/ugur_m4.h

NOTE: We can create a single file for both the header and source code, but it is generally better to separate them for better code organization and readability if you will design a complex machine in my opinion.

NOTE: From this point on, it will be more convenient to use VS Code or a similar code editor for code editing and management.

Let's dive into the step-by-step guide to building a custom QEMU machine based on the STM32F407 ARM Cortex-M4 microcontroller.

Stage-1: ARM Cortex-M4 CPU Creation

I will define machine type name and QOM type in the header file.

#define TYPE_UGUR_M4_MACHINE   "ugur-m4-machine"
OBJECT_DECLARE_SIMPLE_TYPE(UgurM4State, UGUR_M4_MACHINE)

Purpose:

  • Creating the QOM ID of the new machine
  • Obtaining cast/helper macros

I will define the basic machine state structure in the header file but I will extend it with the following stages.

struct UgurM4State {
    MachineState  parent_obj;
    ARMv7MState   mcu;
    struct arm_boot_info bootinfo;
};

Purpose:

  • Maintaining the runtime state of the machine instance
  • Storing the subcomponents of the machine within the state

I will define the basic machine initialization function without peripherals in the source file.

static void ugur_m4_init(MachineState *machine) {
    UgurM4State *s = UGUR_M4_MACHINE(machine);
    DeviceState    *nvic;
    Clock *sysclk;
    Clock *refclk;

    object_initialize_child(OBJECT(s), "mcu", &s->mcu, TYPE_ARMV7M);
    nvic = DEVICE(&s->mcu);
    sysclk = clock_new(OBJECT(machine), "SYSCLK");
    refclk = clock_new(OBJECT(machine), "REFCLK");
    clock_set_hz(sysclk, 100000000);
    clock_set_hz(refclk, 1000000);
    qdev_connect_clock_in(nvic, "cpuclk", sysclk);
    qdev_connect_clock_in(nvic, "refclk", refclk);

    if (machine->kernel_filename) {
        s->bootinfo.board_id = -1;
        arm_load_kernel(ARM_CPU(first_cpu), machine, &s->bootinfo);
    }
}
  • Clock *sysclk/refclk — Two pointers are declared for two hardware clock objects
  • ugur_m4_init() — called when the machine is created; the hardware topology must be established here. machine is the base pointer, cast to its own state type with UGUR_M4_MACHINE(machine).
  • clock_new() — creates two clocks: SYSCLK (CPU clock) and REFCLK (reference clock for peripherals).
  • qdev_connect_clock_in() — connects the clock input pins of the ARMv7MState device.
  • object_initialize_child() — initializes the ARMv7MState object within QOM.
  • arm_boot_info — defined in include/hw/arm/boot.h; carries boot parameters (loader start address, RAM size, board ID, etc.) to the kernel. Used via the bootinfo field of UgurM4State, though not all fields are filled in.
  • board_id = -1 — disables classic Linux ARM board-ID / ATAG / DTB handoff.
  • arm_load_kernel() — loads the kernel/binary into memory and sets the program counter to the entry point. Invoked when the user supplies a binary/ELF file with the -kernel argument.

Flash/RAM memory and peripherals will be added in the following stages. Until now the goal was to keep things simple to explain the core concepts.

Stage-2: Machine Initialization and QEMU Type Registration

I will define the machine class initialization function in the source file.

static void ugur_m4_class_init(ObjectClass *oc, const void *data)
{
    MachineClass *mc = MACHINE_CLASS(oc);

    mc->desc             = "Ugur Cortex-M4 machine";
    mc->init             = ugur_m4_init;
    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4");

    /* Cortex-M machines don't use PC-style peripherals */
    mc->no_floppy   = true;
    mc->no_cdrom    = true;
    mc->no_parallel = true;
}
  • mc->desc — description string shown in the machine help output.
  • mc->init — the initialization function called when the machine is created.
  • mc->default_cpu_type — default CPU type used when no CPU is explicitly specified.
  • mc->no_floppy / mc->no_cdrom / mc->no_parallel — flags indicating that legacy PC-style peripherals are not present.

Now I will define type info in the source file.

static const TypeInfo ugur_m4_type = {
    .name          = TYPE_UGUR_M4_MACHINE,
    .parent        = TYPE_MACHINE,
    .instance_size = sizeof(UgurM4State),
    .class_init    = ugur_m4_class_init,
    .interfaces    = arm_machine_interfaces,
};

This is the metadata given to the QOM type system:

  • name — the unique type name string.
  • parent — set to TYPE_MACHINE; declares this as a machine type.
  • instance_size — the size of the machine state struct allocated per instance.
  • class_init — function called to populate the class vtable when the type is first used.
  • interfaces — ARM-machine-specific interface definitions.

In the final step, the type is registered using the following function when QEMU is initialized;

static void ugur_m4_register(void)
{
    type_register_static(&ugur_m4_type);
}
type_init(ugur_m4_register)
  • type_register_static() — registers the machine type in the QOM type system.
  • type_init() — ensures the registration function is invoked automatically during QEMU's init phase.

Stage-3: Flash and RAM Memory Creation

First we should to define the memory regions for flash and RAM in the header file.

/* ── Memory map constants ─────────────────────────────────────── */
#define UGUR_M4_FLASH_BASE          0x08000000U
#define UGUR_M4_FLASH_SIZE          (1024 * KiB)
#define UGUR_M4_FLASH_ALIAS_BASE    0x00000000U
#define UGUR_M4_SRAM_BASE           0x20000000U
#define UGUR_M4_SRAM_SIZE           (128 * KiB)
#define UGUR_M4_CCMRAM_BASE         0x10000000U
#define UGUR_M4_CCMRAM_SIZE         (64 * KiB)

Then we have to add MemoryRegion objects to the machine state structure. "UgurM4State" struct should look like this:

struct UgurM4State {
    MachineState  parent_obj;

    ARMv7MState   mcu;

    MemoryRegion  flash;
    MemoryRegion  flash_alias;
    MemoryRegion  sram;
    MemoryRegion  ccmram;

    struct arm_boot_info bootinfo;
};

Now we will add a few lines of code to ugur_m4_init() function to allocate memory regions and map them to the system memory map.

// 2. Flash (ROM)
memory_region_init_rom(&s->flash, OBJECT(nvic), "ugur-m4.flash",
                        UGUR_M4_FLASH_SIZE, &error_fatal);
memory_region_add_subregion(sys, UGUR_M4_FLASH_BASE, &s->flash);
memory_region_init_alias(&s->flash_alias, OBJECT(machine),
                            "ugur-m4.flash.alias", &s->flash, 0,
                            UGUR_M4_FLASH_SIZE);
memory_region_add_subregion(sys, UGUR_M4_FLASH_ALIAS_BASE, &s->flash_alias);

// 3. SRAM
memory_region_init_ram(&s->sram, OBJECT(nvic), "ugur-m4.sram",
                        UGUR_M4_SRAM_SIZE, &error_fatal);
memory_region_add_subregion(sys, UGUR_M4_SRAM_BASE, &s->sram);

// 4. CCMRAM
memory_region_init_ram(&s->ccmram, OBJECT(nvic), "ugur-m4.ccmram",
                        UGUR_M4_CCMRAM_SIZE, &error_fatal);
memory_region_add_subregion(sys, UGUR_M4_CCMRAM_BASE, &s->ccmram);

qdev_prop_set_string(nvic, "cpu-type",
                        ARM_CPU_TYPE_NAME("cortex-m4"));
qdev_prop_set_uint32(nvic, "num-irq", UGUR_M4_NUM_IRQ);
object_property_set_link(OBJECT(&s->mcu), "memory",
                            OBJECT(sys), &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->mcu), &error_fatal);
  • memory_region_init_rom() — initializes a read-only (ROM) memory region.
  • memory_region_add_subregion() — maps a memory region into the system address space; can be called multiple times to register several subregions.
  • memory_region_init_alias() — creates a region that transparently aliases all or part of another region.
  • qdev_prop_set_XX() — sets device properties that are declared in the device class definition.
  • object_property_set_link() — binds a link property of one QOM object to another object.
  • sysbus_realize() — finalizes (initializes and activates) a sysbus device.

Now we will update the ugur_m4_init() function to load the kernel and set the boot information. Previously we just define board_id member of the "bootinfo" structure. Now we will define the loader start address and ram size.

    if (machine->kernel_filename) {
        s->bootinfo.board_id = -1;
        s->bootinfo.loader_start = UGUR_M4_FLASH_BASE;
        s->bootinfo.ram_size = UGUR_M4_SRAM_SIZE;
        arm_load_kernel(ARM_CPU(first_cpu), machine, &s->bootinfo);
    }
  • loader_start — tells QEMU where to place the kernel in memory. Here it points to the flash base address 0x08000000.
  • ram_size — the amount of RAM to allocate for the kernel (128 KiB in our case). If left unset, QEMU falls back to the default RAM size defined in the machine class:
static void ugur_m4_class_init(ObjectClass *oc, const void *data)
{
...
    mc->default_ram_size = UGUR_M4_SRAM_SIZE;
...
}
  • default_ram_size — the RAM size used when no -m flag is passed on the command line. If left unset, QEMU falls back to a generic 128 MiB constant — far too large for most embedded targets — causing memory_region_init_ram to fail or produce a machine that doesn't match the real hardware memory map.
  • Setting mc->default_ram_size = UGUR_M4_SRAM_SIZE in class_init ensures the machine boots with the correct amount of RAM out of the box, while still allowing the user to override it with -m.

Let me show you the flow of the "default_ram_size" in QEMU.

qemu_default_ram_size_flow

And here is the summary table:

Scenario ms->ram_size value Result
default_ram_size defined, no -m UGUR_M4_SRAM_SIZE ✅ Correct
default_ram_size defined, -m 512K passed 512 KiB (CLI takes priority) ✅ Overridden safely
default_ram_size not defined, no -m 128 MiB (fallback) ❌ Wrong size
default_ram_size not defined, -m passed CLI value ⚠️ Works but risky

Stage-4: UART

After creating the core components such as CPU, memory and clocks, we can start adding peripherals. We will start with UART.

Good news is that QEMU already has ARM PL011 UART device implementation. You can find the PL011 UART technical reference manual here: ARM PL011. But I will not go through the whole PL011 UART device implementation. Instead, I will just show you how to add and use it in our machine.

First we will define the base address of the UART device in the header file.

#define UGUR_M4_UART0_BASE      0x40000000U

Then we will define the IRQ number of the UART device in the header file.

#define UGUR_M4_UART_IRQ        37

Now we will add the UART device to the machine in the source file. PL011 Uart device module definition is in "hw/arm/pl011.c" file. We will use "pl011_create()" function to create a new PL011 UART device. In future we will learn how to create our own device.

pl011_create(UGUR_M4_UART0_BASE,
            qdev_get_gpio_in(nvic, UGUR_M4_UART_IRQ),
            serial_hd(0));
  • pl011_create() — creates the UART device object, maps it into the system address space, and wires it to the interrupt controller.
  • qdev_get_gpio_in() — retrieves a specific GPIO input pin from the interrupt controller (used here to connect the UART IRQ line).
  • serial_hd() — returns the serial host device for the given unit number, linking the emulated UART to a host serial backend.

Stage-5: Timer

There are also pre-defined timer device modules in QEMU, such as the ARM PL011 UART device module. We will be using the ARM Dual-Timer Module (SP804) on the "ugur-m4" machine. You can access the Reference Manual for the SP804 timer module on the ARM website here: ARM SP804.

First we will define the base address of the timer device in the header file.

#define UGUR_M4_TIMER0_BASE     0x40001000U

Then we will define the IRQ number of the timer devices in the header file.

#define UGUR_M4_TIMER1_IRQ      28
#define UGUR_M4_TIMER2_IRQ      29

Now we will add the timer device to the machine in the source file. SP804 Timer device module definition is in "hw/timer/arm_timer.c" file. We will use "sp804_create()" function to create a new SP804 Timer device.

dev = qdev_new("sp804");
qdev_prop_set_uint32(dev, "freq0", 1000000);
qdev_prop_set_uint32(dev, "freq1", 1000000); 
sbd = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(sbd, &error_fatal);
sysbus_mmio_map(sbd, 0, UGUR_M4_TIMER0_BASE);
sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(nvic, UGUR_M4_TIMER1_IRQ));
  • dev = qdev_new("sp804") — creates a new instance of the ARM SP804 Dual Timer device.
  • qdev_prop_set_uint32() — sets the timer device frequency properties. Both timers are set to 1 MHz.
  • SYS_BUS_DEVICE(dev) — casts the device to a SysBusDevice pointer, which is the standard type for memory-mapped peripherals in QEMU.
  • sysbus_realize_and_unref() — finalizes (realizes) the device and releases the extra reference taken by qdev_new().
  • sysbus_mmio_map() — maps a sysbus device into the system address space.
  • sysbus_connect_irq() — connects a sysbus device to an interrupt line.

Stage-6: GPIO

We will use another device module called "pl061" for the GPIO device. You can find the PL061 GPIO technical reference manual here: ARM PL061.

First we will define the base address of the GPIO device in the header file.

#define UGUR_M4_GPIO0_BASE  0x40002000U

Then we will define the IRQ number of the GPIO device in the header file.

#define UGUR_M4_GPIO_IRQ    6

Now we will add the GPIO device to the machine in the source file. PL061 GPIO device module definition is in "hw/gpio/pl061.c" file.

dev = qdev_new("pl061");
sbd = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(sbd, &error_fatal);
sysbus_mmio_map(sbd, 0, UGUR_M4_GPIO0_BASE);
sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(nvic, UGUR_M4_GPIO_IRQ));

As you can see, same pattern is used for all the devices. Create device, set properties, realize device, map device into memory space, connect device to interrupt controller.

In the final state, the "ugur-m4" machine's header and source files will look like this:

ugur_m4.h

ugur_m4.c

Stage-7: Configure and Build QEMU

We can not directly build QEMU with "ugur-m4" machine. We need to modify the "Kconfig", "meson.build" and "default.mak" files to enable the "ugur-m4" machine in QEMU build configuration.

Let's start with "Kconfig". We need to add the following lines to the "hw/arm/Kconfig" file:

config UGUR_M4
    bool
    default y
    depends on TCG && ARM
    select ARM_V7M      # TYPE_ARMV7M → CPU + integrated NVIC + SysTick
    select PL011        # UART
    select ARM_TIMER    # SP804 Dual Timer
    select PL061        # GPIO
    select UNIMP        # create_unimplemented_device()
  • bool means "UGUR_M4" is a boolean option that can only take either y(yes) or n(no) values. This symbol is invisible in menuconfig and cannot be set manually by the user. It is activated automatically via default y + depends on. I know this explanation a bit long but I initially got confused with these terms.
  • default y means this option is enabled by default, as long as its dependencies (depends on option) are satisfied.
  • depends on TCG && ARM Requires TCG (Tiny Code Generator) and ARM architecture support. So, "UGUR_M4" can only exist if both TCG and ARM conditions are true simultaneously.
  • select ARM_V7M pulls in ARMv7-M core components: Cortex-M CPU, integrated NVIC, and SysTick timer
  • The rest of the select options pull in the respective device modules.

Now we will modify the "meson.build" file. We need to add the following lines to the "hw/arm/meson.build" file:

arm_common_ss.add(when: 'CONFIG_UGUR_M4', if_true: files('ugur_m4.c'))
  • arm_common_ss — the shared source set for the ARM architecture. QEMU's build system manages which files are compiled through such source set objects.
  • .add(when:, if_true:) — the Meson source set API for conditional file inclusion.
  • when: 'CONFIG_UGUR_M4' — the condition is met when the CONFIG_UGUR_M4 symbol is enabled in QEMU’s build configuration. In our case, it is declared in Kconfig with default y, so it evaluates to y unless dependency logic forces it to n or the configuration overrides it.
  • if_true: files('ugur_m4.c') — if the condition is met, ugur_m4.c is included in the build; if the symbol is disabled, the file is excluded from compilation entirely.

Finally we will modify the "default.mak" file. We need to add the following lines to the "hw/arm/default.mak" file:

CONFIG_UGUR_M4=y
  • CONFIG_UGUR_M4=y — explicitly enables the UGUR_M4 board in the default build configuration, acting as a baseline override for the Kconfig default y.

Stage-8: Test the ugur-m4 Machine

In this step, we will write a simple baremetal code compatible with the STM32F407. Since our goal is to test the device modules we defined in the ugur_m4 machine, I won't go into too much detail about the baremetal code itself. You can find the necessary startup (startup_stm32f407xx.s), linker (stm32f4_flash.ld), source code (demo.c), and Makefile for compilation below.

demo.c

Makefile

startup_stm32f407xx.s

stm32f4_flash.ld

Those who have previously developed on the STM32 platform will easily recognize that the startup and linker files were obtained from official STM32F4 resources. In fact, we could have compiled the baremetal code and run it on our ugur_m4 machine using simpler startup and linker files, but I intentionally chose not to do so. My objective here is to design an emulator that behaves as closely as possible to the actual hardware.

Therefore, the purpose of using QEMU (at least for me) is to utilize the resources used in the real device—such as the SDK, kernel, bootloader, application, and dependencies—either without modification or with minimal changes. For this reason, rather than writing minimal startup and linker scripts just to meet our basic needs for the baremetal app, I preferred to use the files from the official STM32 sources.

demo.c performs end-to-end testing of three peripherals added to the ugur_m4 machine:

Module Base Address IRQ Test Scenario
PL011 UART 0x4000_0000 37 Polled TX, interrupt-driven RX echo
SP804 Timer 0x4000_1000 28 1 Hz periodic interrupt
PL061 GPIO 0x4000_2000 — Pin 0 toggle (per timer tick)

Build

make          # produces build/demo.elf, .bin, .hex, .lst
make clean    # removes the build/ directory

Toolchain: arm-none-eabi-gcc (Cortex-M4, Thumb, -O2 -g3)

Running

./qemu-system-arm \
-M ugur-m4 \
-kernel build/demo.elf \
-serial mon:stdio -nographic

The following banner should appear on output:

=== Custom Cortex-M4 QEMU Machine ===
Peripherals: PL011 UART | SP804 Timer | PL061 GPIO

Timer started. You should see 'tick' every second.
Type anything to echo it back via UART RX interrupt.

tick : 1
tick : 2
tick : 3
...

Tested Functions

1. UART — uart_init(), uart_putc(), uart_puts(), uart_putnum()

Function Description
uart_init() Configures PL011 as 8N1, FIFO enabled, RX interrupt enabled. Baud rate: 115200 (IBRD=13, FBRD=1 @ 24 MHz).
uart_putc(c) Waits while TX FIFO is full, then writes a single character.
uart_puts(s) Sends a string; converts \n → \r\n.
uart_putnum(n) Prints an unsigned integer as a decimal string.

Verification:

  • If the banner text appears on -serial mon:stdio output at startup → UART TX (polled) is working.
  • If typing a character in the terminal echoes it back → UART RX interrupt is working.

2. Timer — timer_init_1hz()

Function Description
timer_init_1hz() Configures SP804 Timer 1 in 32-bit periodic mode. LOAD = 999,999 (1 second at 1 MHz clock).

Verification:

  • If tick : N is printed to the console every second → SP804 periodic interrupt and NVIC IRQ 28 routing are working.
  • The tick_count value can be monitored via GDB (volatile int).

3. GPIO — gpio_init(), gpio_toggle_pin0()

Function Description
gpio_init() Sets PL061 pin 0 as output (GPIODIR[0] = 1).
gpio_toggle_pin0() Toggles pin 0 between 0 ↔ 1 on each call (using address-bit masking).

Verification:

  • gpio_toggle_pin0() is called from TIM2_IRQHandler on every tick. Pin state can be verified by reading the PL061_DATA register in GDB.

Interrupt Flow

SP804 Timer IRQ (28)  →  TIM2_IRQHandler()
                            ├─ tick_count++
                            ├─ SP804 IRQ clear
                            ├─ gpio_toggle_pin0()
                            └─ uart print "tick : N"

PL011 UART RX IRQ (37) →  USART1_IRQHandler()
                            ├─ Read all bytes from RX FIFO
                            ├─ Echo each byte back
                            └─ RX IRQ clear

Note: The handler names (TIM2_IRQHandler, USART1_IRQHandler) correspond to STM32F407 vector table slots. The ugur_m4 machine maps these IRQ numbers to the respective devices, hence the same names are used.

Debugging with GDB

# Terminal 1 — Start QEMU in GDB server mode
./qemu-system-arm \
-M ugur-m4 \
-kernel build/demo.elf \
-serial mon:stdio -nographic \
-gdb tcp::5555 -S

# Terminal 2 — Connect GDB
gdb -x run_gdb.py   # or gdb-multiarch -x run_gdb.py

The run_gdb.py script connects via localhost:5555 and sets breakpoints at main, TIM2_IRQHandler, USART1_IRQHandler, and other key locations.

Useful GDB commands:

p tick_count                          # Timer tick counter
x/1xw 0x40002000 + (1 << 2)           # GPIO pin 0 data register
x/1xw 0x40000018                      # UART Flag Register

Expected Output

=== Custom Cortex-M4 QEMU Machine ===
Peripherals: PL011 UART | SP804 Timer | PL061 GPIO

Timer started. You should see 'tick' every second.
Type anything to echo it back via UART RX interrupt.

tick : 1
tick : 2
tick : 3
...

When characters are typed, each one is immediately echoed back.

Conclusion

In this blog post, we have successfully created ugur-m4, a custom basic QEMU machine with armv7m architecture, including UART, GPIO, timer and interrupt controller. We have also written a simple bare-metal program to run on the custom basic machine. I hope this blog post was helpful to you. In the next blog post, I will be creating another custom machine with more detailed peripherals and features.