You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "cwespressif (via GitHub)" <gi...@apache.org> on 2023/12/07 09:22:30 UTC

[PR] xtensa/esp32s3: Tasks use SPIRAM as stack can do SPI flash read/write/erase/map/unmap [nuttx]

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

   ## Summary
   
   Tasks use PSRAM as stack can do SPI flash read/write/erase/map/unmap.
   
   The root cause is as following:
   
   1. When operating SPI flash, cache is also disable, then software can't access PSRAM by data cache.
   2. SPI flash read/write/erase functions have instruction like stack-pop and stack-push which may use stack buffer which is PSRAM space or load/store temp variables which locate in PSRAM space too.
   3. Once operation in step 2 triggers, CPU will trigger exception.
   
   So related SPI flash functions should be sent and run in tasks which use SRAM as task stack.
   
   ## Impact
   
   ## Testing
   
   


-- 
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-unsubscribe@nuttx.apache.org

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


Re: [PR] xtensa/esp32s3: Tasks use SPIRAM as stack can do SPI flash read/write/erase/map/unmap [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11340:
URL: https://github.com/apache/nuttx/pull/11340#discussion_r1418880475


##########
arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c:
##########
@@ -194,9 +367,20 @@ static int esp32s3_erase(struct mtd_dev_s *dev, off_t startblock,
       return ret;
     }
 
+#ifdef CONFIG_ESP32S3_SPI_FLASH_SUPPORT_PSRAM_STACK
+  if (stack_is_psram())
+    {
+      ret = esp32s3_async_op(SPIFLASH_OP_CODE_ERASE, offset, NULL, nbytes);
+    }
+  else
+    {
+      ret = spi_flash_erase_range(offset, nbytes);
+    }
+#else
   ret = spi_flash_erase_range(offset, nbytes);

Review Comment:
   let's change ALL to:
   ```
   #ifdef CONFIG_ESP32S3_SPI_FLASH_SUPPORT_PSRAM_STACK
     if (stack_is_psram())
       {
         ret = esp32s3_async_op(SPIFLASH_OP_CODE_ERASE, offset, NULL, nbytes);
       }
     else
   #endif
       {
         ret = spi_flash_erase_range(offset, nbytes);
       }
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


Re: [PR] xtensa/esp32s3: Tasks use SPIRAM as stack can do SPI flash read/write/erase/map/unmap [nuttx]

Posted by "cwespressif (via GitHub)" <gi...@apache.org>.
cwespressif commented on code in PR #11340:
URL: https://github.com/apache/nuttx/pull/11340#discussion_r1424811783


##########
arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c:
##########
@@ -194,9 +367,20 @@ static int esp32s3_erase(struct mtd_dev_s *dev, off_t startblock,
       return ret;
     }
 
+#ifdef CONFIG_ESP32S3_SPI_FLASH_SUPPORT_PSRAM_STACK
+  if (stack_is_psram())
+    {
+      ret = esp32s3_async_op(SPIFLASH_OP_CODE_ERASE, offset, NULL, nbytes);
+    }
+  else
+    {
+      ret = spi_flash_erase_range(offset, nbytes);
+    }
+#else
   ret = spi_flash_erase_range(offset, nbytes);

Review Comment:
   Done



-- 
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-unsubscribe@nuttx.apache.org

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


Re: [PR] xtensa/esp32s3: Tasks use SPIRAM as stack can do SPI flash read/write/erase/map/unmap [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #11340:
URL: https://github.com/apache/nuttx/pull/11340


-- 
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-unsubscribe@nuttx.apache.org

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