Add STM32F4 support and USART device model
Subsystems (2)
v2 cover Add STM32F4 support and USART device model
From: Yihao Fan <[email protected]>
This patch series introduces basic support for the STM32F407 SoC and a new STM32F4spark machine in QEMU, along with a USART device model.
This series includes:
- A new SoC model (STM32F407) with initial integration.
- A board model called STM32F4spark to instantiate and test the SoC.
- A USART device implementation for STM32F4xx family.
Yihao Fan (3):
Add-the-stm32f407-SoC
Add the STM32F4spark Machine
Add STM32F4xx USART device model
MAINTAINERS | 16 ++ hw/arm/Kconfig | 13 ++ hw/arm/meson.build | 2 + hw/arm/stm32f407_soc.c | 154 +++++++++++++++++++ hw/arm/stm32f4spark.c | 48 ++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 47 ++++++ include/hw/char/stm32f4xx_usart.h | 60 ++++++++ 10 files changed, 580 insertions(+) create mode 100644 hw/arm/stm32f407_soc.c create mode 100644 hw/arm/stm32f4spark.c create mode 100644 hw/char/stm32f4xx_usart.c create mode 100644 include/hw/arm/stm32f407_soc.h create mode 100644 include/hw/char/stm32f4xx_usart.h
Signature · 1 line
2.43.0
PATCH v2 1/3 Add-the-stm32f407-SoC
From: Yihao Fan <[email protected]>
This patch introduces a new QEMU machine type for the STM32F407 SoC featuring a Cortex-M4 core. This will be used by the RT-Spark to create a machine.
--- MAINTAINERS | 7 ++ hw/arm/Kconfig | 6 ++ hw/arm/meson.build | 1 + hw/arm/stm32f407_soc.c | 130 +++++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 39 ++++++++++ 5 files changed, 183 insertions(+) create mode 100644 hw/arm/stm32f407_soc.c create mode 100644 include/hw/arm/stm32f407_soc.h
MAINTAINERS +7 -0
@@ -1137,6 +1137,13 @@ F: hw/misc/stm32f4xx_exti.c F: hw/misc/stm32_rcc.c F: include/hw/misc/stm32_rcc.h +STM32F407 +M: yanl1229 <[email protected]> +M: Yihao Fan <[email protected]> +L: [email protected] +S: Maintained +F: hw/arm/stm32f407_soc.c + Netduino 2 M: Alistair Francis <[email protected]> M: Peter Maydell <[email protected]>
hw/arm/Kconfig +6 -0
@@ -392,6 +392,12 @@ config STM32F405_SOC select STM32F4XX_SYSCFG select STM32F4XX_EXTI +config STM32F407_SOC + bool + select ARM_V7M + select STM32F4XX_SYSCFG + select STM32F4XX_EXTI + config B_L475E_IOT01A bool default y
hw/arm/meson.build +1 -0
@@ -32,6 +32,7 @@ arm_common_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2 arm_common_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c')) arm_common_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c')) arm_common_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c')) +arm_common_ss.add(when: 'CONFIG_STM32F407_SOC', if_true: files('stm32f407_soc.c')) arm_common_ss.add(when: 'CONFIG_B_L475E_IOT01A', if_true: files('b-l475e-iot01a.c')) arm_common_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_soc.c')) arm_common_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp.c', 'xlnx-zcu102.c'))
hw/arm/stm32f407_soc.c new file +130 -0
130 lines not on this page · raw message
include/hw/arm/stm32f407_soc.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef STM32F407_SOC_H +#define STM32F407_SOC_H + +#include "hw/or-irq.h" +#include "hw/arm/armv7m.h" +#include "hw/misc/stm32f4xx_syscfg.h" +#include "hw/misc/stm32f4xx_exti.h" + +#include "qom/object.h" + +#define TYPE_STM32F407_SOC "stm32f407-soc" +OBJECT_DECLARE_SIMPLE_TYPE(STM32F407State, STM32F407_SOC) + +#define SYSCFG_BASE_ADDRESS 0x40013800 +#define SYSCFG_IRQ 71 +#define EXIT_BASE_ADDRESS 0x40013C00 +#define FLASH_BASE_ADDRESS 0x8000000 +#define FLASH_SIZE 0x100000 +#define SRAM_BASE_ADDRESS 0x20000000 +#define SRAM_SIZE (192 * 1024) + + +struct STM32F407State { +/*< private >*/ +SysBusDevice parent_obj; +/*< public >*/ + +char *kernel_filename; +ARMv7MState armv7m; + +STM32F4xxSyscfgState syscfg; +STM32F4xxExtiState exti; + +Clock *sysclk; +Clock *refclk; +}; + +#endif
Signature · 1 line
2.43.0
Re: [PATCH v2 1/3] Add-the-stm32f407-SoC
Quoted 5 lines · On Mon, 21 Jul 2025 at 21:11, <[email protected]> wrote:
From: Yihao Fan <[email protected]>
This patch introduces a new QEMU machine type for the STM32F407 SoC featuring a Cortex-M4 core. This will be used by the RT-Spark to create a machine.
The Subject line of this patch seems to have hyphens instead of spaces. A "hw/arm:" prefix would also be helpful.
hw/arm/stm32f407_soc.c line 1
Quoted 7 lines
hw/arm/stm32f407_soc.c new file +1
-0@@ -0,0 +1,130 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
This seems very similar to the existing stm32f05_soc.c. How different are these two SoCs? Would it make sense to share code?
I've cc'd Alistair as the maintainer of the stm32f05.
thanks
-- PMM
Re: [PATCH v2 1/3] Add-the-stm32f407-SoC
Hi,
Thanks for the comment.
The STM32F407 is similar to the STM32F405. The main differences are in peripherals (the F407 integrates Ethernet MAC and a camera interface, which the F405 lacks). I’ll review the common parts and see what code can be shared in revision V3.
Best Wishes,
--Yihao Fan
Original:
From:Peter Maydell <[email protected]>Date:2025-08-16 01:56:02(中国 (GMT+08:00))To:fanyihao<[email protected]>Cc:qemu-devel<[email protected]> , Alistair Francis <[email protected]>Subject:Re: [PATCH v2 1/3] Add-the-stm32f407-SoCOn Mon, 21 Jul 2025 at 21:11, <[email protected]> wrote:
Quoted 5 lines
From: Yihao Fan <[email protected]>
This patch introduces a new QEMU machine type for the STM32F407 SoC featuring a Cortex-M4 core. This will be used by the RT-Spark to create a machine.
The Subject line of this patch seems to have hyphens instead of spaces. A "hw/arm:" prefix would also be helpful.
hw/arm/stm32f407_soc.c line 1
Quoted 7 lines
hw/arm/stm32f407_soc.c new file +1
-0@@ -0,0 +1,130 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
This seems very similar to the existing stm32f05_soc.c. How different are these two SoCs? Would it make sense to share code?
I've cc'd Alistair as the maintainer of the stm32f05.
thanks
-- PMM
PATCH v2 2/3 Add the STM32F4spark Machine
In reply to [email protected]From: Yihao Fan <[email protected]>
Add the STM32F4spark machine model using the STM32F407 SoC.
--- MAINTAINERS | 7 +++++++ hw/arm/Kconfig | 6 ++++++ hw/arm/meson.build | 1 + hw/arm/stm32f4spark.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 hw/arm/stm32f4spark.c
MAINTAINERS +7 -0
@@ -1030,6 +1030,13 @@ S: Maintained F: hw/arm/stm32vldiscovery.c F: docs/system/arm/stm32.rst +STM32F4SPARK +M: yanl1229 <[email protected]> +M: Yihao Fan <[email protected]> +L: [email protected] +S: Maintained +F: hw/arm/stm32f4spark.c + Versatile Express M: Peter Maydell <[email protected]> L: [email protected]
hw/arm/Kconfig +6 -0
@@ -234,6 +234,12 @@ config STM32VLDISCOVERY depends on TCG && ARM select STM32F100_SOC +config STM32F4SPARK + bool + default y + depends on TCG && ARM + select STM32F407_SOC + config STRONGARM bool select PXA2XX_TIMER
hw/arm/meson.build +1 -0
@@ -17,6 +17,7 @@ arm_common_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c')) arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c')) arm_common_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c')) arm_common_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c')) +arm_common_ss.add(when: 'CONFIG_STM32F4SPARK', if_true: files('stm32f4spark.c')) arm_common_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xilinx_zynq.c')) arm_common_ss.add(when: 'CONFIG_SABRELITE', if_true: files('sabrelite.c'))
hw/arm/stm32f4spark.c new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] Add the STM32F4spark Machine
Quoted 67 lines · On Mon, 21 Jul 2025 at 21:11, <[email protected]> wrote:
From: Yihao Fan <[email protected]>
Add the STM32F4spark machine model using the STM32F407 SoC.
Signed-off-by Yihao Fan <[email protected]>--- MAINTAINERS | 7 +++++++ hw/arm/Kconfig | 6 ++++++ hw/arm/meson.build | 1 + hw/arm/stm32f4spark.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 hw/arm/stm32f4spark.cMAINTAINERS +7
-0@@ -1030,6 +1030,13 @@ S: Maintained F: hw/arm/stm32vldiscovery.c F: docs/system/arm/stm32.rst +STM32F4SPARK +M: yanl1229 <[email protected]> +M: Yihao Fan <[email protected]> +L: [email protected] +S: Maintained +F: hw/arm/stm32f4spark.c + Versatile Express M: Peter Maydell <[email protected]> L: [email protected]hw/arm/Kconfig +6
-0@@ -234,6 +234,12 @@ config STM32VLDISCOVERY depends on TCG && ARM select STM32F100_SOC +config STM32F4SPARK + bool + default y + depends on TCG && ARM + select STM32F407_SOC + config STRONGARM bool select PXA2XX_TIMERhw/arm/meson.build +1
-0@@ -17,6 +17,7 @@ arm_common_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c')) arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c')) arm_common_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c')) arm_common_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c')) +arm_common_ss.add(when: 'CONFIG_STM32F4SPARK', if_true: files('stm32f4spark.c')) arm_common_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xilinx_zynq.c')) arm_common_ss.add(when: 'CONFIG_SABRELITE', if_true: files('sabrelite.c'))hw/arm/stm32f4spark.c new file +0
-0
hw/arm/stm32f4spark.c line 1
Quoted 1 line
hw/arm/stm32f4spark.c new file +1
-0@@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
Generally files should have something more than just the SPDX tag in their opening comment. Usually that is a statement of what the file contains. This is also a good place to put a URL to the datasheet/reference manual/etc for the hardware being modelled.
Otherwise this patch looks OK.
-- PMM
Re: [PATCH v2 2/3] Add the STM32F4spark Machine
Hi,
Thanks, I’ll add the description and datasheet link in the next revision.
Best wishes,
-- Yihao Fan
Original:
Quoted 67 lines · From:Peter Maydell <[email protected]>Date:2025-08-16 01:52:19(中国…
From: Yihao Fan <[email protected]>
Add the STM32F4spark machine model using the STM32F407 SoC.
Signed-off-by Yihao Fan <[email protected]>--- MAINTAINERS | 7 +++++++ hw/arm/Kconfig | 6 ++++++ hw/arm/meson.build | 1 + hw/arm/stm32f4spark.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 hw/arm/stm32f4spark.cMAINTAINERS +7
-0@@ -1030,6 +1030,13 @@ S: Maintained F: hw/arm/stm32vldiscovery.c F: docs/system/arm/stm32.rst +STM32F4SPARK +M: yanl1229 <[email protected]> +M: Yihao Fan <[email protected]> +L: [email protected] +S: Maintained +F: hw/arm/stm32f4spark.c + Versatile Express M: Peter Maydell <[email protected]> L: [email protected]hw/arm/Kconfig +6
-0@@ -234,6 +234,12 @@ config STM32VLDISCOVERY depends on TCG && ARM select STM32F100_SOC +config STM32F4SPARK + bool + default y + depends on TCG && ARM + select STM32F407_SOC + config STRONGARM bool select PXA2XX_TIMERhw/arm/meson.build +1
-0@@ -17,6 +17,7 @@ arm_common_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c')) arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c')) arm_common_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c')) arm_common_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c')) +arm_common_ss.add(when: 'CONFIG_STM32F4SPARK', if_true: files('stm32f4spark.c')) arm_common_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xilinx_zynq.c')) arm_common_ss.add(when: 'CONFIG_SABRELITE', if_true: files('sabrelite.c'))hw/arm/stm32f4spark.c new file +0
-0
hw/arm/stm32f4spark.c line 1
Quoted 1 line
hw/arm/stm32f4spark.c new file +1
-0@@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
Generally files should have something more than just the SPDX tag in their opening comment. Usually that is a statement of what the file contains. This is also a good place to put a URL to the datasheet/reference manual/etc for the hardware being modelled.
Otherwise this patch looks OK.
-- PMM
PATCH v2 3/3 Add STM32F4xx USART device model
In reply to [email protected]From: Yihao Fan <[email protected]>
This patch adds support for the STM32F407 USART controllers device model.
--- MAINTAINERS | 2 + hw/arm/Kconfig | 1 + hw/arm/stm32f407_soc.c | 25 +++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 8 + include/hw/char/stm32f4xx_usart.h | 60 ++++++++ 8 files changed, 335 insertions(+) create mode 100644 hw/char/stm32f4xx_usart.c create mode 100644 include/hw/char/stm32f4xx_usart.h
MAINTAINERS +2 -0
@@ -1150,6 +1150,8 @@ M: Yihao Fan <[email protected]> L: [email protected] S: Maintained F: hw/arm/stm32f407_soc.c +F: hw/char/stm32f4xx_usart.c +F: include/hw/char/stm32f4xx_usart.h Netduino 2 M: Alistair Francis <[email protected]>
hw/arm/Kconfig +1 -0
@@ -403,6 +403,7 @@ config STM32F407_SOC select ARM_V7M select STM32F4XX_SYSCFG select STM32F4XX_EXTI + select STM32F4XX_USART config B_L475E_IOT01A bool
hw/arm/stm32f407_soc.c +25 -0
@@ -20,6 +20,13 @@ static const int exti_irq[] = { 40, 40, 40, 40, 40 }; +static const uint32_t usart_addr[STM_NUM_USARTS ] = { +STM32F407_USART1 ,STM32F407_USART2 ,STM32F407_USART3 , +STM32F407_USART6 +}; +static const int usart_irq[STM_NUM_USARTS ] = { +37 ,38 ,39 ,71 +};static void stm32f407_soc_initfn (Object *obj) {
@@ -32,6 +40,12 @@ static void stm32f407_soc_initfn(Object *obj)object_initialize_child (obj,"syscfg" , &s->syscfg,TYPE_STM32F4XX_SYSCFG );object_initialize_child (obj,"exti" , &s->exti,TYPE_STM32F4XX_EXTI ); +for (i =0 ; i <STM_NUM_USARTS ; i++) { +object_initialize_child (obj,"usart[*]" , &s->usart[i], +TYPE_STM32F4XX_USART ); + } + + s->sysclk =qdev_init_clock_in (DEVICE (s),"sysclk" ,NULL ,NULL ,0 ); s->refclk =qdev_init_clock_in (DEVICE (s),"refclk" ,NULL ,NULL ,0 ); }
@@ -105,6 +117,18 @@ static void stm32f407_soc_realize(DeviceState *dev_soc, Error **errp)qdev_connect_gpio_out (DEVICE (&s->syscfg), i,qdev_get_gpio_in (dev, i)); } +/* USART controllers */ +for (i =0 ; i <STM_NUM_USARTS ; i) { + dev =DEVICE (&(s->usart[i])); +qdev_prop_set_chr (dev,"chardev" ,serial_hd (i)); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->usart[i]), errp)) { +return ; + } + busdev =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (busdev,0 , usart_addr[i]); +sysbus_connect_irq (busdev,0 ,qdev_get_gpio_in (armv7m, usart_irq[i])); + } + }static void stm32f407_soc_class_init (ObjectClass *klass,void *data)
hw/char/Kconfig +3 -0
@@ -51,6 +51,9 @@ config VIRTIO_SERIAL config STM32F2XX_USART bool +config STM32F4XX_USART + bool + config STM32L4X5_USART bool
hw/char/meson.build +1 -0
@@ -32,6 +32,7 @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c')) system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c')) system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c')) system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c')) +system_ss.add(when: 'CONFIG_STM32F4XX_USART', if_true: files('stm32f4xx_usart.c')) system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c')) system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c')) system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
hw/char/stm32f4xx_usart.c new file +236 -0
236 lines not on this page · raw message
include/hw/arm/stm32f407_soc.h +8 -0
@@ -6,6 +6,7 @@#include "hw/arm/armv7m.h" #include "hw/misc/stm32f4xx_syscfg.h" #include "hw/misc/stm32f4xx_exti.h" +#include "hw/char/stm32f4xx_usart.h" #include "qom/object.h"
@@ -20,6 +21,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F407State, STM32F407_SOC)#define SRAM_BASE_ADDRESS 0x20000000#define SRAM_SIZE (192 * 1024) +#define STM_NUM_USARTS 4 +#define STM32F407_USART1 0x40011000 +#define STM32F407_USART2 0x40004400 +#define STM32F407_USART3 0x40004800 +#define STM32F407_USART6 0x40011400 +struct STM32F407State {/*< private >*/
@@ -31,6 +38,7 @@ struct STM32F407State {STM32F4xxSyscfgState syscfg;STM32F4xxExtiState exti; +STM32F4XXUsartState usart[STM_NUM_USARTS ];Clock *sysclk;Clock *refclk;
include/hw/char/stm32f4xx_usart.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 3/3] Add STM32F4xx USART device model
Quoted 6 lines · On Mon, 21 Jul 2025 at 21:11, <[email protected]> wrote:
From: Yihao Fan <[email protected]>
This patch adds support for the STM32F407 USART controllers device model.
Signed-off-by Yihao Fan <[email protected]>
Quoted 9 lines
--- MAINTAINERS | 2 + hw/arm/Kconfig | 1 + hw/arm/stm32f407_soc.c | 25 +++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 8 + include/hw/char/stm32f4xx_usart.h | 60 ++++++++
We generally prefer two separate patches for this:
(1) implementation of the new device
(2) add the new device to the SoC
hw/char/stm32f4xx_usart.c line 8
Quoted 11 lines
hw/char/stm32f4xx_usart.c new file +8
-0@@ -0,0 +1,236 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "qemu/osdep.h" +#include "hw/char/stm32f4xx_usart.h" +#include "qemu/log.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "qemu/module.h"
This looks very similar to the existing stm32f2xx USART. How different are these two devices? Could we share code by having them be two child classes which adjust what features the device exposes?
thanks
- PMM
Re: [PATCH v2 3/3] Add STM32F4xx USART device model
Hi,
The F4xx USART is largely similar to the F2xx. The implementation can mostly be shared, with F4-specific features added separately, allowing a common base while keeping differences isolated. I’ll consider sharing a common base in the next revision.
Best wishes,
-- Yihao Fan
Original:
Quoted 6 lines · From:Peter Maydell <[email protected]>Date:2025-08-16 01:46:06(中国…
From: Yihao Fan <[email protected]>
This patch adds support for the STM32F407 USART controllers device model.
Signed-off-by Yihao Fan <[email protected]>
Quoted 9 lines
--- MAINTAINERS | 2 + hw/arm/Kconfig | 1 + hw/arm/stm32f407_soc.c | 25 +++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 8 + include/hw/char/stm32f4xx_usart.h | 60 ++++++++
We generally prefer two separate patches for this:
(1) implementation of the new device
(2) add the new device to the SoC
hw/char/stm32f4xx_usart.c line 8
Quoted 11 lines
hw/char/stm32f4xx_usart.c new file +8
-0@@ -0,0 +1,236 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "qemu/osdep.h" +#include "hw/char/stm32f4xx_usart.h" +#include "qemu/log.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "qemu/module.h"
This looks very similar to the existing stm32f2xx USART. How different are these two devices? Could we share code by having them be two child classes which adjust what features the device exposes?
thanks
- PMM
Hi,
Just a gentle ping on this patch series:
[PATCH v2 0/3] Add STM32F4 support and USART device model
https://patchew.org/QEMU/[email protected]/
This patch adds support for the STM32F407 SoC, a new STM32F4spark board, and a USART device model. Feedback would be greatly appreciated.
This patch will be applied in the /hw/arm directory.
Let me know if any changes are needed or if I should rebase it on a newer tree. Best regards,
Yihao Fan
[email protected]
Original:
From:Yihao Fan <[email protected]>Date:2025-07-22 04:11:31(中国 (GMT+08:00))To:qemu-devel<[email protected]>Cc:Peter Maydell <[email protected]> , Yihao Fan <[email protected]>Subject:[PATCH v2 0/3] Add STM32F4 support and USART device modelFrom: Yihao Fan <[email protected]>
This patch series introduces basic support for the STM32F407 SoC and a new STM32F4spark machine in QEMU, along with a USART device model.
This series includes:
- A new SoC model (STM32F407) with initial integration.
- A board model called STM32F4spark to instantiate and test the SoC.
- A USART device implementation for STM32F4xx family.
Yihao Fan (3):
Add-the-stm32f407-SoC
Add the STM32F4spark Machine
Add STM32F4xx USART device model
MAINTAINERS | 16 ++ hw/arm/Kconfig | 13 ++ hw/arm/meson.build | 2 + hw/arm/stm32f407_soc.c | 154 +++++++++++++++++++ hw/arm/stm32f4spark.c | 48 ++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 47 ++++++ include/hw/char/stm32f4xx_usart.h | 60 ++++++++ 10 files changed, 580 insertions(+) create mode 100644 hw/arm/stm32f407_soc.c create mode 100644 hw/arm/stm32f4spark.c create mode 100644 hw/char/stm32f4xx_usart.c create mode 100644 include/hw/arm/stm32f407_soc.h create mode 100644 include/hw/char/stm32f4xx_usart.h
Signature · 1 line
2.43.0
Quoted 8 lines · 范艺豪
Hi,
Just a gentle ping on this patch series:
[PATCH v2 0/3] Add STM32F4 support and USART device model
https://patchew.org/QEMU/[email protected]/This patch adds support for the STM32F407 SoC, a new STM32F4spark board, and a USART device model. Feedback would be greatly appreciated
Hi; thanks for the ping. This series is on my list to review, but right now we are in the freeze period for the 10.1 release, so I've been concentrating on bug fix patches which are going into the release. It may be a little while before I can get to it. (Other people are of course welcome to review it instead!)
thanks
-- PMM
Hi, Thanks for the info. No problem at all. Happy to wait. Best wishes,
— Fanyihao
在 2025-08-02 19:17:11,Peter Maydell <[email protected]> 写道:
Quoted 8 lines · 范艺豪
Hi,
Just a gentle ping on this patch series:
[PATCH v2 0/3] Add STM32F4 support and USART device model
https://patchew.org/QEMU/[email protected]/This patch adds support for the STM32F407 SoC, a new STM32F4spark board, and a USART device model. Feedback would be greatly appreciated
Hi; thanks for the ping. This series is on my list to review, but right now we are in the freeze period for the 10.1 release, so I've been concentrating on bug fix patches which are going into the release. It may be a little while before I can get to it. (Other people are of course welcome to review it instead!)
thanks
-- PMM
Quoted 18 lines · On Mon, 21 Jul 2025 at 21:11, <[email protected]> wrote:
From: Yihao Fan <[email protected]>
This patch series introduces basic support for the STM32F407 SoC and a new STM32F4spark machine in QEMU, along with a USART device model.
This series includes:
- A new SoC model (STM32F407) with initial integration.
- A board model called STM32F4spark to instantiate and test the SoC.
- A USART device implementation for STM32F4xx family.Signed-off-by Yihao Fan <[email protected]>Yihao Fan (3):
Add-the-stm32f407-SoC
Add the STM32F4spark Machine
Add STM32F4xx USART device model
Quoted 10 lines
MAINTAINERS | 16 ++ hw/arm/Kconfig | 13 ++ hw/arm/meson.build | 2 + hw/arm/stm32f407_soc.c | 154 +++++++++++++++++++ hw/arm/stm32f4spark.c | 48 ++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 47 ++++++ include/hw/char/stm32f4xx_usart.h | 60 ++++++++
For a new board model there are a couple of things we'd like to see that aren't in this patchset:
(1) Documentation. This lives in docs/system/arm/. For this board you want to add it to stm32.rst.
(2) A test case in tests/functional/ -- generally this is something that downloads an image file from a public stable URL, runs it in QEMU and checks for some output from the guest on the UART indicating success. Lots of examples in this directory to see how to do it.
thanks
-- PMM
Hi ,
Thanks for the review and helpful suggestions.
I will update the board documentation and provide a functional test case in the next version.
Best wishes,
Yihao Fan
Original:
Quoted 18 lines · From:Peter Maydell <[email protected]>Date:2025-08-16 01:49:37(中国…
From: Yihao Fan <[email protected]>
This patch series introduces basic support for the STM32F407 SoC and a new STM32F4spark machine in QEMU, along with a USART device model.
This series includes:
- A new SoC model (STM32F407) with initial integration.
- A board model called STM32F4spark to instantiate and test the SoC.
- A USART device implementation for STM32F4xx family.Signed-off-by Yihao Fan <[email protected]>Yihao Fan (3):
Add-the-stm32f407-SoC
Add the STM32F4spark Machine
Add STM32F4xx USART device model
Quoted 10 lines
MAINTAINERS | 16 ++ hw/arm/Kconfig | 13 ++ hw/arm/meson.build | 2 + hw/arm/stm32f407_soc.c | 154 +++++++++++++++++++ hw/arm/stm32f4spark.c | 48 ++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32f4xx_usart.c | 236 ++++++++++++++++++++++++++++++ include/hw/arm/stm32f407_soc.h | 47 ++++++ include/hw/char/stm32f4xx_usart.h | 60 ++++++++
For a new board model there are a couple of things we'd like to see that aren't in this patchset:
(1) Documentation. This lives in docs/system/arm/. For this board you want to add it to stm32.rst.
(2) A test case in tests/functional/ -- generally this is something that downloads an image file from a public stable URL, runs it in QEMU and checks for some output from the guest on the UART indicating success. Lots of examples in this directory to see how to do it.
thanks
-- PMM