Jonas Karlman c72e37dceb rockchip: rk3399-rock-pi-4: Fix Synchronous Abort
After the commit 788cf33315c7 ("efi: add a helper to generate dynamic
UUIDs") update_info.num_images must match number of valid update images.

On Rock Pi 4 following Synchronous Abort can be observed due to fw_name
being NULL:

  Scanning global bootmeth 'efi_mgr':
  "Synchronous Abort" handler, esr 0x96000010, far 0x0
  elr: 0000000000200e28 lr : 000000000028adb8 (reloc)
  elr: 00000000f3efbe28 lr : 00000000f3f85db8
  x0 : 0000000000000000 x1 : ffffffffffffffff
  x2 : 0000000000000000 x3 : 000000000000000e
  x4 : 0000000000000000 x5 : 00000000f1ef0d78
  x6 : 00000000f3fb3b90 x7 : 0000000000000044
  x8 : 0000000000000010 x9 : 0000000000000031
  x10: 00000000f0ea3fff x11: 00000000f1f29e00
  x12: 0000000000000002 x13: fffffffffffff000
  x14: 00000000f1f29e00 x15: 0000000000000018
  x16: 00000000f3f44f7c x17: 0000000000000000
  x18: 00000000f1ef2de0 x19: 00000000f0ea3040
  x20: 00000000f3ff53d8 x21: 00000000f3fd0498
  x22: 0000000000000000 x23: 00000000f1edb960
  x24: 00000000f1edb95f x25: 00000000f1edb990
  x26: 00000000f1edb964 x27: 00000000f1edb998
  x28: 00000000f1edc1ec x29: 00000000f1edb820

  Code: aa0003e2 d2800000 eb01001f 54000060 (78607843)
  Resetting CPU ...

  resetting ...

Fix this by setting update_info.num_images to 0 when no valid update
images is added to update_info.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: FUKAUMI Naoki <naoki@radxa.com>
2025-01-10 18:56:22 -06:00

61 lines
1.7 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2016 Rockchip Electronics Co., Ltd
*/
#include <dm.h>
#include <efi_loader.h>
#define ROCKPI4_UPDATABLE_IMAGES 2
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
struct efi_capsule_update_info update_info = {
.num_images = ROCKPI4_UPDATABLE_IMAGES,
.images = fw_images,
};
#endif
#ifndef CONFIG_XPL_BUILD
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && IS_ENABLED(CONFIG_EFI_PARTITION)
static bool board_is_rockpi_4b(void)
{
return of_machine_is_compatible("radxa,rockpi4b");
}
static bool board_is_rockpi_4c(void)
{
return of_machine_is_compatible("radxa,rockpi4c");
}
void rockchip_capsule_update_board_setup(void)
{
if (board_is_rockpi_4b()) {
efi_guid_t idbldr_image_type_guid =
ROCKPI_4B_IDBLOADER_IMAGE_GUID;
efi_guid_t uboot_image_type_guid = ROCKPI_4B_UBOOT_IMAGE_GUID;
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
fw_images[0].fw_name = u"ROCKPI4B-IDBLOADER";
fw_images[1].fw_name = u"ROCKPI4B-UBOOT";
} else if (board_is_rockpi_4c()) {
efi_guid_t idbldr_image_type_guid =
ROCKPI_4C_IDBLOADER_IMAGE_GUID;
efi_guid_t uboot_image_type_guid = ROCKPI_4C_UBOOT_IMAGE_GUID;
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
fw_images[0].fw_name = u"ROCKPI4C-IDBLOADER";
fw_images[1].fw_name = u"ROCKPI4C-UBOOT";
} else {
update_info.num_images = 0;
}
}
#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */
#endif /* !CONFIG_XPL_BUILD */