laurenw-arm | 7c7b198 | 2020-10-21 13:34:40 -0500 | [diff] [blame] | 1 | /* |
| 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-arm | 56f1e3e | 2021-03-03 14:19:38 -0600 | [diff] [blame] | 27 | (void)nor_unlock(PLAT_ARM_FLASH_IMAGE_BASE); |
| 28 | ret = nor_word_program(PLAT_ARM_FLASH_IMAGE_BASE, 0); |
laurenw-arm | 7c7b198 | 2020-10-21 13:34:40 -0500 | [diff] [blame] | 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 | |
| 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 | } |