fvp_r_err.c 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2021, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <errno.h>
  7. #include <common/debug.h>
  8. #include <drivers/arm/sp805.h>
  9. #include <drivers/cfi/v2m_flash.h>
  10. #include <plat/arm/common/plat_arm.h>
  11. #include <platform_def.h>
  12. /*
  13. * FVP_R error handler
  14. */
  15. __dead2 void plat_arm_error_handler(int err)
  16. {
  17. int ret;
  18. switch (err) {
  19. case -ENOENT:
  20. case -EAUTH:
  21. /* Image load or authentication error. Erase the ToC */
  22. INFO("Erasing FIP ToC from flash...\n");
  23. (void)nor_unlock(PLAT_ARM_FLASH_IMAGE_BASE);
  24. ret = nor_word_program(PLAT_ARM_FLASH_IMAGE_BASE, 0);
  25. if (ret != 0) {
  26. ERROR("Cannot erase ToC\n");
  27. } else {
  28. INFO("Done\n");
  29. }
  30. break;
  31. default:
  32. /* Unexpected error */
  33. break;
  34. }
  35. (void)console_flush();
  36. /* Setup the watchdog to reset the system as soon as possible */
  37. sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
  38. while (true) {
  39. wfi();
  40. }
  41. }