flash_psram_config.rst 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. SPI Flash and External SPI RAM Configuration
  2. ============================================
  3. This page is a guide for configuring SPI Flash and external SPI RAM. Supported frequency and mode combination, error handling are also elaborated.
  4. Terminology
  5. -----------
  6. ============= ===========================
  7. Term Definition
  8. ============= ===========================
  9. **SPI** Serial Peripheral Interface
  10. **MSPI** Memory SPI Peripheral, SPI Peripheral dedicated for memory
  11. **SDR** Single Data Rate
  12. **DDR** Double Data Rate
  13. **line mode** Number of signals used to transfer data in the data phase of SPI transactions. e.g., for 4-bit-mode, the speed of the data phase would be 4 bit per clock cycle.
  14. **FxRx** F stands for Flash, R stands for PSRAM, x stands for line mode. e.g. F4R4 stands for an {IDF_TARGET_NAME} with Quad Flash and Quad PSRAM
  15. ============= ===========================
  16. .. note::
  17. On {IDF_TARGET_NAME}, MSPI stands for the SPI0/1. SPI0 and SPI1 share a common SPI bus. The main Flash and PSRAM are connected to the MSPI peripheral. CPU accesses them via Cache.
  18. .. _flash-psram-configuration:
  19. How to configure Flash and PSRAM
  20. --------------------------------
  21. ``idf.py menuconfig`` is used to open the configuration menu.
  22. Configure the Flash
  23. ^^^^^^^^^^^^^^^^^^^
  24. The Flash related configurations are under ``Serial flasher config`` menu.
  25. 1. Flash type used on the board. For Octal Flash, select :ref:`CONFIG_ESPTOOLPY_OCT_FLASH`. For Quad Flash, uncheck this configuration.
  26. 2. Flash line mode. Select a line mode in :ref:`CONFIG_ESPTOOLPY_FLASHMODE`. The higher the line mode is, the faster the SPI speed is. See terminology above about the line mode.
  27. 3. Flash sample mode. Select a sample mode in :ref:`CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE`. DDR mode is faster than SDR mode. See terminology above about SDR and DDR mode.
  28. 4. Flash speed. Select a Flash frequency in :ref:`CONFIG_ESPTOOLPY_FLASHFREQ`.
  29. 5. Flash size. Flash size, in megabytes. Select a Flash size in :ref:`CONFIG_ESPTOOLPY_FLASHSIZE`.
  30. Configure the PSRAM
  31. ^^^^^^^^^^^^^^^^^^^
  32. To enable PSRAM, please enable the :ref:`CONFIG_SPIRAM` under ``Component config / Hardware Settings`` menu. Then all the PSRAM related configurations will be visible under ``SPI RAM config`` menu.
  33. 1. PSRAM type used on the board. Select a type in :ref:`CONFIG_SPIRAM_MODE` for Quad or Octal PSRAM.
  34. 2. PSRAM speed. Select a PSRAM frequency in :ref:`CONFIG_SPIRAM_SPEED`.
  35. .. note::
  36. Configuration 1 of Flash and PSRAM should be selected according to your actual hardware.
  37. For the reset of the above configurations:
  38. - Flash and PSRAM share the same internal clock.
  39. - Quad Flash only supports STR mode. Octal Flash may support either/both STR/DTR modes under OPI mode, depending on the flash model and the vendor.
  40. - Quad PSRAM only supports STR mode, while Octal PSRAM only supports DTR mode.
  41. Therefore, some limitations should be noticed when configuring configuration 2, 3 and 4 of Flash, and configuration 2 of PSRAM. Please refer to :ref:`All Supported Modes and Speeds <flash-psram-combination>`
  42. .. note::
  43. If a board with Octal Flash resets before the second-stage bootloader, please refer to :ref:`Error Handling Chapter <flash-psram-error>`
  44. .. _flash-psram-combination:
  45. All Supported Modes and Speeds
  46. ------------------------------
  47. .. note::
  48. For MSPI DDR mode, the data are sampled on both the positive edge and the negative edge. e.g.: if a Flash is set to 80 MHz and DDR mode, then the final speed of the Flash is 160 MHz. This is faster than the Flash setting to 120 Mhz and STR mode.
  49. F8R8 Hardware
  50. ^^^^^^^^^^^^^
  51. ======= =============== ======= ============
  52. Group Flash mode Group PSRAM mode
  53. ======= =============== ======= ============
  54. A 120 MHz SDR A N.A.
  55. B 80 MHz DDR B 80 MHz DDR
  56. C 80 MHz SDR C 40 MHz DDR
  57. C 40 MHz DDR C
  58. C < 40 MHz C
  59. D D disable
  60. ======= =============== ======= ============
  61. 1. Flash mode in group A works with PSRAM mode in group A/D
  62. 2. Flash mode in group B/C works with PSRAM mode in group B/C/D
  63. F4R8 Hardware
  64. ^^^^^^^^^^^^^
  65. ======= =============== ======= ============
  66. Group Flash mode Group PSRAM mode
  67. ======= =============== ======= ============
  68. A 120 MHz SDR A N.A.
  69. B 80 MHz SDR B 80MHz DDR
  70. C 40 MHz SDR C 40MHz DDR
  71. C 20 MHz SDR C
  72. D D disable
  73. ======= =============== ======= ============
  74. 1. Flash mode in group A works with PSRAM mode in group A/D
  75. 2. Flash mode in group B/C works with PSRAM mode in group B/C/D
  76. F4R4 Hardware
  77. ^^^^^^^^^^^^^
  78. ====== =============== ====== ============
  79. Type Flash Type PSRAM
  80. ====== =============== ====== ============
  81. A 120 MHz A 120MHz
  82. B 80 MHz B 80MHz
  83. C 40 MHz C 40MHz
  84. C 20 MHz C
  85. D D disable
  86. ====== =============== ====== ============
  87. 1. Flash in A works with PSRAM in A/C/D
  88. 2. Flash in B works with PSRAM in B/C/D
  89. 3. Flash in C works with PSRAM in A/B/C/D
  90. .. _flash-psram-error:
  91. Error handling
  92. --------------
  93. 1. If a board with Octal Flash resets before the second-stage bootloader:
  94. .. code-block:: c
  95. ESP-ROM:esp32s3-20210327
  96. Build:Mar 27 2021
  97. rst:0x7 (TG0WDT_SYS_RST),boot:0x18 (SPI_FAST_FLASH_BOOT)
  98. Saved PC:0x400454d5
  99. SPIWP:0xee
  100. mode:DOUT, clock div:1
  101. load:0x3fcd0108,len:0x171c
  102. ets_loader.c 78
  103. it may mean that the necessary efuses are not correctly burnt. please check the eFuse bits of the chip using command ``espefuse.py summary``.
  104. The 1st bootloader relies on an eFuse bit ``FLASH_TYPE`` to reset the Flash into the default mode (SPI mode). If this bit is not burnt and the flash is working in OPI mode, 1st bootloader may not be able to read from the flash and load the following images.
  105. Run this command to burn the eFuse bit:
  106. .. code-block:: python
  107. python3 ./espefuse.py -p /dev/<serial_device> --do-not-confirm burn_efuse FLASH_TYPE 1
  108. .. note::
  109. This step is irreversible. Please do check if your hardware is actually using an Octal Flash.