tmedicci opened a new pull request, #16152:
URL: https://github.com/apache/nuttx/pull/16152

   ## Summary
   
   * arch/xtensa/esp32s3: Fix bug regarding SPI flash operation mode
   
   SPI flash operation modes - Dual Output (dout), Dual I/O (dio), Quad Output 
(qout), Quad I/O (qio) and Octal (opi) were not being properly selected. This 
PR fixes this behavior and the device is now able to boot and initialize the 
proper SPI flash mode.
   
   ## Impact
   
   Impact on user: YES. It enables faster access to SPI flash partitions and 
may increase general performance.
   
   Impact on build: NO.
   
   Impact on hardware: YES. It properly initializes the selected SPI flash 
operation mode.
   
   Impact on documentation: NO.
   
   Impact on security: NO.
   
   Impact on compatibility: NO.
   
   ## Testing
   
   From `esp32s3-devkit:spiflash`, select one of the following SPI flash 
operation modes: `CONFIG_ESP32S3_FLASH_MODE_DIO`, 
`CONFIG_ESP32S3_FLASH_MODE_DOUT`, `CONFOG_ESP32S3_FLASH_MODE_QIO`, 
`CONFIG_ESP32S3_FLASH_MODE_QOUT` or `CONFIG_ESP32S3_FLASH_MODE_OCT`, build the 
firmware and with `CONFIG_DEBUG_FEATURES` and check the boot log. 
   
   ### Building
   
   For instance, for quad SPI flash with QIO mode:
   
   ```
   make -j distclean && ./tools/configure.sh esp32s3-devkit:spiflash && 
kconfig-tweak -d ESP32S3_FLASH_MODE_DIO && kconfig-tweak -e 
ESP32S3_FLASH_MODE_QIO && kconfig-tweak -e DEBUG_FEATURES && make olddefconfig 
&& ESP_HAL_3RDPARTY_URL="g...@github.com:tmedicci/esp-hal-3rdparty.git" make 
flash ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom -D /dev/ttyUSB0
   ```
   
   For a board with a OCTAL SPI flash chip:
   
   ```
   make -j distclean && ./tools/configure.sh esp32s3-devkit:spiflash && 
kconfig-tweak -d ESP32S3_FLASH_MODE_DIO && kconfig-tweak -e 
ESP32S3_FLASH_MODE_OCT && kconfig-tweak -e DEBUG_FEATURES && kconfig-tweak -d 
ESP32S3_SPIFLASH_SMARTFS && kconfig-tweak --set-val 
ESP32S3_SPIFLASH_MTD_BLKSIZE 4096 && kconfig-tweak -e BENCHMARK_MTD && make 
olddefconfig && 
ESP_HAL_3RDPARTY_URL="g...@github.com:tmedicci/esp-hal-3rdparty.git" make flash 
ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom -D /dev/ttyUSB0
   ```
   
   Please note that the easiest way to check if the OCTAL spi flash mode is 
enabled is by using the [MTD's test/benchmark 
app](https://github.com/apache/nuttx-apps/pull/3033).
   
   ### Running
   
   Just press the reset button and check the boot log.
   
   ### Results
   
   For the quad SPI flash and QIO mode:
   
   ```
   ESP-ROM:esp32s3-20210327
   Build:Mar 27 2021
   rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
   SPIWP:0xee
   mode:DIO, clock div:2
   load:0x3fc8c5f0,len:0x173c
   load:0x40374000,len:0x626c
   SHA-256 comparison failed:
   Calculated: 803af3c5edb01971d3a279f9821cc5db72e6b17767e165eeb6b6fd4b518a847a
   Expected: 0000000010860000000000000000000000000000000000000000000000000000
   Attempting to boot anyway...
   entry 0x40374fcc
   *** Booting NuttX ***
   I (56) boot: chip revision: v0.1
   I (56) qio_mode: Enabling default flash chip QIO
   I (56) boot.esp32s3: Boot SPI Speed : 40MHz
   I (61) boot.esp32s3: SPI Mode       : QIO
   I (65) boot.esp32s3: SPI Flash Size : 8MB
   ```
   
   For the octal SPI flash and OPI mode:
   
   ```
   ESP-ROM:esp32s3-20210327
   Build:Mar 27 2021
   rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
   SPIWP:0xee
   Octal Flash Mode Enabled
   For OPI Flash, Use Default Flash Boot Mode
   mode:SLOW_RD, clock div:2
   load:0x3fc8c5f0,len:0x1590
   load:0x40374000,len:0x62d4
   SHA-256 comparison failed:
   Calculated: bf33eaea05bf58b87e908da85afde73c46510e44ba95b66730dac33f0c1b5ce9
   Expected: 0000000060870000000000000000000000000000000000000000000000000000
   Attempting to boot anyway...
   entry 0x40374fe0
   *** Booting NuttX ***
   I (74) boot: chip revision: v0.1
   I (74) boot.esp32s3: Boot SPI Speed : 40MHz
   I (74) boot.esp32s3: SPI Mode       : SLOW READ
   I (78) boot.esp32s3: SPI Flash Size : 32MB
   I (83) boot: Enabling RNG early entropy source...
   dram: lma 0x00000020 vma 0x3fc8c5f0 len 0x1590   (5520)
   iram: lma 0x000015b8 vma 0x40374000 len 0x62d4   (25300)
   padd: lma 0x00007898 vma 0x00000000 len 0x8760   (34656)
   imap: lma 0x00010000 vma 0x42010000 len 0x16bc4  (93124)
   padd: lma 0x00026bcc vma 0x00000000 len 0x942c   (37932)
   dmap: lma 0x00030000 vma 0x3c040000 len 0x30a8   (12456)
   total segments stored 6
   AB
   NuttShell (NSH) NuttX-10.4.0
   nsh> mtd /dev/mtdblock0
   FLASH device parameters:
      Sector size:        4096
      Sector count:        256
      Erase block:        1000
      Total size:      1048576
   
   Starting write operation...
   
   Write operation completed in 5.58 seconds
   Total bytes written: 1048576
   Transfer rate [write]: 183.51 KiB/s
   
   Starting read operation...
   
   Read operation completed in 0.11 seconds
   Total bytes read: 1048576
   Transfer rate [read]: 9309.09 KiB/s
   
   Data verification successful: read data matches written data
   nsh>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to