From 72f4b70e8e8e656d88bda77605f73076474f5a55 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 9 Nov 2024 11:43:05 +0100 Subject: [PATCH 1/2] fix(rcar-layout): fix tool build Since 2f1c5e7eb177 ("build: use GCC to link by default") the code does not even compile with GCC14 on debian/unstable with the following error: /usr/lib/gcc-cross/aarch64-linux-gnu/14/../../../../aarch64-linux-gnu/bin/ld: bootparam_sa0.elf: error: PHDR segment not covered by LOAD segment /usr/lib/gcc-cross/aarch64-linux-gnu/14/../../../../aarch64-linux-gnu/bin/ld: cert_header_sa6.elf: error: PHDR segment not covered by LOAD segment Fix the tools build. Signed-off-by: Marek Vasut Change-Id: I830b53e23f25c62da3583c1c3e02e0607a237d15 --- tools/renesas/rcar_layout_create/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/renesas/rcar_layout_create/makefile b/tools/renesas/rcar_layout_create/makefile index 7a64b1908..f89f379e9 100644 --- a/tools/renesas/rcar_layout_create/makefile +++ b/tools/renesas/rcar_layout_create/makefile @@ -102,7 +102,7 @@ $(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/ $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin $(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/ - $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map + $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -static -Wl,--build-id=none -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map $(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/ $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec @@ -111,7 +111,7 @@ $(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/ $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin $(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/ - $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map + $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -static -Wl,--build-id=none -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map ################################################### # Compile From 1a5711519a8e685d3db43620623f0f616317cfe9 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 9 Nov 2024 11:42:59 +0100 Subject: [PATCH 2/2] fix(rcar3-drivers): disable A/B loader support by default The A/B loader [1] meant to be used for convenient CI testing. The tool is installed into the same location as SA0, where it conveniently fits due to its size, and where it makes use of non-volatile PMIC registers to alternate between loading and starting A or B copy of the BL2. The PMIC registers are used because CPU registers are lost across reset. In case the B copy is loaded, it is loaded from 8 MiB offset from start of HF. In case the B copy fails to boot, a simple reset of the system will switch back to booting previously known working A copy and allow recovery. The A/B loader sets MFIS bit MFISBTSTSR_BOOT_PARTITION to pass the information which A/B copy is currently booting on to TFA, which then loads the follow up components from 0 MiB or 8 MiB offset, depending on whether the A or B copy is being booted. The MFISBTSTSR_BOOT_PARTITION interferes with regular A/B switching during boot from eMMC as the boot media, where the BootROM also sets MFISBTSTSR_BOOT_PARTITION bit in case the system boots from SECOND eMMC HW BOOT partition. Since the A/B loader is meant as a development and CI tool, isolate the A/B loader use to RPC HF only and furthermore isolate it behind new RCAR_RPC_HYPERFLASH_ABLOADER option which is disabled by default. [1] https://github.com/marex/abloader Signed-off-by: Marek Vasut Change-Id: I04ecd50fa1405b78e1ba3949d54029034d4f22d8 --- drivers/renesas/common/io/io_rcar.c | 18 ++++++++++++++++-- plat/renesas/rcar/platform.mk | 7 +++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/renesas/common/io/io_rcar.c b/drivers/renesas/common/io/io_rcar.c index 66662c111..1529dc0f0 100644 --- a/drivers/renesas/common/io/io_rcar.c +++ b/drivers/renesas/common/io/io_rcar.c @@ -149,6 +149,9 @@ static uint64_t rcar_image_header[RCAR_MAX_BL3X_IMAGE + 2U] = { 0U }; static uint64_t rcar_image_header_prttn[RCAR_MAX_BL3X_IMAGE + 2U] = { 0U }; static uint64_t rcar_image_number = { 0U }; static uint32_t rcar_cert_load = { 0U }; +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1) +static uint32_t rcar_image_offset = 0U; +#endif static io_type_t device_type_rcar(void) { @@ -196,8 +199,10 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset, *offset = rcar_image_header[addr]; - if (mmio_read_32(MFISBTSTSR) & MFISBTSTSR_BOOT_PARTITION) - *offset += 0x800000; +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1) + *offset += rcar_image_offset; +#endif + *cert = RCAR_CERT_SIZE; *cert *= RCAR_ATTR_GET_CERTOFF(name_offset[i].attr); *cert += RCAR_SDRAM_certESS; @@ -499,6 +504,15 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name) */ offset = name == EMMC_DEV_ID ? RCAR_EMMC_CERT_HEADER : RCAR_FLASH_CERT_HEADER; + +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1) + rcar_image_offset = 0; + if ((name == FLASH_DEV_ID) && + (mmio_read_32(MFISBTSTSR) & MFISBTSTSR_BOOT_PARTITION)) { + rcar_image_offset = 0x800000; + } +#endif + rc = io_seek(handle, IO_SEEK_SET, offset); if (rc != IO_SUCCESS) { WARN("Firmware Image Package header failed to seek\n"); diff --git a/plat/renesas/rcar/platform.mk b/plat/renesas/rcar/platform.mk index 481394946..c19eb3657 100644 --- a/plat/renesas/rcar/platform.mk +++ b/plat/renesas/rcar/platform.mk @@ -148,6 +148,13 @@ RCAR_RPC_HYPERFLASH_LOCKED := 1 endif $(eval $(call add_define,RCAR_RPC_HYPERFLASH_LOCKED)) +# Support A/B switching with RPC HYPERFLASH access by default +# Use together with https://github.com/marex/abloader . +ifndef RCAR_RPC_HYPERFLASH_ABLOADER +RCAR_RPC_HYPERFLASH_ABLOADER := 0 +endif +$(eval $(call add_define,RCAR_RPC_HYPERFLASH_ABLOADER)) + # Process RCAR_SECURE_BOOT flag ifndef RCAR_SECURE_BOOT RCAR_SECURE_BOOT := 1