Skip to content

Conversation

@jhedberg
Copy link
Member

@jhedberg jhedberg commented Oct 30, 2024

Most boards set zephyr,bt-mon-uart to point at the same device as zephyr,console. It's still useful to have the possibility of having these as two different devices, however it's also useful to fall back to the UART console in case a dedicated monitor UART hasn't been specified.

This also ensures that the fallback only happens if the console UART isn't enabled, but a DT chosen property exists for it. Additionally, we now get a user friendly error in case the Bluetooth UART monitor feature has been enabled in Kconfig but there isn't a suitable UART available for it in devicetree.

rugeGerritsen
rugeGerritsen previously approved these changes Oct 30, 2024
@alwa-nordic
Copy link
Contributor

I don't know if it's right to treat zephyr,console as a free-for-all. It is reserved for the console driver.

* - zephyr,console
- Sets UART device used by console driver

At the very least, we should only grab it if CONFIG_UART_CONSOLE=n. Otherwise, we will clobber the console's UART output with binary data. What do you think?

Is there a way to ensure only one driver grabs a DT device?

@alwa-nordic
Copy link
Contributor

alwa-nordic commented Oct 31, 2024

Most boards set zephyr,bt-mon-uart to point at the same device as zephyr,console.

Some wild thinking: Wouldn't it be better if we made it so btmon is not enabled by a kconfig, but rather by the presence of the zephyr,bt-mon-uart DT chosen? Boards should define zephyr,bt-mon-uart to enable btmon by default, and only then. I can see a need to parameterize devkit boards with "functionality switches", but this logic should be explicit in the board subsystem, and it should be such that zephyr,bt-mon-uart chosen does not exits when not enabled. And when it exists, it should give exclusive access to a device.

@jhedberg
Copy link
Member Author

jhedberg commented Oct 31, 2024

@alwa-nordic all good points. Admittedly I was looking for a quick fix here for the fact that I realized none of the Silabs boards set a zephyr,bt-mon-uart chosen property. The idea of removing the prompt (user settability) from the Kconfig option and instead setting it based on the existence of the chosen property sounds like a clean solution, however then it's fair to argue that CONFIG_UART_CONSOLE should also be enabled the same way.

Either way, we do have issue independent of this PR, since if you go and set Bluetooth logs to use BT_MONITOR it does not disable UART_CONSOLE, which means that you get both drivers on most boards enabled and trying to use the same device.

@jhedberg
Copy link
Member Author

jhedberg commented Oct 31, 2024

At the very least, we should only grab it if CONFIG_UART_CONSOLE=n. Otherwise, we will clobber the console's UART output with binary data. What do you think?

I've updated the PR accordingly, and I think this may be a worthwhile short-term improvement. Longer term (post-4.0) we could look into enabling these Kconfig options based on the existence of DT chosen properties.

@jhedberg jhedberg force-pushed the bt_mon_console branch 2 times, most recently from 78c583d to edcc069 Compare October 31, 2024 21:31
@jhedberg jhedberg changed the title Bluetooth: Host: Use console when zephyr,bt-mon-uart isn't specified Bluetooth: Host: Fix monitor UART selection when zephyr,bt-mon-uart isn't specified Oct 31, 2024
@jhedberg jhedberg changed the title Bluetooth: Host: Fix monitor UART selection when zephyr,bt-mon-uart isn't specified Bluetooth: Host: Fix monitor UART selection Oct 31, 2024
Most boards set zephyr,bt-mon-uart to point at the same device as
zephyr,console. It's still useful to have the possibility of having these
as two different devices, however it's useful to fall back to the UART
console in case a dedicated monitor UART hasn't been specified.

This also ensures that the fallback only happens if the console UART isn't
enabled, but a DT chosen property exists for it. Additionally, we now get a
user friendly error in case the Bluetooth UART monitor feature has been
enabled in Kconfig but there isn't a suitable UART available for it in
devicetree.

Signed-off-by: Johan Hedberg <[email protected]>
@jhedberg jhedberg added this to the v4.0.0 milestone Oct 31, 2024
@mmahadevan108 mmahadevan108 merged commit d1a3f4f into zephyrproject-rtos:main Nov 1, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants