[PATCH v2 0/6] hw/char: Implement the STM32L4x5 USART, UART and LPUART

Arnaud Minier posted 6 patches 1 month ago
Failed in applying to current master (apply log)
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Arnaud Minier <arnaud.minier@telecom-paris.fr>, "Inès Varhol" <ines.varhol@telecom-paris.fr>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Alistair Francis <alistair@alistair23.me>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
MAINTAINERS                        |   1 +
docs/system/arm/b-l475e-iot01a.rst |   2 +-
hw/arm/Kconfig                     |   1 +
hw/arm/stm32l4x5_soc.c             |  82 +++-
hw/char/Kconfig                    |   3 +
hw/char/meson.build                |   1 +
hw/char/stm32l4x5_usart.c          | 632 +++++++++++++++++++++++++++++
hw/char/trace-events               |  12 +
hw/misc/stm32l4x5_rcc.c            |   7 +-
include/hw/arm/stm32l4x5_soc.h     |  13 +
include/hw/char/stm32l4x5_usart.h  |  67 +++
tests/qtest/meson.build            |   3 +-
tests/qtest/stm32l4x5_usart-test.c | 326 +++++++++++++++
13 files changed, 1141 insertions(+), 9 deletions(-)
create mode 100644 hw/char/stm32l4x5_usart.c
create mode 100644 include/hw/char/stm32l4x5_usart.h
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
[PATCH v2 0/6] hw/char: Implement the STM32L4x5 USART, UART and LPUART
Posted by Arnaud Minier 1 month ago
This patch adds the STM32L4x5 USART
(Universal Synchronous/Asynchronous Receiver/Transmitter)
device and is part of a series implementing the
STM32L4x5 with a few peripherals.

It implements the necessary functionalities to receive/send
characters over the serial port, which are useful to
communicate with the program currently running.

Many thanks Peter for your review, I think I addressed almost
everything.
I'm just unsure about how to handle the waiting time in the tests.
I understand your concerns about the unreliability of using the wallclock
time but I don't understand how using clock_step() would make it
more reliable. We will always be waiting on something
that is out of our control (i.e. the OS).
I increased the delay from 5s to 10min to match the microbit test
and added a comment (I paraphrased your comment, is that okay ?).

I also saw that Philippe Mathieu-Daudé have sent a patchset with
the first commit of this patchset and another commit to make
clock_set_mul_div() return a boolean.
If this is merged before this patchset (which will probably be
the case), I will remove the first commit.

Changes from v1 to v2:
- Use asynchronous transmission for serial communication
  (based on cmsdk-apb-uart implementation)
- Use qemu_log_mask instead of error_report
- Squash the commit that renamed the base struct
- Use switch statements where appropriate
- Fix RDR and TDR mask size
- Increase time limit in tests
- Remove the global qtest in the tests
- Use assert when checking the interrupt number in the tests
- Correct usage of g_autofree in the SoC

Arnaud Minier (6):
  hw/misc/stm32l4x5_rcc: Propagate period when enabling a clock
  hw/char: Implement STM32L4x5 USART skeleton
  hw/char/stm32l4x5_usart: Enable serial read and write
  hw/char/stm32l4x5_usart: Add options for serial parameters setting
  hw/arm: Add the USART to the stm32l4x5 SoC
  tests/qtest: Add tests for the STM32L4x5 USART

 MAINTAINERS                        |   1 +
 docs/system/arm/b-l475e-iot01a.rst |   2 +-
 hw/arm/Kconfig                     |   1 +
 hw/arm/stm32l4x5_soc.c             |  82 +++-
 hw/char/Kconfig                    |   3 +
 hw/char/meson.build                |   1 +
 hw/char/stm32l4x5_usart.c          | 632 +++++++++++++++++++++++++++++
 hw/char/trace-events               |  12 +
 hw/misc/stm32l4x5_rcc.c            |   7 +-
 include/hw/arm/stm32l4x5_soc.h     |  13 +
 include/hw/char/stm32l4x5_usart.h  |  67 +++
 tests/qtest/meson.build            |   3 +-
 tests/qtest/stm32l4x5_usart-test.c | 326 +++++++++++++++
 13 files changed, 1141 insertions(+), 9 deletions(-)
 create mode 100644 hw/char/stm32l4x5_usart.c
 create mode 100644 include/hw/char/stm32l4x5_usart.h
 create mode 100644 tests/qtest/stm32l4x5_usart-test.c

-- 
2.34.1
Re: [PATCH v2 0/6] hw/char: Implement the STM32L4x5 USART, UART and LPUART
Posted by Peter Maydell 1 month ago
On Sun, 24 Mar 2024 at 16:56, Arnaud Minier
<arnaud.minier@telecom-paris.fr> wrote:
>
> This patch adds the STM32L4x5 USART
> (Universal Synchronous/Asynchronous Receiver/Transmitter)
> device and is part of a series implementing the
> STM32L4x5 with a few peripherals.
>
> It implements the necessary functionalities to receive/send
> characters over the serial port, which are useful to
> communicate with the program currently running.
>
> Many thanks Peter for your review, I think I addressed almost
> everything.
> I'm just unsure about how to handle the waiting time in the tests.
> I understand your concerns about the unreliability of using the wallclock
> time but I don't understand how using clock_step() would make it
> more reliable. We will always be waiting on something
> that is out of our control (i.e. the OS).
> I increased the delay from 5s to 10min to match the microbit test
> and added a comment (I paraphrased your comment, is that okay ?).

I think I was slightly confused between two things. For
a lot of qtests we do want to use clock_step() and not
have wallclock-based delays, but we can only do that where
the thing we're waiting for is purely simulation time
(i.e. where we triggered a change via a qtest write and
then want to look for the result via a qtest read).
Where we're triggering something via a different OS
pathway (e.g. here where we write to the socket that's
backing the chardev connected to the UART and then look
at the UART registers) we do need a wallclock delay.

I recommend you follow Thomas's suggestions about timeouts
in his comments on patch 6; I'd forgotten we have a
meson timeout now too.

thanks
-- PMM