1 /* 2 * Copyright (c) 2019, 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 <plat/common/platform.h> 14 #include <platform_def.h> 15 16 /* 17 * FVP error handler 18 */ 19 __dead2 void plat_arm_error_handler(int err) 20 { 21 int ret; 22 23 switch (err) { 24 case -ENOENT: 25 case -EAUTH: 26 /* Image load or authentication error. Erase the ToC */ 27 INFO("Erasing FIP ToC from flash...\n"); 28 (void)nor_unlock(PLAT_ARM_FIP_BASE); 29 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); 30 if (ret != 0) { 31 ERROR("Cannot erase ToC\n"); 32 } else { 33 INFO("Done\n"); 34 } 35 break; 36 default: 37 /* Unexpected error */ 38 break; 39 } 40 41 (void)console_flush(); 42 43 /* Setup the watchdog to reset the system as soon as possible */ 44 sp805_refresh(ARM_SP805_TWDG_BASE, 1U); 45 46 for (;;) 47 wfi(); 48 } 49