1 /* 2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <errno.h> 8 #include <stdint.h> 9 10 #include <platform_def.h> 11 12 #include <arch_helpers.h> 13 #include <common/debug.h> 14 #include <drivers/cfi/v2m_flash.h> 15 #include <drivers/console.h> 16 #include <plat/arm/common/plat_arm.h> 17 #include <plat/common/platform.h> 18 19 #pragma weak plat_arm_error_handler 20 21 /* 22 * ARM common implementation for error handler 23 */ 24 void __dead2 plat_arm_error_handler(int err) 25 { 26 int ret; 27 28 switch (err) { 29 case -ENOENT: 30 case -EAUTH: 31 /* Image load or authentication error. Erase the ToC */ 32 INFO("Erasing FIP ToC from flash...\n"); 33 (void)nor_unlock(PLAT_ARM_FIP_BASE); 34 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); 35 if (ret != 0) { 36 ERROR("Cannot erase ToC\n"); 37 } else { 38 INFO("Done\n"); 39 } 40 break; 41 default: 42 /* Unexpected error */ 43 break; 44 } 45 46 (void)console_flush(); 47 48 /* Loop until the watchdog resets the system */ 49 for (;;) 50 wfi(); 51 } 52 53 void __dead2 plat_error_handler(int err) 54 { 55 plat_arm_error_handler(err); 56 } 57