This makes cbprintf_nano.c much closer to the standard printf and
therefore more useful. The following are now implemented:
- right justification for everything (only for numbers previously)
- precision value for numbers, chars and strings
- width/precision passed as arguments with *
- "unlimited" padding length
- lower/uppercase hex output
- the #, + and ' ' flags are supported
And the code was heavily reworked to reduce its size as much as
possible to mitigate the size growth. Still, the binary resulting
from cbprintf_nano.c is now between 10% and 20% bigger depending on
the architecture. This is still far smaller than cbprintf_complete.c
which remains about twice as big on average even without FP support.
Many unit tests that were skipped with CONFIG_CBPRINTF_NANO are now
enabled, and a few more were added for good measure.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The ASSERT order is backwards, where the shell->ctx is being accessed
before it is being checked as valid. Moving the check for the
shell->ctx to before the using it.
Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
Fix the order so that it reflects the actual initialization order,
rather than putting PRE_KERNEL initializations after APPLICATION.
Add SMP in the proper location.
Use the helper function to provide unique identifiers for "devices"
that don't have a device pointer (so don't have a name).
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Refactor the output of device list to use standard API to retrieve the
list of devices, and to always display a status rather than hiding
disabled/failed devices.
Add API to associate a distinct identifier with any "device" that does
not have a name.
Where a device has requires dependencies display the devices on which
it depends.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Refactor the output of device list to use standard API to retrieve the
list of devices, and to always display a status rather than hiding
disabled/failed devices.
Add API to associate a distinct identifier with any "device" that does
not have a name.
Where a device has requires dependencies display the devices on which
it depends.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Function shell_root_cmd_find was only used in shell_utils.c file.
Hence it is changed to static and renamed to root_cmd_find.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE
and use PM_ as the prefix for all PM related Kconfigs
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Updated the documantation with newly added configuration features.
Added information where to find minimal shell config file.
Added information how to activate particular features.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
The help command is needed to list all available commands
when it is not possible to use the tab key.
Previously when build-in commands were deactivated command
help was not compiled as well.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Added IS_ENABLED(CONFIG_SHELL_CMDS_SELECT) to remove a dead code.
Added static inline function that returns pointer to the selected
command.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
When history feature is not compiled in it makes no sense to
trim the command. In addition when history feature is not active the
shell will not call function history_put.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
When calculating the size of unused interrupt stacks on SMP,
the "unused" variable is not cleared between CPUs. So this
value keeps incrementing and does not reflect actual unused
size for CPUs other than the first one. So clear the "unused"
variable for each CPU.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This reverts commit e812ee6c21.
This is the initial step towards replacing the core Zephyr formatting
infrastructure with a common functionally-complete solution.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The objects should be const-qualified for consistency with other uses,
including declarations in headers.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Default shell stack size is not always enough when used with
OpenThread. Increasing it to the found adequate value.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Fix a compilation error when shell help feature was not selected and
but shell help command was compiled.
Fixes: #29042
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
With only single RX buffer there is a high chance that such buffer will
not be processed before new bytes come in over UART. This is why it is
good to have at least two buffers, one which can be processed by SMP
layer, while another is being filled with new incoming bytes.
Add Kconfig option which allows to configure multiple buffers filled
with received UART SMP fragments. Use default value of 2, so we can
safely process already received frame in thread, while new fragment
comes in concurrently.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
So far there was a simple char array used as buffer, with additional
variable representing number of bytes already written into it. After
full frame was written, a boolean flag was simply set to notify thread
about being ready to be processed. There was however no mechanism
implemented to prevent new incoming bytes from overwriting such buffer
before (or during) being processed.
Use net_buf to store temporary frame. Define dedicated net_buf_pool,
from which such buffer will be allocated and freed after being
processed. This will prevent from reusing the same buffer before having
it fully processed (and returning once again to available buffer pool)
in shell thread.
Define also fifo that will store buffers that are ready to be
processed. This will be the mechanism for notifying thread about new
UART SMP fragments.
net_buf pool and k_fifo are used on purpose, keeping in mind their
additional overhead (mostly in RAM/ROM usage). This makes the code ready
for increasing number of buffers if needed. In this commit however we
stick with only 1 buffer, to keep minimal changes in processing flow.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
To get a list of all supported shell commands user must hit the TAB
button. It may be awkward on some terminal emulators. This change
enhances the help command in a way it will in addition print all
supported commands.
Fixes: #28785
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
Functions shell_help_subcmd_print and shell_help_cmd_print
are more generic. Now they can operate on command passed as an
argument not hard coded active_cmd.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
Commit 770f232a67 removes an array
termination from the shell_make_argv function. This function was
called from two functions: execute and tab_handle. In the mentioned
commit termination was added only in the execute function.
As a result calling tab_handle function was causing a segmentation
fault. This fix adds array termination to the tab_handle function.
Fixes#28434
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
Closes: #28331
Configurable initialization priority is useful when using CDC ACM
serial device, for example.
Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
Shell was accepting CONFIG_SHELL_ARGC_MAX+1 arguments which lead to
memory corruption and fault. Added error message reported when number
of provided arguments exceeds CONFIG_SHELL_ARGC_MAX.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This fix prevents a scenario when command callback calls shell_fprintf
after the shell cleared the command context flag and before setting
the prompt correctly.
Fixes#27522
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
shell_fprintf requires that formatted output be emitted with a
putchar()-like output function. Newlib does not provide such a
capability. Zephyr provides two solutions: z_prf() which is part of
minimal libc and handles floating point formatting, and z_vprintk()
which is core and does not support floating point.
Move z_prf() out of minimal libc into the core lib area, and use it
unconditionally in the shell.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The smp_shell_rx_byte has been renamed to smp_shell_rx_bytes and now
accepts data buffer pointer and its size as parameters. Return value
has been changed to size_t and represents number of bytes processed from
the given buffer.
The change has been done to more efficiently serve most common scenario
when the function is called in loop to process buffer, byte by byte.
Previously such operation required passing each byte separately,
with the change the function will work directly on source buffer
reducing number of calls and byte copy operations.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
In case when SMP has been enabled, the shell_thread would be signaled
even if no data has been read from fifo.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
In case when shell ring buffer gets full the data may still be taken
from the UART fifo, byte by byte, and accepted by the SMP back-end,
if the back-end has been enabled.
Unfortunately the uart_rx_handle failed to check if it has been
successfull in reading a byte from the fifo, before passing it to
the SMP for processing, which could lead to processing random stack data
as a part of an SMP frame.
Additinally, when the SMP would have accepted the byte,
the uart_rx_handle would fail to signal shell_thread, that the SMP has
internally buffered data that could be processed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
So far SMP shell transport was initialized in APPLICATION run level, but
shell over UART was initialized in POST_KERNEL. This could end up in
situation when received frames were scheduled for further processing in
SMP layer, when it was not initialized yet.
Export smp_shell_init() function declaration and call it before shell is
initialized with all its receive data handlers. This prevents situation
when data is scheduled for processing in SMP layer, when that one is not
ready yet.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>