We're using flash encryption, and some partitions are encrypted while others are not.
Here's my partition table (some rows omitted for clarity):
Code: Select all
# ESP-IDF Partition Table
# Name,Type,SubType,Offset,Size,Flags
nvs,data,nvs,0xF000,28K,
otadata,data,ota,0x16000,8K,
phy_init,data,phy,0x18000,4K,
nvs_keys,data,nvs_keys,0x31000,4K,encrypted
certificates,data,fat,0x32000,120K,encrypted
logs,data,fat,0x60000,1024K,
factory,app,factory,0x180000,2048K,encrypted
ota_0,app,ota_0,0x380000,2304K,encrypted
ota_1,app,ota_1,0x5C0000,2304K,encrypted
* I can write to the partition with esp_partition_write
* I can memory map the partition with esp_partition_mmap
* I can read back the plain-text data via the pointer returned from esp_partition_mmap
* Working as expected!
With the unencrypted "logs" partition:
* I can write to the partition with esp_partition_write
* I can read the data via esp_partition_read - I get back the original data
* I can memory map the partition with esp_partition_mmap
* BUT when I read back the data via the pointer returned from esp_partition_mmap, I get garbage.
The only explanation I can think of at the moment is that the pointer read is (wrongly) going through the flash decryption process even though the partition is not flagged as "encrypted" and contains plain-text data.
I'm using basically the same code for both memory maps, e.g.:
Code: Select all
void *p_logs_mmap_data;
spi_flash_mmap_handle_t logs_mmap_handle;
esp_err_t mmap_result = esp_partition_mmap(
p_logs_partition,
0,
p_logs_partition->size,
SPI_FLASH_MMAP_DATA,
&p_logs_mmap_data,
&logs_mmap_handle
);