Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32F1 failed to compile with CONFIG_UART_ASYNC_API #34543

Closed
roland-xz opened this issue Apr 24, 2021 · 9 comments · Fixed by #34666
Closed

STM32F1 failed to compile with CONFIG_UART_ASYNC_API #34543

roland-xz opened this issue Apr 24, 2021 · 9 comments · Fixed by #34666
Assignees
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Milestone

Comments

@roland-xz
Copy link

roland-xz commented Apr 24, 2021

Describe the bug
Testing nucleo_f103rb board, with my own code or the tests/drivers/uart/uart_async_api code, the compile fails.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a board with STM32F1 SoC, e.g, nucleo_f103rb
  2. $ west build -p auto -b nucleo_f103rb --cmake ./zephyr/tests/drivers/uart/uart_async_api/
  3. See error
/zephyr/drivers/dma/dma_stm32.c: In function 'dma_stm32_configure':
/zephyr/drivers/dma/dma_stm32.c:464:16: error: 'LL_DMA_InitTypeDef' has no member named 'PeriphRequest'
  464 |  DMA_InitStruct.PeriphRequest = config->dma_slot;
      |                ^
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 

Expected behavior
Compile should pass.

Impact
annoyance

Logs and console output
as above

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK 0.12.3
  • Zephyr version: 2.5.99

Additional context
I believe DMA_InitStruct.PeriphRequest is only used by SoCs that support dmamux. STM32F1 does not.
Adding the following seems to fix the problem.

	#if defined(DMAMUX1)
	DMA_InitStruct.PeriphRequest = config->dma_slot;
	#endif
@roland-xz roland-xz added the bug The issue is a bug, or the PR is fixing a bug label Apr 24, 2021
@FRASTM FRASTM added the platform: STM32 ST Micro STM32 label Apr 26, 2021
@FRASTM
Copy link
Collaborator

FRASTM commented Apr 26, 2021

@roland-xz thank you for reporting this issue
The stm32f103 has two DMA controllers (dma V2) but no DMAMUX, and its dma is of special type, where peripheral requests are ORed. COnsequently, it appears that LL_DMA_InitTypeDef structure of the modules stm32cube/stm32f1xx has NO PeriphRequest.

@FRASTM
Copy link
Collaborator

FRASTM commented Apr 26, 2021

A quick fix is to exclude the CONFIG_SOC_SERIES_STM32F1X in the drivers/dma/dma_stm32.c

#if defined(CONFIG_DMA_STM32_V2) || defined(CONFIG_DMAMUX_STM32)
#ifndef CONFIG_SOC_SERIES_STM32F1X
	/*
	 * the with dma V2 and dma mux,
	 * the request ID is stored in the dma_slot
	 */
	DMA_InitStruct.PeriphRequest = config->dma_slot;
#endif
#endif

@FRASTM
Copy link
Collaborator

FRASTM commented Apr 26, 2021

With this exception for the stm32f1x soc serie, the dma binding of the stm32 does not change : a channel (defined by the ref. Manual "Summary of DMA1 requests for each channel") and a slot (not used). In this configuration, it could be specified that slot equal channels, for convenience. So for testing the usart2, the nucleo_f103rb.overlay could be as follows:

&usart2 {
	dmas = <&dma1 7 7 0x440 0>,
		<&dma1 6 6 0x480 0>;
	dma-names = "tx", "rx";
};

&dma1 {
	status = "okay";
};

@roland-xz
Copy link
Author

With this exception for the stm32f1x soc serie, the dma binding of the stm32 does not change : a channel (defined by the ref. Manual "Summary of DMA1 requests for each channel") and a slot (not used). In this configuration, it could be specified that slot equal channels, for convenience. So for testing the usart2, the nucleo_f103rb.overlay could be as follows:

&usart2 {
	dmas = <&dma1 7 7 0x440 0>,
		<&dma1 6 6 0x480 0>;
	dma-names = "tx", "rx";
};

&dma1 {
	status = "okay";
};

@FRASTM Thanks a lot for the suggested fixes.
However, this was the other issue I encountered. I configured dma on usart2 this way the other day, but because zephyr console used uart 2 on this board, the test always failed. Not 100% sure if it was due to a conflict with the console. Please see failure log down below.
Moved the test on usart3 and it passed.

Keen to see tests/drivers/uart/uart_mix_fifo_poll work next because it's close to what I want to do.

*** Booting Zephyr OS build zephyr-v2.5.0-2384-gfacd0f57db85  ***
Running test suite uart_async_test
===================================================================
START - test_single_read_setup
 PASS - test_single_read_setup in 0.1 seconds
===================================================================
START - test_single_read
test
    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:82: test_single_read: (k_sem_take(&rx_rdy, K_MSEC(100)) not equal to 0)
RX_RDY timeout
 FAIL - test_single_read in 0.218 seconds
===================================================================
START - test_chained_read_setup
 PASS - test_chained_read_setup in 0.1 seconds
===================================================================
START - test_chained_read
W: RX was already enabled
Message 0
    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:164: test_chained_read: (k_sem_take(&rx_rdy, K_MSEC(1000)) not equal to 0)
