refactor(flash_enc): move esp_flash_encryption_enabled() to efuse component

This commit is contained in:
Chen Jichang
2026-03-06 18:14:22 +08:00
committed by Chen Ji Chang
parent fea2c08655
commit 04df934c05
53 changed files with 139 additions and 131 deletions
+1 -1
View File
@@ -421,7 +421,7 @@ esp_err_t gdma_config_transfer(gdma_channel_handle_t dma_chan, const gdma_transf
// While, for AHB GDMA version 2 and AXI GDMA, we need to ensure the alignment by software
#if (SOC_PSRAM_DMA_CAPABLE || SOC_DMA_CAN_ACCESS_FLASH) && SOC_AHB_GDMA_VERSION != 1
// if MSPI encryption is enabled, and DMA wants to read/write external memory
if (esp_flash_encryption_enabled() && config->access_ext_mem) {
if (esp_efuse_is_flash_encryption_enabled() && config->access_ext_mem) {
uint32_t enc_mem_alignment = GDMA_LL_GET(ACCESS_ENCRYPTION_MEM_ALIGNMENT);
// when DMA access the encrypted external memory, extra alignment is needed for external memory
ext_mem_alignment = MAX(ext_mem_alignment, enc_mem_alignment);
+3 -3
View File
@@ -19,7 +19,7 @@
#include "hal/efuse_hal.h"
#include "hal/cache_ll.h"
#include "esp_cache.h"
#include "esp_flash_encrypt.h"
#include "esp_efuse.h"
ESP_LOG_ATTR_TAG(TAG, "gdma-link");
@@ -84,7 +84,7 @@ esp_err_t gdma_new_link_list(const gdma_link_list_config_t *config, gdma_link_li
bool items_in_ext_mem = config->flags.items_in_ext_mem;
uint32_t list_items_mem_caps = MALLOC_CAP_8BIT | MALLOC_CAP_DMA;
if (items_in_ext_mem) {
if (esp_flash_encryption_enabled()) {
if (esp_efuse_is_flash_encryption_enabled()) {
items_in_ext_mem = false;
list_items_mem_caps |= MALLOC_CAP_INTERNAL;
ESP_LOGW(TAG, "DMA linked list items cannot be placed in PSRAM when external memory encryption is enabled, using internal memory instead");
@@ -187,7 +187,7 @@ esp_err_t gdma_link_mount_buffers(gdma_link_list_handle_t list, int start_item_i
size_t max_buffer_mount_length = ALIGN_DOWN(GDMA_MAX_BUFFER_SIZE_PER_LINK_ITEM, buffer_alignment);
if (!config->flags.bypass_buffer_align_check) {
ESP_RETURN_ON_FALSE_ISR(((uintptr_t)buf & (buffer_alignment - 1)) == 0, ESP_ERR_INVALID_ARG, TAG, "buf misalign idx=%"PRIu32" align=%"PRIu32, bi, buffer_alignment);
if (esp_flash_encryption_enabled()) {
if (esp_efuse_is_flash_encryption_enabled()) {
// buffer size must be aligned to the encryption alignment which should be provided by the upper buffer_alignment
ESP_RETURN_ON_FALSE_ISR((len & (buffer_alignment - 1)) == 0, ESP_ERR_INVALID_ARG, TAG, "buf len misalign idx=%"PRIu32" len=%"PRIu32" align=%"PRIu32"", bi, len, buffer_alignment);
}
+1 -1
View File
@@ -36,7 +36,7 @@
#include "esp_private/periph_ctrl.h"
#include "esp_private/critical_section.h"
#include "esp_private/sleep_retention.h"
#include "esp_flash_encrypt.h"
#include "esp_efuse.h"
#if CONFIG_GDMA_OBJ_DRAM_SAFE
#define GDMA_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)