qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/arm/stm32f405: Add preliminary flash interface emulation


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] hw/arm/stm32f405: Add preliminary flash interface emulation support
Date: Fri, 6 Mar 2020 10:42:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 3/1/20 9:45 AM, Stephanos Ioannidis wrote:
The flash interface (FLASHIF) peripheral provides a control interface
for the SoC embedded flash memory on the STM32F4xx series devices.

This commit adds preliminary support for the flash interface peripheral
emulation, in order to support proper emulation of the firmware images
that use the STM32Cube driver, which configures and validates the
FLASH_ACR register during system initialisation.

Signed-off-by: Stephanos Ioannidis <address@hidden>
---
  hw/arm/Kconfig                      |   1 +
  hw/arm/stm32f405_soc.c              |  15 +-
  hw/misc/Kconfig                     |   3 +
  hw/misc/Makefile.objs               |   1 +
  hw/misc/stm32f4xx_flashif.c         | 215 ++++++++++++++++++++++++++++
  hw/misc/trace-events                |   4 +
  include/hw/arm/stm32f405_soc.h      |   2 +
  include/hw/misc/stm32f4xx_flashif.h | 144 +++++++++++++++++++

Consider using the scripts/git.orderfile configuration.

  8 files changed, 384 insertions(+), 1 deletion(-)
  create mode 100644 hw/misc/stm32f4xx_flashif.c
  create mode 100644 include/hw/misc/stm32f4xx_flashif.h

diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 3d86691ae0..179696ec91 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -314,6 +314,7 @@ config STM32F205_SOC
  config STM32F405_SOC
      bool
      select ARM_V7M
+    select STM32F4XX_FLASHIF
      select STM32F4XX_SYSCFG
      select STM32F4XX_EXTI
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 9bcad97853..72b16910c7 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -30,6 +30,7 @@
  #include "hw/arm/stm32f405_soc.h"
  #include "hw/misc/unimp.h"
+#define FLASHIF_ADDR 0x40023C00
  #define SYSCFG_ADD                     0x40013800
  static const uint32_t usart_addr[] = { 0x40011000, 0x40004400, 0x40004800,
                                         0x40004C00, 0x40005000, 0x40011400,
@@ -59,6 +60,9 @@ static void stm32f405_soc_initfn(Object *obj)
      sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m),
                            TYPE_ARMV7M);
+ sysbus_init_child_obj(obj, "flashif", &s->flashif, sizeof(s->flashif),
+                          TYPE_STM32F4XX_FLASHIF);
+
      sysbus_init_child_obj(obj, "syscfg", &s->syscfg, sizeof(s->syscfg),
                            TYPE_STM32F4XX_SYSCFG);
@@ -130,6 +134,16 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
          return;
      }
+ /* Flash interface */
+    dev = DEVICE(&s->flashif);

You might want to add a 'link property' to the s->flash memory region here, so you can lock/unlock/program/fuse it later.

+    object_property_set_bool(OBJECT(&s->flashif), true, "realized", &err);
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
+    busdev = SYS_BUS_DEVICE(dev);
+    sysbus_mmio_map(busdev, 0, FLASHIF_ADDR);
+
      /* System configuration controller */
      dev = DEVICE(&s->syscfg);
      object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
@@ -261,7 +275,6 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, 
Error **errp)
      create_unimplemented_device("GPIOI",       0x40022000, 0x400);
      create_unimplemented_device("CRC",         0x40023000, 0x400);
      create_unimplemented_device("RCC",         0x40023800, 0x400);
-    create_unimplemented_device("Flash Int",   0x40023C00, 0x400);
      create_unimplemented_device("BKPSRAM",     0x40024000, 0x400);
      create_unimplemented_device("DMA1",        0x40026000, 0x400);
      create_unimplemented_device("DMA2",        0x40026400, 0x400);
[...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]