添加自定义机器时 Qemu 配置不正确

Qemu is not configured correctly when custom machine is added

我一直在尝试在 QEMU 中开发定制机器:STM32F407。我已经编写了初始脚本,以便在我们执行 -machine help 时将机器名称添加到 QEMU 支持的机器列表中,如定义 SRAMcpu-type 等。我在路径 ~/qemu/hw/arm 中添加了文件 stm32f407ve_scu.c

我还在 makefile.objs 文件中添加了行 obj-$(CONFIG_STM32F407VE_SCU) += stm32f407ve_scu.o

.c 文件包含以下代码:

struct stm32f407ve_scu {
    DeviceState *soc;
    struct arm_boot_info boot_info;

};

static void stm32f407ve_scu_init(MachineState *machine) { //create a space for the machine kernel
    struct stm32f407ve_scu *s =g_new0(struct stm32f407ve_scu, 1);

    if (!machine->kernel_filename){
        fprintf(stderr," Guest image is missing (use -kernel)\n");
        exit(1);
    }

    s->soc = qdev_create(NULL, "stm32f407-soc");
    qdev_prop_set_string (s->soc, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); // assign cortex-m4 as the processor
    object_property_set_bool(OBJECT(s->soc), true, "realized", &error_fatal);

    MemoryRegion *sram =g_new(MemoryRegion,1); //creates new memory region
    memory_region_init_ram(sram, NULL, "scu.sram", 1024 * 1024 * 128, &error_fatal); // ram area defined with size
    vmstate_register_ram_global(sram);

    //loads kernel of maximum size 2MB
    armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 2 * 1024 * 1024);      

}
static void stm32f407ve_scu_machine_init(MachineClass *mc) //defines the machine init struct and description
{
    mc->desc = "STM32F407 board with RAM";
    mc->init = stm32f407ve_scu_init;
}
DEFINE_MACHINE("stm32f407ve_scu", stm32f407ve_scu_machine_init) //machine is defined with initialization clas

当我尝试配置和制作 QEMU 时,我没有收到任何错误,但是没有生成 stm32f407ve_scu.ostm32f407ve_scu.d

为什么没有生成.o 和.d 文件?但是当我看到其他 .c 文件时,它们已生成为 .o 和 .c 。

我在这里错过了什么?我像其他文件一样添加了所有头文件,并使用相同的语法编写我的机器描述。

如果您正在使用 obj-$(CONFIG_STM32F407VE_SCU) += stm32f407ve_scu.o,您需要在某处启用 CONFIG_STM32F407VE_SCU 以构建此文件。这可以在 configure 文件或编辑 default-configs/arm-softmmu.mak 并添加 CONFIG_STM32F407VE_SCU=y.

中完成

如果您只需要构建这个额外的文件,您可以像这样编辑 Makefile.objs

obj-$(CONFIG_ARM_V7M) += armv7m.o stm32f407ve_scu.o

当您使用 ARMv7m (Cortex M4) 时,您的文件将被构建(CONFIG_ARM_V7M 将等于 y