RX_RDY timeout
 FAIL - test_chained_read in 1.31 seconds
===================================================================
START - test_double_buffer_setup
 PASS - test_double_buffer_setup in 0.1 seconds
===================================================================
START - test_double_buffer
W: RX was already enabled

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:217: test_double_buffer: (uart_rx_enable(uart_dev, double_buffer[0], sizeof(double_buffer[0]), 50) not equal to 0)
Failed to enable receiving
 FAIL - test_double_buffer in 0.24 seconds
===================================================================
START - test_read_abort_setup
 PASS - test_read_abort_setup in 0.1 seconds
===================================================================
START - test_read_abort
W: RX was already enabled

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:292: test_read_abort: (k_sem_take(&rx_rdy, K_MSEC(100)) not equal to 0)
RX_RDY timeout
 FAIL - test_read_abort in 0.120 seconds
===================================================================
START - test_chained_write_setup
 PASS - test_chained_write_setup in 0.1 seconds
===================================================================
START - test_chained_write
W: RX was already enabled
Message 1Message 2
    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:508: test_chained_write: (k_sem_take(&rx_rdy, K_MSEC(100)) not equal to 0)
RX_RDY timeout
 FAIL - test_chained_write in 0.121 seconds
===================================================================
START - test_long_buffers_setup
 PASS - test_long_buffers_setup in 0.1 seconds
===================================================================
START - test_long_buffers
W: RX was already enabled

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:580: test_long_buffers: (k_sem_take(&rx_rdy, K_MSEC(200)) not equal to 0)
RX_RDY timeout
 FAIL - test_long_buffers in 0.263 seconds
===================================================================
START - test_write_abort_setup
 PASS - test_write_abort_setup in 0.1 seconds
===================================================================
START - test_write_abort
W: RX was already enabled

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:366: test_write_abort: (k_sem_take(&rx_rdy, K_MSEC(100)) not equal to 0)
RX_RDY timeout
 FAIL - test_write_abort in 0.120 seconds
===================================================================
START - test_forever_timeout_setup
 PASS - test_forever_timeout_setup in 0.1 seconds
===================================================================
START - test_forever_timeout
W: RX was already enabled

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/uart/uart_async_api/src/test_uart_async.c:442: test_forever_timeout: (k_sem_take(&rx_rdy, K_MSEC(100)) not equal to 0)
RX_RDY timeout
 FAIL - test_forever_timeout in 3.120 seconds
===================================================================
Test suite uart_async_test failed.
===================================================================
PROJECT EXECUTION FAILED

@FRASTM
Copy link
Collaborator

FRASTM commented Apr 26, 2021

On the nucleo_f103rb, the usart 2 is the console, so that you cannot run test on it, but on usart3 or usart1

&usart1 {
	dmas = <&dma1 4 4 0x440 0>,
		<&dma1 5 5 0x480 0>;
	dma-names = "tx", "rx";
};
&usart3 {
	dmas = <&dma1 2 2 0x440 0>,
		<&dma1 3 3 0x480 0>;
	dma-names = "tx", "rx";
};

@roland-xz
Copy link
Author

On the nucleo_f103rb, the usart 2 is the console, so that you cannot run test on it, but on usart3 or usart1

&usart1 {
	dmas = <&dma1 4 4 0x440 0>,
		<&dma1 5 5 0x480 0>;
	dma-names = "tx", "rx";
};
&usart3 {
	dmas = <&dma1 2 2 0x440 0>,
		<&dma1 3 3 0x480 0>;
	dma-names = "tx", "rx";
};

Thanks again@FRASTM.
Having trouble configuring the device tree for TIMER_0 with compatible = "st,stm32-timer-counter", and in general DT configuration requires a lot of trials and errors for me.
Do you know of any STM32 specific documentation on this?

@erwango erwango added the priority: low Low impact/importance bug label Apr 26, 2021
@erwango
Copy link
Member

erwango commented Apr 26, 2021

Thanks again@FRASTM.
Having trouble configuring the device tree for TIMER_0 with compatible = "st,stm32-timer-counter", and in general DT configuration requires a lot of trials and errors for me.
Do you know of any STM32 specific documentation on this?

@roland-xz There is no STM32 specific documentation for this, but you can find the list of supported STM32 bindings here:
https://docs.zephyrproject.org/latest/reference/devicetree/bindings.html#stmicroelectronics-st
Generic infirmation about bindings: https://docs.zephyrproject.org/latest/guides/dts/bindings.html

@roland-xz
Copy link
Author

@erwango Thanks for the links.

@erwango erwango added this to the v2.7.0 milestone May 10, 2021
@erwango erwango added Enhancement Changes/Updates/Additions to existing features and removed bug The issue is a bug, or the PR is fixing a bug labels May 10, 2021
@erwango
Copy link
Member

erwango commented May 10, 2021

Moving ticket from bug as enhancement as conclusion is DMA is not yet supported on STM32F1 and requires some implementation for support. cf #34666

@cfriedt cfriedt removed the priority: low Low impact/importance bug label Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants