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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
Setting the prompt to the empty string allows it to be hidden. This is the
intent of the shell command 'shell prompt off'. However, in the most recent
change to the prompt handling, this functionality was lost. Presumably,
the check for 'prompt_length == 0' was to avoid a NULL prompt. However,
NULL is already checked for. Remove the zero-length check and restore the
ability to set the prompt to the empty string.
Signed-off-by: Ryan Smith <elryno@elryno.com>
The bypass mode in shell.c transfers data in a loop and doesn't need
a large buffer. The previous code conditionally used
CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN which unnecessarily tied the bypass
buffer size to RTT configuration and could increase stack usage when
RTT buffer is configured larger.
This adds CONFIG_SHELL_BYPASS_READ_BUF_SIZE with a default of 16 bytes,
which is sufficient for the iterative read loop. A build-time assert
ensures the buffer doesn't exceed SHELL_STACK_SIZE.
Fixes: db9dccdc8a
Signed-off-by: Karel Blavka <karel.blavka@hardwario.com>
Move z_shell_backend_rx_buffer_flush() before state_set() in
shell_start() to prevent a race condition where incoming shell
commands could be lost.
Previously, the sequence was:
1. state_set() - prints the prompt
2. z_shell_backend_rx_buffer_flush() - flushes RX buffer
If the shell thread was preempted after printing the prompt,
the host could see the prompt and send commands. When the
thread resumed, z_shell_backend_rx_buffer_flush() would discard
those commands.
By flushing the RX buffer before printing the prompt, any
commands received after the prompt is visible will not be
affected by the flush operation.
Fixes#99674
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
In d45cd6716b the mayority of the
Zephyr codebased was changed to use the Zephyr native net_ prefixed
types, but some were forgotten.
Without this fix/change the code still builds as we are by now setting
CONFIG_NET_NAMESPACE_COMPAT_MODE. But when this is not set, things
fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Currently all drivers which uses a slot from the debug window have fragile
hardwired slot 'mapping', they are locked to use specific slots even if
there are free slots available for them to take.
The new API hides the management of the slots and descriptors and users
can ask, release or even seize slots that they want to use.
Add a new debug slot manager API and a new default no config option to
allow selection between the hardwired or dynamic debug slot management.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Replaces direct byte shifting and assignment with `sys_put_le16`,
`sys_put_le32`, and `sys_put_le64` to simplify the `memory_dump` function.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
To improve code clarity, use `shell_print` in place of `shell_fprintf`
with `SHELL_NORMAL` where appropriate.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
We're now checking if there is space prior to executing the loop body,
therefore guaranteeing this condition is never going to fire in a
single-threaded context.
Signed-off-by: Stuart Longland <stuartl@vrt.com.au>
Before calling `uart_poll_in`, check we have space to store the character
in the ring buffer beforehand. If we do, *then* poll for the character.
That way we don't miss out on serial traffic when our ring buffer is full
unless we fill our hardware ring buffer too.
Signed-off-by: Stuart Longland <stuartl@vrt.com.au>
Changes the type used in _system_heap extern declarations to use
k_heap instead of sys_heap.
Fixes#100530
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Allow passing some context to the shell bypass callback function by
providing a void pointer user data argument.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Set Log Level to Info when the Telnet socket reports ENETDOWN,
instead of logging an error each time the network is down.
Signed-off-by: Joel Schaller <joel.schaller16@gmail.com>
Let's use CONFIG_NATIVE_LIBC to detect builds with the host C library
instead of pressuming that any build targetting the POSIX architecture
uses it. This has not been the case for several years now, as we can
select different C libraries when targetting the POSIX architecture.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Summary:
As Zephyr getopt is not really compatible with Posix getopt, rename
Zephyr getopt to sys_getopt.
Background:
Zephyr getopt module was introduced in #31356 to be used by the shell.
Zephyr's getopt is not the standard one. It has multiple APIs which make
it more suited for a system like Zephyr where different components may
want to use it for different purposes. Including APIs to init it,
get and set its internal state etc.
Several Zephyr modules (shell, net, wifi, ztest) use this getopt with
these special APIs. The getopt module is bundled in the POSIX
compatibility API subsystem (CONFIG_POSIX_C_LIB_EXT).
Problem description:
As it is not the standard getopt(), no C library can possibly provide
a Zephyr compatible version (even if such C library were to provide a
standard getopt()). As it is bundled in Zephyr's POSIX API in
CONFIG_POSIX_C_LIB_EXT), multiple components that depend on it are
selecting CONFIG_POSIX_C_LIB_EXT. Zephyr core components should not
depend on the POSIX API in this way.
Changes done in this commit:
Rename the getopt*() APIs to sys_getopt*() and move them into a module
under lib/utils with its own Kconfig option to enable it.
Zephyr's users are changed to use this new component.
The POSIX subsystem can continue providing getopt() by calling the new
sys_getopt() and in that way retain backwards compatibility for external
users.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Gives access to all log output format flag configurations
for shell backend.
shell log backend doesn't use log_backend_std_get_flags()
and it's debateable if it should, so give it its own fullly
configurable format set for maximum backend bandwidth control
Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
Depending on the ring buffer configuration, users may encounter
the "size too big" assertion in runtime. Let's enable the
RING_BUFFER_LARGE when we know that it is required.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The UART device used by the backend needs to be gotten before use,
and put after. In limited cases, device drivers call
pm_device_runtime_get() as part of the call to uart_rx_enable(),
this is not the case for polling, nor interrupt driven API calls
for most if not all drivers, nor is that expected.
Implement pm_device_runtime calls in shell uart backend similar to
the logging uart backend to support all uart drivers in all
configurations.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Previously, the bypass() function was called while the shell mutex
was still held, preventing the use of shell APIs (e.g. shell_print())
inside the bypass context.
This change unlocks the shell mutex before invoking bypass() and
locks it again afterwards, restoring proper shell context handling
and preventing potential deadlocks.
Issue fixed by: roni1234321
Fixes#97722
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
Add support for 64-bit devmem operations for 64-bit devices.
Signed-off-by: Sergii Vystoropskyi <vistorop@meta.com>
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Add support for 64-bit devmem operations for 64-bit devices.
Signed-off-by: Sergii Vystoropskyi <vistorop@meta.com>
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The shell history initialization function doesn't work in if the shell
instance hasn't been created through the shell macro. This removes the
function to avoid confusion.
Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
The ring_buffer API was not ideal for this use case, as it is designed for
concurrent access, which is not needed here. The new implementation using
k_heap is more readable and easier to maintain.
There is a slight penalty in memory usage & effectiveness due to the
overhead of k_heap, but since this isn't a production-critical path, the
trade-off is acceptable.
Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
Revert a change that broke the stable API function shell_set_bypass.
This reverts commit 6b876dba1ba61b659b1b2d4c3ccd0ac41bd56027.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>