Use this short header style in all Kconfig files:
# <description>
# <copyright>
# <license>
...
Also change all <description>s from
# Kconfig[.extension] - Foo-related options
to just
# Foo-related options
It's clear enough that it's about Kconfig.
The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)
git ls-files '*Kconfig*' | \
xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).
Go for the most common style:
- Indent properties with a single tab, including for choices.
Properties on choices work exactly the same syntactically as
properties on symbols, so not sure how the no-indentation thing
happened.
- Indent help texts with a tab followed by two spaces
- Put a space between 'config' and the symbol name, not a tab. This
also helps when grepping for definitions.
- Do '# A comment' instead of '#A comment'
I tweaked Kconfiglib a bit to find most of the stuff.
Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
User could telnet to zephyr only once and the second connection
was denied. The reason was that the telnet socket was not properly
marked as accepting a new connection.
Fixes#20042
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Unused since commit 08f0d93cbb ("shell: Improve handling of log
messages").
Discovered with a script.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Use the int_literal_to_timeout Coccinelle script to convert literal
integer arguments for kernel API timeout parameters to the standard
timeout value representations.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
These checks should be against CONFIG_SHELL_LOG_BACKEND,
and not against CONFIG_LOG, since it's possible to enable
logging without building this particular backend.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The $(dt_chosen_label) preprocessor function should be passed
$(DT_CHOSEN_Z_SHELL_UART), not $(UART_SHELL_ON_DEV_NAME).
DT_CHOSEN_Z_SHELL_UART is set right before the Kconfig symbol
definition, to work around the comma in 'zephyr,shell-uart'.
The Kconfig preprocessor functions are defined in
scripts/kconfig/kconfigfunctions.py.
Fixes: #19178
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.
Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.
This conversion allows us to remove code in gen_defines.py for the
following chosen properties:
zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
1) Dump time sinse last scheduler call
Could be handy for tickless kernel debug.
Will indicate that no rtc irq is called
2) Dump current timeout of each thread
Could be used to find yout when thread will wake up
3) Dump human friendly thread state
4) Use shell_prin instead shell_fprintf
Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
With CONFIG_LOG_IMMEDIATE, log output is printed immediately. If a
shell command is in progress, there's no prompt to erase, nor should
we print a new prompt after the log message is output.
Before this patch, a simple shell command like:
int cmd_log_erase(const struct shell *shell, size_t argc, char **argv)
{
LOG_INF("hello world");
return 0;
}
would output something like:
uart:~$ log erase
[00:00:02.623,718] <inf> cmd_log: hello world
uart:~$ loguart:~$
This patch fixes prompt handling while a command is active, and fixes
put_sync_hexdump to behave like put_sync_string.
Signed-off-by: Jim Paris <jim@jtan.com>
move misc/reboot.h to power/reboot.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Ctrl+N - moves in history to next entry
Ctrl+P - moves in history to previous entry
Behavior of those meta-keys is the same as in bash and emacs, which
makes Zephyr shell even more familiar to play with.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Using void pointers as universal arguments is widely used. However, when
compiling a 64-bit target, the compiler doesn't like when an int is
converted to a pointer and vice versa despite the presence of a cast.
This is due to a width mismatch between ints (32 bits) and pointers
(64 bits). The trick is to cast to a widening integer type such as
intptr_t and then cast to
void*.
When appropriate, the INT_TO_POINTER macro is used instead of this
double cast to make things clearer. The converse with POINTER_TO_INT
is also done which also serves as good code annotations.
While at it, remove unneeded casts to specific pointer types from void*
in the vicinity, and move to typed variable upon function entry to make
the code cleaner.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The structure of the va_list type is architecture-dependent, and it
doesn't seem possible to initialize va_list variables in a portable way
(except by using va_start()). In particular, the x86_64 ABI defines the
type like this:
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
} va_list[1];
Fortunately, the va_start() macro expects an uninitialized va_list
variable, so we can simply remove the initializers to make the code
portable.
Signed-off-by: Jakob Olesen <jolesen@fb.com>
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When mcumgr smp data was received over shell uart transport
it was not waking up shell thread and thus request was not
processed. Shell thread must be waken up on any incoming
data, even data which is only dedicated for mcumgr smp.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Shell history module reworked to use ring buffer for storing
commands. Dedicated buffer is used to story all command lineary.
History capacity is in bytes not in number of entries, e.g.
many short commands can be stored or few long (depending on
CONFIG_SHELL_HISTORY_BUFFER).
Removed implicit command null termination from shell_history and
added it to shell after fetching command line from the history.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The "select" command has been implemented, which allows user to
narrow down the command tree.
This implementation differs from the "select" command available
in the legacy shell. In a new implementation, if the selected
command has a handler and if the user has not entered the
registered subcommand, the shell will call the handler of selected
command and pass the text as arguments.
This may be useful, for example, if someone wants to use the
shell as an interface to a modem that supports AT commands.
Instead of each time you write e.g:
at at+command1
at at+command2
at at+command3
user can execute following commands:
select at
at+command1
at+command2
at+command3
where:
at - root command for passing at commands to the modem
at+commandX - at command passed to the modem.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
By moving signals initialization to shell instance init function,
shell instance is ready to receive RX signals from backend before
thread is ready to handle them.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Adding possibility to modify shell prompt in Kconfig and in prj.config
file.
Fixes#14547.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Modified commands which depends on compile time flags to
use conditional macros.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added macros which can be used to create a command which depends
on compilation flag. Macros are a cleaner alternative to #ifdefs
around command registration and command handler.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This introduces shell_hexdump API which can be used to print an array
such as a network buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The 'Shell Options' menu contains just the 'menuconfig SHELL' menu in
the menuconfig interface.
Remove the 'Shell Options' menu and put 'menuconfig SHELL' directly in
the top-level menu instead. Also change the prompt from "Enable shell"
to just "Shell", to make it consistent with "Logging".
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
A transport may receive multiple bytes of data between shell_thread
wakeups, but state_collect is only called once per wakeup. So it must
process all data, and only return when all data from the transport has
been consumed. This is mostly handled correctly, but there were two
places where state_collect would return early instead.
Signed-off-by: Jim Paris <jim@jtan.com>
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier. Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.
By default all files without license information are under the default
license of Zephyr, which is Apache version 2.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
Add TELNET backed for shell module. The TELNET implementation is based
on the telnet_console driver.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Shell was selecting logger option which lead to define
CONFIG_LOG_RUNTIME_FILTERING generation even though log
was disabled. That messed up logger and lead to compilation
failure.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This didn't compile if CONFIG_SHALL_ECHO_STATUS wasn't
enabled.
Based on a fix by Rodrigo Peixoto.
Fixes: #14546
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
According to the Coverity issue 190614 (github issue #12319)
Fix for logically dead code in function buffer_trim
Before while execution cannot reach this statement: buff[0] = '\0';
Tested and noticed that part of code is unnecessary inside of while
For the test, I made the same function in CodeBlocks and send to it
string to detect and delete whitespaces. After deletion of dead code
part, I tested function again, it works.
Function buffer_trim first detects whitespace characters in the end
of the string using first while, then it adds '\0' to the end
of the string to mark that string has new end after all whitespace
characters. Second while finds whitespaces at the beginning
of the string and counts how many whitespaces it found.
In the end using if counted whitespaces are removing from the
string.
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.
Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Shell arguments structure was stored as a pointer in shell structure
and NULL pointer indicated that argument count checking is skipped.
It has been reworked to hold the structure (2 bytes) in the shell
structure with mandatory=0 skipping the check. This approach is cpp
friendly, contrary to the legacy one.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
It was possible to deadlock the shell when command
suspended shell's thread and next another thread wanted
to print something on the shell.
To avoid that shell releases mutex before entering command
handler. Due to this change some adapations to shell
internal print functions have been applied.
This change addresses following usecase:
1. A command handler needs to call a (system) function which
communicate results via a callback, and this callback is expected
to print these results. The callback is called by the system from
another thread.
2. To achieve that, the handler needs to pass `struct shell *`
to callbacks, but also some other data specific to callback.
Thus, handles allocates some structure will those fields on
the stack.
3. The handler schedules this callback to be called.
4. As a reference to stack structure is passed to the callback,
the handler can't return immediately (or stack data will go out
of scope and will be overwritten).
5. So, the handler blocks waiting for callback to finish.
Previously, this scenario led to deadlock when the callback
trying or print to shell. With these changes, it just works,
as long as main handler and callback serialize there access
to the shell structure (i.e. when callback prints, the main
handler is blocked waiting for its completion).
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Shell RTT backend was using RTT call which was using
lock (mutex). In case of panic, that lead to failure
if panic occured in the interrupt context where mutex
is not permitted.
Implementation changed to use write without log in
blocking mode.
Additionally, added static assert to check if raw RTT
log backend is not enabled on channel 0 which is used
by shell RTT backend.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Prompt length is used when printing log messages to erase
prompt. If length is not updated and new prompt is longer
than default one then only part of the prompt is erased
which looks like data corruption.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This change removes special handling for shell root commands.
Currently there is one loop in execute function that is used
to search commands on each level.
Fixed a bug where command buffer has been processed twice
when it was not needed (wildcards not found).
This change will allow to simplify "select" command
introduction.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Shell will store only pointer to the prompt string instead of
copying it to the RAM buffer. It will save RAM memory and
it will simplify implementation of a new feature: "select"
command. When a command will be selected than shell will
display command syntax as a prompt.
Removed obsolete ASSERT check in a static function.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Replace generating CONFIG_ symbols with DT_ symbols for chosen
properties like 'zephyr,console' or 'zephyr,bt-mon-uart'. We now use a
kconfigfunctions (dt_str_val) to extract the info from dts into Kconfig.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Last parameter of exec_cmd function has been corrected from
structure type to pointer to structure type.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>