Page 1 of 1

some questions about spi_flash_mmap

Posted: Mon Sep 18, 2017 3:11 am
by tobewinner
1, Will spi_flash_mmap decrypt data unconditional if Flash Encryption is on?I mean no matter the area is in partitions or not.
2, As We know, Not all of the flash is encrypted. Is it possible to save data in area which is not support now using spi_flash_write_encrypted and read them using spi_flash_mmap?

Re: some questions about spi_flash_mmap

Posted: Mon Sep 18, 2017 4:08 am
by ESP_igrr
Memory-mapped reads from flash are always decrypted if flash encryption is on, that is how the flash MMU is designed.
Therefore you can't use memory mapping to read from unencrypted partitions in flash, if flash encryption is on. (Or rather, you can, but such reads will produce garbage)

Re: some questions about spi_flash_mmap

Posted: Mon Sep 18, 2017 7:01 am
by tobewinner
ESP_igrr wrote:Memory-mapped reads from flash are always decrypted if flash encryption is on, that is how the flash MMU is designed.
Therefore you can't use memory mapping to read from unencrypted partitions in flash, if flash encryption is on. (Or rather, you can, but such reads will produce garbage)
And question 2?
Is it possible to save data in area which is not supportted now (unused area, not in partitions) using spi_flash_write_encrypted and read them using spi_flash_mmap?

Re: some questions about spi_flash_mmap

Posted: Mon Sep 18, 2017 10:35 am
by ESP_igrr
Is it possible to save data in area which is not supportted now (unused area, not in partitions) using spi_flash_write_encrypted and read them using spi_flash_mmap?
All area of the flash chip is supported, in the sense that it can be accessed via spi_flash_* APIs and esp_partition_* APIs (in the latter case, provided that you define a partition for respective area). Yes, you can write to unpartitioned space using spi_flash_write_encrypted and then use spi_flash_mmap to read.
But this is not recommended, in general. Most applications should use esp_partition_* APIs. That is the best way to ensure that your application is future proof and will not conflict with other components.