Commit graph zephyr/drivers/console
Author SHA1 Message Date
Aric Radzin
c4ccaa5216 drivers: console: uart_mcumgr: Fix async RX timeout Kconfig
CONFIG_MCUMGR_TRANSPORT_UART_ASYNC=y fails to build unless the
unrelated CONFIG_UART_CONSOLE_MCUMGR=y is also set. The RX timeout added
by commit 3b9cd7b9cb ("drivers: console: uart_mcumgr: Add async
timeout") is defined under UART_CONSOLE_MCUMGR, the UART console's
MCUmgr passthrough, so CONFIG_UART_CONSOLE_MCUMGR_ASYNC_RX_TIMEOUT_US
is undefined in any other configuration.

Move the option next to the other MCUmgr UART async options as
MCUMGR_TRANSPORT_UART_ASYNC_RX_TIMEOUT_US, under
MCUMGR_TRANSPORT_UART_ASYNC, which guards the driver code that uses
it. The prompt, default and help text are unchanged. The option has
not been in a release, so it is renamed without a deprecation period.

Tested by building samples/subsys/mgmt/mcumgr/smp_svr for
nrf52840dk/nrf52840 with serial.conf and the asynchronous UART API,
which fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-12 23:33:59 +02:00
Aric Radzin
a1e8d6f97c mgmt: mcumgr: transport: Deprecate UART and shell MTU Kconfigs
CONFIG_MCUMGR_TRANSPORT_UART_MTU and CONFIG_MCUMGR_TRANSPORT_SHELL_MTU
only set the value returned by the get_mtu callbacks of the UART and
shell transports, which the SMP layer does not use. Serial frames are
limited to MCUMGR_SERIAL_MAX_FRAME (127) bytes and the reassembled
packet size is limited by CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE.

Deprecate them along with the callback. They keep their default and
keep working until removal, and emit a deprecation warning when changed
from the default (on a separate symbol, due to Kconfig limitations).

Also fix the UART_MCUMGR_RX_BUF_COUNT help text, which related the
buffer count to the UART MTU. Each receive buffer holds one line until
it is decoded into the packet buffer, so the count only limits how many
fragments can be queued.

Fixes #54106

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-09-30 19:42:14 +02:00
Måns Ansgariusson
0bde5ccbeb lib: ring_buffer: drop select/depends on RING_BUFFER
The slim ring buffer API is now header-only and always available and the
tree has already migrated from the _claim/_finish API, so the RING_BUFFER
symbol no longer gates any code.
Remove the now-redundant "select RING_BUFFER" and CONFIG_RING_BUFFER=y
entries across drivers, subsystems, samples and tests.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-09-16 07:29:22 +02:00
Krzysztof Chruściński
3a9e2cfd7f drivers: console: uart: if disabled, avoid pm_device_runtime_put_async
Use pm_device_runtime_put if CONFIG_PM_DEVICE_RUNTIME_ASYNC=n.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-09-11 05:25:09 -04:00
Anas Nashif
65aeeaa122 drivers: console: drop the duplicated console hook prototypes
MISRA C:2012 Rule 8.2 requires every parameter in a function type to be
named, including the parameters of function pointer parameters.
The WCH SDI and Whisper console drivers re-declared the stdout and
printk hook install functions locally instead of including the headers
that already declare them, and both copies left the hook parameter
unnamed. Include <zephyr/sys/libc-hooks.h> and
<zephyr/sys/printk-hooks.h> instead. The Whisper console keeps its no-op
fallbacks for the configurations where the hooks are not built in.

Name them after the arguments the documentation or the
definitions already use. No functional change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-19 11:19:38 +02:00
2b41462310 drivers: console: add a QingKe Debug Module console driver
The QingKe V2A, V2C, and V4C have a Debug Module with two data
registers `data0` and `data1`. These can be used with SDI compatible
debuggers such as `minichlink` to send console data to the host.

Add a console driver communicates with the host and fails gracefully
if the driver is enabled but the debugger is not connected.

Compared to the UART console, the debug console uses 916 bytes less
flash and frees up a UART.

Tested on the ch32v006evt and bluepillplus_ch32v203. To test, add
`&sdiconsole { status = "okay"; };` to the board Devicetree, set
`zephyr,console = &sdiconsole`, and enable the driver.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2026-06-22 14:25:42 +02:00
Fin Maaß
4d859419d9 drivers: serial: don't check return value of uart_irq_update()
Remove return value checks of uart_irq_update().
Needed for changing it's return value to void.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-19 17:46:51 -04:00
Egill Sigurdur
16ac4a5b78 kernel: mem_slab: add K_MEM_SLAB_DEFINE_TYPE for automatic alignment
Introduces K_MEM_SLAB_DEFINE_TYPE() and K_MEM_SLAB_DEFINE_STATIC_TYPE()
helpers to allow the user to declare slabs for types without having to
manually ensure the alignment is correct.

Manual slab alignment was very error-prone and this change fixes several
instances of misalignment that would be trapped by the undefined
behavior sanitizer when running on 64-bit targets.

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2026-05-07 18:09:41 -05:00
Jamie McCrae
3b9cd7b9cb drivers: console: uart_mcumgr: Add async timeout
Adds a timeout which is non-0 for this driver, Kconfig based on
commit by Jordan Yates:
  95d8deb572

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-05-05 14:07:17 -05:00
Måns Ansgariusson
bde9f88ad1 drivers: console: switch from ring_buf_item to ring_buf
This commit updates the ipm_console_receiver driver to use the standard
ring_buf API instead of ring_buf_item*.

Since the ipm_console driver operates at the byte level, there is no need
to use the item-level API. This makes way for the removal of ring_buf_item
api in the future.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-04-29 16:28:23 -04:00
Tahsin Mutlugun
9a8657193a arch: xtensa: semihost: Add simulator support
Add semihosting for Xtensa Instruction Set Simulator (ISS) via `simcall`
instruction.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2026-04-23 13:12:03 -04:00
Daniel Leung
c32c608615 console: add driver for consoleio in Whisper simulator
This adds a very simple output only console driver for
the consoleio provided by Whisper ISS for simulating
SweRV SoCs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-03-23 08:56:34 -04:00
Joakim Andersson
9ec3b06186 drivers: console: Do not add newline when flushing buffer
Do not add a newline when flushing the buffer to the host terminal.
The caller may not want these newlines to be added, and the host
terminal can handle line wrapping on its own.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2026-03-06 21:39:17 +01:00
Joakim Andersson
2b16db9abd drivers: console: Add buffer size configuration for posix console stdout
Add buffer size configuration for posix console stdout buffer.
This allows to increase the buffer size for the posix console, which is
needed to avoid message flushed in the middle of ansi escape sequences.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2026-03-06 21:39:17 +01:00
Jamie McCrae
d5df08a1cc mgmt: mcumgr: transport: uart: Add support for non-console raw mode
Adds support for using MCUmgr over UART (not via shell) in a raw
mode which does not include base64 and other SMP over console
encoding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-27 10:23:45 -06:00
Jamie McCrae
891c2e3a9c drivers: console: kconfig: Fix MCUmgr names
Fixes the text case used for MCUmgr

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-27 10:23:45 -06:00
Fin Maaß
8a862f4ee8 drivers: console: uart: use uart_irq_rx_ready directly
as we are only handeling rx interupts, we don't need
to call uart_irq_is_pending to check, we can just directly
use uart_irq_rx_ready.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 13:59:12 -06:00
Fin Maaß
92484cbc06 drivers: console: don't use irq functions outside
don't use uart irq api functions outside a
interrupt.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 13:59:12 -06:00
Jisheng Zhang
1292d6e11a drivers: console: support building for SoCs with no MMU
The device_map() is not defined for SoCs with no MMU, add the
device_map() macro when !DEVICE_MMIO_IS_IN_RAM to support building for
SoCs with no MMU.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
2025-12-08 13:15:53 -05:00
Josuah Demangeon
30950b888d style: drivers: sort Kconfig and CMake includes
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Jiafei Pan
04c9da22d7 drivers: ram_console: fix code typo
It should use semicolon.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-10-15 12:03:51 +03:00
Henrik Brix Andersen
3eedebe031 drivers: console: posix_arch_console: remove build warning
Remove build warning when building the posix_arch_console driver with
CONFIG_PRINTK=n and CONFIG_STDOUT_CONSOLE=n.

Fixes: #93790

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-07-29 08:51:32 -04:00
Mike Szczys
5f1e9a3523 drivers: uart_mcumgr: log warning when smp drops data
Add warning logs when data is dropped on the serial transport by the smp
system due to buffer overrun.

Signed-off-by: Mike Szczys <mike@golioth.io>
2025-07-23 09:32:06 +02:00
Daniel Marjamäki
eb80530618 sca: Fix undefined behavior during preprocessing
According to the C standard it is undefined behavior to use preprocessor
directives inside macro invocations.

Cppcheck stops when it see this UB with an error message, and so this
change will improve Cppcheck analysis

This is a refactoring to fix UB, no logical change is intended.

Signed-off-by: Daniel Marjamäki <daniel.marjamaki@cppchecksolutions.com>
2025-06-27 14:14:35 +02:00
Daniel Mangum
8e037fd89a drivers: console: uart_mcumgr: rename callback
Updates uart_mgumgr_recv_cb to uart_mcumgr_recv_cb to reflect the context
in which it is used.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2025-04-22 09:58:40 +02:00
Jordan Yates
826e598218 console: winstream: add missing Kconfig dependency
Add a missed dependency to all sub-symbols of `WINSTREAM_CONSOLE`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-15 13:08:03 +01:00
Anas Nashif
57b8b05221 console: winstream: fix conditional
should be CONFIG_SOC_FAMILY_INTEL_ADSP and not SOC_FAMILY_INTEL_ADSP.

Partially fixes #83636

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-01-08 19:11:29 +01:00
Andy Ross
14418a7f39 drivers/console: Add static buffer feature to winstream_console
The winstream code itself is reasonably generic, but the console
integration was written to the intel_adsp memory window driver only,
as that was the only consumer.

Add an alternative that allows the winstream to be pointed to by a
linker symbol instead.  The platform layer is responsible for putting
it where it needs to go.

Also includes a 20-byte "descriptor" recodr (with a very large magic
number) in the binary that points to the winstream, for the benefit of
external tooling that needs to find it at runtime.

Signed-off-by: Andy Ross <andyross@google.com>
2025-01-06 20:33:04 +01:00
Giancarlo Stasi
2f8af56042 drivers: console: rtt_console: use Segger recommended write API
Use recommended write API that internally locks RTT usage and checks
if the RTTcontrol block initialization is done.

Signed-off-by: Giancarlo Stasi <giancarlo.stasi.co@gmail.com>
2024-08-12 10:14:34 +02:00
Fabio Baltieri
f1a639ca9f console: ipm_console_sender: fix function naming camel case
Should be console_out not consoleOut.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-08-01 16:49:08 +01:00
Fabio Baltieri
e466efaf74 libc, console: declare __stdout_hook_install in libc-hooks.h
Declare __stdout_hook_install in libc-hooks.h and use it in the console
drivers rather than redeclare it every time.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-08-01 16:49:08 +01:00
Fabio Baltieri
ef14c9b867 lib: os: add a header for printk hook functions
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.

Move the documentation into the header and also unify the way that
console drivers call the function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 10:41:01 +03:00
Hou Zhiqiang
1cd37f21f3 drivers: ram_console: add option to link console buffer to given section
Currently, the ram_console buffer is defined as a global var, its
address is determined during the building and may be changed when
code update. This is not a problem if the ram_console is just used
in debug purpose.

While in the heterogeneous SoCs, there can be multiple MPU Cores
and several MCU cores, it can run multiple OS/bare-metal instances
on these cores, but the UART ports may be not enough, so the
ram_console can be leveraged. To make it easy to use, it's better
make the console buffer fixed and predefined.

This patch adds a option to link the console buffer to a given
section, through the "zephyr,memory-region" device tree node, then
the address can be known from the device tree node and easy to
check from other cores running Linux/U-Boot.

To use this option, the chosen property 'zephyr,ram-console' must
be added, the following is a example:

	chosen {
		zephyr,ram-console = &ram_console;
	};

	ram_console: memory@93d00000 {
		compatible = "zephyr,memory-region";
		reg = <0x93d00000 DT_SIZE_K(4)>;
		zephyr,memory-region = "RAM_CONSOLE";
	};

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
2024-06-12 17:09:24 -05:00
Hou Zhiqiang
209568eabe driver: ram_console: leave one byte from the defined buffer size
Leave one byte from the CONFIG_RAM_CONSOLE_BUFFER_SIZE to ensure
the NULL-termination.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
2024-06-12 17:09:24 -05:00
Anas Nashif
5df1df2e7a Revert "drivers/console/xtensa_sim_console: force \r\n byte sequence"
This reverts commit 99aa65c725.

With this change, various simulators fail with no output with this
change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-06 20:06:26 -04:00
Bjarki Arge Andreasen
79640aea09 drivers: console: remove uart_mux and gsm_mux
Remove the deprecated uart_mux and gsm_mux modules and all of
their configurations/dependencies across zephyr.

Optimally uart_mux and gsm_mux would be removed in their own
respective PRs, but the two modules are directly coupled, so
to preserve bisectability, they must be removed together.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-29 10:49:08 -07:00
Yong Cong Sin
bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Filip Kokosinski
99aa65c725 drivers/console/xtensa_sim_console: force \r\n byte sequence
Force `\r\n` byte sequence for newline for the Xtensa simulator console
driver. This effectively mirrors the behavior of the UART console driver.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2024-05-15 09:33:27 +02:00
Gerard Marull-Paretas
b548a73e79 drivers: console: uart_mux: fix incorrect usage of configuration API
First, the API ops are available only if
CONFIG_UART_USE_RUNTIME_CONFIGURE=y, but the driver was not guarding the
code. Also, according to the API specs, these functions are optional,
and the interface already returns -ENOSYS if they are not implemented.
To solve both problems, just drop the dummy implementation.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-02-06 19:33:42 +01:00
Anas Nashif
d7678f1694 xtensa: move to use system cache API support for coherency
Remove custom implementation and use system cache interface instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-02-03 13:42:33 -05:00
Anas Nashif
a1e03d079a console: winstream: define as a proper console
eb2e5de01c made this a console driver but without adding the needed
hooks. This adds the hooks to support the console interface.

Fixes #65987
Fixes #66264

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-31 19:19:19 +01:00
Erwan Gouriou
b98c7942ca pm: console: Use async runtime put to minimize resumption/suspension
When device runtime pm is enabled on console device, do not suspend
device synchronously on each char transmission, but rather use asynchronous
suspension request.
This will save useless and costly suspension/resumption procedure, which
can involve uart device clock suspension but also pin configuration
to sleep state (which itself involves gpio clock activation ...).

On STM32, using asynch device suspension allows to divide by 3 the
transmission time of a character chain.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-01-18 10:51:10 +01:00
Jordan Yates
d131981257 console: uart: remove pm_device_runtime_is_enabled check
`pm_device_runtime_get` and `pm_device_runtime_put` have returned `0`
when device runtime PM is not enabled since #56222. Manually checking
the state is no longer required.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-06 18:00:21 -05:00
Flavio Ceolin
eb2e5de01c console: winstream: Select CONSOLE_HAS_DRIVER
Select symbol CONSOLE_HAS_DRIVER when enabling WINSTREAM_CONSOLE.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-06 17:57:47 -05:00
Flavio Ceolin
be1720872c console: Fix Kconfig dependency for xtensa sim
Xtensa simulator console should not be enabled when the target is using
winstream console, otherwise we will have multiple definitions of the
same function.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-06 17:57:47 -05:00
Jakub Michalski
56bb73d7c7 console: fix '\r' and '\n' handling in uart_console_isr()
Receiving uart messages like: "\r*\n*\n" ('*' is a wildcard here) resulted
in invalid echo and invalid console_getline() output.
For example after receiving "\rabc\nd\n" uart_console_isr() echoes
"\r\nabcd\r\n" (note that "\r\n" before 'd' is missing) and after calling
console_getline() twice we received "" and "abcd".

uart_console_isr() changes single occurences of '\n' and '\r' to "\r\n" and
to avoid outputting "\r\n\r\n" after receiving "\r\n" it keeps track of the
last character. But it was tracking only the control characters not all
characters so in case of inputs like "\r*\n" the '\n' was omitted because
the last tracked character was '\r'.

Its fixed by tracking last character no matter of its type

Signed-off-by: Jakub Michalski <jmichalski@internships.antmicro.com>
Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
2023-11-29 17:16:35 -05:00
Jamie McCrae
1b364c1422 drivers: console: uart_mcumgr: Skip reading FIFO during setup
Drops calling the UART FIFO read function during the setup
function (when not in async mode) which could cause issues on
some devices since this function is not called in an ISR.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-27 09:12:36 +00:00
Andy Ross
3620e6b969 drivers/console: xtensa_sim_console: implement arch_printk_char_out()
This is an older driver and didn't support the weak
arch_printk_char_out() hook, which is a link-time symbol that allows
logging to work from the first instruction.  Some drivers can't do
that because they need an initialization step, but this one works
great.

Signed-off-by: Andy Ross <andyross@google.com>
2023-11-21 15:49:48 +01:00
Mariano Goluboff
45f664abf5 drivers: console: fix dropped characters when using debug hooks
When using console debug server hooks, not all characters are
processed if the server hook returns non-zero for one character
while there are other characters in the buffer. This is seen
when using a fast console (like USB) where multiple characters
come in before the ISR is called. Fix it by continuing to
process characters instead of returning from the ISR with
characters still in the buffer.

Fixes: #64661

Signed-off-by: Mariano Goluboff <mariano.goluboff@nordicsemi.no>
2023-11-09 15:32:10 +01:00
Anas Nashif
4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00