Skip to content

Commit

Permalink
99 extra flash ram (#100)
Browse files Browse the repository at this point in the history
* #99 - proper deprecation
* support -m arg
* option to expand flash storage
  • Loading branch information
vintagepc authored Dec 22, 2021
1 parent 74c513d commit fdcac08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
27 changes: 12 additions & 15 deletions hw/arm/prusa/prusa-mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ static void prusa_mini_init(MachineState *machine)

dev = qdev_new(TYPE_STM32F407_SOC);
qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
qdev_prop_set_uint32(dev,"sram-size", machine->ram_size);
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
STM32F407State *SOC = STM32F407_SOC(dev);
// We (ab)use the kernel command line to piggyback custom arguments into QEMU.
// Parse those now.
arghelper_setargs(machine->kernel_cmdline);

int default_flash_size = FLASH_SIZE;
if (arghelper_is_arg("4x_flash"))
{
default_flash_size <<=2; // quadruple the flash size for debug code.
}
if (arghelper_is_arg("appendix")) {
SOC->gpio[GPIO_A].idr_mask |= 0x2000;
}
Expand All @@ -71,13 +76,13 @@ static void prusa_mini_init(MachineState *machine)
load_image_targphys(machine->kernel_filename,0x20000-64,get_image_size(machine->kernel_filename));
armv7m_load_kernel(ARM_CPU(first_cpu),
BOOTLOADER_IMAGE,
FLASH_SIZE);
default_flash_size);
}
else // Raw bin or ELF file, load directly.
{
armv7m_load_kernel(ARM_CPU(first_cpu),
machine->kernel_filename,
FLASH_SIZE);
default_flash_size);
}
}

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

static void prusa_mini_machine_init(MachineClass *mc)
{
mc->desc = "Prusa Mini Board";
mc->desc = "Prusa Mini";
mc->init = prusa_mini_init;
mc->default_ram_size = F407_SRAM_SIZE;
}

DEFINE_MACHINE("prusa-mini", prusa_mini_machine_init)


// TODO - remove this at some point in the future...

static void buddy_init(MachineState *machine)
{
error_setg(&error_fatal, "-machine prusabuddy has been deprecated. Please use -machine prusa-mini instead.\n");
};


static void buddy_machine_init(MachineClass *mc)
{
mc->desc = "Prusa Mini Board (Deprecated)";
mc->init = buddy_init;
mc->desc = "Prusa Mini Board";
mc->deprecation_reason = "prusabuddy has been deprecated because it's a board, not a machine. Use -machine prusa-mini instead";
}

DEFINE_MACHINE("prusabuddy", buddy_machine_init)
4 changes: 3 additions & 1 deletion hw/arm/prusa/stm32f407/stm32f407_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "net/net.h"
#include "hw/i2c/smbus_eeprom.h"
#include "exec/ramblock.h"
#include "hw/qdev-properties.h"
#define SYSCFG_ADD 0x40013800
static const uint32_t usart_addr[] = { 0x40011000, 0x40004400, 0x40004800,
0x40004C00, 0x40005000, 0x40011400,
Expand Down Expand Up @@ -194,7 +195,7 @@ static void stm32f407_soc_realize(DeviceState *dev_soc, Error **errp)
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
memory_region_add_subregion(system_memory, 0, &s->flash_alias);

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

static Property stm32f407_soc_properties[] = {
DEFINE_PROP_STRING("cpu-type", STM32F407State, cpu_type),
DEFINE_PROP_UINT32("sram-size",STM32F407State, ram_size, 192*KiB),
DEFINE_PROP_END_OF_LIST(),
};

Expand Down
8 changes: 5 additions & 3 deletions hw/arm/prusa/stm32f407/stm32f407_soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "hw/misc/stm32f4xx_syscfg.h"
#include "hw/timer/stm32f2xx_timer.h"
// #include "hw/char/stm32f2xx_usart.h"
#include "qemu/units.h"
#include "hw/misc/stm32f4xx_exti.h"
#include "hw/or-irq.h"
#include "stm32f4xx_adc.h"
Expand Down Expand Up @@ -64,9 +64,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F407State, STM32F407_SOC)
#define STM_NUM_DMAS 2

#define FLASH_BASE_ADDRESS 0x08000000
#define FLASH_SIZE (1024 * 1024)
#define FLASH_SIZE (1U *MiB)
#define SRAM_BASE_ADDRESS 0x20000000
#define SRAM_SIZE (192 * 1024)
#define F407_SRAM_SIZE (192 * KiB)


// Convenience enum.
Expand Down Expand Up @@ -135,6 +135,8 @@ struct STM32F407State {
MemoryRegion ccmsram;
MemoryRegion temp_usb;

uint32_t ram_size;

};

#endif

0 comments on commit fdcac08

Please sign in to comment.