【问题标题】:Qemu is not configured correctly when custom machine is added添加自定义机器时未正确配置 Qemu
【发布时间】:2019-04-03 11:55:05
【问题描述】:

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

我还在 ma​​kefile.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 。

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

【问题讨论】:

  • 请显示代码和/或说明错误。请不要使用图片链接。问题中缺少文本。图片上的文字太小,有些人看不懂。图像上的文本无法被搜索引擎索引以供将来的访问者使用。另见Why not upload images of code on SO when asking a question?
  • 我实际上添加了图像而不是链接,我不知道为什么它显示错误。我会更新。感谢您指出。

标签: c linux embedded qemu


【解决方案1】:

如果您使用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

【讨论】:

  • obj-y 和 obj-$(CONFIG_ARM_V7M) += armv7m.o stm32f407ve_scu.o 都有效,谢谢。如果不在 .mak 文件 obj-y 中添加 CONFIG_STM32F407VE_SCU=y ,这是否意味着它需要任何默认值?那是CONFIG_ARM_V7M?以及添加CONFIG_ARM_V7M和自定义名称有什么区别?
  • 是的,CONFIG_ARM_V7M 在构建支持 arm-softmmu 的 QEMU 时默认启用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多