boards/risc-v/esp32c3: Remove the flash encryption test.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
Abdelatif Guettouche 2021-10-15 18:43:10 +02:00 committed by Gustavo Henrique Nihei
parent c83c1071cc
commit 55e8b17974
3 changed files with 0 additions and 182 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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 */