Commit graph

21541 commits

Author SHA1 Message Date
Dominik Ermel
94968dfee4 storage/stream/flash: Don't update last erased page offset on failure
The stream_flash_erase_page would update stream_flash_ctx member
last_erased_page_start_offset, to page offset it attempted to erase,
even if such operation failed.
The commit changes this behaviour so that in case of failure the
last_erased_page_start_offset would still hold previously, successfully,
erase page offset.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Vinayak Kariappa Chettimada
21e83e40ad Bluetooth: controller: Fix ticker job_guard
Move the ticker job_guard reset to after
ticker_job_compare_update, so that the ticks_current and
ticks_slot_previous are updated before ticker_worker gets
to execute. Without this fix, there is a possibility that
ticker_worker will use incorrect ticks_slot_previous and
ticks_current value under race conditions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-02 15:51:48 +01:00
Vinayak Kariappa Chettimada
ebecca7c47 Bluetooth: controller: Fix ticker to avoid recursive ticker_job
Fix ticker job to defer itself to avoid recursive
invocation to itself due to ticker interface calls from
inside the ticker operation callbacks.

The recursive use was exposed when using ticker stop
operation callback of stopping an auxiliary PDU to stop
the primary PDU scheduling as part of generation of
Advertising Terminate event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-02 15:51:48 +01:00
Robert Lubos
651e4ac62b net: lwm2m: Make sure that endpoint string is NULL terminated
In case the endpoint string provided by the application is longer or
equal to CLIENT_EP_LEN - 1, the strncpy() function will not add the NULL
terminator. As the endpoint buffer is treated as a C-string in other
places in the code, make sure it's NULL terminated by adding NULL
explicitly at the end of the buffer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-02 09:16:01 -05:00
Robert Lubos
f14a9556d6 net: lwm2m: Make query buffer large enough to encode all query strings
Make sure query string used by the lwm2m_rd_client is large enough to
encode any query string that can be sent during bootstrap/registration.
As the maximum query string length is related to the endpoint name,
which is limited by `CONFIG_LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH`,
make the query string corellated to the value of this config.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-02 09:16:01 -05:00
Hubert Miś
14b2b2d63e net: shell: UDP commands
This commit adds to network shell set of basic commands for UDP
protocol to receive and send datagrams.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-02 14:20:52 +02:00
Dominik Ermel
bbacab82f1 fs: shell: cmd_read does should open file for read-only
The cmd_read function uses fs_open with FS_O_CREATE | FS_O_RDWR flags
to open file it will only read; the flags has been changed
to FS_O_READ.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-01 12:57:55 -06:00
Jakub Rzeszutko
7e46765153 shell: add getopt library support
This functionality is is enabled by setting CONFIG_SHELL_GETOPT.
It is not active by default.

User can call following functions inside command handlers:
 - shell_getopt - getopt function based on freebsd implementation
 - shell_getopt_status_get - returns getopt status

Beware when getopt functionality is enabled shell will not parse
command handler to look for "-h" or "--help" options and print
help message automatically.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-03-01 09:50:32 -05:00
Jakub Rzeszutko
b64fb7c92d shell: make detecting help option optional
Shell will not "steal" by default "-h" and "--help" each time
help functions are enabled.
This change is necessary to implement and use the getopt library.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-03-01 09:50:32 -05:00
Jacob Siverskog
c2afabcc7c usb: mass storage: add missing prompt to Kconfig
thread stack size was missing input prompt.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-03-01 09:27:57 -05:00
Jukka Rissanen
9df116ed0f net: utils: Check null pointer in net_sprint_ll_addr_buf()
Check NULL value when we are trying to print link address
because the link address can be null.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-01 14:23:30 +02:00
Jukka Rissanen
b86b778ca5 net: utils: net_pkt_hexdump() was missing log_strdup()
As the input string can be allocated from stack, we need to use
log_strdup() in net_pkt_hexdump() to print the extra string.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-01 14:23:30 +02:00
Ioannis Glaropoulos
1d55f94a32 testsuite: only enable TEST_ARM_CORTEX_M when building tests
Add a dependency on TEST_ARM_CORTEX_M switch, so it
only gets switched on when building tests, not samples,
as originally intended.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-01 14:33:26 +03:00
Vinayak Kariappa Chettimada
f9511079b2 Bluetooth: controller: Remove vendor specific internal LLL include
Remove inclusion of vendor specific internal LLL include
files in ULL source code.

Prefix `lll/` include file path to correctly include vendor
defined types and function implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-01 11:24:40 +01:00
Krzysztof Chruscinski
b4da16e81c logging: Refactor msg_finalize
Extract notifying about new log message into separate function.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-02-28 17:12:29 -05:00
Krzysztof Chruscinski
e0392c5a86 logging: Cleaning up log minimal
Removed printk.h include from log_core.h.

