Skip to content

Commit fdcac08

Browse files
authored
99 extra flash ram (#100)
* #99 - proper deprecation * support -m arg * option to expand flash storage
1 parent 74c513d commit fdcac08

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

hw/arm/prusa/prusa-mini.c

+12-15
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ static void prusa_mini_init(MachineState *machine)
4444

4545
dev = qdev_new(TYPE_STM32F407_SOC);
4646
qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
47+
qdev_prop_set_uint32(dev,"sram-size", machine->ram_size);
4748
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
4849
STM32F407State *SOC = STM32F407_SOC(dev);
4950
// We (ab)use the kernel command line to piggyback custom arguments into QEMU.
5051
// Parse those now.
5152
arghelper_setargs(machine->kernel_cmdline);
52-
53+
int default_flash_size = FLASH_SIZE;
54+
if (arghelper_is_arg("4x_flash"))
55+
{
56+
default_flash_size <<=2; // quadruple the flash size for debug code.
57+
}
5358
if (arghelper_is_arg("appendix")) {
5459
SOC->gpio[GPIO_A].idr_mask |= 0x2000;
5560
}
@@ -71,13 +76,13 @@ static void prusa_mini_init(MachineState *machine)
7176
load_image_targphys(machine->kernel_filename,0x20000-64,get_image_size(machine->kernel_filename));
7277
armv7m_load_kernel(ARM_CPU(first_cpu),
7378
BOOTLOADER_IMAGE,
74-
FLASH_SIZE);
79+
default_flash_size);
7580
}
7681
else // Raw bin or ELF file, load directly.
7782
{
7883
armv7m_load_kernel(ARM_CPU(first_cpu),
7984
machine->kernel_filename,
80-
FLASH_SIZE);
85+
default_flash_size);
8186
}
8287
}
8388

@@ -314,25 +319,17 @@ static void prusa_mini_init(MachineState *machine)
314319

315320
static void prusa_mini_machine_init(MachineClass *mc)
316321
{
317-
mc->desc = "Prusa Mini Board";
322+
mc->desc = "Prusa Mini";
318323
mc->init = prusa_mini_init;
324+
mc->default_ram_size = F407_SRAM_SIZE;
319325
}
320326

321327
DEFINE_MACHINE("prusa-mini", prusa_mini_machine_init)
322328

323-
324-
// TODO - remove this at some point in the future...
325-
326-
static void buddy_init(MachineState *machine)
327-
{
328-
error_setg(&error_fatal, "-machine prusabuddy has been deprecated. Please use -machine prusa-mini instead.\n");
329-
};
330-
331-
332329
static void buddy_machine_init(MachineClass *mc)
333330
{
334-
mc->desc = "Prusa Mini Board (Deprecated)";
335-
mc->init = buddy_init;
331+
mc->desc = "Prusa Mini Board";
332+
mc->deprecation_reason = "prusabuddy has been deprecated because it's a board, not a machine. Use -machine prusa-mini instead";
336333
}
337334

338335
DEFINE_MACHINE("prusabuddy", buddy_machine_init)

hw/arm/prusa/stm32f407/stm32f407_soc.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "net/net.h"
3434
#include "hw/i2c/smbus_eeprom.h"
3535
#include "exec/ramblock.h"
36+
#include "hw/qdev-properties.h"
3637
#define SYSCFG_ADD 0x40013800
3738
static const uint32_t usart_addr[] = { 0x40011000, 0x40004400, 0x40004800,
3839
0x40004C00, 0x40005000, 0x40011400,
@@ -194,7 +195,7 @@ static void stm32f407_soc_realize(DeviceState *dev_soc, Error **errp)
194195
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
195196
memory_region_add_subregion(system_memory, 0, &s->flash_alias);
196197

197-
memory_region_init_ram(&s->sram, NULL, "STM32F407.sram", SRAM_SIZE,
198+
memory_region_init_ram(&s->sram, NULL, "STM32F407.sram", s->ram_size,
198199
&err);
199200
if (err != NULL) {
200201
error_propagate(errp, err);
@@ -560,6 +561,7 @@ static void stm32f407_soc_realize(DeviceState *dev_soc, Error **errp)
560561

561562
static Property stm32f407_soc_properties[] = {
562563
DEFINE_PROP_STRING("cpu-type", STM32F407State, cpu_type),
564+
DEFINE_PROP_UINT32("sram-size",STM32F407State, ram_size, 192*KiB),
563565
DEFINE_PROP_END_OF_LIST(),
564566
};
565567

hw/arm/prusa/stm32f407/stm32f407_soc.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "hw/misc/stm32f4xx_syscfg.h"
3030
#include "hw/timer/stm32f2xx_timer.h"
31-
// #include "hw/char/stm32f2xx_usart.h"
31+
#include "qemu/units.h"
3232
#include "hw/misc/stm32f4xx_exti.h"
3333
#include "hw/or-irq.h"
3434
#include "stm32f4xx_adc.h"
@@ -64,9 +64,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F407State, STM32F407_SOC)
6464
#define STM_NUM_DMAS 2
6565

6666
#define FLASH_BASE_ADDRESS 0x08000000
67-
#define FLASH_SIZE (1024 * 1024)
67+
#define FLASH_SIZE (1U *MiB)
6868
#define SRAM_BASE_ADDRESS 0x20000000
69-
#define SRAM_SIZE (192 * 1024)
69+
#define F407_SRAM_SIZE (192 * KiB)
7070

7171

7272
// Convenience enum.
@@ -135,6 +135,8 @@ struct STM32F407State {
135135
MemoryRegion ccmsram;
136136
MemoryRegion temp_usb;
137137

138+
uint32_t ram_size;
139+
138140
};
139141

140142
#endif

0 commit comments

Comments
 (0)