bootloader_flash.h 1.5 KB

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