1 /* 2 * B-L475E-IOT01A Discovery Kit machine 3 * (B-L475E-IOT01A IoT Node) 4 * 5 * Copyright (c) 2023-2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> 6 * Copyright (c) 2023-2024 Inès Varhol <ines.varhol@telecom-paris.fr> 7 * 8 * SPDX-License-Identifier: GPL-2.0-or-later 9 * 10 * This work is licensed under the terms of the GNU GPL, version 2 or later. 11 * See the COPYING file in the top-level directory. 12 * 13 * This work is heavily inspired by the netduinoplus2 by Alistair Francis. 14 * Original code is licensed under the MIT License: 15 * 16 * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> 17 */ 18 19 /* 20 * The reference used is the STMicroElectronics UM2153 User manual 21 * Discovery kit for IoT node, multi-channel communication with STM32L4. 22 * https://www.st.com/en/evaluation-tools/b-l475e-iot01a.html#documentation 23 */ 24 25 #include "qemu/osdep.h" 26 #include "qapi/error.h" 27 #include "hw/boards.h" 28 #include "hw/qdev-properties.h" 29 #include "qemu/error-report.h" 30 #include "hw/arm/stm32l4x5_soc.h" 31 #include "hw/arm/boot.h" 32 33 /* B-L475E-IOT01A implementation is derived from netduinoplus2 */ 34 35 #define TYPE_B_L475E_IOT01A MACHINE_TYPE_NAME("b-l475e-iot01a") 36 OBJECT_DECLARE_SIMPLE_TYPE(Bl475eMachineState, B_L475E_IOT01A) 37 38 typedef struct Bl475eMachineState { 39 MachineState parent_obj; 40 41 Stm32l4x5SocState soc; 42 } Bl475eMachineState; 43 44 static void bl475e_init(MachineState *machine) 45 { 46 Bl475eMachineState *s = B_L475E_IOT01A(machine); 47 const Stm32l4x5SocClass *sc; 48 49 object_initialize_child(OBJECT(machine), "soc", &s->soc, 50 TYPE_STM32L4X5XG_SOC); 51 sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal); 52 53 sc = STM32L4X5_SOC_GET_CLASS(&s->soc); 54 armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0, 55 sc->flash_size); 56 } 57 58 static void bl475e_machine_init(ObjectClass *oc, void *data) 59 { 60 MachineClass *mc = MACHINE_CLASS(oc); 61 static const char *machine_valid_cpu_types[] = { 62 ARM_CPU_TYPE_NAME("cortex-m4"), 63 NULL 64 }; 65 mc->desc = "B-L475E-IOT01A Discovery Kit (Cortex-M4)"; 66 mc->init = bl475e_init; 67 mc->valid_cpu_types = machine_valid_cpu_types; 68 69 /* SRAM pre-allocated as part of the SoC instantiation */ 70 mc->default_ram_size = 0; 71 } 72 73 static const TypeInfo bl475e_machine_type[] = { 74 { 75 .name = TYPE_B_L475E_IOT01A, 76 .parent = TYPE_MACHINE, 77 .instance_size = sizeof(Bl475eMachineState), 78 .class_init = bl475e_machine_init, 79 } 80 }; 81 82 DEFINE_TYPES(bl475e_machine_type) 83