Commit Graph

432 Commits

Author SHA1 Message Date
Dominik Ermel db34adf9c3 mgmt/mcumgr: Standardise MCUmgr Kconfig names
Standardise Kconfig options for MCUmgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Robert Lubos 55af3dd075 shell: Clear command buffer when leaving bypass mode
If bypass mode is left outside of the registered bypass handler, the
command buffer was not cleared, basically containig leftovers from the
processing of the previous command. This resulted in undefined behaviour
on consecutive shell operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 09:46:53 +00:00
Wojciech Slenska 4b2fffc7f9 shell: added SHELL_AUTOSTART configuration option
In some applications, there is a need to don't start the shell by
default, but run it later on some special condition.
When SHELL_AUTOSTART is set to n, the shell is not started after
boot but can be enabled later from the application code.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-14 15:17:02 +01:00
Wojciech Slenska 29400b18a6 shell: shell_log_backend: added check for msg allocation
When the message buffer cannot be allocated, dropped package
counter should be incremented.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-05 15:35:03 +01:00
Krzysztof Chruscinski 1f63a07c5f shell: Fix log message queue size for all backends
188d2dfcca introduced a change where log message queue again
become configurable through Kconfig instead of being fixed in
the code. However, it updated only the configuration of an UART
backend. This commit updates other backends as well. Including
dummy backend which has fixed in the code value.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-05 15:20:01 +01:00
Chris Friedt 510dca57da shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory rather than
dumping one byte (word, etc) at a time. Additionally, it
respects alignment requirements so it works for e.g. 32-bit
register accesses.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-05 11:28:22 +01:00
Chris Friedt cdc0f30dbb Revert "shell: devmem: add devmem dump subcommand"
This seems to have caused build failures in spite
of CI passing in PR 52653.

This reverts commit 0a02a4a2af.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-02 14:09:37 +09:00
Chris Friedt 0a02a4a2af shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory
rather than dumping one byte at a time.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-01 15:52:47 -05:00
Jamie McCrae b635b55ef0 logging: Increase dummy shell buffer size to 400 bytes for LOG_PRINTK
If LOG_PRINTK is used then the buffer size needs to be larger to
account for the additional header/footer output from the shell.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-29 10:46:26 +01:00
Armin Brauns 1f41c01553 shell: kernel: right-align stack usage percentages
This improves readability by aliging digits with the same significance
vertically.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-11-23 11:33:47 +01:00
Wojciech Slenska 188d2dfcca shell: shell_log_backend: take buffer size from config
Use LOG_MESSAGE_QUEUE_SIZE config instead of hardcoded value.
LOG_MESSAGE_QUEUE_SIZE default value has been changed to 512, so
it is now matching to the hardcoded value.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-11-22 13:05:29 +09:00
Kumar Gala a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Kumar Gala c778eb2a56 smp: Move arrays to use CONFIG_MP_MAX_NUM_CPUS
Move to use CONFIG_MP_MAX_NUM_CPUS for array size declarations instead
of CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-17 14:40:12 +09:00
Gerard Marull-Paretas eda9689789 shell: device_service: add missing EARLY init level
The device_service shell was missing the capability to list devices
registered in the EARLY init level.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-14 09:55:48 +02:00
Andrei Emeltchenko ab2594e313 shell: devmem: Update help string for devmem
Update help string to make it more clear.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Andrei Emeltchenko 1ff34e234c shell: devmem: Fix help for devmem module
Fixes devmem help string shown below:

uart:~$ devmem -h
devmem - Read/write physical memory"devmem address [width [value]]

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Gerard Marull-Paretas e5eade32e2 shell: device_service: fix MISRA 5.7 violation
Changes in device_service have triggered MISRA 5.7 violation CI error
(Tag name should be unique). Renamed shell to sh, same as some other
modules.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 495245a971 init: remove _SYS_INIT_LEVEL* definitions
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Andrew Hedin 4507608d71 shell: Improve kernel stacks alignment
Use Kconfig value to determine name field width.
Pad stack size to 4 characters.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2022-09-20 09:05:00 +00:00
Yong Cong Sin 148317f075 shell/mqtt: Handle negative return value of `wait`
`wait()` returns the retval of `zsock_poll()` which can be
negative but is currently unhandled.

This patch make sure that the error will be handled.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-09-07 10:30:16 +02:00
Yong Cong Sin 834fb411e3 shell/mqtt: minor MISRA-related fixes
Minor MISRA-related fixes so that the conditionals are boolean
and precedence of statements are explicit.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-09-07 10:30:16 +02:00
Jakub Rzeszutko 66d4471d48 shell: add function checking shell readiness.
Tests with shell commands will fail if they are started
before the shell backend is initialized or started.
Adding API function: shell_ready indicating shell readiness.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-09-06 12:36:01 +02:00
Jakub Rzeszutko 2b05f467f0 shell: add missing asserts to api functions
Add missing macro: __ASSERT_NO_MSG to API functions.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-09-06 12:36:01 +02:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Krzysztof Chruscinski 64ab22bf43 shell: Add option to format logging timestamp
Add option to control formatting of the logging timestamp. By default
formatting is enabled which maintains backward compatibility.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-05 14:27:00 +02:00
Krzysztof Chruscinski 6890a9a434 shell: Fix dependency to log_output
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.

