I am trying to run some benchmarks on the ESP32 to see how flash encryption affects performance. I am using esp_partition_write to write to an OTA partition, which, to my knowledge, will transparently encrypt the contents of write buffer when flash encryption is enabled. Based on this post, I was led to believe that writing to encrypted flash in this matter would cause some noticeable slowdown. You can see the code below for reference.
Code: Select all
void write_flash()
{
int64_t beginT, endT;
char data[32];
memset(data, 'x', sizeof(data));
const esp_partition_t* partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, "ota_0");
beginT = esp_timer_get_time();
for(int i = 0; i < RUNS; i++)
{
esp_partition_erase_range(partition, i, sizeof(data));
esp_partition_write(partition, i, data, sizeof(data));
}
endT = esp_timer_get_time();
printf("%lld\n", endT - beginT);
}
Does anybody have an explanation? I am truly at a loss here. I have tested this multiple times with several different partitions. I tried writing 512 bytes instead of 32 bytes. However, the results are consistent. I also checked to make sure esp_partition_write returns ESP_OK, and it does.
I am using ESP-IDF v4.0-rc-10-g08219f3cf.