-
Notifications
You must be signed in to change notification settings - Fork 3k
Optional hardware flow control for STDOUT #6603
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
@0xc0170 as discussed. |
platform/mbed_retarget.cpp
Outdated
@@ -147,6 +147,9 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud) { | |||
if (stdio_uart_inited) return; | |||
serial_init(&stdio_uart, tx, rx); | |||
serial_baud(&stdio_uart, baud); | |||
#if STDIO_UART_FC |
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.
Looking at the other config there, should this become
MBED_CONF_PLATFORM_STDIO_FC or FLOW_CONTROL
?
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.
That would imply the configuration is defined in platform/mbed_lib.json
, which would make it impossible to configure from targets.json
or custom_targets.json
.
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.
So why not put it in the base target, Target
, in targets.json?
Certainly a good thing to have. For the pin names, I think I'd be happier with using the standard RTS/CTS names. As to activation, I think this has to be app-configurable - the target is indicating by defines that it has a default serial port for console, and what its pins are, and certainly it must indicate that it has RTS/CTS pins. The current concept is that "STDIO_UART" defines are normally set by the target, not the app, I believe. But that doesn't mean an app necessarily definitely wants to use them - eg it may be that you've not configured your terminal properly, or you're talking to a test rig that doesn't have it wired. I would have thought you needed a JSON config enable for this, alongside the baudrate. Particularly if we start adding the defines to existing targets - having it on by default could cause backwards compatibility issues. So counter suggestion:
|
@kjbracey-arm
Wouldn't that be a deviation from our current behavior? Specifically, NRF52 derived boards come in variants that require flow control to be either on or off explicitly. So, without a default setting (not on the app-level) debug output wont work.
Sounds good.
I originally did something similar, but we got a request to not put this is an I would like to keep it out of |
I guess in many cases the debug UART is via an on-board device which may have its own fixed requirement, rather than pass it through as user-visible. So if I understand correctly the problem is that the target itself can only override a library setting via the We can add target overrides to Feels like this is a general tooling issue it would be nice to address - have a way for the "overrides" inside the target JSON to affect libraries. I can't see why that couldn't operate at the same basic ordering level as the If the request is "avoid use the mbed config system because it isn't flexible enough", I think the correct response is to improve the flexibility, not avoid it. Easier said than done though, I suspect. Who do we need to discuss this with? |
It's interesting that the docs for the config use this specific example of Should baud and flow control actually be target options in the base Are target config options totally unused at present? Don't see any in |
@theotherjimmy Can you please review this ? |
They are used by the NRF52: https://github.com/ARMmbed/mbed-os/blob/master/targets/targets.json#L3506-L3516 The annoying part is that it is tied to DAPLINK on the NRF52. If you use JLINK, flow control has to be disabled. So in that sense it is not really a hardware setting. Usually the NRF52_DK board is shipped with JLINK as default. But in our CI it is using DAPLINK. |
Yes, I believe so.
I agree. However, our users would like to keep everything in custom_target.json. |
I don't really follow that, and this feels like splitting hairs in a way that prevents the |
I have yet to see a justification for this statement. I still consider |
It's a limitation of the config system as it's implemented ATM. You may think that it could be as easy as just "flipping a switch" but the current config system is structured around the assumptions that:
This proposed flexibility breaks all 2/3 of these assumptions, and would require a pretty big rewrite of the config system (which might be a good thing, it's currently extremely difficult read/understand) |
I'm with @theotherjimmy on this one. Flow control should be defined at the target level. Even more specifically at the BOARD level. We have custom NRF boards that do not break out flow control lines and therefore do not support flow control. |
It sounds like if I rename the flow control pins to STDIO_UART_RTS and STDIO_UART_CTS as suggested by @kjbracey-arm then everyone gets something they want. Flow control will be disabled by default so @loverdeg-ep doesn't have to worry about disabling it anymore and @theotherjimmy can enable flow control in targets.json if he wants. |
It sounds like @theotherjimmy and I are in agreement - this would structually fit as a proper target JSON setting, in the base I agree with the config docs example that the term This leaves the
I'm the person who put it in as Arguably all those STDIO_UART pin selection defines could also be Target JSON settings. Something for a later PR, perhaps. |
@kjbracey-arm I've added the console settings to the base target. Please take a look! |
targets/targets.json
Outdated
}, | ||
"console-uart-flow-control-type": { | ||
"help": "Console hardware flow control type. Value must be of type SerialBase::Flow.", | ||
"value": "SerialBase::RTSCTS" |
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.
Yay, looks like the correct place.
I'd prefer to have a single setting here, rather than setting + enable. Not sure what @theotherjimmy thinks.
We should avoid the "SerialBase::" prefix - just enumerate the valid token-type strings, and the C++ code can add prefixes or otherwise detect as required.
If you ever need special compile-time behaviour for certain settings rather than simple passthrough, using simple identifiers makes that possible. (Compare config changes done in #6566 for channel band names)
So one option with valid values null
, "RTS"
, "CTS"
and "RTSCTS"
? Then for the current simple case you just #ifdef
on that, rather than #if
on the enable, and it leaves open the door for future concat-type trickery. If you did that trickery now, you could specifically detect "Disabled"
, but seems pointless.
Some platforms have interface chips with hardware flow control enabled by default. This commit adds configurable flow control to STDOUT. Usage: * Define pin names STDIO_UART_RTS for Rx-flow-control and STDIO_UART_CTS for Tx-flow-control. * Set target.console-uart-flow-control. Valid options are: null, RTS, CTS, and RTSCTS.
@kjbracey-arm That should be it. |
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. Would like a second opinion from @theotherjimmy
# elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS | ||
console.set_flow_control(SerialBase::CTS, NC, STDIO_UART_CTS); | ||
# elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS | ||
console.set_flow_control(SerialBase::RTSCTS, STDIO_UART_RTS, STDIO_UART_CTS); |
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.
Was originally thinking this would use concat(FlowControl, MBED_CONF_TARGET_CONSOLE_UART_FLOW_CONTROL)
and SerialBase::MBED_CONF_TARGET_CONSOLE_UART_FLOW_CONTROL
, but yes, guess we should be spelling it out like this to not reference the CTS/RTS we're not using, so that's not necessary.
"bootloader_supported": false, | ||
"config": { | ||
"console-uart-flow-control": { | ||
"help": "Console hardware flow control. Options: null, RTS, CTS, RTSCTS.", |
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.
Should it be including quotes in the help? Last 3 options are JSON strings.
/morph build |
Build : SUCCESSBuild number : 1758 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 1395 |
/morph export-build |
Test : FAILUREBuild number : 1565 |
Exporter Build : SUCCESSBuild number : 1398 |
/morph test |
1 similar comment
/morph test |
Test : SUCCESSBuild number : 1569 |
Test : FAILUREBuild number : 1570 |
/morph test |
@studavekar Can you check the errors, if we shall track this issue with echo for kw24d and report it? I checked the logs, in the last 20 runs, few reported similar failure and dont see any issue reported. |
Test : SUCCESSBuild number : 1578 |
Description
Some platforms have interface chips with hardware flow control
enabled by default. This commit adds configurable flow control to
STDOUT.
Usage:
STDIO_UART_CTS for Tx-flow-control.
Pull request type
[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change