-
Notifications
You must be signed in to change notification settings - Fork 747
Fix UartMux to be able to use multiple muxes #3216
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
Conversation
8d245f2
to
904672c
Compare
Does this conflict or overlap #3046? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me -- it was always a problem that the receive buffer was defined in the capsule.
I am adding a new label for this PR to track changes that modify the board interface in a way that an out-of-tree board maintainer would need to replicate, just so we can track these types of changes between releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this is inline with the I2C component, but I'm not sure about this change. static_ini_half!
was created for a very specific purpose: to support sharing components when the actual object is templated on a chip-specific type. Here there is no chip-specific type in the virtual uart object, and as such the console component didn't use static_init_half.
I don't think we should continue to use static_init_half for a different purpose (to allow the same component to be used multiple times). Also, there is currently no indication of which components can be used multiple times. If components are going to be maintainable and usable, I think we need something more clear about how they can be used.
Ideally the policy should be that every component is reusable; but that would require a high-effort overhaul of all components to get there, and we have seen with #1618 that there isn't anyone motivated for a whole-scale components overhaul. IMO it seems like a shame to not at least make usability improvements on an as-needed basis, or to block those improvements on a very high-effort complete overhaul. |
@bradjc are you suggesting moving the arguments of The |
I'm not suggesting we do a full change to components, or that we cannot upgrade the console component independently of all other components. What I'm saying is that tock/kernel/src/utilities/static_init.rs Lines 136 to 142 in d21666d
But what I want to avoid is adding a new hack using an old hack to get re-usable components. I assume there must be some mechanism we can add or use that makes it clear that the console component is now reusable. |
So using |
I updated it to use the |
3566a55
to
30b24b7
Compare
814faa5
bc0a8cf
to
814faa5
Compare
I rebased it to use the new |
bors r+ |
3216: Fix UartMux to be able to use multiple muxes r=bradjc a=alexandruradovici ### Pull Request Overview This pull request fixes the way in which `UartMux` is being instantiated. Before this PR: - the `new` function from the `UartMuxComponent` would instantiate the `UartMux` using a `static_init!` macro. Due to this, instantiating two `UartMux` structures would result in the second instance overwriting the first one. - the `RX_BUF` was defined within the `virtual_uart` capsule, meaning that two instances of `UartMux` would use the same buffer. This PR: - moves the instantiating of the `UartMux` in the `uart_mux_component_helper` macro. - moves the instantiating of the `RX_BUF` in the `uart_mux_component_helper` macro. #### Example ```rust let uart_mux1 = components::console::UartMuxComponent::new( &peripherals.usart1, 115200, dynamic_deferred_caller, ) .finalize(components::uart_component_helper!(64)); let uart_mux2 = components::console::UartMuxComponent::new( &peripherals.usart2, 1 8000 15200, dynamic_deferred_caller, ) .finalize(components::uart_component_helper!(64)); ``` Without this PR `uart_mux2` overwrites `uart_mux1`, as the structure is allocated in the same memory space. This PR enables the `usart2` for the STM32F3Discovery board. This is similar to what the I2C and SPI components do. ### Testing Strategy This pull request was tested using an STM32F3 Discovery board with two serial ports. One serial port was used for the kernel messages and process console, while the second one was used for applications. ### TODO or Help Wanted N/A ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make prepush`. Co-authored-by: Alexandru RADOVICI <alexandru.radovici@wyliodrin.com> Co-authored-by: Alexandru Radovici <msg4alex@gmail.com>
Build failed: |
this does duplicate code, but without this change, users may use the uart_mux_component_helper with an expression that is not a constant, which will not compile
58eb86c
015a623
to
58eb86c
Compare
Rebased |
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
bors r+ |
Pull Request Overview
This pull request fixes the way in which
UartMux
is being instantiated. Before this PR:new
function from theUartMuxComponent
would instantiate theUartMux
using astatic_init!
macro. Due to this, instantiating twoUartMux
structures would result in the second instance overwriting the first one.RX_BUF
was defined within thevirtual_uart
capsule, meaning that two instances ofUartMux
would use the same buffer.This PR:
UartMux
in theuart_mux_component_helper
macro.RX_BUF
in theuart_mux_component_helper
macro.Example
Without this PR
uart_mux2
overwritesuart_mux1
, as the structure is allocated in the same memory space.This PR enables the
usart2
for the STM32F3Discovery board.This is similar to what the I2C and SPI components do.
Testing Strategy
This pull request was tested using an STM32F3 Discovery board with two serial ports. One serial port was used for the kernel messages and process console, while the second one was used for applications.
TODO or Help Wanted
N/A
Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.