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>
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>
If the disconnect work has not yet run when a connect event is received the
connect event is dropped.
Prevent this behaviour by reorganizing `network_evt_handler()`.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Rename these three macros to an unprefixed lower-case variant. This is
normally not done for Zephyr macros (see container_of) but in this case
it seems like a good idea to adopt the lowercase names to:
1. have the same convention as the equivalent Linux macros, helping devs
working cross project recognizing (mis)use patterns.
2. make it somewhat intuitive that the lowercase ones are meant to be
used in functions while the uppercase ones are to be used for static
evaluation.
Add few c++ guards to avoid colliding with std::min and std::max.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
commands should not have spaces around hyphens:
version - extended --> version-extended
build - version --> build-version
Fixes: zephyrproject-rtos/zephyr#96591
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
When logging through shell is enabled, it is inconvenient to use
the shell when there are logs coming in. Having a mechanism for
easy disabling/re-enabling the shell logs is a nice quality of life
feature.
To toggle the logs, `CTRL+T` combination can be used. This is
available only when meta key feature is enabled.
Signed-off-by: Heghedus Razvan <heghedus.razvan@protonmail.com>
`#ifdef` will always evaluate to true when used on string Kconfig options.
Therefore username and password is set to "" if unset in Kconfig which is
not an issue.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Replace `select NET_MGMT` and `select NET_MGMT_EVENT` with
`select NET_CONNECTION_MANAGER` to get L4 events.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Change topic from <device_id>_rx (and tx) to <device_id>/sh/rx.
This allows use of wildcards. E.g. subscribe to all devices "+/sh/tx".
Level "sh" is added to the topic to make it less generic and prevent
potential clashes with other topics.
The topic part after <device_id> is configurable via Kconfig.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
The interrupt-driven UART API is emulated via polling on native_sim,
which introduces additional overhead. Defaulting to poll mode improves
performance by avoiding this emulation cost.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
It might come in handy to filter the output of a device list
command, by adding a filter (auto-completion enabled as well).
Such as:
$ device list uart
devices:
- uart@2f8 (READY)
DT node labels: uart1
- uart@3f8 (READY)
DT node labels: uart0
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Co-authored-by: Dimitris Karnikis <dika@bang-olufsen.dk>
Co-authored-by: Hans Binderup <habi@bang-olufsen.dk>
It might come in handy to access non-initialized devices throuhg the
shell. I.e. devices which 'zephyr,deferred-init' DTS attribute was set.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
It is actually easy to have device name going beyond 20 characters.
There is a maximum defined internally, better using it.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Allow changing delays via Kconfig values.
Use identical delay (`SHELL_MQTT_WORK_DELAY_MS`) for connect, subscribe and
process work instead of varying 1 or 2 second delay.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
This commit brings a shell command to retreive the following application
version information:
- APP_VERSION_STRING
- APP_VERSION_EXTENDED_STRING
- APP_BUILD_VERSION
Signed-off-by: Alex Fabre <alex.fabre@rtone.fr>