bootloader_flash_config.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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();
  26. /**
  27. * @brief Set the flash CS setup and hold time.
  28. *
  29. * @note CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
  30. * cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1.
  31. *
  32. * @return None
  33. */
  34. void bootloader_flash_cs_timing_config();
  35. /**
  36. * @brief Configure SPI flash clock.
  37. *
  38. * @note This function only set clock frequency for SPI0.
  39. *
  40. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  41. *
  42. * @return None
  43. */
  44. void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
  45. /**
  46. * @brief Configure SPI flash gpio, include the IO matrix and drive strength configuration.
  47. *
  48. * @param pfhdr Pointer to App image header, from where to fetch flash settings.
  49. *
  50. * @return None
  51. */
  52. void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
  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. /**
  62. * @brief Return the pin number used for custom SPI flash and/or SPIRAM WP pin
  63. *
  64. * Can be determined by eFuse values in most cases, or overriden in configuration
  65. *
  66. * This value is only meaningful if the other SPI flash pins are overriden via eFuse.
  67. *
  68. * This value is only meaningful if flash is set to QIO or QOUT mode, or if
  69. * SPIRAM is enabled.
  70. *
  71. * @return Pin number to use, or -1 if the default should be kept
  72. */
  73. int bootloader_flash_get_wp_pin(void);
  74. #ifdef __cplusplus
  75. }
  76. #endif