blob: 7ee752b86be38c13d0409a439682e38ddfca2032 [file] [log] [blame]
laurenw-arm7c7b1982020-10-21 13:34:40 -05001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
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>
13#include <platform_def.h>
14
15/*
16 * FVP_R 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");
laurenw-arm56f1e3e2021-03-03 14:19:38 -060027 (void)nor_unlock(PLAT_ARM_FLASH_IMAGE_BASE);
28 ret = nor_word_program(PLAT_ARM_FLASH_IMAGE_BASE, 0);
laurenw-arm7c7b1982020-10-21 13:34:40 -050029 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
40 (void)console_flush();
41
42 /* Setup the watchdog to reset the system as soon as possible */
43 sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
44
45 while (true) {
46 wfi();
47 }
48}