bootloader_flash_config.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2018 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. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "sdkconfig.h"
  16. #include "esp_image_format.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * @brief Update the flash id in g_rom_flashchip(global esp_rom_spiflash_chip_t structure).
  22. *
  23. * @return None
  24. */
  25. void bootloader_flash_update_id(void);
  26. /**
  27. * @brief Update the flash size in g_rom_flashchip (global esp_rom_spiflash_chip_t structure).
  28. *
  29. * @param size The size to store, in bytes.
  30. * @return None
  31. */
  32. void bootloader_flash_update_size(uint32_t size);
  33. /**
  34. * @brief Set the flash CS setup and hold time.
  35. *
  36. * @note CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
  37. * cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1.
  38. *
  39. * @return None
  40. */
  41. void bootloader_flash_cs_timing_config(void);
  42. /**
  43. * @brief Configure SPI flash clock.
  44. *
  45. * @note This function only set clock frequency for SPI0.
  46. *
  47. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  48. *
  49. * @return None
  50. */
  51. void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
  52. /**
  53. * @brief Configure SPI flash gpio, include the IO matrix and drive strength configuration.
  54. *
  55. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  56. *
  57. * @return None
  58. */
  59. void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
  60. /**
  61. * @brief Configure SPI flash read dummy based on different mode and frequency.
  62. *
  63. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  64. *
  65. * @return None
  66. */
  67. void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
  68. #ifdef CONFIG_IDF_TARGET_ESP32
  69. /**
  70. * @brief Return the pin number used for custom SPI flash and/or SPIRAM WP pin
  71. *
  72. * Can be determined by eFuse values in most cases, or overriden in configuration
  73. *
  74. * This value is only meaningful if the other SPI flash pins are overriden via eFuse.
  75. *
  76. * This value is only meaningful if flash is set to QIO or QOUT mode, or if
  77. * SPIRAM is enabled.
  78. *
  79. * @return Pin number to use, or -1 if the default should be kept
  80. */
  81. int bootloader_flash_get_wp_pin(void);
  82. #endif
  83. #ifdef __cplusplus
  84. }
  85. #endif