blob: d9ad5175ba34f9fc7987a69bde28bf804d9f963d [file] [log] [blame]
Juan Castillob6132f12015-10-06 14:01:35 +01001/*
Roberto Vargas2ca18d92018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Juan Castillob6132f12015-10-06 14:01:35 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillob6132f12015-10-06 14:01:35 +01005 */
6
Sandrine Bailleux628198b2016-08-18 09:24:40 +01007#include <arch_helpers.h>
Juan Castillob6132f12015-10-06 14:01:35 +01008#include <board_arm_def.h>
9#include <debug.h>
10#include <errno.h>
11#include <norflash.h>
Roberto Vargas2ca18d92018-02-12 12:36:17 +000012#include <platform.h>
Juan Castillob6132f12015-10-06 14:01:35 +010013#include <stdint.h>
14
15/*
16 * FVP error handler
17 */
18void plat_error_handler(int err)
19{
20 int ret;
21
22 switch (err) {
23 case -ENOENT:
24 case -EAUTH:
25 /* Image load or authentication error. Erase the ToC */
26 INFO("Erasing FIP ToC from flash...\n");
27 nor_unlock(PLAT_ARM_FIP_BASE);
28 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
29 if (ret) {
30 ERROR("Cannot erase ToC\n");
31 } else {
32 INFO("Done\n");
33 }
34 break;
35 default:
36 /* Unexpected error */
37 break;
38 }
39
40 /* Loop until the watchdog resets the system */
41 for (;;)
Sandrine Bailleux628198b2016-08-18 09:24:40 +010042 wfi();
Juan Castillob6132f12015-10-06 14:01:35 +010043}