diff --git a/boards/xtensa/esp32/common/Kconfig b/boards/xtensa/esp32/common/Kconfig index 944e54cbf8..88ae2f03c6 100644 --- a/boards/xtensa/esp32/common/Kconfig +++ b/boards/xtensa/esp32/common/Kconfig @@ -40,22 +40,6 @@ choice ESP32_SPIFLASH_FS endchoice -config ESP32_SPIFLASH_ENCRYPTION_TEST - bool "SPI Flash encryption test" - default n - depends on ESP32_SPIFLASH - select DEBUG_ASSERTIONS - ---help--- - Enable SPI Flash encryption test. This option will also select - DEBUG_ASSERTIONS to enable kernel assert macro. - -config ESP32_SPIFLASH_TEST_ADDRESS - hex "SPI Flash test address" - default 0x180000 - depends on ESP32_SPIFLASH_ENCRYPTION_TEST - ---help--- - SPI Flash encryption test read/write address. - config ESP32_LCD_OVERCLOCK bool "Run LCD at higher clock speed than allowed" default n diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h b/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h index 6ed828ef0c..bd419ce909 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h @@ -110,24 +110,6 @@ int esp32_mmcsd_initialize(int minor); int esp32_spiflash_init(void); -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST -void esp32_spiflash_encrypt_test(void); -#endif - /**************************************************************************** * Name: esp32_gpio_init ****************************************************************************/ diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c index 106df62a4f..1b88bbc31e 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c @@ -196,11 +196,6 @@ int esp32_bringup(void) #endif #ifdef CONFIG_ESP32_SPIFLASH - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - esp32_spiflash_encrypt_test(); -#endif - ret = esp32_spiflash_init(); if (ret) { diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c index 922322deb2..43ee3a587f 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c @@ -515,165 +515,3 @@ int esp32_spiflash_init(void) return ret; } - -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - -void esp32_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 = esp32_spiflash_get_mtd(); - struct mtd_dev_s *enc_mtd = esp32_spiflash_encrypt_get_mtd(); - const uint32_t address = CONFIG_ESP32_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 ret = %d\n", ret); - DEBUGASSERT(0); - } - - wbuf = kmm_malloc(size); - if (!wbuf) - { - ferr("ERROR: Failed to alloc %d heap\n", size); - DEBUGASSERT(0); - } - - rbuf = kmm_malloc(size); - if (!rbuf) - { - ferr("ERROR: Failed to alloc %d 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 ret=%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 ret=%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 ret=%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 ret=%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 ret=%d\n", ret); - DEBUGASSERT(0); - } - - ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf); - if (ret != rw_nblocks) - { - ferr("ERROR: Failed to write ret=%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 ret=%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 ret=%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: ESP32 SPI Flash encryption test successfully\n"); -} - -#endif /* CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST */ diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h index 83107c3b0c..1e72116c5b 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h @@ -99,23 +99,5 @@ int esp32_mmcsd_initialize(int minor); int esp32_spiflash_init(void); -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST -void esp32_spiflash_encrypt_test(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_XTENSA_ESP32_ESP32_ETHERNETKIT_SRC_ESP32_ETHERNETKIT_H */ diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c index f09919f0b8..7dc5b632d1 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c @@ -141,11 +141,6 @@ int esp32_bringup(void) #endif #ifdef CONFIG_ESP32_SPIFLASH - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - esp32_spiflash_encrypt_test(); -#endif - ret = esp32_spiflash_init(); if (ret) { diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c index e0bcc7a03f..0b720c4444 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c @@ -515,165 +515,3 @@ int esp32_spiflash_init(void) return ret; } - -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - -void esp32_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 = esp32_spiflash_get_mtd(); - struct mtd_dev_s *enc_mtd = esp32_spiflash_encrypt_get_mtd(); - const uint32_t address = CONFIG_ESP32_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 ret = %d\n", ret); - DEBUGASSERT(0); - } - - wbuf = kmm_malloc(size); - if (!wbuf) - { - ferr("ERROR: Failed to alloc %d heap\n", size); - DEBUGASSERT(0); - } - - rbuf = kmm_malloc(size); - if (!rbuf) - { - ferr("ERROR: Failed to alloc %d 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 ret=%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 ret=%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 ret=%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 ret=%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 ret=%d\n", ret); - DEBUGASSERT(0); - } - - ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf); - if (ret != rw_nblocks) - { - ferr("ERROR: Failed to write ret=%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 ret=%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 ret=%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: ESP32 SPI Flash encryption test successfully\n"); -} - -#endif /* CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST */ diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32-wrover-kit.h b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32-wrover-kit.h index 6d54a5c6ad..1b9c715f47 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32-wrover-kit.h +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32-wrover-kit.h @@ -106,24 +106,6 @@ int esp32_mmcsd_initialize(int minor); int esp32_spiflash_init(void); -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST -void esp32_spiflash_encrypt_test(void); -#endif - /**************************************************************************** * Name: esp32_gpio_init ****************************************************************************/ diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c index af7871d7a2..ce0740c4fa 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c @@ -175,11 +175,6 @@ int esp32_bringup(void) #endif #ifdef CONFIG_ESP32_SPIFLASH - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - esp32_spiflash_encrypt_test(); -#endif - ret = esp32_spiflash_init(); if (ret) { diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c index 4443d123b6..0180445a3e 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c @@ -515,165 +515,3 @@ int esp32_spiflash_init(void) return ret; } - -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - -void esp32_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 = esp32_spiflash_get_mtd(); - struct mtd_dev_s *enc_mtd = esp32_spiflash_encrypt_get_mtd(); - const uint32_t address = CONFIG_ESP32_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 ret = %d\n", ret); - DEBUGASSERT(0); - } - - wbuf = kmm_malloc(size); - if (!wbuf) - { - ferr("ERROR: Failed to alloc %d heap\n", size); - DEBUGASSERT(0); - } - - rbuf = kmm_malloc(size); - if (!rbuf) - { - ferr("ERROR: Failed to alloc %d 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 ret=%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 ret=%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 ret=%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 ret=%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 ret=%d\n", ret); - DEBUGASSERT(0); - } - - ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf); - if (ret != rw_nblocks) - { - ferr("ERROR: Failed to write ret=%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 ret=%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 ret=%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: ESP32 SPI Flash encryption test successfully\n"); -} - -#endif /* CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST */ diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c index 701f611290..dda9f9917f 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c @@ -165,11 +165,6 @@ int esp32_bringup(void) #endif #ifdef CONFIG_ESP32_SPIFLASH - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - esp32_spiflash_encrypt_test(); -#endif - ret = esp32_spiflash_init(); if (ret) { diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_spiflash.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_spiflash.c index f4a623af31..7c7468fa24 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_spiflash.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_spiflash.c @@ -206,165 +206,3 @@ int esp32_spiflash_init(void) return ret; } - -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - -void esp32_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 = esp32_spiflash_get_mtd(); - struct mtd_dev_s *enc_mtd = esp32_spiflash_encrypt_get_mtd(); - const uint32_t address = CONFIG_ESP32_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 ret = %d\n", ret); - DEBUGASSERT(0); - } - - wbuf = kmm_malloc(size); - if (!wbuf) - { - ferr("ERROR: Failed to alloc %d heap\n", size); - DEBUGASSERT(0); - } - - rbuf = kmm_malloc(size); - if (!rbuf) - { - ferr("ERROR: Failed to alloc %d 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 ret=%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 ret=%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 ret=%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 ret=%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 ret=%d\n", ret); - DEBUGASSERT(0); - } - - ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf); - if (ret != rw_nblocks) - { - ferr("ERROR: Failed to write ret=%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 ret=%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 ret=%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: ESP32 SPI Flash encryption test successfully\n"); -} - -#endif /* CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST */ diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/ttgo_lora_esp32.h b/boards/xtensa/esp32/ttgo_lora_esp32/src/ttgo_lora_esp32.h index 46627e227f..1638fc1e2b 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/ttgo_lora_esp32.h +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/ttgo_lora_esp32.h @@ -121,24 +121,6 @@ int esp32_mmcsd_initialize(int minor); int esp32_spiflash_init(void); -/**************************************************************************** - * Name: esp32_spiflash_encrypt_test - * - * Description: - * Test ESP32 SPI Flash driver read/write with encryption. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST -void esp32_spiflash_encrypt_test(void); -#endif - /**************************************************************************** * Name: esp32_gpio_init ****************************************************************************/