bootloader_flash_config.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "sdkconfig.h"
  8. #include "esp_image_format.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /**
  13. * @brief Update the flash id in g_rom_flashchip(global esp_rom_spiflash_chip_t structure).
  14. *
  15. * @return None
  16. */
  17. void bootloader_flash_update_id(void);
  18. /**
  19. * @brief Update the flash size in g_rom_flashchip (global esp_rom_spiflash_chip_t structure).
  20. *
  21. * @param size The size to store, in bytes.
  22. * @return None
  23. */
  24. void bootloader_flash_update_size(uint32_t size);
  25. /**
  26. * @brief Set the flash CS setup and hold time.
  27. *
  28. * @note CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
  29. * cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1.
  30. *
  31. * @return None
  32. */
  33. void bootloader_flash_cs_timing_config(void);
  34. /**
  35. * @brief Configure SPI flash clock.
  36. *
  37. * @note This function only set clock frequency for SPI0.
  38. *
  39. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  40. *
  41. * @return None
  42. */
  43. void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
  44. /**
  45. * @brief Configure SPI flash gpio, include the IO matrix and drive strength configuration.
  46. *
  47. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  48. *
  49. * @return None
  50. */
  51. void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
  52. #ifdef CONFIG_IDF_TARGET_ESP32
  53. /**
  54. * @brief Configure SPI flash read dummy based on different mode and frequency.
  55. *
  56. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  57. *
  58. * @return None
  59. */
  60. void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
  61. #else
  62. // The meaning has changed on this chip. Deprecated, Call `bootloader_configure_spi_pins()` and `bootloader_flash_set_dummy_out()` directly.
  63. void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr) __attribute__((deprecated));
  64. #endif
  65. #ifdef CONFIG_IDF_TARGET_ESP32
  66. /**
  67. * @brief Return the pin number used for custom SPI flash and/or SPIRAM WP pin
  68. *
  69. * Can be determined by eFuse values in most cases, or overriden in configuration
  70. *
  71. * This value is only meaningful if the other SPI flash pins are overriden via eFuse.
  72. *
  73. * This value is only meaningful if flash is set to QIO or QOUT mode, or if
  74. * SPIRAM is enabled.
  75. *
  76. * @return Pin number to use, or -1 if the default should be kept
  77. */
  78. int bootloader_flash_get_wp_pin(void);
  79. #endif
  80. #ifdef __cplusplus
  81. }
  82. #endif