blob: c9b20905f627b51c2f6c0e00610f8e835858377c [file] [log] [blame]
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +01001/*
Zelalem87675d42020-02-03 14:56:42 -06002 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <errno.h>
8
9#include <common/debug.h>
10#include <drivers/arm/sp805.h>
11#include <drivers/cfi/v2m_flash.h>
12#include <plat/arm/common/plat_arm.h>
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010013#include <platform_def.h>
14
15/*
16 * FVP error handler
17 */
18__dead2 void plat_arm_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 (void)nor_unlock(PLAT_ARM_FIP_BASE);
28 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
29 if (ret != 0) {
30 ERROR("Cannot erase ToC\n");
31 } else {
32 INFO("Done\n");
33 }
34 break;
35 default:
36 /* Unexpected error */
37 break;
38 }
39
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050040 console_flush();
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010041
42 /* Setup the watchdog to reset the system as soon as possible */
43 sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
44
45 for (;;)
46 wfi();
47}