Since LOG_PRINTK cannot be enabled with LOG_MINIMAL removed
support for both.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-02-28 17:12:29 -05:00
Johann Fischer
6568f4ab99 usb: hid: remove usb_hid_descriptor from public header
usb_hid_descriptor struct is only used internally and
is not intended to be used by the USB HID device application.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-02-28 16:50:24 -05:00
Johann Fischer
879a5cfe48 usb: hid: replace deprecated macros
Replace deprecated macros.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-02-28 16:50:24 -05:00
Jordan Yates
54d13ba589 lorawan: add callback for datarate changes
Add a callback to notify applications when the datarate has changed.
This allows applications to know when payload sizes have changed without
needing to call `lorawan_get_payload_sizes` before each transmission.

This also enables:
 * Monitoring of network conditions on the device
 * Determining if a network connection has been lost

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-02-28 16:36:57 -05:00
Jordan Yates
bdf13bcc1d lorawan: store current datarate for ADR
Keep track of the current network datarate when ADR is enabled.

The datarate can change in two circumstances. Firstly, the datarate may
change as a result of a command from the LoRaWAN server as the link
budget varies. Secondly, the datarate may be changed due to not
receiving an expected ADRACKReq response. This necessitates querying the
datarate on both packet reception and transmission to provide timely
notifications to the application.

Due to querying the default region datarate at startup and validating
manual datarate parameters, when ADR is not enabled the datarate will
never be different from the value provided to `lorawan_set_datarate`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-02-28 16:36:57 -05:00
Jordan Yates
8c1a45b90d lorawan: queriable minimum datarate
Add a function to query the minimum possible datarate on the network.
This value may change over the lifetime of the connection as a result
of commands from the network server.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-02-28 16:36:57 -05:00
Jordan Yates
fa09d0d612 lorawan: queriable payload sizes
Add the ability for applications to query the maximum size of packets
that can be sent. This must be dynamically queried as the sizes change
with datarate, region, and as MAC commands are added by the stack.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-02-28 16:36:57 -05:00
Jack Rosenthal
ea9866dc86 shell: add an option for minimal default configuration
The default shell configuration has heavy flash and memory requirements,
requiring project maintainers to set many configuration options to "n"
to keep flash and memory requirements within reason.

This adds a new configuration option, CONFIG_SHELL_MINIMAL, which will
disable flash and memory heavy options by default, and allow project
maintainers to select/imply only the options they want.

On a quick test from an ARM board I'm working on, enabling this option
cut flash space requirements by ~8 KB, and memory requirements by ~1 KB.

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
2021-02-27 10:26:33 +01:00
Vinayak Kariappa Chettimada
92f5b68f2c Bluetooth: Use bt_id_get function to get count
Allow NULL pointer to be passed to bt_id_get function so
that only count can be fetched.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-26 08:12:43 -05:00
Jack Rosenthal
bc58706538 shell: typo correction in Kconfig
"supporort" -> "support"

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
2021-02-25 15:19:25 -05:00
Peter Bigot
84334badfb bluetooth: host: improve documentation on stack override
There's a prompt to set the TX stack size, that's documented as an
advanced setting, but attempts to override it it are rejected unless
you add another setting that allows it to be change.  Tell the user
how to make changes work.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-02-25 16:53:35 +02:00
Piotr Pryga
deeecaaa8f Bluetooth: host: direction: Remove compilation warning
Remove compilation warning caused by currently not used
hci_df_set_conn_cte_tx_param function.
Code is sorrounded by #ifdef CONFIG_BT_CTLR_DF_CONN_CTE_RSP.
The CONFIG_BT_CTLR_DF_CONN_CTE_RSP is changed to be disabled
by default (until complete implementation of the feature is
provided).

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Piotr Pryga
8dcf8c111f dts: bindings: net: wireless: Change dfe-ant-num property name
Change dfe-ant-num propert name to dfe-antenna-num.
The change is conde to keep the same naming style
for all properies, like dfe-pdu-antenna property.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Piotr Pryga
64cb4bbc37 Bluetooth: controller: LLL: DF add initialization of ant switching GPIOs
Add initialization of GPIOs that are used for antenna switching.
GPIOs provided to DFE extension in Radio peripheral, to drive
antenna switching, should be initialized in GPIO peripheral beforehand.
The initialization is optional and may be disabled by Kconfig.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Piotr Pryga
e91a54799e Bluetooth: controller: LLL: Fix not switching antennas in AoD mode
Antenna switching done by Radio with use of GPIOs provided in
PSEL.DFEGPIO registers. Registers were initialized once during
controller initialization.
At preparation of new radio event, Radio peripheral is powered
down and up to resset its registers. It is related with multi
protocol handling and possible leftovers in Radio registers.

