bootloader_flash.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include <esp_err.h>
  15. #include <esp_spi_flash.h> /* including in bootloader for error values */
  16. #include "sdkconfig.h"
  17. #include "soc/soc_caps.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Read flash ID by sending RDID command (0x9F)
  23. * @return flash raw ID
  24. * mfg_id = (ID >> 16) & 0xFF;
  25. flash_id = ID & 0xffff;
  26. */
  27. uint32_t bootloader_read_flash_id(void);
  28. #if SOC_CACHE_SUPPORT_WRAP
  29. /**
  30. * @brief Set the burst mode setting command for specified wrap mode.
  31. *
  32. * @param mode The specified warp mode.
  33. * @return always ESP_OK
  34. */
  35. esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode);
  36. #endif
  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 bootloader_flash_unlock(void);
  44. /**
  45. * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation.
  46. *
  47. * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write).
  48. */
  49. esp_err_t bootloader_flash_xmc_startup(void);
  50. #ifdef __cplusplus
  51. }
  52. #endif