From 31ad1d0a81d9b1a5733fe56cb42b214f4fb43eeb Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 14:54:20 +0100 Subject: [PATCH 1/8] drivers: spi: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Fixes broken 16-bit on STM32N6 series. Signed-off-by: Mathieu Choplain --- drivers/spi/spi_ll_stm32.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index de3f2b48b68eb..0351a4916e666 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -1366,11 +1366,12 @@ static int transceive_dma(const struct device *dev, spi_stm32_cs_control(dev, true); uint8_t word_size_bytes = SPI_WORD_SIZE_GET(config->operation) / BITS_PER_BYTE; + struct dma_config *rx_cfg = &data->dma_rx.dma_cfg, *tx_cfg = &data->dma_tx.dma_cfg; - data->dma_rx.dma_cfg.source_data_size = word_size_bytes; - data->dma_rx.dma_cfg.dest_data_size = word_size_bytes; - data->dma_tx.dma_cfg.source_data_size = word_size_bytes; - data->dma_tx.dma_cfg.dest_data_size = word_size_bytes; + rx_cfg->source_data_size = rx_cfg->source_burst_length = word_size_bytes; + rx_cfg->dest_data_size = rx_cfg->dest_burst_length = word_size_bytes; + tx_cfg->source_data_size = tx_cfg->source_burst_length = word_size_bytes; + tx_cfg->dest_data_size = tx_cfg->dest_burst_length = word_size_bytes; while (data->ctx.rx_len > 0 || data->ctx.tx_len > 0) { size_t dma_len; @@ -1712,8 +1713,11 @@ static int spi_stm32_init(const struct device *dev) STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, /* SINGLE transfer */ \ + /* use single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dma_callback = dma_callback, \ From b783ed3a28a3639423c4ce6d72a9b32a2ee7123d Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:02:48 +0100 Subject: [PATCH 2/8] drivers: adc: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/adc/adc_stm32.c | 7 +++++-- drivers/adc/adc_stm32wb0.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index e16471b6039f2..eeddf7b6f065e 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -1828,8 +1828,11 @@ static DEVICE_API(adc, api_stm32_driver_api) = { STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, /* SINGLE transfer */ \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .dma_callback = dma_callback, \ diff --git a/drivers/adc/adc_stm32wb0.c b/drivers/adc/adc_stm32wb0.c index 02d65e1c7ab5b..59173733581ba 100644 --- a/drivers/adc/adc_stm32wb0.c +++ b/drivers/adc/adc_stm32wb0.c @@ -1230,8 +1230,11 @@ static struct adc_stm32wb0_data adc_data = { STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), .dest_data_size = STM32_DMA_CONFIG_MEMORY_DATA_SIZE( STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), - .source_burst_length = 1, /* SINGLE transfer */ - .dest_burst_length = 1, /* SINGLE transfer */ + /* single transfers (burst length = data size) */ + .source_burst_length = STM32_DMA_CONFIG_PERIPHERAL_DATA_SIZE( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), + .dest_burst_length = STM32_DMA_CONFIG_MEMORY_DATA_SIZE( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), .block_count = 1, .dma_callback = adc_stm32wb0_dma_callback, /* head_block and user_data are initialized at runtime */ From 28f3894b5ba48b77a2c5469ba35ca674a626c03a Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:02:55 +0100 Subject: [PATCH 3/8] drivers: i2c: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/i2c/i2c_ll_stm32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c_ll_stm32.c b/drivers/i2c/i2c_ll_stm32.c index 2e1ef4b2ed036..96b5b6b0110b6 100644 --- a/drivers/i2c/i2c_ll_stm32.c +++ b/drivers/i2c/i2c_ll_stm32.c @@ -509,8 +509,11 @@ void i2c_stm32_dma_rx_cb(const struct device *dma_dev, void *user_data, STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dest_data_size = STM32_DMA_CONFIG_##dest##_DATA_SIZE( \ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ - .source_burst_length = 1, \ - .dest_burst_length = 1, \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dma_callback = i2c_stm32_dma_##dir##_cb, \ },)) From 4a4935f81e50273dd2667a65ff64345dd6f74da6 Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:03:08 +0100 Subject: [PATCH 4/8] drivers: i2s: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/i2s/i2s_ll_stm32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2s/i2s_ll_stm32.c b/drivers/i2s/i2s_ll_stm32.c index 3459d50925e0e..523ecda6dbddf 100644 --- a/drivers/i2s/i2s_ll_stm32.c +++ b/drivers/i2s/i2s_ll_stm32.c @@ -946,8 +946,9 @@ static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel) .channel_direction = src_dev##_TO_##dest_dev, \ .source_data_size = 2, /* 16bit default */ \ .dest_data_size = 2, /* 16bit default */ \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = 2, \ + .dest_burst_length = 2, \ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dma_callback = dma_##dir##_callback, \ From c6358c463e5de8b4f37f4fa2d478294f6afc52b0 Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:03:14 +0100 Subject: [PATCH 5/8] drivers: i3c: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/i3c/i3c_stm32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/i3c_stm32.c b/drivers/i3c/i3c_stm32.c index b85d2b331ad90..73fe603c01b99 100644 --- a/drivers/i3c/i3c_stm32.c +++ b/drivers/i3c/i3c_stm32.c @@ -2150,8 +2150,11 @@ static DEVICE_API(i3c, i3c_stm32_driver_api) = { STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .block_count = 1, \ .dma_callback = i3c_stm32_dma_##dir##_cb, \ }, \ From 1c532375776669a94f116182b6ad44a79bb8e404 Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:03:20 +0100 Subject: [PATCH 6/8] drivers: uart: stm32: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/serial/uart_stm32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 08b77ad362a35..4e276d8324373 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -2504,8 +2504,11 @@ static int uart_stm32_pm_action(const struct device *dev, enum pm_device_action STM32_DMA_CHANNEL_CONFIG(index, dir)),\ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE(\ STM32_DMA_CHANNEL_CONFIG(index, dir)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE(\ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE(\ + STM32_DMA_CHANNEL_CONFIG(index, dir)), \ .block_count = 1, \ .dma_callback = uart_stm32_dma_##dir##_cb, \ }, \ From 58b149c222538995d02b63baa91c1bf0f137306a Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:03:31 +0100 Subject: [PATCH 7/8] drivers: video: stm32_dcmi: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- drivers/video/video_stm32_dcmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/video/video_stm32_dcmi.c b/drivers/video/video_stm32_dcmi.c index d59cc50c2090e..6a5c720343ec7 100644 --- a/drivers/video/video_stm32_dcmi.c +++ b/drivers/video/video_stm32_dcmi.c @@ -482,8 +482,11 @@ static void video_stm32_dcmi_irq_config_func(const struct device *dev) STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, /* SINGLE transfer */ \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ + STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ STM32_DMA_CHANNEL_CONFIG_BY_IDX(index, 0)), \ .dma_callback = dcmi_dma_callback, \ From b23aea22975f79723121ec18f388ba8208fecef9 Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 26 Nov 2025 15:04:14 +0100 Subject: [PATCH 8/8] mgmt: ec_host_cmd: backends/stm32_spi: configure proper DMA burst length The burst length unit is bytes, not number of transfers. This had not been an issue since the DMA driver historically ignored the values, but has now become one since they are used and (most importantly for us) validated. Signed-off-by: Mathieu Choplain --- .../ec_host_cmd/backends/ec_host_cmd_backend_spi_stm32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_spi_stm32.c b/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_spi_stm32.c index 34dbe422ca662..eeb695968cbab 100644 --- a/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_spi_stm32.c +++ b/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_spi_stm32.c @@ -196,8 +196,11 @@ static int prepare_rx(struct ec_host_cmd_spi_ctx *hc_spi); DT_DMAS_CELL_BY_NAME(id, dir, channel_config)), \ .dest_data_size = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ DT_DMAS_CELL_BY_NAME(id, dir, channel_config)), \ - .source_burst_length = 1, /* SINGLE transfer */ \ - .dest_burst_length = 1, /* SINGLE transfer */ \ + /* single transfers (burst length = data size) */ \ + .source_burst_length = STM32_DMA_CONFIG_##src_dev##_DATA_SIZE( \ + DT_DMAS_CELL_BY_NAME(id, dir, channel_config)), \ + .dest_burst_length = STM32_DMA_CONFIG_##dest_dev##_DATA_SIZE( \ + DT_DMAS_CELL_BY_NAME(id, dir, channel_config)), \ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ DT_DMAS_CELL_BY_NAME(id, dir, channel_config)), \ .dma_callback = dma_callback, \