From e4a25ed91947af1ec87f23725de4ac86a3353b48 Mon Sep 17 00:00:00 2001 From: Su Hang Date: Thu, 16 Aug 2018 14:05:28 +0100 Subject: loader: Implement .hex file loader This patch adds Intel Hexadecimal Object File format support to the generic loader device. The file format specification is available here: http://www.piclist.com/techref/fileext/hex/intel.htm This file format is often used with microcontrollers such as the micro:bit, Arduino, STM32, etc. Users expect to be able to run .hex files directly with without first converting them to ELF. Most micro:bit code is developed in web-based IDEs without direct user access to binutils so it is important for QEMU to handle this file format natively. Signed-off-by: Su Hang Signed-off-by: Stefan Hajnoczi Acked-by: Alistair Francis Message-id: 20180814162739.11814-6-stefanha@redhat.com Signed-off-by: Peter Maydell --- hw/core/generic-loader.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw/core/generic-loader.c') diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index cb0e68486d..fde32cbda1 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -147,6 +147,10 @@ static void generic_loader_realize(DeviceState *dev, Error **errp) size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, as); } + + if (size < 0) { + size = load_targphys_hex_as(s->file, &entry, as); + } } if (size < 0 || s->force_raw) { -- cgit 1.4.1