Support vbootrom for AST2700
Subsystems (2)
PATCH 1/9 hw/arm/aspeed_ast27x0: Add "vbootrom_size" field to AspeedSoCClass
In reply to Jamin Lin viaIntroduced a "vbootrom_size" attribute in "AspeedSoCClass" to define virtual boot ROM size.
Initialized "vbootrom_size" to "0x20000" for both AST2700 A0 and A1 variants.
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0.c | 2 ++ 2 files changed, 3 insertions(+)
include/hw/arm/aspeed_soc.h +1 -0
@@ -152,6 +152,7 @@ struct AspeedSoCClass {const char *const *valid_cpu_types;uint32_t silicon_rev;uint64_t sram_size; +uint64_t vbootrom_size;uint64_t secsram_size;int spis_num;int ehcis_num;
hw/arm/aspeed_ast27x0.c +2 -0
@@ -898,6 +898,7 @@ static void aspeed_soc_ast2700a0_class_init(ObjectClass *oc, void *data) sc->valid_cpu_types = valid_cpu_types; sc->silicon_rev =AST2700_A0_SILICON_REV ; + sc->vbootrom_size =0x20000 ; sc->sram_size =0x20000 ; sc->spis_num =3 ; sc->wdts_num =8 ;
@@ -925,6 +926,7 @@ static void aspeed_soc_ast2700a1_class_init(ObjectClass *oc, void *data) sc->valid_cpu_types = valid_cpu_types; sc->silicon_rev =AST2700_A1_SILICON_REV ; + sc->vbootrom_size =0x20000 ; sc->sram_size =0x20000 ; sc->spis_num =3 ; sc->wdts_num =8 ;
Signature · 1 line
2.43.0
PATCH 3/9 hw/arm/aspeed_ast27x0 Introduce vbootrom memory region
In reply to Jamin Lin viaIntroduce a new vbootrom memory region. The region is mapped at address "0x00000000" and has a size of 128KB, identical to the SRAM region size. This memory region is intended for loading a vbootrom image file as part of the boot process.
The vbootrom region is initialized as ROM and registered in the SoC's address space using the ASPEED_DEV_VBOOTROM index.
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
include/hw/arm/aspeed_soc.h +1 -0
@@ -59,6 +59,7 @@ struct AspeedSoCState {MemoryRegion sram;MemoryRegion spi_boot_container;MemoryRegion spi_boot; +MemoryRegion vbootrom;AddressSpace dram_as;AspeedRtcState rtc;AspeedTimerCtrlState timerctrl;
hw/arm/aspeed_ast27x0.c +10 -0
@@ -24,6 +24,7 @@#include "qemu/log.h" static const hwaddr aspeed_soc_ast2700_memmap[] = { + [ASPEED_DEV_VBOOTROM ] =0x00000000 , [ASPEED_DEV_SRAM ] =0x10000000 , [ASPEED_DEV_HACE ] =0x12070000 , [ASPEED_DEV_EMMC ] =0x12090000 ,
@@ -657,6 +658,15 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SRAM ], &s->sram); +/* VBOOTROM */ + name =g_strdup_printf ("aspeed.vbootrom.%d" ,CPU (&a->cpu[0 ])->cpu_index); +if (!memory_region_init_rom (&s->vbootrom,OBJECT (s), name, + sc->vbootrom_size, errp)) { +return ; + } +memory_region_add_subregion (s->memory, + sc->memmap[ASPEED_DEV_VBOOTROM ], &s->vbootrom); +/* SCU */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->scu), errp)) {return ;
Signature · 1 line
2.43.0
cover Support vbootrom for AST2700
v1:
Add initial support for AST27x0
The purpose of vbootrom here is to simulate the work of BootMCU SPL (riscv) in AST2700, because QEMU doesn't support heterogenous architecture yet.
ast27x0_bootrom.bin is a simplified, free (Apache 2.0) boot ROM for ASPEED AST27x0 BMC SOC. It currently implements the bare minimum to load, parse, initialize and run boot images stored in SPI flash, but may grow more features over time as needed. The source code is available at:
https://github.com/google/vbootrom
Jamin Lin (9):
hw/arm/aspeed_ast27x0: Add "vbootrom_size" field to AspeedSoCClass hw/arm/aspeed_ast27x0: Rename variable sram_name to name in ast2700
realize
hw/arm/aspeed_ast27x0 Introduce vbootrom memory region hw/arm/aspeed: Enable vbootrom support by default on AST2700 EVB
machines
hw/arm/aspeed: Reuse rom_size variable for vbootrom setup hw/arm/aspeed: Add support for loading vbootrom image via "-bios"
pc-bios: Add AST27x0 vBootrom
tests/functional/aspeed: Update AST2700 functional test to use
vbootrom
docs/system/arm/aspeed: Support vbootrom for AST2700
MAINTAINERS | 1 + docs/system/arm/aspeed.rst | 18 +++-------- include/hw/arm/aspeed.h | 1 + include/hw/arm/aspeed_soc.h | 2 ++ hw/arm/aspeed.c | 37 ++++++++++++++++++++++- hw/arm/aspeed_ast27x0.c | 20 ++++++++++--- pc-bios/README | 6 ++++ pc-bios/ast27x0_bootrom.bin | Bin 0 -> 15464 bytes pc-bios/meson.build | 1 + tests/functional/test_aarch64_aspeed.py | 38 +----------------------- 10 files changed, 68 insertions(+), 56 deletions(-) create mode 100644 pc-bios/ast27x0_bootrom.bin
Signature · 1 line
2.43.0
PATCH 8/9 tests/functional/aspeed: Update AST2700 functional test to use vbootrom
Refactor the AST2700 functional test to boot using the vbootrom image instead of manually loading boot components with -device loader. The boot ROM binary is now passed via the
-bios option, using the image located in pc-bios/ast27x0_bootrom.bin.
--- tests/functional/test_aarch64_aspeed.py | 38 +------------------------ 1 file changed, 1 insertion(+), 37 deletions(-)
tests/functional/test_aarch64_aspeed.py +1 -37
@@ -36,43 +36,7 @@ def do_test_aarch64_aspeed_sdk_start(self, image): 'c1f4496aec06743c812a6e9a1a18d032f34d62f3ddb6956e924fef62aa2046a5') def start_ast2700_test(self, name): - num_cpu = 4 - uboot_size = os.path.getsize(self.scratch_file(name, - 'u-boot-nodtb.bin')) - uboot_dtb_load_addr = hex(0x400000000 + uboot_size) - - load_images_list = [ - { - 'addr': '0x400000000', - 'file': self.scratch_file(name, - 'u-boot-nodtb.bin') - }, - { - 'addr': str(uboot_dtb_load_addr), - 'file': self.scratch_file(name, 'u-boot.dtb') - }, - { - 'addr': '0x430000000', - 'file': self.scratch_file(name, 'bl31.bin') - }, - { - 'addr': '0x430080000', - 'file': self.scratch_file(name, 'optee', - 'tee-raw.bin') - } - ] - - for load_image in load_images_list: - addr = load_image['addr'] - file = load_image['file'] - self.vm.add_args('-device', - f'loader,force-raw=on,addr={addr},file={file}') - - for i in range(num_cpu): - self.vm.add_args('-device', - f'loader,addr=0x430000000,cpu-num={i}') - - self.vm.add_args('-smp', str(num_cpu)) + self.vm.add_args('-bios', 'ast27x0_bootrom.bin') self.vm.add_args('-device', 'tmp105,bus=aspeed.i2c.bus.1,address=0x4d,id=tmp-test') self.do_test_aarch64_aspeed_sdk_start(
Signature · 1 line
2.43.0
PATCH 4/9 hw/arm/aspeed: Enable vbootrom support by default on AST2700 EVB machines
In reply to Jamin Lin viaIntroduce a new "vbootrom" field in the AspeedMachineClass to indicate whether a machine supports the virtual boot ROM region.
Set this field to true by default for the AST2700-A0 and AST2700-A1 EVB machines.
--- include/hw/arm/aspeed.h | 1 + hw/arm/aspeed.c | 2 ++ 2 files changed, 3 insertions(+)
include/hw/arm/aspeed.h +1 -0
@@ -40,6 +40,7 @@ struct AspeedMachineClass {void (*i2c_init)(AspeedMachineState *bmc);uint32_t uart_default;bool sdhci_wp_inverted; +bool vbootrom; };
hw/arm/aspeed.c +2 -0
@@ -1689,6 +1689,7 @@ static void aspeed_machine_ast2700a0_evb_class_init(ObjectClass *oc, void *data) amc->macs_mask =ASPEED_MAC0_ON |ASPEED_MAC1_ON |ASPEED_MAC2_ON ; amc->uart_default =ASPEED_DEV_UART12 ; amc->i2c_init = ast2700_evb_i2c_init; + amc->vbootrom = true; mc->auto_create_sdcard = true; mc->default_ram_size =1 * GiB;aspeed_machine_class_init_cpus_defaults (mc);
@@ -1709,6 +1710,7 @@ static void aspeed_machine_ast2700a1_evb_class_init(ObjectClass *oc, void *data) amc->macs_mask =ASPEED_MAC0_ON |ASPEED_MAC1_ON |ASPEED_MAC2_ON ; amc->uart_default =ASPEED_DEV_UART12 ; amc->i2c_init = ast2700_evb_i2c_init; + amc->vbootrom = true; mc->auto_create_sdcard = true; mc->default_ram_size =1 * GiB;aspeed_machine_class_init_cpus_defaults (mc);
Signature · 1 line
2.43.0
PATCH 5/9 hw/arm/aspeed: Reuse rom_size variable for vbootrom setup
In reply to Jamin Lin viaMove the declaration of rom_size to an outer scope in aspeed_machine_init() so it can be reused for setting up the vbootrom region as well.
This avoids introducing a redundant local variable and ensures consistent ROM sizing logic when both SPI boot and vbootrom are used.
--- hw/arm/aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/aspeed.c +2 -1
@@ -381,6 +381,7 @@ static void aspeed_machine_init(MachineState *machine)AspeedSoCClass *sc;int i;DriveInfo *emmc0 =NULL ; +uint64_t rom_size;bool boot_emmc; bmc->soc =ASPEED_SOC (object_new (amc->soc_name));
@@ -475,7 +476,7 @@ static void aspeed_machine_init(MachineState *machine)BlockBackend *fmc0 = dev ?m25p80_get_blk (dev) :NULL ;if (fmc0 && !boot_emmc) { -uint64_t rom_size =memory_region_size (&bmc->soc->spi_boot); + rom_size =memory_region_size (&bmc->soc->spi_boot);aspeed_install_boot_rom (bmc, fmc0, rom_size); }else if (emmc0) {aspeed_install_boot_rom (bmc,blk_by_legacy_dinfo (emmc0),64 * KiB);
Signature · 1 line
2.43.0
PATCH 6/9 hw/arm/aspeed: Add support for loading vbootrom image via "-bios"
In reply to Jamin Lin viaIntroduce "aspeed_load_vbootrom()" to support loading a virtual boot ROM image into the vbootrom memory region, using the "-bios" command-line option.
--- hw/arm/aspeed.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
hw/arm/aspeed.c +32 -0
@@ -27,6 +27,7 @@#include "system/reset.h" #include "hw/loader.h" #include "qemu/error-report.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "hw/qdev-clock.h" #include "system/system.h"
@@ -305,6 +306,32 @@ static void aspeed_install_boot_rom(AspeedMachineState *bmc, BlockBackend *blk, rom_size, &error_abort); } +/* +* This function locates the vbootrom image file specified via the command line +* using the -bios option. It loads the specified image into the vbootrom +* memory region and handles errors if the file cannot be found or loaded. +*/ +static void aspeed_load_vbootrom (MachineState *machine,uint64_t rom_size) +{ +AspeedMachineState *bmc =ASPEED_MACHINE (machine); +const char *bios_name = machine->firmware; + g_autofree char *filename = NULL; +AspeedSoCState *soc = bmc->soc; +int ret; + + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (!filename) { +error_report ("Could not find vbootrom image '%s'" , bios_name); +exit (1 ); + } + + ret =load_image_mr (filename, &soc->vbootrom); +if (ret <0 ) { +error_report ("Failed to load vbootrom image '%s'" , filename); +exit (1 ); + } +} +void aspeed_board_init_flashes (AspeedSMCState *s,const char *flashtype,unsigned int count,int unit0) {
@@ -483,6 +510,11 @@ static void aspeed_machine_init(MachineState *machine) } } +if (amc->vbootrom) { + rom_size =memory_region_size (&bmc->soc->vbootrom); +aspeed_load_vbootrom (machine, rom_size); + } +arm_load_kernel (ARM_CPU (first_cpu), machine, &aspeed_board_binfo); }
Signature · 1 line
2.43.0
PATCH 7/9 pc-bios: Add AST27x0 vBootrom
In reply to Jamin Lin viaThe boot ROM is a minimal implementation designed to load an AST27x0 boot image. Its source code is available at:
https://github.com/google/vbootrom
--- MAINTAINERS | 1 + pc-bios/README | 6 ++++++ pc-bios/ast27x0_bootrom.bin | Bin 0 -> 15464 bytes pc-bios/meson.build | 1 + 4 files changed, 8 insertions(+) create mode 100644 pc-bios/ast27x0_bootrom.bin
MAINTAINERS +1 -0
@@ -1163,6 +1163,7 @@ F: docs/system/arm/fby35.rst F: tests/*/*aspeed* F: tests/*/*ast2700* F: hw/arm/fby35.c +F: pc-bios/ast27x0_bootrom.bin NRF51 M: Joel Stanley <[email protected]>
pc-bios/README +6 -0
@@ -89,6 +89,12 @@ more features over time as needed. The source code is available at: https://github.com/google/vbootrom +- ast27x0_bootrom.bin is a simplified, free (Apache 2.0) boot ROM for + ASPEED AST27x0 BMC SOC. It currently implements the bare minimum to + load, parse, initialize and run boot images stored in SPI flash, but may grow + more features over time as needed. The source code is available at: + https://github.com/google/vbootrom + - hppa-firmware.img (32-bit) and hppa-firmware64.img (64-bit) are firmware files for the HP-PARISC (hppa) architecture. They are built form the SeaBIOS-hppa sources, which is a fork of SeaBIOS
pc-bios/ast27x0_bootrom.bin new file binary +0 -0
pc-bios/meson.build +1 -0
@@ -84,6 +84,7 @@ blobs = [ 'npcm8xx_bootrom.bin', 'vof.bin', 'vof-nvram.bin', + 'ast27x0_bootrom.bin', ] dtc = find_program('dtc', required: false)
Signature · 1 line
2.43.0
PATCH 2/9 hw/arm/aspeed_ast27x0: Rename variable sram_name to name in ast2700 realize
In reply to Jamin Lin viaThe variable "sram_name" was only used for naming the SRAM memory region. Rename it to "name" for consistency with similar code and avoid unnecessary new local variable declarations.
--- hw/arm/aspeed_ast27x0.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/aspeed_ast27x0.c +4 -4
@@ -577,7 +577,7 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);AspeedINTCClass *ic =ASPEED_INTC_GET_CLASS (&a->intc[0 ]);AspeedINTCClass *icio =ASPEED_INTC_GET_CLASS (&a->intc[1 ]); - g_autofree char *sram_name = NULL; + g_autofree char *name = NULL;qemu_irq irq;/* Default boot region (SPI memory or ROMs) */
@@ -649,9 +649,9 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) }/* SRAM */ - sram_name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&a->cpu[0 ])->cpu_index); -if (!memory_region_init_ram (&s->sram,OBJECT (s), sram_name, sc->sram_size, - errp)) { + name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&a->cpu[0 ])->cpu_index); +if (!memory_region_init_ram (&s->sram,OBJECT (s), name, sc->sram_size, + errp)) {return ; } memory_region_add_subregion(s->memory,
Signature · 1 line
2.43.0
PATCH 9/9 docs/system/arm/aspeed: Support vbootrom for AST2700
In reply to Jamin Lin viaUsing the vbootrom image instead of manually loading boot components with -device loader. The boot ROM binary is now passed via the -bios option, using the image located in pc-bios/ast27x0_bootrom.bin.
--- docs/system/arm/aspeed.rst | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
docs/system/arm/aspeed.rst +4 -14
@@ -250,24 +250,14 @@ under Linux), use : Booting the ast2700-evb machine ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Boot the AST2700 machine from the flash image, use an MTD drive : +Boot the AST2700 machine using a flash image, with an MTD drive and +the virtual boot ROM : .. code-block:: bash - IMGDIR=ast2700-default - UBOOT_SIZE=$(stat --format=%s -L ${IMGDIR}/u-boot-nodtb.bin) - $ qemu-system-aarch64 -M ast2700-evb \ - -device loader,force-raw=on,addr=0x400000000,file=${IMGDIR}/u-boot-nodtb.bin \ - -device loader,force-raw=on,addr=$((0x400000000 + ${UBOOT_SIZE})),file=${IMGDIR}/u-boot.dtb \ - -device loader,force-raw=on,addr=0x430000000,file=${IMGDIR}/bl31.bin \ - -device loader,force-raw=on,addr=0x430080000,file=${IMGDIR}/optee/tee-raw.bin \ - -device loader,cpu-num=0,addr=0x430000000 \ - -device loader,cpu-num=1,addr=0x430000000 \ - -device loader,cpu-num=2,addr=0x430000000 \ - -device loader,cpu-num=3,addr=0x430000000 \ - -smp 4 \ - -drive file=${IMGDIR}/image-bmc,format=raw,if=mtd \ + -bios ast27x0_bootrom.bin \ + -drive file=image-bmc,format=raw,if=mtd \ -nographic Aspeed minibmc family boards (``ast1030-evb``)
Signature · 1 line
2.43.0
Hi all,
Quoted 8 lines
Subject: [PATCH v1 0/9] Support vbootrom for AST2700
v1:
Add initial support for AST27x0
The purpose of vbootrom here is to simulate the work of BootMCU SPL
(riscv)
in AST2700, because QEMU doesn't support heterogenous architecture yet.
Quoted 6 lines
ast27x0_bootrom.bin is a simplified, free (Apache 2.0) boot ROM for ASPEED AST27x0 BMC SOC. It currently implements the bare minimum to load, parse, initialize and run boot images stored in SPI flash, but may grow more features over time as needed. The source code is available at:
https://github.com/google/vbootrom
This patch series failed to build because I missed including one patch. I will resend the series as v2.
Sorry for the inconvenience.
Jamin
Quoted 31 lines
Jamin Lin (9):
hw/arm/aspeed_ast27x0: Add "vbootrom_size" field to AspeedSoCClass hw/arm/aspeed_ast27x0: Rename variablesram_nameto name in ast2700
realize
hw/arm/aspeed_ast27x0 Introduce vbootrom memory region hw/arm/aspeed: Enable vbootrom support by default on AST2700 EVB
machines
hw/arm/aspeed: Reuserom_sizevariable for vbootrom setup hw/arm/aspeed: Add support for loading vbootrom image via "-bios"
pc-bios: Add AST27x0 vBootrom
tests/functional/aspeed: Update AST2700 functional test to use
vbootrom
docs/system/arm/aspeed: Support vbootrom for AST2700MAINTAINERS | 1 + docs/system/arm/aspeed.rst | 18 +++-------- include/hw/arm/aspeed.h | 1 + include/hw/arm/aspeed_soc.h | 2 ++ hw/arm/aspeed.c | 37 ++++++++++++++++++++++- hw/arm/aspeed_ast27x0.c | 20 ++++++++++--- pc-bios/README | 6 ++++ pc-bios/ast27x0_bootrom.bin | Bin 0 -> 15464 bytes pc-bios/meson.build | 1 + tests/functional/test_aarch64_aspeed.py | 38 +----------------------- 10 files changed, 68 insertions(+), 56 deletions(-) create mode 100644pc-bios/ast27x0_bootrom.bin
--
2.43.0