Commit graph zephyr/subsys/shell
Author SHA1 Message Date
Benjamin Cabé
e5c2d7f4fe shell: kernel: remove deprecated log_level command
Remove the `kernel log_level <module> <severity>` shell subcommand. It
has warned at runtime on every invocation since commit 8207a05304
("shell: modules: kernel_service: deprecate log_level"), first released
in Zephyr 4.1, so it is well past the two-release deprecation window.
The `log enable <severity> <module>` command from the logging command
set provides the same functionality.

The command was fully self-contained in log-level.c and registered
through KERNEL_CMD_ARG_ADD, so removing the file and its CMakeLists.txt
entry drops it entirely; no other code referenced it.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
2026-09-02 15:30:08 +02:00
Måns Ansgariusson
8c9ad65a52 shell: backends: Update ring_buf usage to new zero-copy API
This commit updates the usage of ring_buf to utilize the new
put_ptr/commit/get_ptr/consume pattern instead of the traditional
claim/finish approach. This change is part of a larger refactor aimed at
streamlining the ring_buf API and improving its efficiency.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-08-25 09:00:03 +02:00
Krzysztof Chruściński
fa563a5658 shell: backends: uart: Fix asynchronous API
Fix regression introduced by 069d3a7652. async_read() function
was allocating new buffer even when UART was not expecting it.
Buffer pool was quickly drained and shell was unresponsive.
Added additional check to attempt to allocate new a new buffer
only if UART is waiting for new buffer (UART is disabled or there
is unhandled RX buffer request).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-08-23 14:42:00 -04:00
Aziz Sellami
0a99b8611f shell: shell_help: handle intentional indentation
The whitespace-skipping loop in formatted_text_print() advances past
every character for which isspace() returns non-zero. Because isspace()
matches both newlines and ordinary spaces, any leading spaces that
follow
a '\n' in a help string were being discarded, stripping intentional
indentation from continuation lines.

Fix this by breaking out of the loop immediately after consuming the
'\n'. The newline itself must still be skipped to prevent an empty line
from being printed, but the spaces that follow it on the next line are
part of the author's intended layout and must be preserved.

Before this fix, a help string such as:

  "[-v] [-n <count>]\n"
  "    Options:\n"
  "        -v          verbose output\n"
  "        -n <count>  number of iterations (default: 1)"

was rendered as:

  test - [-v] [-n <count>]
         Options:
         -v          verbose output
         -n <count>  number of iterations (default: 1)

After this fix:

  test - [-v] [-n <count>]
             Options:
                 -v          verbose output
                 -n <count>  number of iterations (default: 1)

Signed-off-by: Aziz Sellami <aziz.sellami@nxp.com>
2026-08-14 15:14:18 +02:00
Saksham Gupta
c684962b84 shell: replace deprecated k_sleep with k_msleep
This replaces the older k_sleep(K_MSEC(time)) pattern with the modern,

more efficient k_msleep(time) API. This prevents double-macro expansion

overhead and adheres to Zephyr's preferred timeout style.

Signed-off-by: Saksham Gupta <saksham77779@gmail.com>
2026-08-05 23:26:50 +01:00
Jakub Rzeszutko
3268045e90 shell: fix state race between shell_stop() and state_collect()
shell_stop() read/wrote sh->ctx->state without taking the shell lock.
If a command was still running on the shell thread, state_collect()
would finish with an unconditional state_set(ACTIVE), clobbering the
SHELL_STATE_INITIALIZED shell_stop() had just set. The log backend
was left disabled and shell_start() would then fail with -ENOTSUP.

Fix by having shell_stop() take the same lock shell_thread() already
holds during shell_process()/state_collect(), like shell_start()
already does. Returns -EBUSY if the lock is busy.

Fixes #115019

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2026-08-05 14:10:05 +01:00
Anas Nashif
0fd394521d shell: telnet: document that the backend is unauthenticated
The telnet backend exposes the full Zephyr shell over an unauthenticated,
unencrypted TCP port, which is equivalent to granting full device control
to anyone who can reach the port. There is no in-tree authentication to
switch on, so add the security warning to the Kconfig help, mirroring the
guidance already given for MCUMGR_GRP_SHELL.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-03 15:05:19 -04:00
Etienne Carriere
f01beaed95 shell: use diamond include for non-local header files
Use #include <> instead of #include "" to include a header file which path
is not relative to the directory path of the file emitting the #include
directive.

