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 <arch_helpers.h> 8 #include <console.h> 9 #include <debug.h> 10 #include <errno.h> 11 #include <norflash.h> 12 #include <platform.h> 13 #include <platform_def.h> 14 #include <stdint.h> 15 16 /* 17 * ARM common implementation for error handler 18 */ 19 void plat_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 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 /* Loop until the watchdog resets the system */ 44 for (;;) 45 wfi(); 46 } 47