Add an extra "usage=%d" to the device status to show the current usage
counter when PM runtime is enabled.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a shell_device_filter variant of the shell device lookup helper that
takes a callback as an argument. This allows more complex filtering on
the device than the existing name prefix.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Similar to logging module, allow application specific extension of
shell fprintf APIs at a macro level.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Improve the default serial backend init level.
The documentation says to be bigger than the init level of the serial
device used. Since serial devices default to the kernel device init
level (50) then put this to default of application level drivers (90).
Signed-off-by: Joakim Andersson <joerchan@gmail.com>
Resolved a data race in shell.c by copying the user-provided
prompt-string into a private buffer within the shell, ensuring
proper synchronization with the shell-thread.
Fixes: #64972
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
If host is not reading RTT data (because there is no PC connection
or RTT reading application is not running on the host), thread will
stuck continuously trying to write to RTT. All threads with equal or
lower priority are blocked then. Adding detection of that case and
if host is not reading data for configurable period then data is
dropped until host accepts new data.
Similar solution is using in RTT logging backend.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Simple rename to align the kernel naming scheme. This is being
used throughout the tree, especially in the architecture code.
As this is not a private API internal to kernel, prefix it
appropriately with K_.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit fixes this error seen in CI so that things
work even if CONFIG_POSIX_API is enabled.
subsys/shell/backends/shell_mqtt.c:727:12: error:
conflicting types for 'write'; have
'int(const struct shell_transport *, const void *, size_t, size_t *)'
727 | static int write(const struct shell_transport *transport,
const void *data, size_t length)
include/zephyr/posix/unistd.h:230:9: note: previous declaration
of 'write' with type
'ssize_t(int, const void *, size_t)'
230 | ssize_t write(int file, const void *buffer, size_t count);
subsys/shell/backends/shell_mqtt.c:787:12: error:
conflicting types for 'read'; have
'int(const struct shell_transport *, void *, size_t, size_t *)'
787 | static int read(const struct shell_transport *transport,
void *data, size_t length, size_t *cnt)
include/zephyr/posix/unistd.h:231:9: note: previous declaration
of 'read' with type
'ssize_t(int, void *, size_t)'
231 | ssize_t read(int file, void *buffer, size_t count);
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Return availability of free buffers after data is consumed. This
information may be important for the module using uart_async_rx to
schedule next reception if there is a new buffer available.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
arch_interface.h is for architecture and should not be
under sys/. So move it under include/zephyr/arch/.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Current TELNET implementation wrongly assumed that if the command is
present, it will always be included at the beginning of the packet/data
buffer. Such assumptions however are not valid for STREAM sockets,
where the actual stream data could be fragmented in any way.
Therefore, the command parsing needed rework, so that we analyze each
byte received for the command escape code, and once received we enter
"command parsing" mode. Once no more commands are identified in a data
streak, the command bytes are removed from the data buffer before the
buffer is provided to the shell subsystem for processing.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Rework TELNET shell backend to use socket API for communication and
socket service library for socket monitoring.
Additionally, rework the TX part so that non-blocking TX is used when
sending from the system work queue. In case transfer is not possible at
the moment, the TX work is rescheduled instead of blocking the system
work queue.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Shell stack size is too low for OpenThread without joiner
functionality, causing overflow.
In this commit, the value of stack size is not changed.
Incorrect assigning of value for opentrhead with
no joiner functionality has been removed.
Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Added missing condition to check if log backend is configured before
calling the function: z_shell_log_backend_disable. Without this, in some
configurations, a compilation error appeared due to calling a
non-existent function.
Fixes: #69555
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
Introduce a backend for the Shell subsystem using a RPMsg endpoint.
This is useful for tooling & testing a remote processor from linux.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The shell currently prints out `: command not found` and
`Please specify a subcommand.` when invalid commands are
sent.
This can cause issues in certain situations, such as if a U-Boot
console in interactive mode is on the other end of the shell's
UART, where the U-Boot console will stop booting the device
if it receives any characters, and it will print out strings that
the shell then sees as commands. This causes the shell to send
out the messages above, preventing the device running
U-Boot on the other end from booting up.
I added the configurations
`CONFIG_SHELL_MSG_SPECIFY_SUBCOMMAND` and
`CONFIG_SHELL_MSG_CMD_NOT_FOUND` to allow disabling
these messages.
Signed-off-by: Brian Moran <brian.moran@sabantoag.com>
This patch modifies the way SHELL_BACKEND_SERIAL_API_ASYNC is selected.
The current logic causes conflicts (no console output) when the user tries
to use one of the UARTs in async mode, by setting CONFIG_SHELL_ASYNC_API,
while using Shell with a different UART (typically the Console's one).
Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
Include the full version in the output of the "kernel version" shell
subcommand. Previously, EXTRAVERSION was not included, causing
e.g. "3.6.0-rc1" to be printed as "3.6.0".
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
* The include for the host libC should be guarded with
using the host libC instead of the POSIX arch, as this
supports other C libraries.
* This code uses getopt, which is an extension to the
C library. Let's explicity select one of the extensions
which includes it instead of relaying on somebody having
set it for this file somewhere else.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The previous behavior of the CONFIG_SHELL_AUTOSTART option, where setting
it to 'n' disabled shell interaction at startup but kept the logger
active as a shell backend, was inconsistent.
Now, when CONFIG_SHELL_AUTOSTART is set to 'n', both the shell and the
logger are inactive at startup. Calling the shell_start function will
activate them and print any pending logs. This change ensures a more
consistent and logical behavior regarding shell and logger activity at
startup.
Additionally, now when the shell_stop function is called, both the shell
and the logger are halted. This enhancement ensures that stopping
the shell also effectively stops the associated logger.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
If there's not enough networking buffers at certain moment,
they might become available later. So instead of closing connection
(and failing assertation) sleep and retry. This avoid the following
assertion failure when there's much of data to send:
net_pkt: Data buffer (1500) allocation failed.
net_tcp: conn: 0x20076024 packet allocation failed, len=1460
shell_telnet: Failed to send -105, shutting down
ASSERTION FAIL [err == 0] @ .../subsys/shell/shell_ops.c:416
os: r0/a1: 0x00000004 r1/a2: 0x000001a0 r2/a3: 0x00000004
os: r3/a4: 0x20044380 r12/ip: 0x00001958 r14/lr: 0x080c9027
os: xpsr: 0x41000000
os: Faulting instruction address (r15/pc): 0x0811ed26
os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
os: Current thread: 0x20045100 (shell_telnet)
os: Halting system
Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's
byteswap.h. byteswap.h from host compiler used in posix_native_64 boards
causes a compilation issue.
This commit renames __bswap_ to BSWAP_ to prevent collision.
Before this commit a compilation error can be created by adding #include
<byteswap.h> to samples/net/sockets/echo/src/socket_echo.c
This does not change external API to byteorder.h, but does change
internal implementation which some other source files depend on.
Replaced manual byteswap operations in devmem_service.c with APIs from
byteorder.h which automatically converts to CPU endianess when necessary.
Fixes#44324
Signed-off-by: Jonathan Hamberg <jonathanhamberg@gmail.com>
Always use k_thread_foreach_unlocked with callbacks which print
something out to the shell, as they might call arch_irq_unlock.
Fixes#66660.
Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
There are several subsystems and boards which require a relatively large
system heap (used by k_malloc()) to function properly. This became even
more notable with the recent introduction of the ACPICA library, which
causes ACPI-using boards to require a system heap of up to several
megabytes in size.
Until now, subsystems and boards have tried to solve this by having
Kconfig overlays which modify the default value of HEAP_MEM_POOL_SIZE.
This works ok, except when applications start explicitly setting values
in their prj.conf files:
$ git grep CONFIG_HEAP_MEM_POOL_SIZE= tests samples|wc -l
157
The vast majority of values set by current sample or test applications
is much too small for subsystems like ACPI, which results in the
application not being able to run on such boards.
To solve this situation, we introduce support for subsystems to specify
their own custom system heap size requirement. Subsystems do
this by defining Kconfig options with the prefix HEAP_MEM_POOL_ADD_SIZE_.
The final value of the system heap is the sum of the custom
minimum requirements, or the value existing HEAP_MEM_POOL_SIZE option,
whichever is greater.
We also introduce a new HEAP_MEM_POOL_IGNORE_MIN Kconfig option which
applications can use to force a lower value than what subsystems have
specficied, however this behavior is disabled by default.
Whenever the minimum is greater than the requested value a CMake warning
will be issued in the build output.
This patch ends up modifying several places outside of kernel code,
since the presence of the system heap is no longer detected using a
non-zero CONFIG_HEAP_MEM_POOL_SIZE value, rather it's now detected using
a new K_HEAP_MEM_POOL_SIZE value that's evaluated at build.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Addresses a potential issue when the string contains only '\0',
which results in z_shell_strlen(str) returning len as 0.
Since the for-loop expects len >= 1, the function now immediately
returns when len == 0.
As the null check for 'str' is already handled inside
z_shell_strlen(), an additional check for 'str' is not needed.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
EAGAIN error is returned if the tcp window size is full. Retry
sending the packet instead of closing the connection if this
error occurs.
Also the full payload may not be sent in a single call to
net_context_send(). Keep track of the number of bytes remaining
and try to send the full payload.
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Reinstate the `SHELL_UART_DEFINE` macro and moved the struct
declarations to header file, making it possible to create
another UART shell backend instance by doing
`SHELL_UART_DEFINE()` + `SHELL_DEFINE()` + `shell_init()`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Fixing typo from the original implementation in
44705b698c725166834f19d6fd5db2804f9a0d60, which resulted in
the name of current shell instance getting print over and over
again.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
`smp_shell_input_timeout_handler`. Create a public function in
the `shell_uart.c` for it to get the pointer to the
`smp_shell_data` and fix the compilation error.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
When UART asynchronous API support was added to shell it was set up
to be the default one and was turning on asynchronous API if it was
supported. However, it may lead to complation failures if device
requires additional setup for asynchronous UART (e.g DMA in device
tree). Becuase of that, it is reverted back to use interrupt driven
API and use asynchronous API if it is already enabled in the
application.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Fixing compilation failure due to treating void pointer as uint8_t
array. Added missing casting.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Rework UART backend to clearly use single instance approach as
before it was a bit messy with some parts of implementation indicating
multi-instance approach and some single instance. Backend has been
around for years and multi-instance requirement never came.
Added support for UART asynchronous API which is more efficient
in terms of power consumption and performance. Asynchronous API
support is using uart_async_rx helper module for handling data
received asynchronously.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
It declares a variable inside a switch statement without brackets to
properly delimit the scope, making clang barf. This patch adds them.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Adding support for echo option if telnet commands are supported. This is
useful when the telnet client is in character mode. It allows to use the
arrow keys, ctrl-c and more. Something to keep in mind is that when
character mode is turned on by the client, network traffic is
considerably increased as each typed character is sent over the wire.
Note: echo mode is only supported if SHELL_TELNET_SUPPORT_COMMAND is
enabled.
Signed-off-by: David Corbeil <david.corbeil@dynon.com>
The shell name defined with `SHELL_DEFINE` is implicitly
guaranteed to be unique while it is possible that more than one
shell backends can have the same prompt.
Print the name of the shell backend alongside with its prompt
to differentiate between the backends.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Added some new APIs to get the backend instances more easily,
so that dev does not need to rely on `shell_backend_*_get_ptr`,
which looks more like a hack to access a local variable.
These APIs are basically copied from the log backend
implementation.
Added testcase for the APIs.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Rename the shell backend `thread_name` variable to just `name`,
to be used for other things not specific to thread later.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Compiler can't tell that k_thread_abort() won't return and issues a
warning unless we tell it that control never gets this far.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
HAS_DTS has become a redundant option. All Zephyr architectures now
select this option, meaning devicetree has become a de-facto
requirement. In fact, if any board does not provide a devicetree
source, the build system uses an empty stub, meaning the devicetree
machinery always runs.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Added a condition to check if the size of the copied
memory is a positive number.
Fixes#58700Fixes#58703
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
The connectivity monitoring subfeature of conn_mgr is currently also
named conn_mgr, which is confusing.
This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short,
for clarity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Set correct SHELL_BACKEND_SERIAL_INIT_PRIORITY if ACPI is enabled.
Otherwise when enabling SHELL using menuconfig, etc serial backend is
not working.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The default stack size is too small on 64bit.
Some standard shell commands cause stack overflow
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>