This change was made running scripts/check_quoted_includes.py script
proposed in https://github.com/zephyrproject-rtos/zephyr/pull/112135
with the Linux shell command below and manually selecting the applicable
changes:
$ find subsys/shell/ -type f -exec \
    ./scripts/check_quoted_includes.py -w {} \;

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-07-31 14:52:03 -04:00
Krzysztof Chruściński
069d3a7652 shell: backends: uart: Fix case when needs to be re-enabled
If RX buffers are not provided on time it may be possible that device
enters disabling phase. Code was attempting to re-enable the UART
immediately when that is detected but it fails if UART is not yet
disabled. If providing next buffer fails then just release that
buffer and wait for UART_RX_DISABLED event. Re-enable UART from
that event.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-31 14:51:49 -04:00
Phil Hindman
3dfe2a9743 shell: backends: Use atomic_set in tx_disable path
atomic_set is used to access tx_busy in the irq_write function (in order to
get atomic exchange behavior) so we should also access it atomically here
(even though we don't need atomic exchange behavior here).

Signed-off-by: Phil Hindman <phindman@xes-inc.com>
2026-07-31 13:04:48 -04:00
Sandro Scherer
2020e4c7d4 shell: fix history UB applying zero offset to null pointer
node is NULL if shell history is empty.
Applying a zero offset to NULL is undefined behavior.

Signed-off-by: Sandro Scherer <sandro.scherer@siemens.com>
2026-07-31 13:04:13 -04:00
Chingbin Li
e60464c5d6 shell: add thread id notice to help description of subcommand 'unwind'
In most usage scenarios, the thread id parameter is useful for unwind
subcommand. For example, use the 'kernel thread list' command to
locate the <thread id> of the target thread, then check the call trace
with 'kernel thread unwind <thread id>'.
At least, users should be reminded that this command accepts the
<thread id> parameter to check the call trace of any thread.

Signed-off-by: Chingbin Li <liqb365@163.com>
2026-07-31 13:03:52 -04:00
Adrien Ricciardi
209d82ece8 shell: Increase argc count for CAN shell
The "send" command of the CAN shell allows to send also CAN FD frames,
which can contain up to 64 bytes of data.

Increase the shell argc count to be able to send a fully complete CAN FD
frame with all the payload.

The exact count of argc is determined by the following command, which
uses extended ID, enables CAN FD and bit rate switch, and specify the
maximum payload size :

can send can0 -e -f -b 12345678 00 01 02 03 04 05 06 07 08 09 10 11 12 13
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2026-07-28 11:29:19 +01:00
Alberto Escolar Piedras
a408be9067 shell: telnet: Initialize addr to avoid unitialized use warning
Without optimizations the compiler does not follow how addr may be used,
only that it passed to zsoc_accept. And warns that it may be used
unitialized. Let's initialize it to zero to silence this warning.

If optimizations are used, the compiler should anyhow drop the
initialization.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-07-24 12:39:28 -07:00
Nicolas Pitre
5188d5009b kernel: timeout: add min-heap backend
Add a binary min-heap as a selectable timeout backend alongside the
sorted delta list, plugging into the backend abstraction rather than
forking timeout.c. Pending timeouts are kept in a min-heap keyed on
absolute expiry tick; insertion and arbitrary removal are O(log n),
which scales better than the delta list's O(n) insertion when many
timeouts are pending.

The backend is a new kernel/timeout_minheap.h: the heap instance (a
min_heap_ref from the previous commit), its comparator and the
z_timeout_q_*() operations, included only by timeout.c (after curr_tick)
so the whole backend stays private to that translation unit. struct
_timeout gains the abs_ticks + heap_handle representation, selected by
Kconfig (the delta list's node + dticks is the #else), with the common
fn pointer kept as a shared trailing member; the per-node helpers in
timeout_q.h grow a matching min-heap variant. The kernel shell thread
dump prints the backend's raw scheduling field (dticks or abs_ticks)
under #ifdef.

Because the shared z_add_timeout() already applies the post-#107452
conditional tick round-up, the heap inherits it: the backend's insert
simply stores abs_ticks = curr_tick + dticks. Likewise in-flight
handler synchronization (PR #109977) lives in timeout.c, so the heap
node carries no ANNOUNCING/ABORTED sentinels -- "not queued" is just
heap_handle.idx == 0.

The backend is EXPERIMENTAL, depends on TIMEOUT_64BIT (absolute ticks
need 64-bit precision), and uses a fixed-capacity heap
(CONFIG_TIMEOUT_HEAP_MAX_ENTRIES) whose overflow is a fatal error.

The min-heap algorithm, struct fields, Kconfig and capacity model are
derived from Sayooj K Karun's min-heap timeout subsystem (#106013),
reworked here to fit the pluggable backend and the current in-tree
in-flight-handler synchronization.

Co-authored-by: Sayooj K Karun <sayooj@aerlync.com>
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-09 18:02:12 -04:00
Flavio Ceolin
4e5f155428 shell: Reject zero terminal size from VT100 reply
A peer replying to the ESC[6n cursor-position query with ESC[0;0R
causes terminal_size_get() to store terminal_wid = 0. Any later
shell-core helper that divides or moduloes by terminal_wid then
faults with a divide-by-zero.

Validate the parsed coordinates and treat zero as a parsing failure.
cmd_resize() already restores CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH/
HEIGHT on error, so a forged reply now behaves the same as a
terminal-response timeout.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2026-07-07 09:52:46 +02:00
Krzysztof Chruściński
6e1bb84e63 shell: remote: Append read-only strings by default
Read-only strings can only be skipped if shell main core has
access to the read only memory of the remote core. By default
assume that it has not access.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-07 09:50:47 +02:00
Etienne Carriere
64c41a237c shell: use <> to include Zephyr headers instead of ""
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.

This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
    `grep -rsl "#include \"zephyr/" subsys/shell/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 06:49:18 -04:00
Michael Zimmermann
e10af22991 tree-wide: replace usages of k_work_q thread with thread_id
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-29 22:17:45 -04:00
Jakub Topic
27cfd15888 shell: backends: uart: disable RX on async_uninit
async_uninit() was a no-op, so when the shell UART transport was
uninitialized, UART RX stayed enabled and the device remained active.
Call uart_rx_disable() in async_uninit to match async_init's rx_enable(),
so the UART is fully disabled on uninit.

Signed-off-by: Jakub Topic <jakub.topic@anitra.cz>
2026-06-26 13:01:42 -04:00
Anas Nashif
8104af619e typos: fix various typos under subsys/
Fix various typos.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Benjamin Cabé
df448d3d2a shell: name unused shell_thread parameters
Omitting the parameter name in a function definition is a C23 extension.
Fix this by naming second and third parameter in shell_thread function
definition to address compilation warning promoted to error in CI with
LLVM.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-06-09 22:53:27 +02:00
Phil Hindman
9d717a9161 shell: Move init code from the shell_thread to shell_init
Up to now, some initialization has been deferred from the shell_init
function (which starts the shell_thread) to the shell_thread function. When
using SHELL_AUTOSTART this is fine, but when autostart is disabled this
causes a race between the shell_thread and whatever thread eventually calls
shell_start, because shell_start needs initialization to have completed
before it runs.  So, move the remaining initialization code from the
beginning of the shell_thread to shell_init (before starting the
shell_thread).

Signed-off-by: Phil Hindman <phindman@xes-inc.com>
2026-06-09 19:56:07 +02:00
Sylvio Alves
511be4d07c shell: kernel thread stacks: add cpu affinity on smp
Display which CPU each thread and interrupt stack is running on when
SMP is enabled. Shows CPU ID as the last column for clarity and proper
alignment. On non-SMP systems, output remains unchanged.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-09 11:55:44 +02:00
Jakub Rzeszutko
79721b12dc shell: fix log output during shell_readline
Log messages arriving during shell_readline corrupt the input line
because the log backend does not account for the different line
layout in readline mode (no shell prompt, optional readline prompt).

Fix by checking readline_state in process_log_msg (immediate mode)
and shell_log_process (deferred mode) to properly erase and restore
the readline input line. Process deferred logs inside the readline
loop so they appear in real-time.

Introduce shell_readline_prompt_set() so command handlers can
register a prompt string that is printed at readline start and
restored after log output.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2026-06-08 21:28:47 -04:00
Jakub Rzeszutko
a2b12dc2ab shell: uart: fix SMP over async UART data handling
Fix four bugs in shell UART async backend when using
SMP (mcumgr) transport:
1. Use CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_TIMEOUT
   Kconfig value instead of hardcoded 10000 in
   rx_enable().
2. Consume all claimed bytes (blen) in
   uart_async_rx_data_consume(), not just shell
   bytes (sh_cnt). SMP-consumed bytes also need to
   be released from the async RX buffer.
3-4. Loop in async_read() to keep claiming data when
     SMP consumes all bytes, preventing data from
     getting stuck in the buffer until the next
     UART_RX_RDY event.

Fixes #98597

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2026-06-08 19:00:34 +02:00
Alberto Escolar Piedras
4e97be67b4 shell: Initialize to 0 placeholder for dynamic_get callback
Instead of relaying on the dynamic_get() callback initializing the whole
struct shell_static_entry *entry,
pre-initialize it to 0, so previous garbage in the stack does not cause
random behaviour.

The issue can be seen when running with valgrind, for example:
```
twister -p native_sim -T tests/drivers/comparator/shell/ --enable-valgrind
cmake -GNinja -DBOARD=native_sim ../tests/drivers/comparator/shell/
ninja
valgrind zephyr/zephyr.exe
```

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-05-29 23:36:58 +02:00
Nicolas Pitre
90d1963745 sys: util: move lowercase min/max/clamp to a new minmax.h
Since commit 37717b229f ("sys: util: rename Z_MIN Z_MAX Z_CLAMP to min
max and clamp"), <zephyr/sys/util.h> unconditionally defines function-
like macros named `min`, `max`, and `clamp` in the global namespace (in
C mode). util.h gets pulled in transitively by very broad headers,
including the POSIX layer's <pthread.h>, so any third-party C code that
uses these names as ordinary identifiers (e.g. XNNPACK's static `clamp`
helper and its public `clamp` struct field) fails to build as soon as
<pthread.h> is included.

Following the approach used by Linux, move the lowercase `min`, `max`,
`min3`, `max3`, and `clamp` macros (and their helpers) into a new
<zephyr/sys/minmax.h> header that has to be included explicitly by
source files that want them. util.h keeps the uppercase MIN/MAX/CLAMP,
so most code is unaffected; only the (much smaller) set of files that
actually use the lowercase variants needs to pick up the new include.

Fixes #107853.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-19 17:49:24 -04:00
Jukka Rissanen
d3dfbfb3d3 shell: aliases: Do not enable by default
As the aliases support will increase stack usage, turn the
feature off by default in order to avoid surprises with
tests and samples.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-12 08:57:40 +02:00
Jukka Rissanen
dd3fcffa1c shell: Add support for tab completion for aliased subcommands
Make sure user is able to tab complete aliased subcommands.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Jukka Rissanen
363c8a1581 shell: Add aliases support
Allow user to specify a file containing command name aliases.
The format of the file is:

    # This is an example aliases file. The file can have
    # comments on it.
    stacks="kernel thread stacks"
    foo=bar

There is "aliases" shell command that can show the current
list of aliases specified in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Jukka Rissanen
e22c29c8d4 net: ssh: server: Add multi instance support
Allow multiple incoming SSH connections if we are the server.
This is controlled by CONFIG_SSH_SERVER_SHELL_COUNT option, the
default value is 1 so only one simultaneous ssh connections by
default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
2736baba9c shell: Add ssh backend
Add ssh backend for client and server.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
57ce922032 shell: Check return code from api read()
Make sure to check the return code from sh->iface->api->read()
and bail out if there is an error. The issue was noticed in ssh
client testing where the ssh shell was terminated which then caused
a forever loop.

Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 15:00:15 +02:00
Krzysztof Chruściński
70389cf7ec shell: Extend shell with remote client support
Add option for remote shell client. Remote shell client is an
implementation of shell on the client core which supports
IPC communication with host shell implementation. It allows
to use host shell backends to execute commands on the remote
client. The remote client implementation takes much less
memory than the normal shell implementation.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Krzysztof Chruściński
aaf5bba2a0 shell: Move hexdump printing to shell_utils
In preparation for remote shell support, move hexdump printing to
the shell_utils.c file. Main shell.c file is not compiled for remote
shell client.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Krzysztof Chruściński
b5c9f03553 shell: Add compile time guards
Do not compile shell_help() implementation if CONFIG_SHELL_HELP=n.
In that case, empty inline function is implemented in the shell
header and it may fail to compile.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Krzysztof Chruściński
c61dfc6856 shell: backends: dummy: Add RX notification
When input buffer is written, notify the shell. It will wake the
shell thread which will process the input buffer.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Jakub Rzeszutko
79cf685dfe shell: prevent deadlock from non-yieldable context
shell_vfprintf can block on k_event_wait when the TX ring buffer is full.
Calling it from a non-yieldable context (ISR, spinlock, pre-kernel)
causes a deadlock.

Add a k_can_yield() check in shell_vfprintf as both an assert for debug
builds and a runtime guard that silently drops the output when called
from a context that cannot yield, preventing the deadlock regardless
of whether asserts are enabled.

Fixes: #103954

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2026-04-17 16:42:54 +01:00
Muhammad Waleed Badar
ab32cd6fb8 net: shell: add HTTP client shell commands
Add HTTP client shell commands under the 'net http' subcommand group.
Supports GET, POST, PUT, and DELETE methods.

Commands:
  net http get <url>
  net http post <url> <body>
  net http put <url> <body>
  net http delete <url>

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-04-14 22:22:41 -04:00
Nicolas Pitre
1c9955a060 pm: shell: hold sys_clock_lock() around timer driver calls
sys_clock_set_timeout() and sys_clock_elapsed() are now documented
as requiring the system clock lock to be held by the caller. Wrap
the calls in subsys/pm/pm.c, soc/nxp/rw/power.c and the kernel
shell thread list command with sys_clock_lock()/sys_clock_unlock().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-04-07 11:40:49 -05:00
Pieter De Gendt
7b0e88ac61 shell: backends: telnet: Use struct net_sockaddr_storage
A struct net_sockaddr should be considered an incomplete type, replace by
using net_sockaddr_storage.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-03-24 07:07:17 -04:00
Fabio Baltieri
d0067a18c9 shell: add missing dependency for KERNEL_THREAD_SHELL_UNWIND
The option needs a dependency to THREAD_MONITOR, fix a build breakage
with, for example:

west build -p -b nrf52dk/nrf52832 samples/subsys/shell/shell_module -- \
-DCONFIG_EXTRA_EXCEPTION_INFO=y -DCONFIG_THREAD_MONITOR=n

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-03-23 12:32:52 -05:00
Arthur Gay
099d0e0590 shell: websocket: Fix client disconnection handling
Don't rely solely on disconnect events to determine writability, since
the socket can drop at any time. A send() to a closed socket fails and
the resulting error reaches the shell thread, where a failing __ASSERT
causes a crash.

Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
2026-03-19 17:02:00 +01:00
Arthur Gay
164cf2c8e8 shell: websocket: Fix race condition
Guard the websocket shell backend's internal state with a mutex.
The disconnect callback executes on a different thread than the shell
and can interleave with sends, leading to writes on an invalid fd or
a disconnected socket.

Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
2026-03-19 17:02:00 +01:00
Alberto Escolar Piedras
f9002f02fc shell: backends: shell_telnet: Remove uses of net logging helper macros
These macros are private to the net subsystem, let's not use them in
other subsystems.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-03-17 18:21:28 -04:00
Pieter De Gendt
20d62fe4e0 shell: Add shell_readline helper
Introduce a helper function to wait for user input with a timeout.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-11 17:47:50 -06:00
Pieter De Gendt
186597eb99 shell: dummy: Add input buffer
Allow reading from the dummy shell backend, useful for testing purposes.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-11 17:47:50 -06:00
Pieter De Gendt
15b86499ce shell: devmem_service: Unmap virtual memory
WHen running the shell devmem dump command and CONFIG_MMU is enabled, the
virtual memory wasn't unmapped.

Call the device_unmap function to cleanup virtual memory resources.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-10 10:53:32 +01:00
Andreas Klinger
22ba487f3d shell: add new command zyclictest
- Name derived from Zephyr cyclictest
- Inspired by Linux realtime test program cyclictest
- Measure latency of interrupt service routine as well as thread with the
  help of the timer interrupt, of which the programmed point of time is
  known.
- Zyclictest thread is running in background while individual application
  under test can be running in foreground.

- The interval can be set up with optional argument -i. It should be at
  least double of expected worst case thread latency to get valid output.
  If this is not met the measurement needs to be repeated.
- The priority can also be set up. It should be the priority of the
  application which should run on the final product.
- The maximum size of the histogram is hard coded to 200 so far.

- After stopping measurement the maximum latency, number of errors /
  overflows and the histogram itself is printed.
- Histogram is printed in a form which is easy to be used by plotting
  programs like GNUplot or Python matplotlib.

- Example: One wants to know what is the expected maximum latency of a
  cooperative task with priority of -10.

  $ zyclictest start -i 400 -p -10

  $ # start your application test cases

  $ zyclictest stop

Count: 547329
                   IRQ  Thread
Max-Latency:        21      27
Errors:              0       0
Overflow:            0       0
Histogram:
...
 23                  0  547306
 24                  0       2
 25                  0       5
 26                  0       5
 27                  0       2

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2026-02-05 10:27:48 +00:00