Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configs/board/nucleo-f767zi/usart3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=3
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
3 changes: 2 additions & 1 deletion configs/board/nucleo-f767zi/usart6.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=6
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
3 changes: 2 additions & 1 deletion configs/board/stm32f746g-disco/usart1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=1
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
3 changes: 2 additions & 1 deletion configs/board/stm32f746g-disco/usart6.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=6
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
3 changes: 2 additions & 1 deletion configs/board/stm32f769i-discovery/usart1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=1
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
3 changes: 2 additions & 1 deletion configs/board/stm32f769i-discovery/usart6.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ parity=none
stopbits=1
flowcontrol=none
instance=6
rx_ring_size=256
; ~44 ms at 921600 baud: what the DMA brings while the reader is not scheduled
rx_ring_size=4096
rx_ring_wait_mode=some_data
15 changes: 15 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ All parameters are in the `[dmuart]` section:
| `rx_ring_size` | integer | 256 | Capacity of the RX ring buffer, in bytes (0 disables it) |
| `rx_ring_wait_mode` | string | "some_data" | RX ring read-wait behavior: "none" (return immediately), "some_data" (wait for at least one byte), "all_data" (wait for the full requested length) |

### Receiving by DMA (STM32F7)

On STM32F7 a UART with an RX ring receives by DMA: a circular 1 KiB buffer
(from the `dma` heap when there is one - uncached DTCM -, else the D-cache
is invalidated for it) that the USART's idle line and the DMA's half / end
of the buffer drain into the ring. No byte is lost to an interrupt that
runs late: the USART has no FIFO, at 921600 baud a byte comes every ~11 us.
The stream is one of the two the UART can use (dmdma's leases); none free -
the UART receives by interrupt, as without DMA.

The ring is then what holds the bytes until the reader is scheduled: size
it for that, not for a line. At 921600 baud 256 bytes are 2.8 ms; a reader
reading byte by byte behind a busy thread (a display's rendering) misses
them - the old ones are dropped. The F7 boards' consoles have 4096 (~44 ms).

## Examples

### Basic 115200 8N1
Expand Down
13 changes: 12 additions & 1 deletion src/port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ dmod_add_library(${DMOD_MODULE_NAME} ${DMOD_MODULE_VERSION}
${COMMON_SOURCES}
)

dmod_link_modules(${DMOD_MODULE_NAME}
# One dmod_link_modules() call: each call rewrites the target's version
# requirements file.
# stm32f7: RX by DMA - dmdma 0.4 (its lease API), dmheap (the buffer from
# dmod-boot's "dma" heap, never cached).
set(DMUART_PORT_MODULES
dm_sw_ring
dmclk_port
dmosi
)
if(DMUART_MCU_SERIES STREQUAL "stm32f7")
list(APPEND DMUART_PORT_MODULES
dmdma@>=0.4
dmheap
)
endif()
dmod_link_modules(${DMOD_MODULE_NAME} ${DMUART_PORT_MODULES})

target_include_directories(${DMOD_MODULE_NAME} BEFORE PRIVATE
${CMAKE_SOURCE_DIR}/include
Expand Down
Loading
Loading