Skip to content

Commit 86ba82e

Browse files
committed
hw/xtensa: add ESP32 ROM
1 parent 31abff8 commit 86ba82e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

hw/xtensa/esp32.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "qemu/log.h"
1313
#include "qemu/error-report.h"
1414
#include "qapi/error.h"
15+
#include "qemu-common.h"
1516
#include "hw/hw.h"
1617
#include "hw/boards.h"
1718
#include "hw/loader.h"
@@ -582,16 +583,38 @@ static void esp32_machine_inst_init(MachineState *machine)
582583
*/
583584
cpu_reset(CPU(&s->cpu[0]));
584585

586+
const char *load_elf_filename = NULL;
587+
if (machine->firmware) {
588+
load_elf_filename = machine->firmware;
589+
}
585590
if (machine->kernel_filename) {
591+
qemu_log("Warning: both -bios and -kernel arguments specified. Only loading the the -kernel file.\n");
592+
load_elf_filename = machine->kernel_filename;
593+
}
594+
595+
if (load_elf_filename) {
586596
uint64_t elf_entry;
587597
uint64_t elf_lowaddr;
588-
int success = load_elf(machine->kernel_filename, NULL,
598+
int success = load_elf(load_elf_filename, NULL,
589599
translate_phys_addr, &s->cpu[0],
590600
&elf_entry, &elf_lowaddr,
591601
NULL, 0, EM_XTENSA, 0, 0);
592602
if (success > 0) {
593603
s->cpu[0].env.pc = elf_entry;
594604
}
605+
} else {
606+
char *rom_binary = qemu_find_file(QEMU_FILE_TYPE_BIOS, "esp32-r0-rom.bin");
607+
if (rom_binary == NULL) {
608+
error_report("Error: -bios argument not set, and ROM code binary not found");
609+
exit(1);
610+
}
611+
612+
int size = load_image_targphys(rom_binary, esp32_memmap[ESP32_MEMREGION_IROM].base, esp32_memmap[ESP32_MEMREGION_IROM].size);
613+
if (size < 0) {
614+
error_report("Error: could not load ROM binary '%s'", rom_binary);
615+
exit(1);
616+
}
617+
g_free(rom_binary);
595618
}
596619
}
597620

pc-bios/esp32-r0-rom.bin

448 KB
Binary file not shown.

0 commit comments

Comments
 (0)