mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
arch/esp32_partition: read data from SPI Flash at designated
address (with decryption) Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
This commit is contained in:
@@ -55,4 +55,24 @@ enum ota_img_bootseq
|
|||||||
OTA_IMG_BOOT_SEQ_MAX
|
OTA_IMG_BOOT_SEQ_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32_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 esp32_partition_read_decrypt(const char *label, size_t offset,
|
||||||
|
void *buf, size_t size);
|
||||||
|
|
||||||
#endif /* __ARCH_XTENSA_INCLUDE_ESP32_PARTITION_H */
|
#endif /* __ARCH_XTENSA_INCLUDE_ESP32_PARTITION_H */
|
||||||
|
|||||||
@@ -1038,6 +1038,56 @@ int esp32_partition_read(const char *label, size_t offset, void *buf,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32_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 esp32_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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
mtd = esp32_spiflash_encrypt_get_mtd();
|
||||||
|
if (!mtd)
|
||||||
|
{
|
||||||
|
ferr("ERROR: Failed to get SPI flash MTD\n");
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
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: esp32_partition_write
|
* Name: esp32_partition_write
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user