microbit: do not rely on -kernel option
PATCH 1/1 microbit: do not rely on -kernel option
Microbit programs are typically in Intel HEX (.hex) format. The generic loader supports .hex files but it doesn't work as expected:
$ qemu-system-arm -M microbit -device loader,file=microbit.hex Guest image must be specified (using -kernel)
This error comes from armv7m_load_kernel(). Don't try to use it.
Note that we need to register the reset handler that armv7m_load_kernel() used to register for us.
Signed-off-by Stefan Hajnoczi <[email protected]>
--- hw/arm/microbit.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
hw/arm/microbit.c +14 -2
@@ -13,6 +13,7 @@#include "hw/boards.h" #include "hw/arm/arm.h" #include "exec/address-spaces.h" +#include "qemu/error-report.h" #include "hw/arm/nrf51_soc.h"
@@ -27,6 +28,13 @@ typedef struct {#define MICROBIT_MACHINE (obj) \ OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE) +static void microbit_cpu_reset (void *opaque) +{ +ARMCPU *cpu = opaque; + +cpu_reset (CPU (cpu)); +} +static void microbit_init (MachineState *machine) {MicrobitMachineState *s =MICROBIT_MACHINE (machine);
@@ -39,8 +47,12 @@ static void microbit_init(MachineState *machine) &error_fatal);object_property_set_bool (soc, true,"realized" , &error_fatal); -armv7m_load_kernel (ARM_CPU (first_cpu), machine->kernel_filename, -NRF51_SOC (soc)->flash_size); +if (machine->kernel_filename) { +error_report ("-device loader,file=<filename> must be used instead of -kernel" ); +exit (1 ); + } + +qemu_register_reset (microbit_cpu_reset,ARM_CPU (first_cpu)); }static void microbit_machine_class_init (ObjectClass *oc,void *data)
Signature · 1 line
2.17.2
Stefan Hajnoczi
NAKhw/arm/microbit.c static void microbit_init(MachineState *machine) · line 53
Quoted 10 lines · Stefan Hajnoczi
hw/arm/microbit.c +4
-2@@ -39,8 +47,12 @@ static void microbit_init(MachineState *machine) &error_fatal);object_property_set_bool (soc, true,"realized" , &error_fatal); -armv7m_load_kernel (ARM_CPU (first_cpu), machine->kernel_filename, -NRF51_SOC (soc)->flash_size); +if (machine->kernel_filename) { +error_report ("-device loader,file=<filename> must be used instead of -kernel" ); +exit (1 ); + }
NACK
Julia pointed out this breaks boot-serial-test.
Stefan