blob: 36c022a684a798a003784d96ff13595fde937b1b [file] [log] [blame]
David Brown5153bd62017-01-06 11:16:53 -07001/*
2 * Copyright (c) 2012-2014 Wind River Systems, Inc.
Tamas Banee6615d2020-09-30 07:58:48 +01003 * Copyright (c) 2020 Arm Limited
David Brown5153bd62017-01-06 11:16:53 -07004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
Marti Bolivareb940802017-05-01 23:15:29 -040018#include <assert.h>
David Brown5153bd62017-01-06 11:16:53 -070019#include <zephyr.h>
Peter Bigot54c1e3f2020-01-25 05:50:12 -060020#include <drivers/gpio.h>
Andrzej Puzdrowskif1d189c2019-12-12 09:34:11 +010021#include <sys/__assert.h>
Peter Bigot54c1e3f2020-01-25 05:50:12 -060022#include <drivers/flash.h>
Andrzej Puzdrowskif99a4c72019-06-28 15:16:35 +020023#include <drivers/timer/system_timer.h>
Emanuele Di Santoc4bf7802018-07-20 11:39:57 +020024#include <usb/usb_device.h>
Evan Gates4632d8d2018-06-28 13:27:40 -070025#include <soc.h>
Rafał Kuźnia505c6e62020-07-17 13:18:15 +020026#include <linker/linker-defs.h>
David Brown5153bd62017-01-06 11:16:53 -070027
Marti Bolivar51181cf2017-03-20 11:03:41 -040028#include "target.h"
29
Marti Bolivar4a97b4c2017-01-31 18:20:02 -050030#include "bootutil/bootutil_log.h"
Ricardo Salveti3a2c1242017-01-19 10:22:35 -020031#include "bootutil/image.h"
32#include "bootutil/bootutil.h"
Tamas Banee6615d2020-09-30 07:58:48 +010033#include "bootutil/fault_injection_hardening.h"
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +020034#include "flash_map_backend/flash_map_backend.h"
Ricardo Salveti3a2c1242017-01-19 10:22:35 -020035
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +020036#ifdef CONFIG_MCUBOOT_SERIAL
Marko Kiiskila149b4572018-06-06 14:18:54 +030037#include "boot_serial/boot_serial.h"
38#include "serial_adapter/serial_adapter.h"
39
40const struct boot_uart_funcs boot_funcs = {
41 .read = console_read,
42 .write = console_write
43};
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +020044#endif
45
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +053046#ifdef CONFIG_BOOT_WAIT_FOR_USB_DFU
47#include <usb/class/usb_dfu.h>
48#endif
49
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +010050#if CONFIG_MCUBOOT_CLEANUP_ARM_CORE
51#include <arm_cleanup.h>
52#endif
53
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010054#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_IMMEDIATE)
55#ifdef CONFIG_LOG_PROCESS_THREAD
56#warning "The log internal thread for log processing can't transfer the log"\
57 "well for MCUBoot."
58#else
59#include <logging/log_ctrl.h>
60
Krzysztof Chruscinski821214e2020-03-24 07:50:32 +010061#define BOOT_LOG_PROCESSING_INTERVAL K_MSEC(30) /* [ms] */
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010062
63/* log are processing in custom routine */
Andrzej Puzdrowskiaf148532020-02-25 12:51:26 +010064K_THREAD_STACK_DEFINE(boot_log_stack, CONFIG_MCUBOOT_LOG_THREAD_STACK_SIZE);
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010065struct k_thread boot_log_thread;
Andrzej Puzdrowski84591632020-02-24 11:50:19 +010066volatile bool boot_log_stop = false;
67K_SEM_DEFINE(boot_log_sem, 1, 1);
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010068
69/* log processing need to be initalized by the application */
70#define ZEPHYR_BOOT_LOG_START() zephyr_boot_log_start()
Andrzej Puzdrowski84591632020-02-24 11:50:19 +010071#define ZEPHYR_BOOT_LOG_STOP() zephyr_boot_log_stop()
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010072#endif /* CONFIG_LOG_PROCESS_THREAD */
73#else
74/* synchronous log mode doesn't need to be initalized by the application */
75#define ZEPHYR_BOOT_LOG_START() do { } while (false)
Andrzej Puzdrowski84591632020-02-24 11:50:19 +010076#define ZEPHYR_BOOT_LOG_STOP() do { } while (false)
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +010077#endif /* defined(CONFIG_LOG) && !defined(CONFIG_LOG_IMMEDIATE) */
78
Jon Helge Nistade58f9bd2019-11-25 15:59:52 +010079#ifdef CONFIG_SOC_FAMILY_NRF
80#include <hal/nrf_power.h>
81
82static inline bool boot_skip_serial_recovery()
83{
Fabio Utzig63b4eac2019-12-17 09:59:47 -030084#if NRF_POWER_HAS_RESETREAS
Kumar Gala0813efe2020-05-27 12:25:41 -050085 uint32_t rr = nrf_power_resetreas_get(NRF_POWER);
Jon Helge Nistade58f9bd2019-11-25 15:59:52 +010086
87 return !(rr == 0 || (rr & NRF_POWER_RESETREAS_RESETPIN_MASK));
88#else
89 return false;
90#endif
91}
92#else
93static inline bool boot_skip_serial_recovery()
94{
95 return false;
96}
97#endif
98
Emanuele Di Santo9f1933d2018-11-20 10:59:59 +010099MCUBOOT_LOG_MODULE_REGISTER(mcuboot);
100
Andrew Boie7238f512017-03-02 13:39:06 -0800101void os_heap_init(void);
102
103#if defined(CONFIG_ARM)
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200104
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200105#ifdef CONFIG_SW_VECTOR_RELAY
106extern void *_vector_table_pointer;
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200107#endif
108
Andrew Boie7238f512017-03-02 13:39:06 -0800109struct arm_vector_table {
David Brown0d0652a2017-04-11 17:33:30 -0600110 uint32_t msp;
111 uint32_t reset;
David Brown5153bd62017-01-06 11:16:53 -0700112};
113
Emanuele Di Santofcfff582018-11-01 16:06:36 +0100114extern void sys_clock_disable(void);
115
Andrew Boie7238f512017-03-02 13:39:06 -0800116static void do_boot(struct boot_rsp *rsp)
117{
David Brown0d0652a2017-04-11 17:33:30 -0600118 struct arm_vector_table *vt;
Marti Bolivareb940802017-05-01 23:15:29 -0400119 uintptr_t flash_base;
120 int rc;
Andrew Boie7238f512017-03-02 13:39:06 -0800121
David Brown0d0652a2017-04-11 17:33:30 -0600122 /* The beginning of the image is the ARM vector table, containing
123 * the initial stack pointer address and the reset vector
124 * consecutively. Manually set the stack pointer and jump into the
125 * reset vector
126 */
Marti Bolivareb940802017-05-01 23:15:29 -0400127 rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
128 assert(rc == 0);
129
130 vt = (struct arm_vector_table *)(flash_base +
131 rsp->br_image_off +
David Brown0d0652a2017-04-11 17:33:30 -0600132 rsp->br_hdr->ih_hdr_size);
Arvid Rosén9ed399c2020-08-19 08:57:11 +0200133
David Brown0d0652a2017-04-11 17:33:30 -0600134 irq_lock();
Andrzej Puzdrowski960a2d62019-08-12 16:28:26 +0200135#ifdef CONFIG_SYS_CLOCK_EXISTS
David Brown0d0652a2017-04-11 17:33:30 -0600136 sys_clock_disable();
Andrzej Puzdrowski960a2d62019-08-12 16:28:26 +0200137#endif
Jun Li01bef712019-05-08 21:55:54 -0700138#ifdef CONFIG_USB
Emanuele Di Santoc4bf7802018-07-20 11:39:57 +0200139 /* Disable the USB to prevent it from firing interrupts */
140 usb_disable();
141#endif
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100142#if CONFIG_MCUBOOT_CLEANUP_ARM_CORE
143 cleanup_arm_nvic(); /* cleanup NVIC registers */
Ioannis Glaropoulos70af7082020-10-22 15:14:48 +0200144
145#ifdef CONFIG_CPU_CORTEX_M7
146 /* Disable instruction cache and data cache before chain-load the application */
147 SCB_DisableDCache();
148 SCB_DisableICache();
149#endif
150
151#if CONFIG_CPU_HAS_ARM_MPU
152 z_arm_clear_arm_mpu_config();
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100153#endif
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200154
Håkon Øye Amundsen6a8dbba2020-10-01 12:52:38 +0000155#if defined(CONFIG_BUILTIN_STACK_GUARD) && \
156 defined(CONFIG_CPU_CORTEX_M_HAS_SPLIM)
157 /* Reset limit registers to avoid inflicting stack overflow on image
158 * being booted.
159 */
160 __set_PSPLIM(0);
161 __set_MSPLIM(0);
162#endif
163
Ioannis Glaropoulos70af7082020-10-22 15:14:48 +0200164#endif /* CONFIG_MCUBOOT_CLEANUP_ARM_CORE */
165
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200166#ifdef CONFIG_BOOT_INTR_VEC_RELOC
Rafał Kuźnia505c6e62020-07-17 13:18:15 +0200167#if defined(CONFIG_SW_VECTOR_RELAY)
168 _vector_table_pointer = vt;
169#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
170 SCB->VTOR = (uint32_t)__vector_relay_table;
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200171#endif
Rafał Kuźnia505c6e62020-07-17 13:18:15 +0200172#elif defined(CONFIG_CPU_CORTEX_M_HAS_VTOR)
173 SCB->VTOR = (uint32_t)vt;
174#endif /* CONFIG_SW_VECTOR_RELAY */
175#else /* CONFIG_BOOT_INTR_VEC_RELOC */
176#if defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) && defined(CONFIG_SW_VECTOR_RELAY)
177 _vector_table_pointer = _vector_start;
178 SCB->VTOR = (uint32_t)__vector_relay_table;
179#endif
180#endif /* CONFIG_BOOT_INTR_VEC_RELOC */
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200181
David Brown57837b92018-03-13 15:56:38 -0600182 __set_MSP(vt->msp);
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100183#if CONFIG_MCUBOOT_CLEANUP_ARM_CORE
184 __set_CONTROL(0x00); /* application will configures core on its own */
Andrzej Puzdrowski56c15e72020-10-29 09:16:50 +0100185 __ISB();
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100186#endif
David Brown0d0652a2017-04-11 17:33:30 -0600187 ((void (*)(void))vt->reset)();
Andrew Boie7238f512017-03-02 13:39:06 -0800188}
Rajavardhan Gundi40c28e32018-12-09 13:32:01 +0530189
190#elif defined(CONFIG_XTENSA)
191#define SRAM_BASE_ADDRESS 0xBE030000
192
193static void copy_img_to_SRAM(int slot, unsigned int hdr_offset)
194{
195 const struct flash_area *fap;
196 int area_id;
197 int rc;
198 unsigned char *dst = (unsigned char *)(SRAM_BASE_ADDRESS + hdr_offset);
199
200 BOOT_LOG_INF("Copying image to SRAM");
201
202 area_id = flash_area_id_from_image_slot(slot);
203 rc = flash_area_open(area_id, &fap);
204 if (rc != 0) {
Fabio Utzigcac58f62019-09-06 08:52:35 -0300205 BOOT_LOG_ERR("flash_area_open failed with %d\n", rc);
Rajavardhan Gundi40c28e32018-12-09 13:32:01 +0530206 goto done;
207 }
208
209 rc = flash_area_read(fap, hdr_offset, dst, fap->fa_size - hdr_offset);
210 if (rc != 0) {
Fabio Utzigcac58f62019-09-06 08:52:35 -0300211 BOOT_LOG_ERR("flash_area_read failed with %d\n", rc);
Rajavardhan Gundi40c28e32018-12-09 13:32:01 +0530212 goto done;
213 }
214
215done:
216 flash_area_close(fap);
217}
218
219/* Entry point (.ResetVector) is at the very beginning of the image.
220 * Simply copy the image to a suitable location and jump there.
221 */
222static void do_boot(struct boot_rsp *rsp)
223{
224 void *start;
225
226 BOOT_LOG_INF("br_image_off = 0x%x\n", rsp->br_image_off);
227 BOOT_LOG_INF("ih_hdr_size = 0x%x\n", rsp->br_hdr->ih_hdr_size);
228
229 /* Copy from the flash to HP SRAM */
230 copy_img_to_SRAM(0, rsp->br_hdr->ih_hdr_size);
231
232 /* Jump to entry point */
233 start = (void *)(SRAM_BASE_ADDRESS + rsp->br_hdr->ih_hdr_size);
234 ((void (*)(void))start)();
235}
236
Andrew Boie7238f512017-03-02 13:39:06 -0800237#else
238/* Default: Assume entry point is at the very beginning of the image. Simply
239 * lock interrupts and jump there. This is the right thing to do for X86 and
240 * possibly other platforms.
241 */
242static void do_boot(struct boot_rsp *rsp)
243{
Marti Bolivareb940802017-05-01 23:15:29 -0400244 uintptr_t flash_base;
David Brown0d0652a2017-04-11 17:33:30 -0600245 void *start;
Marti Bolivareb940802017-05-01 23:15:29 -0400246 int rc;
Andrew Boie7238f512017-03-02 13:39:06 -0800247
Marti Bolivareb940802017-05-01 23:15:29 -0400248 rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
249 assert(rc == 0);
250
251 start = (void *)(flash_base + rsp->br_image_off +
252 rsp->br_hdr->ih_hdr_size);
Andrew Boie7238f512017-03-02 13:39:06 -0800253
David Brown0d0652a2017-04-11 17:33:30 -0600254 /* Lock interrupts and dive into the entry point */
255 irq_lock();
256 ((void (*)(void))start)();
Andrew Boie7238f512017-03-02 13:39:06 -0800257}
258#endif
David Brown5153bd62017-01-06 11:16:53 -0700259
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100260#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_IMMEDIATE) &&\
261 !defined(CONFIG_LOG_PROCESS_THREAD)
262/* The log internal thread for log processing can't transfer log well as has too
263 * low priority.
264 * Dedicated thread for log processing below uses highest application
265 * priority. This allows to transmit all logs without adding k_sleep/k_yield
266 * anywhere else int the code.
267 */
268
269/* most simple log processing theread */
270void boot_log_thread_func(void *dummy1, void *dummy2, void *dummy3)
271{
272 (void)dummy1;
273 (void)dummy2;
274 (void)dummy3;
275
276 log_init();
277
278 while (1) {
279 if (log_process(false) == false) {
Andrzej Puzdrowski84591632020-02-24 11:50:19 +0100280 if (boot_log_stop) {
281 break;
282 }
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100283 k_sleep(BOOT_LOG_PROCESSING_INTERVAL);
284 }
285 }
Andrzej Puzdrowski84591632020-02-24 11:50:19 +0100286
287 k_sem_give(&boot_log_sem);
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100288}
289
290void zephyr_boot_log_start(void)
291{
292 /* start logging thread */
293 k_thread_create(&boot_log_thread, boot_log_stack,
294 K_THREAD_STACK_SIZEOF(boot_log_stack),
295 boot_log_thread_func, NULL, NULL, NULL,
296 K_HIGHEST_APPLICATION_THREAD_PRIO, 0,
297 BOOT_LOG_PROCESSING_INTERVAL);
298
299 k_thread_name_set(&boot_log_thread, "logging");
300}
Andrzej Puzdrowski84591632020-02-24 11:50:19 +0100301
302void zephyr_boot_log_stop(void)
303{
304 boot_log_stop = true;
305
306 /* wait until log procesing thread expired
307 * This can be reworked using a thread_join() API once a such will be
308 * available in zephyr.
309 * see https://github.com/zephyrproject-rtos/zephyr/issues/21500
310 */
311 (void)k_sem_take(&boot_log_sem, K_FOREVER);
312}
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100313#endif/* defined(CONFIG_LOG) && !defined(CONFIG_LOG_IMMEDIATE) &&\
314 !defined(CONFIG_LOG_PROCESS_THREAD) */
315
David Brown5153bd62017-01-06 11:16:53 -0700316void main(void)
317{
David Brown0d0652a2017-04-11 17:33:30 -0600318 struct boot_rsp rsp;
319 int rc;
Tamas Banee6615d2020-09-30 07:58:48 +0100320 fih_int fih_rc = FIH_FAILURE;
David Brown5153bd62017-01-06 11:16:53 -0700321
Andrzej Puzdrowski210b3182020-10-13 13:52:15 +0200322 MCUBOOT_WATCHDOG_FEED();
323
David Brown0d0652a2017-04-11 17:33:30 -0600324 BOOT_LOG_INF("Starting bootloader");
Ricardo Salveti7cf3d9e2017-01-18 16:38:22 -0200325
David Brown0d0652a2017-04-11 17:33:30 -0600326 os_heap_init();
David Brown5153bd62017-01-06 11:16:53 -0700327
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100328 ZEPHYR_BOOT_LOG_START();
329
Tamas Banee6615d2020-09-30 07:58:48 +0100330 (void)rc;
331
Kumar Gala32b61f32020-04-08 12:02:03 -0500332#if (!defined(CONFIG_XTENSA) && defined(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL))
333 if (!flash_device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL)) {
334 BOOT_LOG_ERR("Flash device %s not found",
335 DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
David Brown0d0652a2017-04-11 17:33:30 -0600336 while (1)
337 ;
338 }
Kumar Gala9a5b9512020-04-08 12:06:21 -0500339#elif (defined(CONFIG_XTENSA) && defined(JEDEC_SPI_NOR_0_LABEL))
340 if (!flash_device_get_binding(JEDEC_SPI_NOR_0_LABEL)) {
341 BOOT_LOG_ERR("Flash device %s not found", JEDEC_SPI_NOR_0_LABEL);
Rajavardhan Gundi40c28e32018-12-09 13:32:01 +0530342 while (1)
343 ;
344 }
Rajavardhan Gundic3353b22018-12-06 17:24:10 +0530345#endif
David Brown5153bd62017-01-06 11:16:53 -0700346
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200347#ifdef CONFIG_MCUBOOT_SERIAL
348
Dominik Ermel1422b4b2020-09-11 11:31:38 +0000349 struct device const *detect_port;
Kumar Gala0813efe2020-05-27 12:25:41 -0500350 uint32_t detect_value = !CONFIG_BOOT_SERIAL_DETECT_PIN_VAL;
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200351
352 detect_port = device_get_binding(CONFIG_BOOT_SERIAL_DETECT_PORT);
353 __ASSERT(detect_port, "Error: Bad port for boot serial detection.\n");
354
Peter Bigot36e90292020-01-30 05:36:47 -0600355 /* The default presence value is 0 which would normally be
356 * active-low, but historically the raw value was checked so we'll
357 * use the raw interface.
358 */
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200359 rc = gpio_pin_configure(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN,
Peter Bigot36e90292020-01-30 05:36:47 -0600360#ifdef GPIO_INPUT
361 GPIO_INPUT | GPIO_PULL_UP
362#else
363 GPIO_DIR_IN | GPIO_PUD_PULL_UP
364#endif
Andrzej Puzdrowski5d96bd22020-02-20 10:35:33 +0100365 );
Andrzej Puzdrowski82d73952018-06-13 14:55:51 +0200366 __ASSERT(rc == 0, "Error of boot detect pin initialization.\n");
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200367
Peter Bigot36e90292020-01-30 05:36:47 -0600368#ifdef GPIO_INPUT
369 rc = gpio_pin_get_raw(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN);
370 detect_value = rc;
371#else
Emanuele Di Santofcfff582018-11-01 16:06:36 +0100372 rc = gpio_pin_read(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN,
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200373 &detect_value);
Peter Bigot36e90292020-01-30 05:36:47 -0600374#endif
375 __ASSERT(rc >= 0, "Error of the reading the detect pin.\n");
Jon Helge Nistade58f9bd2019-11-25 15:59:52 +0100376 if (detect_value == CONFIG_BOOT_SERIAL_DETECT_PIN_VAL &&
377 !boot_skip_serial_recovery()) {
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200378 BOOT_LOG_INF("Enter the serial recovery mode");
Marko Kiiskila149b4572018-06-06 14:18:54 +0300379 rc = boot_console_init();
Carles Cufie2a36122018-06-15 10:51:02 +0200380 __ASSERT(rc == 0, "Error initializing boot console.\n");
Marko Kiiskila149b4572018-06-06 14:18:54 +0300381 boot_serial_start(&boot_funcs);
Andrzej Puzdrowski8e96b832017-09-08 16:49:14 +0200382 __ASSERT(0, "Bootloader serial process was terminated unexpectedly.\n");
383 }
384#endif
385
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530386#ifdef CONFIG_BOOT_WAIT_FOR_USB_DFU
Andrzej Puzdrowskiac1f1ff2020-02-05 08:40:12 +0100387 rc = usb_enable(NULL);
388 if (rc) {
389 BOOT_LOG_ERR("Cannot enable USB");
390 } else {
391 BOOT_LOG_INF("Waiting for USB DFU");
392 wait_for_usb_dfu();
393 BOOT_LOG_INF("USB DFU wait time elapsed");
394 }
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530395#endif
396
Tamas Banee6615d2020-09-30 07:58:48 +0100397 FIH_CALL(boot_go, fih_rc, &rsp);
398 if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
David Brown0d0652a2017-04-11 17:33:30 -0600399 BOOT_LOG_ERR("Unable to find bootable image");
Tamas Banee6615d2020-09-30 07:58:48 +0100400 FIH_PANIC;
David Brown0d0652a2017-04-11 17:33:30 -0600401 }
David Brown5153bd62017-01-06 11:16:53 -0700402
Marti Bolivar88f48d92017-05-01 22:30:02 -0400403 BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
404 rsp.br_image_off);
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +0200405
David Brown0d0652a2017-04-11 17:33:30 -0600406 BOOT_LOG_INF("Jumping to the first image slot");
Andrzej Puzdrowski84591632020-02-24 11:50:19 +0100407 ZEPHYR_BOOT_LOG_STOP();
David Brown0d0652a2017-04-11 17:33:30 -0600408 do_boot(&rsp);
David Brown5153bd62017-01-06 11:16:53 -0700409
David Brown0d0652a2017-04-11 17:33:30 -0600410 BOOT_LOG_ERR("Never should get here");
411 while (1)
412 ;
David Brown5153bd62017-01-06 11:16:53 -0700413}