VT100 commands are now stored as strings rather than character arrays.
This change will make it easier to create a unified macro for sending
all VT100 commands.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This patch fixes the issue that can cause a deadlock in shell.
When two threads simultaneously poll the TXDONE signal, only one
of them will receive it, leaving second one stalled.
The problem was that shell's context contains k_poll_event objects that
were polled by multiple threads. Polling it overwrites the poller field
that was set by previous thread.
Instead, the k_poll_event object must be created on the stack by every
thread that wants to poll the TXDONE signal.
This makes sure that no thread will be left waiting for this signal
forever.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Problem:
In some cases, as described in: https://github.com/zephyrproject-rtos/zephyr/issues/36948
shell backend sends characters to output before serial device
is ready for it. It results in observing additional characters
inserted on the shell input after device boot.
Solution:
Added waiting on DTR signal before sending anything to the output.
Fixes: #36948
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
We get build issues due to the removal of the Kconfig symbol
CONFIG_UART_SHELL_ON_DEV_NAME on platforms that didn't have a uart
set as we'd get a default value for those platforms. Update the
Kconfig logic to only enable SHELL_BACKEND_SERIAL if we have
zephyr,shell-uart specified in the devicetree to address the issue.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Follow up on commit bfd45e5b8c
("drivers: remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME")
Now we can also remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME
since all UART drivers are converted to devicetree and we can just use
DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart)).
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit adds a devmem load command for shell that allows
users to easily load arbitrary data into the device memory.
Signed-off-by: Mateusz Sierszulski <msierszulski@internships.antmicro.com>
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:
Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The function to execute shell commands: shell_execute_cmd will now
behave similarly to invoking command line commands.
I.e. after the command is executed the command buffer is cleared,
while the cursor is set to the initial position.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Currently, in Zephyr the shell thread is the lowest priority i.e.
K_LOWEST_APPLICATION_THREAD_PRIO. Due to this all the other threads can
preempt the shell thread. Proposed solution is to add Kconfig which
gives the flexibility to change the priority of the shell thread.
This is now implemented using a new Kconfig variable
SHELL_THREAD_PRIORITY_OVERRIDE. By setting this option
SHELL_THREAD_PRIORITY can be set.
Signed-off-by: Uday Ammu <udaykiran@google.com>
All variables for address, width and value are unsigned, so use strtoul
instead of strtol. This fixes an issue when 0xffffffff is about to be
assigned to specific address, which was truncated to 0x7fffffff so far.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.
All drivers and tests have been adjusted accordingly.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Added api call that can set a callback that is called whenever
data is received on shell. When callback is set, shell processing
is bypassed and data is passed to that callback.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Promote the "edac mem" shell subcommand to a generic "devmem" root shell
command. This command is useful for poking around registers and memory
outside of the EDAC drivers.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
If the shell root command shall be set in the application, e.g. for
implementing a login scheme, it is an advantage to set this already
during shell init.
This is now implemented using a new Kconfig variable SHELL_CMD_ROOT.
Signed-off-by: Hans Wilmers <hans@wilmers.no>
Allow the user to disable VT100 commands to have a plain shell
without terminal emulation in order to avoid a lot of garbage
ASCII characters in shell output.
Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
The tabulator handler creates a single structure if it is handling
dynamic commands. If the currently processed dynamic command has a
dynamic subcommand they both share the same structure.
As a result tabulation operation may result in undefined behaviour.
As a solution, a new structure was introduced to keep subcommand
information.
Fixes#35926.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Shell log backend depends on logging being enabled. Lack of this
dependency leads to compilation failure when logging is disabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The commit adds Kconfig option to configure dummy shell buffer size.
Size of this buffer determines how mutch of command output will be
stored in buffer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Allow time for the shell to successfully echo the reboot command input
before the reboot abruptly terminates it. n This can help external
systems that interact with the shell and require the reboot command's
echo to successfully complete to synchronise with the device.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35325
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
When shell log backend was disabled fifo used only in
deferred mode was unconditionally flushed which lead to
errors in immediate mode where fifo was not present. On
the other hand, in case of LOG2_MODE_DEFERRED fifo (mpsc_pbuf)
was initialized in enable stage.
In order to clean things up, deferred v1 fifo flushing and
deferred v2 mpsc pbuf initialization were moved to fifo_reset
function which is called when shell log backend is enabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Remove this intrusive tracing feature in favor of the new object tracing
using the main tracing feature in zephyr. See #33603 for the new tracing
coverage for all objects.
This will allow for support in more tools and less reliance on GDB for
tracing objects.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Reboot functionality has nothing to do with PM, so move it out to the
subsys/os folder.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit increases the shell stack sizes when used with
OpenThread shell and the joiner to compensate for enlarged
MPU stack guard.
Signed-off-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
Uninitialization of uart transport was missing disabling of TX
interrupt. It had to be done by the user before using uart.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When shell had too many pending log messages it was attempting to
drop expired messages and retrying to put the new message. There
was an assumption that enough messages are dropped and new message
can be put. It may not be the case if no message expired during
given time. Wrapped the operation in loop to continue until expired
message is freed and new message is enqueued.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If the telnet client operates in a character mode, it may send
individual characters in packets. Such packets were dropped in the
telnet shell backend instead of being process by the shell engine.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace k_work_cancel_delayable() with k_work_cancel_delayable_sync()
to make sure that the submitted work becomes idle before accessing
sensitive data.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This functions is being called across the tree, no reason why it should
not be a public API.
The current usage violates a few MISRA rules.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Init function can be called multiple times (after each shell
reinitialization). It was missing reseting ring buffers and tx_busy
flag. When called once proper state of those variable where handled
by ram sections initialization.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Shell uninitialization is not synchronous, it is deferred to shell
thread so resources used by the shell (e.g. transport resource like
uart) cannot be used until it is completed. Added callback which
notifies when all resources are released and shell is uninitialized.
Callback is called from shell thread just before it is aborted.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add Z_SHELL_SET_FLAG_ATOMIC macro to use technique from
shell_process() to atomically set and return the previous
value.
Change all void z_flag_*_set() functions to bool z_flag_*_set()
and use macro to return previous value after setting.
Modify shell_process() to use this modified z_flag_processing_set()
function.
Reorder flags to keep last_nl on byte boundary.
Add public setters for insert_mode, echo, and mode_delete for
completeness.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Add flag to shell_flags to control echo as obscure
character (for passwords) or not. Add setter and getter
functions. Modify shell echo to use this flag if set.
Also add public setter for color mode and obscure mode.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
The clock/timer APIs are not application facing APIs, however, similar
to arch_ and a few other APIs they are available to implement drivers
and add support for new hardware and are documented and available to be
used outside of the clock/kernel subsystems.
Remove the leading z_ and provide them as clock_* APIs for someone
writing a new timer driver to use.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Building this file with CONFIG_COVERAGE=y and CONFIG_SHELL_LOG_BACKEND=n
fails on the llvm-clang compiler. Swapping the IS_ENABLED and
log_backend allows the compiler to optimize out the if block even with
coverage enabled.
Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
Sometimes it is hard to tell which instance of a thread is which
in the printed list, based solely on the name (if present) and
the k_thread pointer, so also print the thread entry fn pointer.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
If a shell command is compiled out using SHELL_COND_CMD(),
a line for this command will still be printed but will
be blank. Change it so compiled out commands are not
listed as blank lines.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
This functionality is is enabled by setting CONFIG_SHELL_GETOPT.
It is not active by default.
User can call following functions inside command handlers:
- shell_getopt - getopt function based on freebsd implementation
- shell_getopt_status_get - returns getopt status
Beware when getopt functionality is enabled shell will not parse
command handler to look for "-h" or "--help" options and print
help message automatically.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Shell will not "steal" by default "-h" and "--help" each time
help functions are enabled.
This change is necessary to implement and use the getopt library.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
The default shell configuration has heavy flash and memory requirements,
requiring project maintainers to set many configuration options to "n"
to keep flash and memory requirements within reason.
This adds a new configuration option, CONFIG_SHELL_MINIMAL, which will
disable flash and memory heavy options by default, and allow project
maintainers to select/imply only the options they want.
On a quick test from an ARM board I'm working on, enabling this option
cut flash space requirements by ~8 KB, and memory requirements by ~1 KB.
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>