Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 1 | /* |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved. |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <string.h> |
| 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <arch_helpers.h> |
| 11 | #include <common/debug.h> |
Yann Gautier | a3bd8d1 | 2021-06-18 11:33:26 +0200 | [diff] [blame] | 12 | #include <common/desc_image_load.h> |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 13 | #include <drivers/fwu/fwu.h> |
| 14 | #include <drivers/fwu/fwu_metadata.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | #include <drivers/io/io_block.h> |
| 16 | #include <drivers/io/io_driver.h> |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 17 | #include <drivers/io/io_fip.h> |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 18 | #include <drivers/io/io_memmap.h> |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 19 | #include <drivers/io/io_mtd.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 20 | #include <drivers/io/io_storage.h> |
| 21 | #include <drivers/mmc.h> |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 22 | #include <drivers/partition/efi.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 23 | #include <drivers/partition/partition.h> |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 24 | #include <drivers/raw_nand.h> |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 25 | #include <drivers/spi_nand.h> |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 26 | #include <drivers/spi_nor.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 27 | #include <drivers/st/io_mmc.h> |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 28 | #include <drivers/st/stm32_fmc2_nand.h> |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 29 | #include <drivers/st/stm32_qspi.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 30 | #include <drivers/st/stm32_sdmmc2.h> |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 31 | #include <drivers/usb_device.h> |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 32 | #include <lib/fconf/fconf.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 33 | #include <lib/mmio.h> |
| 34 | #include <lib/utils.h> |
| 35 | #include <plat/common/platform.h> |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 36 | #include <tools_share/firmware_image_package.h> |
| 37 | |
| 38 | #include <platform_def.h> |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 39 | #include <stm32cubeprogrammer.h> |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 40 | #include <stm32mp_fconf_getter.h> |
Yann Gautier | 8636a5f | 2022-05-06 15:27:32 +0200 | [diff] [blame] | 41 | #include <stm32mp_io_storage.h> |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 42 | #include <usb_dfu.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 43 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 44 | /* IO devices */ |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 45 | uintptr_t fip_dev_handle; |
| 46 | uintptr_t storage_dev_handle; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 47 | |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 48 | static const io_dev_connector_t *fip_dev_con; |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 49 | |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 50 | #if STM32MP_SDMMC || STM32MP_EMMC |
Yann Gautier | ac22dd5 | 2021-03-22 14:22:14 +0100 | [diff] [blame] | 51 | static struct mmc_device_info mmc_info; |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 52 | |
Yann Gautier | f9af3bc | 2018-11-09 15:57:18 +0100 | [diff] [blame] | 53 | static uint32_t block_buffer[MMC_BLOCK_SIZE] __aligned(MMC_BLOCK_SIZE); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 54 | |
Yann Gautier | a3bd8d1 | 2021-06-18 11:33:26 +0200 | [diff] [blame] | 55 | static io_block_dev_spec_t mmc_block_dev_spec = { |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 56 | /* It's used as temp buffer in block driver */ |
| 57 | .buffer = { |
| 58 | .offset = (size_t)&block_buffer, |
| 59 | .length = MMC_BLOCK_SIZE, |
| 60 | }, |
| 61 | .ops = { |
| 62 | .read = mmc_read_blocks, |
| 63 | .write = NULL, |
| 64 | }, |
| 65 | .block_size = MMC_BLOCK_SIZE, |
| 66 | }; |
Vyacheslav Yurkov | e43a080 | 2021-06-04 10:10:51 +0200 | [diff] [blame] | 67 | |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 68 | static const io_dev_connector_t *mmc_dev_con; |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 69 | #endif /* STM32MP_SDMMC || STM32MP_EMMC */ |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 70 | |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 71 | #if STM32MP_SPI_NOR |
| 72 | static io_mtd_dev_spec_t spi_nor_dev_spec = { |
| 73 | .ops = { |
| 74 | .init = spi_nor_init, |
| 75 | .read = spi_nor_read, |
| 76 | }, |
| 77 | }; |
| 78 | #endif |
| 79 | |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 80 | #if STM32MP_RAW_NAND |
| 81 | static io_mtd_dev_spec_t nand_dev_spec = { |
| 82 | .ops = { |
| 83 | .init = nand_raw_init, |
| 84 | .read = nand_read, |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 85 | .seek = nand_seek_bb |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 86 | }, |
| 87 | }; |
| 88 | |
| 89 | static const io_dev_connector_t *nand_dev_con; |
| 90 | #endif |
| 91 | |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 92 | #if STM32MP_SPI_NAND |
| 93 | static io_mtd_dev_spec_t spi_nand_dev_spec = { |
| 94 | .ops = { |
| 95 | .init = spi_nand_init, |
| 96 | .read = nand_read, |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 97 | .seek = nand_seek_bb |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 98 | }, |
| 99 | }; |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 100 | #endif |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 101 | |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 102 | #if STM32MP_SPI_NAND || STM32MP_SPI_NOR |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 103 | static const io_dev_connector_t *spi_dev_con; |
| 104 | #endif |
| 105 | |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 106 | #if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 107 | static const io_dev_connector_t *memmap_dev_con; |
| 108 | #endif |
| 109 | |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 110 | io_block_spec_t image_block_spec = { |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 111 | .offset = 0U, |
| 112 | .length = 0U, |
| 113 | }; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 114 | |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 115 | int open_fip(const uintptr_t spec) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 116 | { |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 117 | return io_dev_init(fip_dev_handle, (uintptr_t)FIP_IMAGE_ID); |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 118 | } |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 119 | |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 120 | int open_storage(const uintptr_t spec) |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 121 | { |
| 122 | return io_dev_init(storage_dev_handle, 0); |
| 123 | } |
Vyacheslav Yurkov | e43a080 | 2021-06-04 10:10:51 +0200 | [diff] [blame] | 124 | |
Ahmad Fatoum | bd68528 | 2022-05-19 07:42:33 +0200 | [diff] [blame] | 125 | #if STM32MP_EMMC_BOOT |
| 126 | static uint32_t get_boot_part_fip_header(void) |
| 127 | { |
| 128 | io_block_spec_t emmc_boot_fip_block_spec = { |
| 129 | .offset = STM32MP_EMMC_BOOT_FIP_OFFSET, |
| 130 | .length = MMC_BLOCK_SIZE, /* We are interested only in first 4 bytes */ |
| 131 | }; |
| 132 | uint32_t magic = 0U; |
| 133 | int io_result; |
| 134 | size_t bytes_read; |
| 135 | uintptr_t fip_hdr_handle; |
| 136 | |
| 137 | io_result = io_open(storage_dev_handle, (uintptr_t)&emmc_boot_fip_block_spec, |
| 138 | &fip_hdr_handle); |
| 139 | assert(io_result == 0); |
| 140 | |
| 141 | io_result = io_read(fip_hdr_handle, (uintptr_t)&magic, sizeof(magic), |
| 142 | &bytes_read); |
| 143 | if ((io_result != 0) || (bytes_read != sizeof(magic))) { |
| 144 | panic(); |
| 145 | } |
| 146 | |
| 147 | io_close(fip_hdr_handle); |
| 148 | |
| 149 | VERBOSE("%s: eMMC boot magic at offset 256K: %08x\n", |
| 150 | __func__, magic); |
| 151 | |
| 152 | return magic; |
| 153 | } |
| 154 | #endif |
| 155 | |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 156 | static void print_boot_device(boot_api_context_t *boot_context) |
| 157 | { |
| 158 | switch (boot_context->boot_interface_selected) { |
| 159 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD: |
| 160 | INFO("Using SDMMC\n"); |
| 161 | break; |
| 162 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC: |
| 163 | INFO("Using EMMC\n"); |
| 164 | break; |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 165 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_QSPI: |
| 166 | INFO("Using QSPI NOR\n"); |
| 167 | break; |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 168 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC: |
| 169 | INFO("Using FMC NAND\n"); |
| 170 | break; |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 171 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_QSPI: |
| 172 | INFO("Using SPI NAND\n"); |
| 173 | break; |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 174 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART: |
| 175 | INFO("Using UART\n"); |
| 176 | break; |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 177 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB: |
| 178 | INFO("Using USB\n"); |
| 179 | break; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 180 | default: |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 181 | ERROR("Boot interface %u not found\n", |
| 182 | boot_context->boot_interface_selected); |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 183 | panic(); |
| 184 | break; |
| 185 | } |
| 186 | |
| 187 | if (boot_context->boot_interface_instance != 0U) { |
| 188 | INFO(" Instance %d\n", boot_context->boot_interface_instance); |
| 189 | } |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 190 | } |
| 191 | |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 192 | #if STM32MP_SDMMC || STM32MP_EMMC |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 193 | static void boot_mmc(enum mmc_device_type mmc_dev_type, |
| 194 | uint16_t boot_interface_instance) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 195 | { |
| 196 | int io_result __unused; |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 197 | struct stm32_sdmmc2_params params; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 198 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 199 | zeromem(¶ms, sizeof(struct stm32_sdmmc2_params)); |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 200 | |
Yann Gautier | ac22dd5 | 2021-03-22 14:22:14 +0100 | [diff] [blame] | 201 | mmc_info.mmc_dev_type = mmc_dev_type; |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 202 | |
| 203 | switch (boot_interface_instance) { |
| 204 | case 1: |
| 205 | params.reg_base = STM32MP_SDMMC1_BASE; |
| 206 | break; |
| 207 | case 2: |
| 208 | params.reg_base = STM32MP_SDMMC2_BASE; |
| 209 | break; |
| 210 | case 3: |
| 211 | params.reg_base = STM32MP_SDMMC3_BASE; |
| 212 | break; |
| 213 | default: |
| 214 | WARN("SDMMC instance not found, using default\n"); |
| 215 | if (mmc_dev_type == MMC_IS_SD) { |
| 216 | params.reg_base = STM32MP_SDMMC1_BASE; |
| 217 | } else { |
| 218 | params.reg_base = STM32MP_SDMMC2_BASE; |
| 219 | } |
| 220 | break; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 221 | } |
| 222 | |
Yann Gautier | ac22dd5 | 2021-03-22 14:22:14 +0100 | [diff] [blame] | 223 | params.device_info = &mmc_info; |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 224 | if (stm32_sdmmc2_mmc_init(¶ms) != 0) { |
| 225 | ERROR("SDMMC%u init failed\n", boot_interface_instance); |
| 226 | panic(); |
| 227 | } |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 228 | |
Ahmad Fatoum | bd68528 | 2022-05-19 07:42:33 +0200 | [diff] [blame] | 229 | /* Open MMC as a block device to read FIP */ |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 230 | io_result = register_io_dev_block(&mmc_dev_con); |
| 231 | if (io_result != 0) { |
| 232 | panic(); |
| 233 | } |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 234 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 235 | io_result = io_dev_open(mmc_dev_con, (uintptr_t)&mmc_block_dev_spec, |
| 236 | &storage_dev_handle); |
| 237 | assert(io_result == 0); |
Ahmad Fatoum | bd68528 | 2022-05-19 07:42:33 +0200 | [diff] [blame] | 238 | |
| 239 | #if STM32MP_EMMC_BOOT |
| 240 | if (mmc_dev_type == MMC_IS_EMMC) { |
| 241 | io_result = mmc_part_switch_current_boot(); |
| 242 | assert(io_result == 0); |
| 243 | |
| 244 | if (get_boot_part_fip_header() != TOC_HEADER_NAME) { |
| 245 | WARN("%s: Can't find FIP header on eMMC boot partition. Trying GPT\n", |
| 246 | __func__); |
| 247 | io_result = mmc_part_switch_user(); |
| 248 | assert(io_result == 0); |
| 249 | return; |
| 250 | } |
| 251 | |
| 252 | VERBOSE("%s: FIP header found on eMMC boot partition\n", |
| 253 | __func__); |
| 254 | image_block_spec.offset = STM32MP_EMMC_BOOT_FIP_OFFSET; |
| 255 | } |
| 256 | #endif |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 257 | } |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 258 | #endif /* STM32MP_SDMMC || STM32MP_EMMC */ |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 259 | |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 260 | #if STM32MP_SPI_NOR |
| 261 | static void boot_spi_nor(boot_api_context_t *boot_context) |
| 262 | { |
| 263 | int io_result __unused; |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 264 | |
| 265 | io_result = stm32_qspi_init(); |
| 266 | assert(io_result == 0); |
| 267 | |
| 268 | io_result = register_io_dev_mtd(&spi_dev_con); |
| 269 | assert(io_result == 0); |
| 270 | |
| 271 | /* Open connections to device */ |
| 272 | io_result = io_dev_open(spi_dev_con, |
| 273 | (uintptr_t)&spi_nor_dev_spec, |
| 274 | &storage_dev_handle); |
| 275 | assert(io_result == 0); |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 276 | } |
| 277 | #endif /* STM32MP_SPI_NOR */ |
| 278 | |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 279 | #if STM32MP_RAW_NAND |
| 280 | static void boot_fmc2_nand(boot_api_context_t *boot_context) |
| 281 | { |
| 282 | int io_result __unused; |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 283 | |
| 284 | io_result = stm32_fmc2_init(); |
| 285 | assert(io_result == 0); |
| 286 | |
| 287 | /* Register the IO device on this platform */ |
| 288 | io_result = register_io_dev_mtd(&nand_dev_con); |
| 289 | assert(io_result == 0); |
| 290 | |
| 291 | /* Open connections to device */ |
| 292 | io_result = io_dev_open(nand_dev_con, (uintptr_t)&nand_dev_spec, |
| 293 | &storage_dev_handle); |
| 294 | assert(io_result == 0); |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 295 | } |
| 296 | #endif /* STM32MP_RAW_NAND */ |
| 297 | |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 298 | #if STM32MP_SPI_NAND |
| 299 | static void boot_spi_nand(boot_api_context_t *boot_context) |
| 300 | { |
| 301 | int io_result __unused; |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 302 | |
| 303 | io_result = stm32_qspi_init(); |
| 304 | assert(io_result == 0); |
| 305 | |
| 306 | io_result = register_io_dev_mtd(&spi_dev_con); |
| 307 | assert(io_result == 0); |
| 308 | |
| 309 | /* Open connections to device */ |
| 310 | io_result = io_dev_open(spi_dev_con, |
| 311 | (uintptr_t)&spi_nand_dev_spec, |
| 312 | &storage_dev_handle); |
| 313 | assert(io_result == 0); |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 314 | } |
| 315 | #endif /* STM32MP_SPI_NAND */ |
| 316 | |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 317 | #if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 318 | static void mmap_io_setup(void) |
| 319 | { |
| 320 | int io_result __unused; |
| 321 | |
| 322 | io_result = register_io_dev_memmap(&memmap_dev_con); |
| 323 | assert(io_result == 0); |
| 324 | |
| 325 | io_result = io_dev_open(memmap_dev_con, (uintptr_t)NULL, |
| 326 | &storage_dev_handle); |
| 327 | assert(io_result == 0); |
| 328 | } |
| 329 | |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 330 | #if STM32MP_UART_PROGRAMMER |
| 331 | static void stm32cubeprogrammer_uart(void) |
| 332 | { |
| 333 | int ret __unused; |
| 334 | boot_api_context_t *boot_context = |
| 335 | (boot_api_context_t *)stm32mp_get_boot_ctx_address(); |
| 336 | uintptr_t uart_base; |
| 337 | |
| 338 | uart_base = get_uart_address(boot_context->boot_interface_instance); |
| 339 | ret = stm32cubeprog_uart_load(uart_base, DWL_BUFFER_BASE, DWL_BUFFER_SIZE); |
| 340 | assert(ret == 0); |
| 341 | } |
| 342 | #endif |
| 343 | |
| 344 | #if STM32MP_USB_PROGRAMMER |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 345 | static void stm32cubeprogrammer_usb(void) |
| 346 | { |
| 347 | int ret __unused; |
| 348 | struct usb_handle *pdev; |
| 349 | |
| 350 | /* Init USB on platform */ |
| 351 | pdev = usb_dfu_plat_init(); |
| 352 | |
| 353 | ret = stm32cubeprog_usb_load(pdev, DWL_BUFFER_BASE, DWL_BUFFER_SIZE); |
| 354 | assert(ret == 0); |
| 355 | } |
| 356 | #endif |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 357 | #endif /* STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER */ |
| 358 | |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 359 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 360 | void stm32mp_io_setup(void) |
| 361 | { |
| 362 | int io_result __unused; |
| 363 | boot_api_context_t *boot_context = |
| 364 | (boot_api_context_t *)stm32mp_get_boot_ctx_address(); |
Yann Gautier | f9d40d5 | 2019-01-17 14:41:46 +0100 | [diff] [blame] | 365 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 366 | print_boot_device(boot_context); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 367 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 368 | if ((boot_context->boot_partition_used_toboot == 1U) || |
| 369 | (boot_context->boot_partition_used_toboot == 2U)) { |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 370 | INFO("Boot used partition fsbl%u\n", |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 371 | boot_context->boot_partition_used_toboot); |
| 372 | } |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 373 | |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 374 | io_result = register_io_dev_fip(&fip_dev_con); |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 375 | assert(io_result == 0); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 376 | |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 377 | io_result = io_dev_open(fip_dev_con, (uintptr_t)NULL, |
| 378 | &fip_dev_handle); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 379 | |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 380 | switch (boot_context->boot_interface_selected) { |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 381 | #if STM32MP_SDMMC |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 382 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD: |
| 383 | dmbsy(); |
| 384 | boot_mmc(MMC_IS_SD, boot_context->boot_interface_instance); |
| 385 | break; |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 386 | #endif |
| 387 | #if STM32MP_EMMC |
Yann Gautier | eae3fbf | 2019-04-23 13:34:03 +0200 | [diff] [blame] | 388 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC: |
| 389 | dmbsy(); |
| 390 | boot_mmc(MMC_IS_EMMC, boot_context->boot_interface_instance); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 391 | break; |
Nicolas Le Bayon | 3f42cad | 2019-09-03 09:52:05 +0200 | [diff] [blame] | 392 | #endif |
Lionel Debieve | cb0dbc4 | 2019-09-25 09:11:31 +0200 | [diff] [blame] | 393 | #if STM32MP_SPI_NOR |
| 394 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_QSPI: |
| 395 | dmbsy(); |
| 396 | boot_spi_nor(boot_context); |
| 397 | break; |
| 398 | #endif |
Lionel Debieve | 402a46b | 2019-11-04 12:28:15 +0100 | [diff] [blame] | 399 | #if STM32MP_RAW_NAND |
| 400 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC: |
| 401 | dmbsy(); |
| 402 | boot_fmc2_nand(boot_context); |
| 403 | break; |
| 404 | #endif |
Lionel Debieve | 186b046 | 2019-09-24 18:30:12 +0200 | [diff] [blame] | 405 | #if STM32MP_SPI_NAND |
| 406 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_QSPI: |
| 407 | dmbsy(); |
| 408 | boot_spi_nand(boot_context); |
| 409 | break; |
| 410 | #endif |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 411 | #if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER |
| 412 | #if STM32MP_UART_PROGRAMMER |
| 413 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART: |
| 414 | #endif |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 415 | #if STM32MP_USB_PROGRAMMER |
| 416 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB: |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 417 | #endif |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 418 | dmbsy(); |
| 419 | mmap_io_setup(); |
| 420 | break; |
| 421 | #endif |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 422 | |
| 423 | default: |
| 424 | ERROR("Boot interface %d not supported\n", |
| 425 | boot_context->boot_interface_selected); |
Yann Gautier | 4c2b73d | 2021-06-30 17:04:22 +0200 | [diff] [blame] | 426 | panic(); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 427 | break; |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | int bl2_plat_handle_pre_image_load(unsigned int image_id) |
| 432 | { |
| 433 | static bool gpt_init_done __unused; |
| 434 | uint16_t boot_itf = stm32mp_get_boot_itf_selected(); |
| 435 | |
| 436 | switch (boot_itf) { |
| 437 | #if STM32MP_SDMMC || STM32MP_EMMC |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 438 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC: |
Ahmad Fatoum | bd68528 | 2022-05-19 07:42:33 +0200 | [diff] [blame] | 439 | #if STM32MP_EMMC_BOOT |
| 440 | if (image_block_spec.offset == STM32MP_EMMC_BOOT_FIP_OFFSET) { |
| 441 | break; |
| 442 | } |
| 443 | #endif |
| 444 | /* fallthrough */ |
| 445 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD: |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 446 | if (!gpt_init_done) { |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 447 | /* |
| 448 | * With FWU Multi Bank feature enabled, the selection of |
| 449 | * the image to boot will be done by fwu_init calling the |
| 450 | * platform hook, plat_fwu_set_images_source. |
| 451 | */ |
| 452 | #if !PSA_FWU_SUPPORT |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 453 | const partition_entry_t *entry; |
| 454 | |
| 455 | partition_init(GPT_IMAGE_ID); |
| 456 | entry = get_partition_entry(FIP_IMAGE_NAME); |
| 457 | if (entry == NULL) { |
| 458 | ERROR("Could NOT find the %s partition!\n", |
| 459 | FIP_IMAGE_NAME); |
| 460 | return -ENOENT; |
| 461 | } |
| 462 | |
| 463 | image_block_spec.offset = entry->start; |
| 464 | image_block_spec.length = entry->length; |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 465 | #endif |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 466 | gpt_init_done = true; |
Yann Gautier | a3bd8d1 | 2021-06-18 11:33:26 +0200 | [diff] [blame] | 467 | } else { |
| 468 | bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id); |
Yann Gautier | c6f77b0 | 2022-05-06 09:50:43 +0200 | [diff] [blame] | 469 | assert(bl_mem_params != NULL); |
Yann Gautier | a3bd8d1 | 2021-06-18 11:33:26 +0200 | [diff] [blame] | 470 | |
| 471 | mmc_block_dev_spec.buffer.offset = bl_mem_params->image_info.image_base; |
| 472 | mmc_block_dev_spec.buffer.length = bl_mem_params->image_info.image_max_size; |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | break; |
| 476 | #endif |
| 477 | |
| 478 | #if STM32MP_RAW_NAND || STM32MP_SPI_NAND |
| 479 | #if STM32MP_RAW_NAND |
| 480 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC: |
| 481 | #endif |
| 482 | #if STM32MP_SPI_NAND |
| 483 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_QSPI: |
| 484 | #endif |
| 485 | image_block_spec.offset = STM32MP_NAND_FIP_OFFSET; |
| 486 | break; |
| 487 | #endif |
| 488 | |
| 489 | #if STM32MP_SPI_NOR |
| 490 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_QSPI: |
| 491 | image_block_spec.offset = STM32MP_NOR_FIP_OFFSET; |
| 492 | break; |
| 493 | #endif |
| 494 | |
Patrick Delaunay | e50571b | 2021-10-28 13:48:52 +0200 | [diff] [blame] | 495 | #if STM32MP_UART_PROGRAMMER |
| 496 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART: |
| 497 | if (image_id == FW_CONFIG_ID) { |
| 498 | stm32cubeprogrammer_uart(); |
| 499 | /* FIP loaded at DWL address */ |
| 500 | image_block_spec.offset = DWL_BUFFER_BASE; |
| 501 | image_block_spec.length = DWL_BUFFER_SIZE; |
| 502 | } |
| 503 | break; |
| 504 | #endif |
Patrick Delaunay | 9c5ee78 | 2021-07-06 14:07:56 +0200 | [diff] [blame] | 505 | #if STM32MP_USB_PROGRAMMER |
| 506 | case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB: |
| 507 | if (image_id == FW_CONFIG_ID) { |
| 508 | stm32cubeprogrammer_usb(); |
| 509 | /* FIP loaded at DWL address */ |
| 510 | image_block_spec.offset = DWL_BUFFER_BASE; |
| 511 | image_block_spec.length = DWL_BUFFER_SIZE; |
| 512 | } |
| 513 | break; |
| 514 | #endif |
| 515 | |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 516 | default: |
| 517 | ERROR("FIP Not found\n"); |
| 518 | panic(); |
Yann Gautier | 8244e1d | 2018-10-15 09:36:58 +0200 | [diff] [blame] | 519 | } |
Yann Gautier | 0ed7b2a | 2021-05-19 18:48:16 +0200 | [diff] [blame] | 520 | |
| 521 | return 0; |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /* |
| 525 | * Return an IO device handle and specification which can be used to access |
| 526 | * an image. Use this to enforce platform load policy. |
| 527 | */ |
| 528 | int plat_get_image_source(unsigned int image_id, uintptr_t *dev_handle, |
| 529 | uintptr_t *image_spec) |
| 530 | { |
| 531 | int rc; |
| 532 | const struct plat_io_policy *policy; |
| 533 | |
Yann Gautier | 29f1f94 | 2021-07-13 18:07:41 +0200 | [diff] [blame] | 534 | policy = FCONF_GET_PROPERTY(stm32mp, io_policies, image_id); |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 535 | rc = policy->check(policy->image_spec); |
| 536 | if (rc == 0) { |
| 537 | *image_spec = policy->image_spec; |
| 538 | *dev_handle = *(policy->dev_handle); |
| 539 | } |
| 540 | |
| 541 | return rc; |
| 542 | } |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 543 | |
| 544 | #if (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT |
| 545 | /* |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 546 | * In each boot in non-trial mode, we set the BKP register to |
| 547 | * FWU_MAX_TRIAL_REBOOT, and return the active_index from metadata. |
| 548 | * |
| 549 | * As long as the update agent didn't update the "accepted" field in metadata |
| 550 | * (i.e. we are in trial mode), we select the new active_index. |
| 551 | * To avoid infinite boot loop at trial boot we decrement a BKP register. |
| 552 | * If this counter is 0: |
| 553 | * - an unexpected TAMPER event raised (that resets the BKP registers to 0) |
| 554 | * - a power-off occurs before the update agent was able to update the |
| 555 | * "accepted' field |
| 556 | * - we already boot FWU_MAX_TRIAL_REBOOT times in trial mode. |
| 557 | * we select the previous_active_index. |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 558 | */ |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 559 | #define INVALID_BOOT_IDX 0xFFFFFFFF |
| 560 | |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 561 | uint32_t plat_fwu_get_boot_idx(void) |
| 562 | { |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 563 | /* |
| 564 | * Select boot index and update boot counter only once per boot |
| 565 | * even if this function is called several times. |
| 566 | */ |
| 567 | static uint32_t boot_idx = INVALID_BOOT_IDX; |
| 568 | const struct fwu_metadata *data; |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 569 | |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 570 | data = fwu_get_metadata(); |
| 571 | |
| 572 | if (boot_idx == INVALID_BOOT_IDX) { |
| 573 | boot_idx = data->active_index; |
| 574 | if (fwu_is_trial_run_state()) { |
| 575 | if (stm32_get_and_dec_fwu_trial_boot_cnt() == 0U) { |
| 576 | WARN("Trial FWU fails %u times\n", |
| 577 | FWU_MAX_TRIAL_REBOOT); |
| 578 | boot_idx = data->previous_active_index; |
| 579 | } |
| 580 | } else { |
| 581 | stm32_set_max_fwu_trial_boot_cnt(); |
| 582 | } |
| 583 | } |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 584 | |
Nicolas Toromanoff | 5a937cd | 2022-02-07 10:12:04 +0100 | [diff] [blame] | 585 | return boot_idx; |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | static void *stm32_get_image_spec(const uuid_t *img_type_uuid) |
| 589 | { |
| 590 | unsigned int i; |
| 591 | |
| 592 | for (i = 0U; i < MAX_NUMBER_IDS; i++) { |
| 593 | if ((guidcmp(&policies[i].img_type_guid, img_type_uuid)) == 0) { |
| 594 | return (void *)policies[i].image_spec; |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | return NULL; |
| 599 | } |
| 600 | |
| 601 | void plat_fwu_set_images_source(const struct fwu_metadata *metadata) |
| 602 | { |
| 603 | unsigned int i; |
| 604 | uint32_t boot_idx; |
| 605 | const partition_entry_t *entry; |
| 606 | const uuid_t *img_type_uuid, *img_uuid; |
| 607 | io_block_spec_t *image_spec; |
| 608 | |
| 609 | boot_idx = plat_fwu_get_boot_idx(); |
| 610 | assert(boot_idx < NR_OF_FW_BANKS); |
| 611 | |
| 612 | for (i = 0U; i < NR_OF_IMAGES_IN_FW_BANK; i++) { |
| 613 | img_type_uuid = &metadata->img_entry[i].img_type_uuid; |
| 614 | image_spec = stm32_get_image_spec(img_type_uuid); |
| 615 | if (image_spec == NULL) { |
| 616 | ERROR("Unable to get image spec for the image in the metadata\n"); |
| 617 | panic(); |
| 618 | } |
| 619 | |
| 620 | img_uuid = |
| 621 | &metadata->img_entry[i].img_props[boot_idx].img_uuid; |
| 622 | |
| 623 | entry = get_partition_entry_by_uuid(img_uuid); |
| 624 | if (entry == NULL) { |
| 625 | ERROR("Unable to find the partition with the uuid mentioned in metadata\n"); |
| 626 | panic(); |
| 627 | } |
| 628 | |
| 629 | image_spec->offset = entry->start; |
| 630 | image_spec->length = entry->length; |
| 631 | } |
| 632 | } |
Sughosh Ganu | d1f8713 | 2021-12-01 16:46:34 +0530 | [diff] [blame] | 633 | |
| 634 | static int plat_set_image_source(unsigned int image_id, |
| 635 | uintptr_t *handle, |
| 636 | uintptr_t *image_spec, |
| 637 | const char *part_name) |
| 638 | { |
| 639 | struct plat_io_policy *policy; |
| 640 | io_block_spec_t *spec; |
| 641 | const partition_entry_t *entry = get_partition_entry(part_name); |
| 642 | |
| 643 | if (entry == NULL) { |
| 644 | ERROR("Unable to find the %s partition\n", part_name); |
| 645 | return -ENOENT; |
| 646 | } |
| 647 | |
| 648 | policy = &policies[image_id]; |
| 649 | |
| 650 | spec = (io_block_spec_t *)policy->image_spec; |
| 651 | spec->offset = entry->start; |
| 652 | spec->length = entry->length; |
| 653 | |
| 654 | *image_spec = policy->image_spec; |
| 655 | *handle = *policy->dev_handle; |
| 656 | |
| 657 | return 0; |
| 658 | } |
| 659 | |
| 660 | int plat_fwu_set_metadata_image_source(unsigned int image_id, |
| 661 | uintptr_t *handle, |
| 662 | uintptr_t *image_spec) |
| 663 | { |
| 664 | char *part_name; |
| 665 | |
| 666 | assert((image_id == FWU_METADATA_IMAGE_ID) || |
| 667 | (image_id == BKUP_FWU_METADATA_IMAGE_ID)); |
| 668 | |
| 669 | partition_init(GPT_IMAGE_ID); |
| 670 | |
| 671 | if (image_id == FWU_METADATA_IMAGE_ID) { |
| 672 | part_name = METADATA_PART_1; |
| 673 | } else { |
| 674 | part_name = METADATA_PART_2; |
| 675 | } |
| 676 | |
| 677 | return plat_set_image_source(image_id, handle, image_spec, |
| 678 | part_name); |
| 679 | } |
Sughosh Ganu | b721f8a | 2021-12-01 16:45:11 +0530 | [diff] [blame] | 680 | #endif /* (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT */ |