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 <marek.vasut+renesas@mailbox.org>
Change-Id: I04ecd50fa1405b78e1ba3949d54029034d4f22d8
This commit is contained in:
Marek Vasut 2024-11-09 11:42:59 +01:00
parent 72f4b70e8e
commit 1a5711519a
2 changed files with 23 additions and 2 deletions

View file

@ -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");

View file

@ -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