diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 68c783b..aebf9a2 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -144,6 +144,13 @@ if(DMBOOT_FLASH_DMD_FILES OR DMBOOT_MAIN_MODULE OR DMBOOT_SHELL) COMMAND ${DMF_GET} -d "${DMBOOT_COMBINED_FLASH_DMD}" -o "${DMBOOT_MODULES_OUT_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type "${DMBOOT_MODULE_TYPE}" --config-dir "${DMBOOT_CONFIG_DIR}" --config-map "${DMBOOT_CONFIG_MAP}" --views-dir "${DMBOOT_EVIEWS_DIR}" ) endif() + if(DMBOOT_EMULATION) + # Renode's USART cannot be served by DMA: the UARTs receive by interrupt + list(APPEND _FLASH_DOWNLOAD_COMMANDS + COMMAND ${CMAKE_COMMAND} -DDMUART_CONFIG_DIR=${DMBOOT_CONFIG_DIR}/drivers/dmuart + -P "${CMAKE_SOURCE_DIR}/scripts/emulation_uart_config.cmake" + ) + endif() list(APPEND _FLASH_DOWNLOAD_COMMANDS COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_MODULES_MARKER_FILE}" ) diff --git a/scripts/emulation_uart_config.cmake b/scripts/emulation_uart_config.cmake new file mode 100644 index 0000000..d690fb3 --- /dev/null +++ b/scripts/emulation_uart_config.cmake @@ -0,0 +1,18 @@ +# Emulation: the UARTs receive by interrupt. +# +# Renode's STM32F7 USART has no DMA request line, so a UART that receives by +# DMA (dmuart's default) gets nothing there - the console would not read a +# key. dmuart's `rx_dma=0` makes it receive by interrupt, which the model +# serves; the hardware keeps the DMA. Run on the driver configuration the +# modules brought (DMBOOT_CONFIG_DIR/drivers/dmuart/*.ini): +# +# cmake -DDMUART_CONFIG_DIR= -P emulation_uart_config.cmake +# +file(GLOB DMUART_INIS "${DMUART_CONFIG_DIR}/*.ini") +foreach(INI ${DMUART_INIS}) + file(READ "${INI}" CONTENT) + if(CONTENT MATCHES "driver_name=dmuart" AND NOT CONTENT MATCHES "(^|\n)rx_dma=") + string(REGEX REPLACE "(\n[ \t]*rx_ring_size=[^\n]*)" "\\1\nrx_dma=0" CONTENT "${CONTENT}") + file(WRITE "${INI}" "${CONTENT}") + endif() +endforeach()