Due to that, PSEL.DFEGPIO registers should be initialized
at the preparation of every event that will transmit
or receive CTE and run antenna switching.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Piotr Pryga
9b3c941d4d Bluetooth: controller: Kconfig: Disable ant switching when CTE Rx not supp
Anternna switching should be disabled when CTE Rx is not supported
or disabled. Added missing dependency on BT_CTLR_DF_CTE_RX.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Piotr Pryga
dee17b0bca Bluetooth: controller: Fix compilation errors related with DF code
Add missing declarations of functions that are compiled in when
CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY is selected
Add missing include of header file.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-02-25 14:53:27 +01:00
Vinayak Kariappa Chettimada
8806225cb2 Bluetooth: controller: openisa: Fix unsupported ISR profiling
Fix duplicate include of lll_test.c file under the
unsupported ISR profiling feature in OpenISA port.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-25 12:54:35 +01:00
Vinayak Kariappa Chettimada
a0e34a1477 Bluetooth: controller: Fix missing cond. compile of adv extra data
Fix missing conditional compilation of Advertising PDU's
exta data member.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-25 12:54:20 +01:00
Vinayak Kariappa Chettimada
298b3ca467 Bluetooth: controller: #if defined(...) vs #if IS_ENABLED(..)
Use `#if defined(...)` instead of `#if IS_ENABLED(..)` when
conditional compilation of definitions in source code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-25 12:54:13 +01:00
Shlomi Vaknin
e61834c9ed disk: stm32: Select USE_STM32_HAL_SD_EX on stm32l4
This commit prepares supporting sdmmc on
stm32l4+ devices. When trying to compile the
sdmmc driver there is a compilation error
because `HAL_SDEx_DriveTransceiver_1_8V_Callback`
is not implemented. We solve this by compiling
also `sd_ex` in cube as this function is implemented
there as weak.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-02-24 18:10:09 -06:00
Johan Hedberg
0ba9437938 Bluetooth: L2CAP: Fix missing buffer length check for sdu_len
We should verify that the buffer has sufficient data before attempting
to parse the SDU length field. If we get a too short packet just
disconnect the channel.

Fixes #32497

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-02-24 23:52:43 +02:00
Vinayak Kariappa Chettimada
8ded9c2487 Bluetooth: controller: Fix undeclared BT_CTLR_SCAN_SET
Fix undeclared BT_CTLR_SCAN_SET when BT_OBSERVER is
disabled.

Regression in commit bee6aa325b ("Bluetooth: controller:
Increased thread context operation queue count").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-24 13:46:31 -06:00
Joakim Andersson
f8005c7ba9 Bluetooth: host: Fix array overrun of client features bitset
Fix array overrun of client features bitset, where CF_BYTE_LAST was
incorrectly defined as 2 using module instead of divide.
Also fix additional bit-logic when number of bits would exceed a byte:
 - Inner for loop iterates from 0 to number of bits on a single byte.
 - Same bitmask used for all bytes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-24 10:37:45 -05:00
Vinayak Kariappa Chettimada
9cb07ab413 Bluetooth: controller: Use define for common ext. header minimum size
Use define for the common extended header format's minimum
length value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-24 15:53:56 +01:00
Vinayak Kariappa Chettimada
c3befdc771 Bluetooth: controller: Handle ACAD in Periodic Advertising
Handle ACAD field in when updating the Advertising Data in
Periodic Advertising PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-24 15:53:56 +01:00
Martí Bolívar
31c1dc58ad Bluetooth: controller: fix typo
A macro is misspelled.

Fixes: #32599
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-24 07:21:48 -05:00
Hubert Miś
dd319c2d4c net: socket send timeout option
This patch adds SO_SNDTIMEO option used to time out socket sending
operations.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-24 14:16:33 +02:00
Christian Taedcke
c467149ad9 net: pkt: Add function net_pkt_get_contiguous_len()
This returns the available contingous space in the packet starting from
the current cursor position.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2021-02-24 09:43:52 +02:00
Joakim Andersson
61584fb35f Bluetooth: host: Don't auto-update device name and document behavior
Don't auto-update the device name in the advertising data as that
would clear any other scan-response data set by the application.
Document the behavior of the advertise with device name option
and the need to update data by the application to make sure
advertising data does not get cleared.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-23 20:08:51 +01:00
Joakim Andersson
84dffe5b3c Bluetooth: host: Fix endianness issue in reading CPF descriptor
Fix endianness issue in reading CPF descriptor not converting from
native endianess to little-endian on the 'unit' and 'description'
fields.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-23 20:07:53 +01:00
Joakim Andersson
22218129a6 Bluetooth: host: Use definitions of UUID values instead of constants
Use the definitions of UUID values instead of magic constants with
explanation in comment.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-02-23 20:07:53 +01:00
Nicolas Pitre
fb73ac392c lib/os/cbprintf_nano.c: several improvements
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>
2021-02-23 19:39:59 +01:00
Vinayak Kariappa Chettimada
27b7c27dca Bluetooth: controller: Use Ext. Advertising association for BIG created
Check for associated Extended Advertising set to determine
whether Broadcast ISO Group instance has been already
created.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-23 19:36:41 +01:00
Vinayak Kariappa Chettimada
fc2e71dfec Bluetooth: controller: Add association between adv, sync and iso
Add association between extended advertising, periodic
advertising and broadcast ISO instance, so that attempts to
create and terminate BIG can detect error conditions.

Error conditions being, trying to create BIG without a valid
periodic advertising train, or terminating BIG without prior
creation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-23 19:36:41 +01:00