blob: 8d4959504e33bcf34521154b2810dcf82c010594 [file] [log] [blame]
Juan Castillob6132f12015-10-06 14:01:35 +01001/*
Sandrine Bailleux628198b2016-08-18 09:24:40 +01002 * Copyright (c) 2015-2016, 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>
12#include <stdint.h>
13
14/*
15 * FVP error handler
16 */
17void plat_error_handler(int err)
18{
19 int ret;
20
21 switch (err) {
22 case -ENOENT:
23 case -EAUTH:
24 /* Image load or authentication error. Erase the ToC */
25 INFO("Erasing FIP ToC from flash...\n");
26 nor_unlock(PLAT_ARM_FIP_BASE);
27 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
28 if (ret) {
29 ERROR("Cannot erase ToC\n");
30 } else {
31 INFO("Done\n");
32 }
33 break;
34 default:
35 /* Unexpected error */
36 break;
37 }
38
39 /* Loop until the watchdog resets the system */
40 for (;;)
Sandrine Bailleux628198b2016-08-18 09:24:40 +010041 wfi();
Juan Castillob6132f12015-10-06 14:01:35 +010042}