Skip to content

Commit 333858e

Browse files
committed
fix(dma): add burst size check when dma access psram
1 parent ad6904d commit 333858e

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

components/esp_hw_support/dma/gdma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ esp_err_t gdma_config_transfer(gdma_channel_handle_t dma_chan, const gdma_transf
357357
// burst size must be power of 2
358358
ESP_RETURN_ON_FALSE((max_data_burst_size & (max_data_burst_size - 1)) == 0, ESP_ERR_INVALID_ARG,
359359
TAG, "invalid max_data_burst_size: %"PRIu32, max_data_burst_size);
360+
#if SOC_AHB_GDMA_SUPPORT_PSRAM || SOC_AXI_GDMA_SUPPORT_PSRAM
361+
if (config->access_ext_mem) {
362+
ESP_RETURN_ON_FALSE(max_data_burst_size <= GDMA_LL_MAX_BURST_SIZE_PSRAM, ESP_ERR_INVALID_ARG,
363+
TAG, "max_data_burst_size must not exceed %d when accessing external memory", GDMA_LL_MAX_BURST_SIZE_PSRAM);
364+
}
365+
#endif
360366
}
361367
gdma_pair_t *pair = dma_chan->pair;
362368
gdma_group_t *group = pair->group;

components/hal/esp32c5/include/hal/gdma_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "soc/pcr_struct.h"
99
#include "hal/ahb_dma_ll.h"
1010
#define GDMA_LL_AHB_BURST_SIZE_ADJUSTABLE 1 // AHB GDMA supports adjustable burst size
11+
#define GDMA_LL_MAX_BURST_SIZE_PSRAM 32 // PSRAM controller doesn't support burst access with size > 32 bytes
1112

1213
#ifdef __cplusplus
1314
extern "C" {

components/hal/esp32c61/include/hal/gdma_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "soc/pcr_struct.h"
99
#include "hal/ahb_dma_ll.h"
1010
#define GDMA_LL_AHB_BURST_SIZE_ADJUSTABLE 1 // AHB GDMA supports adjustable burst size
11+
#define GDMA_LL_MAX_BURST_SIZE_PSRAM 32 // PSRAM controller doesn't support burst access with size > 32 bytes
1112

1213
#ifdef __cplusplus
1314
extern "C" {

components/hal/esp32h4/include/hal/gdma_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "soc/pcr_struct.h"
99
#include "hal/ahb_dma_ll.h"
1010
#define GDMA_LL_AHB_BURST_SIZE_ADJUSTABLE 1 // AHB GDMA supports adjustable burst size
11+
#define GDMA_LL_MAX_BURST_SIZE_PSRAM 64 // PSRAM support INCR16
1112

1213
#ifdef __cplusplus
1314
extern "C" {

components/hal/esp32p4/include/hal/gdma_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#define GDMA_LL_AHB_DESC_ALIGNMENT 4
4949
#define GDMA_LL_AXI_DESC_ALIGNMENT 8
50+
#define GDMA_LL_MAX_BURST_SIZE_PSRAM 64 // PSRAM controller doesn't support burst access with size > 64 bytes
5051

5152
#define GDMA_LL_TX_ETM_EVENT_TABLE(group, chan, event) \
5253
(uint32_t[2][GDMA_ETM_EVENT_MAX]){ \

components/hal/esp32s3/include/hal/gdma_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern "C" {
6464

6565
#define GDMA_LL_AHB_BURST_SIZE_ADJUSTABLE 1 // AHB GDMA supports adjustable burst size
6666
#define GDMA_LL_AHB_RX_BURST_NEEDS_ALIGNMENT 1
67+
#define GDMA_LL_MAX_BURST_SIZE_PSRAM 64 // PSRAM controller doesn't support burst access with size > 64 bytes
6768

6869
///////////////////////////////////// Common /////////////////////////////////////////
6970

0 commit comments

Comments
 (0)