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>
The device returns 2 bytes for GetStatus(Device) request.
If the device is self-powered then it shall respond with
bit 0 set to 1 when responding to GetStatus(Device) req.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Zephyr allows an application to register additional file systems,
which may have maximum filename lengths different from the in-tree
FatFs and littlefs options. Provide a Kconfig variable that allows
the default inference to be overridden.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
The documentation claims that Zephyr supports external file system
implementations, and there's no reason not to do so. Rework the API
to allow this.
Note that the file system type cannot legally be an enum anymore,
since we need to support file system types that don't have an
identifier assigned in that enum. Rely on the implicit conversion of
enum values to int to preserve backwards compatibility.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Flash memory can be write but there is no way to check flash integrity.
Add flash_img_check method that verify flash integrity. This is useful
to avoid firmware reboot and test. Another use is ensure that firmware
upgrade routines from internet server to flash slot are performing
properly. This uses flash_area_check_int_sha256 method to check a
SHA-256 hash. On sucess match, zero is returned, otherwise a negative
errno value.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Add SHA-256 flash integrity method. It reads flash data from a
device giving an offset creating a SHA-256 hash to be compared
with a reference. On sucess match, zero is returned, otherwise
a negative errno value.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
When lazy loading of CCCs are enabled there is no settings set handler
register for the 'bt/ccc' key, this means that the settings set handler
for 'bt' key is called instead. This handler does not know what to do
for the 'ccc' subkey, and returns -ENOENT for the entry.
This results in an error message logged by the settings subsystem.
"E: set-value failure. key: bt/ccc/f8c39e2f98210 error(-2)"
Fix this by providing an empty handler for the 'bt/ccc' key when
Lazy Loading feature is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix periodic advertising delete implementation, to not
NULL the callback pointer when deleting the instance so
that the application's terminate callback can be called
thereafter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This new option allows to include `sockets_tls.c` into the build when
socket offloading is enabled.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Given that the offloaded poll handling differs from the poll handling of
native sockets (entire poll function call is offloaded), some
adjustements were needed to make TLS socket work with offloaded poll
calls.
To achieve this, in case socket offloading is used, instead of jumping
directly to the offloaded poll call, a TLS wrapper for the offloaded
poll will be called. This wrapper will do additional checks at the
mbedtls level, to verify that the event is only notified to the caller
when the application data is available (i. e. not to report events
during handshake or when partial data is received, not ready to
decrypt).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Separate TLS sockets implementation from net_context layer. Instead of
calling net_context functions directly, create an underlying TCP/UDP
socket, and call socket functions on it instead. This results in a
simpler design, where we don't need to duplicate specific parts of code
from the native socket implementation. Additionally, this allows to use
a different TCP/UDP stack underneath (i. e. when sockets offloading is
used).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds helper function to verify protocol, which was done in
two different places in the code. The function returns the underlying
protocol information on success.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
GDB on host may ask the guest to read the a pointer contents even if
it is pointing to NULL. Send an error code when this occurs.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
It implements gdb remote protocol to talk with a host gdb during the
debug session. The implementation is divided in three layers:
1 - The top layer that is responsible for the gdb remote protocol.
2 - An architecture specific layer responsible to write/read registers,
set breakpoints, handle exceptions, ...
3 - A transport layer to be used to communicate with the host
The communication with GDB in the host is synchronous and the systems
stops execution waiting for instructions and return its execution after
a "continue" or "step" command. The protocol has an exception that is
when the host sends a packet to cause an interruption, usually triggered
by a Ctrl-C. This implementation ignores this instruction though.
This initial work supports only X86 using uart as backend.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
SERIAL_HAS_DRIVER and UART_INTERRUPT_DRIVEN should be selected by the
driver. If something needs is should dependson these options.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
TEST_RANDOM_GENERATOR should not be used in subsystems because it does
not generate truly random numbers. This is indented to be used only
for tests purpose.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When connection is closed and we send ACK flag, use proper seq
values so that any data that is still in flight will get acked too.
Currently this assumes that window is still open.
Fixes#27876
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Entropy device, as being unique here, does not need to be passed through
mbedtls and can instead set static locally.
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Uart device is unique and thus does not need to be passed through the
logging context. Only the assert() requires a void * cast.
On log_output side, the device usage was removed. It is actually unclear
why it has been set like this since depending on the context, it can be
anything and not specifically a device.
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
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>
Many #ifdefs can be removed, but the UNPROV_BEACON_INT Kconfig
variable needs to be also made available also. This is done by making
its prompt (user selectability) optional rather than the option
itself. This approach is fine for "parameter style" options, but
should probably not be used for feature enabling options.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This emulator supports basic reads and writes with 8-bit addressing.
It connects itself to any AT24 devices it finds in the device tree. The
I2C emulation controller driver is used to direct I2C messages from the
AT24 driver to the AT24 emulator.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Create a header file and implementation for emulators. Set up a linker
list so that emulators can be found and initialised at start-up.
Emulators are used to emulate hardware devices, to support testing of
various subsystems. For example, it is possible to write an emulator
for an I2C compass such that it appears on the I2C bus and can be used
just like a real hardware device.
Emulators often implement special features for testing. For example a
compass may support returning bogus data if the I2C bus speed is too
high, or may return invalid measurements if calibration has not yet
been completed. This allows for testing that high-level code can
handle these situations correctly. Test coverage can therefore
approach 100% if all failure conditions are emulated.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Simon Glass <sjg@chromium.org>
A build assert in dummy.c lists the following requirement:
[...] receive thread priority shall be higher than the Bluetooth
Host's Tx and the Controller's receive thread priority.
This is required in order to dispatch Number of Completed Packets
event before any new data arrives on a connection to the Host threads.
The drivers uses a priority that is equal to the Host TX thread,
and since they don't use the CONFIG define that is only available
to the controller then this BUILD_ASSERT will not catch the
requirement.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Following are the changes to variable names that are matching
with tag names (Rule 5.7 violations)
In kernel.h, event_type is matching with a tag name in
lib/os/onoff.c. Added a _ prefix to event_type and
also to the macro argument names.
In userspace.c, *dyn_obj is matching with the tag name
dyn_obj in the file itslef. Changed it to dyn
In device.h, device_mmio.h, init.h and init.c,
changed the *device to dev. Except for one change in
init.h
Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
Adds a Config Client API for deleting netkeys on the target node, with
matching shell command.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added a callback that lets an application get write error
(if any) when subscribing to a gatt characteristic.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
In certain application configuration the networking log backend must not
be started, when the application starts. Starting it must be delayed
until routes to the logging server are established.
This commit introduces a new Kconfig setting to be able to control that
behaviour.
Fixes#27464
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
The commit fixes the problem where the SMP over shell responses have
been sent with use of k_str_out(), which is configured to use console
UART directly. This caused problem when user decided to attach
shell to a different UART then the one that has been used by
the console driver, because the SMP responses would still be sent
to the console UART rather than the shell UART.
The updated code uses, for shell SMP responses, the UART that has been
selected for the shell.
Fixes#26939
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This patch removes the hard-coded number of transfer buffers and allows
you to increase the number of transfer buffers when multiple USB
devices are used.
Signed-off-by: Pavel Král <pavel.kral@omsquare.com>
Fix option USE_IDENTITY for bt_le_ext_adv_* API.
The random static identity address that was set in bt_le_ext_adv_create
was overwritten in bt_le_ext_adv_start in the call to
le_adv_set_private_addr.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Unit tests may include C++ code, so ensure the compiler flags are
consistent to avoid link errors.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Add the nRF52805-specific file with radio related defintions.
Use also specific configurations for certain PPI channels used by
the controller, as this SoC has limited number of programmable PPI
channels.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Change hard-coded (D)PPI channel bitfield values to the BIT() macro
calls with the corresponding channel base value supplied as parameter,
to make it possible to actually change this base value if needed.
Remove unused *_EXCLUDE macros.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
nRF5340 does have SWI peripheral, hence use it instead of
the single available EGU peripheral. Use of SWI will allow
controller's LLL, ULL_HIGH and ULL_LOW execution context to
be independently configured to different interrupt priority
levels.
When ULL_HIGH priority equals ULL_LOW priority, only SWI2
is used by controller. Otherwise, SWI3 is used for ULL_LOW.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Detect and handle AD data set race condition between thread
and ISR context.
Fixes#27637.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add cpu_dsb() hal interface so that data synchronization
barrier be used in ARM Cortex M4 and M33 architecture
implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Set the AD data double buffer first index as volatile
because it is modified in LLL ISR context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>