bootloader_flash.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <esp_err.h>
  8. #include <esp_spi_flash.h> /* including in bootloader for error values */
  9. #include "sdkconfig.h"
  10. #include "soc/soc_caps.h"
  11. #include "bootloader_flash_override.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * @brief Read flash ID by sending RDID command (0x9F)
  17. * @return flash raw ID
  18. * mfg_id = (ID >> 16) & 0xFF;
  19. flash_id = ID & 0xffff;
  20. */
  21. uint32_t bootloader_read_flash_id(void);
  22. #if SOC_CACHE_SUPPORT_WRAP
  23. /**
  24. * @brief Set the burst mode setting command for specified wrap mode.
  25. *
  26. * @param mode The specified warp mode.
  27. * @return always ESP_OK
  28. */
  29. esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode);
  30. #endif
  31. /**
  32. * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation.
  33. *
  34. * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write).
  35. */
  36. esp_err_t bootloader_flash_xmc_startup(void);
  37. /**
  38. * @brief Unlock Flash write protect.
  39. * Please do not call this function in SDK.
  40. *
  41. * @note This can be overridden because it's attribute weak.
  42. */
  43. esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void);
  44. #ifdef __cplusplus
  45. }
  46. #endif