This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 55e8b17974fd6608a14a091599a9f64db5baa10e
Author: Abdelatif Guettouche <abdelatif.guettou...@espressif.com>
AuthorDate: Fri Oct 15 18:43:10 2021 +0200

    boards/risc-v/esp32c3: Remove the flash encryption test.
    
    Signed-off-by: Abdelatif Guettouche <abdelatif.guettou...@espressif.com>
---
 boards/risc-v/esp32c3/esp32c3-devkit/Kconfig       |  16 --
 .../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c   |   5 -
 .../esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c  | 161 ---------------------
 3 files changed, 182 deletions(-)

diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig 
b/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
index 4fb1a55..218697c 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
@@ -78,22 +78,6 @@ config ESP32C3_SPIFLASH_FS_MOUNT_PT
        depends on ESP32C3_SPIFLASH_LITTLEFS
        default "/data"
 
-config ESP32C3_SPIFLASH_ENCRYPTION_TEST
-       bool "SPI Flash encryption test"
-       default n
-       depends on ESP32C3_SPIFLASH
-       select DEBUG_ASSERTIONS
-       ---help---
-               Enable SPI Flash encryption test. This option will also select
-               DEBUG_ASSERTIONS to enable kernel assert macro.
-
-config ESP32C3_SPIFLASH_TEST_ADDRESS
-       hex "SPI Flash test address"
-       default 0x180000
-       depends on ESP32C3_SPIFLASH_ENCRYPTION_TEST
-       ---help---
-               SPI Flash encryption test read/write address.
-
 if LCD_ST7735 || LCD_ST7789 || LCD_GC9A01
 
 config ESP32C3_LCD_RSTPIN
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c 
b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
index 692a44d..fc0de5a 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
@@ -148,11 +148,6 @@ int esp32c3_bringup(void)
 #endif
 
 #ifdef CONFIG_ESP32C3_SPIFLASH
-
-#  ifdef CONFIG_ESP32C3_SPIFLASH_ENCRYPTION_TEST
-  esp32c3_spiflash_encrypt_test();
-#  endif
-
   ret = esp32c3_spiflash_init();
   if (ret)
     {
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c 
b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c
index cef2237..bc00a5c 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c
@@ -532,164 +532,3 @@ int esp32c3_spiflash_init(void)
   return ret;
 }
 
-/****************************************************************************
- * Name: esp32c3_spiflash_encrypt_test
- *
- * Description:
- *   Test ESP32-C3 SPI Flash driver read/write with encryption.
- *
- * Input Parameters:
- *   None
- *
- * Returned Value:
- *   None.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_ESP32C3_SPIFLASH_ENCRYPTION_TEST
-
-void esp32c3_spiflash_encrypt_test(void)
-{
-  int i;
-  int ret;
-  uint8_t *wbuf;
-  uint8_t *rbuf;
-  struct mtd_geometry_s geo;
-  uint32_t erase_block;
-  uint32_t erase_nblocks;
-  uint32_t rw_block;
-  uint32_t rw_nblocks;
-  struct mtd_dev_s *mtd = esp32c3_spiflash_mtd();
-  struct mtd_dev_s *enc_mtd = esp32c3_spiflash_encrypt_mtd();
-  const uint32_t address = CONFIG_ESP32C3_SPIFLASH_TEST_ADDRESS;
-  const uint32_t size = 4096;
-
-  ret = MTD_IOCTL(enc_mtd, MTDIOC_GEOMETRY,
-                  (unsigned long)(uintptr_t)&geo);
-  if (ret < 0)
-    {
-      ferr("ERROR: Failed to get GEO errno =%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  wbuf = kmm_malloc(size);
-  if (!wbuf)
-    {
-      ferr("ERROR: Failed to alloc %" PRIu32 " heap\n", size);
-      DEBUGASSERT(0);
-    }
-
-  rbuf = kmm_malloc(size);
-  if (!rbuf)
-    {
-      ferr("ERROR: Failed to alloc %" PRIu32 " heap\n", size);
-      DEBUGASSERT(0);
-    }
-
-  for (i = 0; i < size; i++)
-    {
-      wbuf[i] = (uint8_t)random();
-    }
-
-  erase_block = address / geo.erasesize;
-  erase_nblocks = size / geo.erasesize;
-
-  rw_block = address / geo.blocksize;
-  rw_nblocks = size / geo.blocksize;
-
-  ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
-  if (ret != erase_nblocks)
-    {
-      ferr("ERROR: Failed to erase block errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  ret = MTD_BWRITE(enc_mtd, rw_block, rw_nblocks, wbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to encrypt write errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  memset(rbuf, 0, size);
-  ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  if (memcmp(wbuf, rbuf, size))
-    {
-      ferr("ASSERT: Encrypted and decrypted data is not same\n");
-      DEBUGASSERT(0);
-    }
-
-  memset(rbuf, 0, size);
-  ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  if (!memcmp(wbuf, rbuf, size))
-    {
-      ferr("ASSERT: Encrypted and normal data is same\n");
-      DEBUGASSERT(0);
-    }
-
-  for (i = 0; i < size; i++)
-    {
-      wbuf[i] = (uint8_t)random();
-    }
-
-  ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
-  if (ret != erase_nblocks)
-    {
-      ferr("ERROR: Failed to erase errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to write errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  memset(rbuf, 0, size);
-  ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  if (!memcmp(wbuf, rbuf, size))
-    {
-      ferr("ASSERT: Normal and decrypted data is same\n");
-      DEBUGASSERT(0);
-    }
-
-  memset(rbuf, 0, size);
-  ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
-  if (ret != rw_nblocks)
-    {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
-      DEBUGASSERT(0);
-    }
-
-  if (memcmp(wbuf, rbuf, size))
-    {
-      ferr("ASSERT: Normal and normal data is not same\n");
-      DEBUGASSERT(0);
-    }
-
-  kmm_free(wbuf);
-  kmm_free(rbuf);
-
-  finfo("INFO: SPI Flash encryption test success\n");
-}
-
-#endif /* CONFIG_ESP32C3_SPIFLASH_ENCRYPTION_TEST */

Reply via email to