Original commit (b0072e1cea) was
reverted, reappling.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-01 20:54:13 +02:00
Carles Cufi 7dde7f626f Revert "shell: Fix dependency to log_output"
This reverts commit b0072e1cea.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-30 17:28:05 -04:00
Anders Storrø 32ebeb0a5c Shell: Increase ARGC_MAX default val
Increase deafult value of SHELL_ARGC_MAX configuration.
This allows users to utilize deeper nested shell menus without
risking maxing out the number of allowed arguments.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-29 10:31:38 +02:00
Krzysztof Chruscinski b0072e1cea shell: Fix dependency to log_output
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-25 12:18:26 +02:00
Jakub Rzeszutko 5e33b2daea shell: add backends command
Add command that lists all active shell backends.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-08-25 12:13:37 +02:00
Eric Johnson 7f74797b8f shell: Fix handling mandatory args with optional raw arg
Previous code provided incorrect argc value to handlers when a command
used SHELL_OPT_ARG_RAW option.

Fixes #48380

Signed-off-by: Eric Johnson <eric.johnson2@walgreens.com>
2022-08-22 16:29:59 +00:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Gerard Marull-Paretas e0125d04af devices: constify statically initialized device pointers
It is frequent to find variable definitions like this:

```c
static const struct device *dev = DEVICE_DT_GET(...)
```

That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Jonathan Rico 1d0692b2f7 shell: kernel: fix sleep command
Was trying to parse the second argument instead of the first one.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-03 18:47:03 +02:00
Jonathan Rico 76f74344a8 Shell: kernel: Add runtime log filtering command
Use `kernel log-level modulename severity`
Also enable it for the Bluetooth Shell.

Then one can compile-in a lot of BT modules like so:

CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_DEBUG_L2CAP=y
CONFIG_BT_DEBUG_ATT=y
CONFIG_BT_DEBUG_GATT=y

And at runtime select only, e.g. GATT

kernel log-level bt_hci_core 0
kernel log-level bt_l2cap 0
kernel log-level bt_att 0

And then re-enable L2CAP if needed later

kernel log-level bt_l2cap 4

And so on..

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico ad4cf99eb3 Shell: add kernel sleep command
Basic sleep command for scripting purposes.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Yudong Zhang 47ea15edcd shell: mqtt: fix call to bin2hex
Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Damian Krolik fc9f59ce0f shell: fix synchronization in log immediate mode
When LOG_MODE_IMMEDIATE is used, logs processed by the shell
log backend may be intertwined with messages printed by
shell commands running on the shell thread.

It is because the shell uses a mutex while the shell log
backend uses the IRQ lock for synchronization. Switch the
latter to use the mutex as well whenever it's possible.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-07-06 17:59:32 +00:00
Andrei Emeltchenko 6bc6b5c405 shell: mqtt: Remove unneeded variable
Remove unneeded variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-23 15:43:59 -05:00
Krzysztof Chruscinski 9833ca61c9 logging: Removing v2 suffix from logging names
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 15:46:37 -04:00
Krzysztof Chruscinski 041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Stephanos Ioannidis 33f87408c4 global: Correct extern K_KERNEL_STACK_ARRAY_DEFINE usage
This commit corrects all `extern K_KERNEL_STACK_ARRAY_DEFINE` macro
usages to use the `K_KERNEL_STACK_ARRAY_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Krzysztof Chruscinski c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Krzysztof Chruscinski 747d6ffdb0 shell: Remove support for logging v1
Remove support for logging v1 from shell log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Andrei Emeltchenko a9b3c936e2 shell: uart: Fix compilation warning
Use ARG_UNUSED() to fix compilation warning unused-but-set-variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-06 22:47:11 +02:00
Gerhard Jörges d99827f0a5 shell: suppress newlines on boot when promt is an empty string
If the user sets the default_prompt to an empty string no newlines will
be printed during boot.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-06-05 14:42:26 +02:00
Alexej Rempel 476d199752 logging: shell: fix shell stats null pointer dereference
If CONFIG_SHELL_STATS is disabled, shell->stats is NULL and
must not be dereferenced. Guard against it.

Fixes #44089

Signed-off-by: Alexej Rempel <Alexej.Rempel@de.eckerle-gruppe.com>
2022-05-15 21:32:10 +02:00
Gerhard Jörges 6be558af5b shell: check echo flag in z_shell_cursor_in_empty_line()
If the echo flag is disabled the cmd_buff isn't printed and the
characters in it must not be counted in this function.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-05-13 10:22:17 -05:00
Gerard Marull-Paretas 5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Yuriy Vynnychek e71448a00d shell: fix missing "update" for the last RXRDY signal
Fixed the issue when sometimes "update" is not called for the
last RXRDY signal. First, need to reset the signal and only
after that need to call the "update" function.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-04-29 16:11:43 +02:00