|
12 | 12 | #include "qemu/log.h"
|
13 | 13 | #include "qemu/error-report.h"
|
14 | 14 | #include "qapi/error.h"
|
| 15 | +#include "qemu-common.h" |
15 | 16 | #include "hw/hw.h"
|
16 | 17 | #include "hw/boards.h"
|
17 | 18 | #include "hw/loader.h"
|
@@ -582,16 +583,38 @@ static void esp32_machine_inst_init(MachineState *machine)
|
582 | 583 | */
|
583 | 584 | cpu_reset(CPU(&s->cpu[0]));
|
584 | 585 |
|
| 586 | + const char *load_elf_filename = NULL; |
| 587 | + if (machine->firmware) { |
| 588 | + load_elf_filename = machine->firmware; |
| 589 | + } |
585 | 590 | 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) { |
586 | 596 | uint64_t elf_entry;
|
587 | 597 | uint64_t elf_lowaddr;
|
588 |
| - int success = load_elf(machine->kernel_filename, NULL, |
| 598 | + int success = load_elf(load_elf_filename, NULL, |
589 | 599 | translate_phys_addr, &s->cpu[0],
|
590 | 600 | &elf_entry, &elf_lowaddr,
|
591 | 601 | NULL, 0, EM_XTENSA, 0, 0);
|
592 | 602 | if (success > 0) {
|
593 | 603 | s->cpu[0].env.pc = elf_entry;
|
594 | 604 | }
|
| 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); |
595 | 618 | }
|
596 | 619 | }
|
597 | 620 |
|
|
0 commit comments