summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhian Liang <[email protected]>2026-11-24 12:21:35 +0800
committerRbb666 <[email protected]>2026-12-01 10:18:42 +0800
commit373b0729a403a9618fd7900961aeba5773760e63 (patch)
tree55e12704cb5079a2df9debf7238fb92717bf19d3
parent284b510dda03949cfd6236e09eea58846c3ec7e7 (diff)
serial_v2: align the DMA rx ping buffer to a cache line
Signed-off-by: Zhian Liang <[email protected]>
-rw-r--r--bsp/hpmicro/hpm5100evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm5300evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm5301evklite/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm5e00evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6200evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6300evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6750evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6750evk2/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6750evkmini/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6800evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6e00evk/rtconfig.py2
-rw-r--r--bsp/hpmicro/hpm6p00evk/rtconfig.py2
-rw-r--r--components/drivers/serial/dev_serial_v2.c11
13 files changed, 21 insertions, 14 deletions
diff --git a/bsp/hpmicro/hpm5100evk/rtconfig.py b/bsp/hpmicro/hpm5100evk/rtconfig.py
index 5febf5ae4b..99dc7d1a07 100644
--- a/bsp/hpmicro/hpm5100evk/rtconfig.py
+++ b/bsp/hpmicro/hpm5100evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm5300evk/rtconfig.py b/bsp/hpmicro/hpm5300evk/rtconfig.py
index 1ea9e310de..f70240747e 100644
--- a/bsp/hpmicro/hpm5300evk/rtconfig.py
+++ b/bsp/hpmicro/hpm5300evk/rtconfig.py
@@ -82,7 +82,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm5301evklite/rtconfig.py b/bsp/hpmicro/hpm5301evklite/rtconfig.py
index b7720eadf3..58a8ebcd0f 100644
--- a/bsp/hpmicro/hpm5301evklite/rtconfig.py
+++ b/bsp/hpmicro/hpm5301evklite/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm5e00evk/rtconfig.py b/bsp/hpmicro/hpm5e00evk/rtconfig.py
index 962fe9789b..b7c57975f7 100644
--- a/bsp/hpmicro/hpm5e00evk/rtconfig.py
+++ b/bsp/hpmicro/hpm5e00evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6200evk/rtconfig.py b/bsp/hpmicro/hpm6200evk/rtconfig.py
index fc0b56fb23..7d4e0eec4a 100644
--- a/bsp/hpmicro/hpm6200evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6200evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6300evk/rtconfig.py b/bsp/hpmicro/hpm6300evk/rtconfig.py
index 3b276240c1..192fe0f6d0 100644
--- a/bsp/hpmicro/hpm6300evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6300evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6750evk/rtconfig.py b/bsp/hpmicro/hpm6750evk/rtconfig.py
index a859c323d7..1fe4e725ff 100644
--- a/bsp/hpmicro/hpm6750evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6750evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6750evk2/rtconfig.py b/bsp/hpmicro/hpm6750evk2/rtconfig.py
index bc118615e0..e01446e94b 100644
--- a/bsp/hpmicro/hpm6750evk2/rtconfig.py
+++ b/bsp/hpmicro/hpm6750evk2/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6750evkmini/rtconfig.py b/bsp/hpmicro/hpm6750evkmini/rtconfig.py
index bc118615e0..e01446e94b 100644
--- a/bsp/hpmicro/hpm6750evkmini/rtconfig.py
+++ b/bsp/hpmicro/hpm6750evkmini/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6800evk/rtconfig.py b/bsp/hpmicro/hpm6800evk/rtconfig.py
index c5744e06c8..88b5b89167 100644
--- a/bsp/hpmicro/hpm6800evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6800evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6e00evk/rtconfig.py b/bsp/hpmicro/hpm6e00evk/rtconfig.py
index 72dd531804..19dc9cdae2 100644
--- a/bsp/hpmicro/hpm6e00evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6e00evk/rtconfig.py
@@ -82,7 +82,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/bsp/hpmicro/hpm6p00evk/rtconfig.py b/bsp/hpmicro/hpm6p00evk/rtconfig.py
index 52990f6b60..c3c792483d 100644
--- a/bsp/hpmicro/hpm6p00evk/rtconfig.py
+++ b/bsp/hpmicro/hpm6p00evk/rtconfig.py
@@ -81,7 +81,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
- DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
+ DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
diff --git a/components/drivers/serial/dev_serial_v2.c b/components/drivers/serial/dev_serial_v2.c
index 952d2c1f78..e258395354 100644
--- a/components/drivers/serial/dev_serial_v2.c
+++ b/components/drivers/serial/dev_serial_v2.c
@@ -1107,6 +1107,10 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
struct rt_serial_device *serial;
struct rt_serial_rx_fifo *rx_fifo = RT_NULL;
rt_size_t rx_fifo_size = 0;
+#ifdef RT_SERIAL_USING_DMA
+ rt_size_t dma_ping_offset = 0;
+ rt_uint8_t *dma_ping = RT_NULL;
+#endif
RT_ASSERT(dev != RT_NULL);
serial = (struct rt_serial_device *)dev;
@@ -1135,7 +1139,9 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
#ifdef RT_SERIAL_USING_DMA
if (serial->config.dma_ping_bufsz < RT_SERIAL_RX_MINBUFSZ / 2)
serial->config.dma_ping_bufsz = RT_SERIAL_RX_MINBUFSZ / 2;
- rx_fifo_size = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz + serial->config.dma_ping_bufsz;
+
+ dma_ping_offset = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz;
+ rx_fifo_size = dma_ping_offset + RT_ALIGN(serial->config.dma_ping_bufsz, RT_CPU_CACHE_LINE_SZ) + RT_CPU_CACHE_LINE_SZ;
#else
rx_fifo_size = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz;
#endif
@@ -1149,8 +1155,9 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
serial->config.rx_bufsz);
#ifdef RT_SERIAL_USING_DMA
+ dma_ping = (rt_uint8_t *)RT_ALIGN((rt_ubase_t)rx_fifo + dma_ping_offset, RT_CPU_CACHE_LINE_SZ);
rt_ringbuffer_init(&rx_fifo->dma_ping_rb,
- (rt_uint8_t *)rx_fifo + sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz,
+ dma_ping,
serial->config.dma_ping_bufsz);
#endif