This is an automated email from the ASF dual-hosted git repository. archer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new cb980cc977 arch/esp32s3_partition: Read data from SPI Flash at designated address (with decryption) cb980cc977 is described below commit cb980cc9776f865b88268936a3a1d1fc525eddac Author: nuttxs <zhaoqing.zh...@sony.com> AuthorDate: Wed Jan 8 19:14:47 2025 +0800 arch/esp32s3_partition: Read data from SPI Flash at designated address (with decryption) --- arch/xtensa/src/esp32s3/esp32s3_partition.c | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/xtensa/src/esp32s3/esp32s3_partition.c b/arch/xtensa/src/esp32s3/esp32s3_partition.c index 93d949b9d6..950aed6ae0 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_partition.c +++ b/arch/xtensa/src/esp32s3/esp32s3_partition.c @@ -934,6 +934,54 @@ int esp32s3_partition_read(const char *label, size_t offset, void *buf, return OK; } +/**************************************************************************** + * Name: esp32s3_partition_read_decrypt + * + * Description: + * Read data from SPI Flash at designated address (with decryption) + * + * Input Parameters: + * label - Partition label + * offset - Offset in SPI Flash + * buf - Data buffer pointer + * size - Data number + * + * Returned Value: + * 0 if success or a negative value if fail. + * + ****************************************************************************/ + +int esp32s3_partition_read_decrypt(const char *label, size_t offset, + void *buf, size_t size) +{ + int ret; + int partion_offset; + DEBUGASSERT(label != NULL && buf != NULL); + struct mtd_dev_s *mtd = esp32s3_spiflash_encrypt_mtd(); + if (!mtd) + { + ferr("ERROR: Failed to get SPI flash MTD\n"); + return -ENOSYS; + } + + partion_offset = partition_get_offset(label, strlen(label)); + if (partion_offset < 0) + { + ferr("ERROR: Failed to get partition: %s offset\n", label); + return partion_offset; + } + + ret = MTD_READ(mtd, partion_offset + offset, + size, (uint8_t *)buf); + if (ret != size) + { + ferr("ERROR: Failed to get read data from MTD\n"); + return -EIO; + } + + return OK; +} + /**************************************************************************** * Name: esp32s3_partition_write *