Commit graph

19212 commits

Author SHA1 Message Date
Jordan Yates
7598330a74 sd: lower log level for boot message
This log message does not need to be repeated 10 times at the INFO level
when the same information is provided after all the retries are done:
```
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Legacy card detected, no CMD8 support
<inf> sd: Card does not support CMD8, assuming legacy card
```
to
```
<inf> sd: Card does not support CMD8, assuming legacy card
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-17 08:54:51 -04:00
Benjamin Cabé
3735ae94a1 profiling: doc: clean up grammar/spelling
Clean up documentation pages for the new perf tool
as they contained several typos, grammar errors, and
duplicated content between main doc page and sample
page

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-08-16 16:30:07 +01:00
Jonathan Rico
80a92f51a5 Bluetooth: Host: Add missing bt_tx_irq_raise()
Trigger the TX processor on connection teardown.

When a disconnection happens before the controller has acknowledged some
ACL fragments the host has sent, we run `process_unack_tx()` to free
those unacknowledged buffers and their associated TX contexts.

The problem is that the TX processor still holds a reference to the conn
object. That reference is not released until the TX processor is
triggered again and figures out that the connection is invalid.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-16 16:29:41 +01:00
Vinayak Kariappa Chettimada
3590bd648f Bluetooth: Controller: Fix missing invalid aux offset check
Fix missing invalid aux offset check that was being caught
in a development assertion check. If aux offset where less
than the PDU time of the primary channel PDU, radio was
redundantly being setup delayed for reception that was
being caught in an assertion check.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-16 16:29:28 +01:00
Vinayak Kariappa Chettimada
521ea5561a Bluetooth: Controller: Add assertion checks for delayed radio start
Add assertion checks for delayed radio start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-16 16:29:28 +01:00
Johann Fischer
f851cad162 usb: device_next: add device configuration change notification
Notify only if the device configuration has changed. Pass only the
configuration value as the message status, the actual device speed can
be obtained with usbd_bus_speed().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-08-16 08:50:25 -04:00
Théo Battrel
f3dcaaee35 Tests: Bluetooth: Add another ISO frag test
This test create a setup where an ISO broadcaster will send fragmented
data and get stopped after sending the first fragment and repeating that
operation multiple time to verify that buffers are not leaked.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-08-16 11:20:14 +01:00
Théo Battrel
3a098c9f61 Bluetooth: Host: Unref ISO fragments after disconnection
When sending data using ISO and the data is fragmented, if the
connection is cut before all the fragments are sent, the data buffer
will be leaked.

Fix the issue by unref'ing the buffer when ISO is not in a connected
state.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-08-16 11:20:14 +01:00
Théo Battrel
70696f5b0f Bluetooth: Host: Free ISO TX context
When disconnected while sending data, if ISO doesn't get the number of
completed packets it will not call `process_unack_tx` and thus will leak
TX context.

Fix that by setting the connection state in ISO disconnection which will
trigger a call to `process_unack_tx`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-08-16 11:20:14 +01:00
Alberto Escolar Piedras
17369f6209 unit_testing: Correct one comment refering to native_posix
It should have reffered to the architecture,
not one of its board's name.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-08-16 09:21:18 +01:00
Henrik Brix Andersen
69fe9b0c50 net: buf: remove use of special putter and getter functions
Convert users of net_buf_put() and net_buf_get() functions to use
non-wrapped putters and getters k_fifo_put() and k_fifo_get().

Special handling of net_bufs in k_fifos is no longer needed after commit
3d306c181f, since these actions are now
atomic regardless of any net_buf fragments.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-08-16 09:55:11 +02:00
Emil Gydesen
9014bb66a6 Bluetooth: Logging: Fix typo Voluem -> Volume
Fix a small typo.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-16 09:50:03 +02:00
Luis Ubieda
775cd201c3 bluetooth: host: Add API to get a connection's UATT MTU
Similar to bt_att_get_mtu but only considering the Unenhanced ATT
channel.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-08-15 10:17:13 +01:00
Pisit Sawangvonganan
14c6925596 ztest: replace shell_fprintf(sh, SHELL_ERROR, ...) with shell_error
Replace `shell_fprintf(sh, SHELL_ERROR, ...)` with
`shell_error(sh, ...)` since it brings the same underlying
action with less typing.

Note: `shell_error` already concatenates `\n` to format strings,
so we remove `\n` from the original code.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-15 10:16:36 +01:00
Pisit Sawangvonganan
347c56c600 ztest: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in `subsys/testsuite/ztest/src/ztest.c` file.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-15 10:16:36 +01:00
Félix Piédallu
61e5958eff log: formatting: Add configuration for blue DBG log
It's usual to show debug logs as blue.
Showing dbg and info with different colors are good,
but it's preferable to keep info logs with default
color.

Signed-off-by: Félix Piédallu <felix@piedallu.me>
2024-08-14 12:35:01 -04:00
Seppo Takalo
1cd6b5f1c1 net: lwm2m: remove deprecated APIs and confs
Remove deprecated APIs and configs:
* CONFIG_LWM2M_RD_CLIENT_SUPPORT
* lwm2m_get_u64()
* lwm2m_set_u64()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-08-14 09:14:43 -04:00
Alberto Escolar Piedras
f5f5937657 subsys/bluetooth: Correct BT_HCI_VS_EXT_DETECT default
native_sim should be treated as native_posix.
Let's fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-08-14 09:14:10 -04:00
Jonathan Rico
73572e4151 Bluetooth: L2CAP: Initialize private channel object members
We own those fields, so we should initialize them before use.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-14 10:47:49 +01:00
Seppo Takalo
b5ac5f7eba net: lwm2m: Send is only supported on LwM2M 1.1
LwM2M SEND functionality is defined in LwM2M v1.1
So quard the condition with protocol version, not
server object version.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-08-14 10:47:24 +01:00
Jun Lin
1aff275642 soc: npcx: scfg: select host interface type in global
The Host Interface Type in the DEVCNT register sets the HIF type
(either eSPI or LPC).
Currently, it is configured in the host-interface-related drivers like
eSPI or SHI. However, some I/O pads sourced from VHIF in the other
modules such as GPIO and I3C also rely on this field. It might be
problematic when using those I/Os without enabling eSPI or SHI drivers.
This commit moves the setting from the specific drivers to the global
system initialization function scfg_init().

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-08-14 10:47:15 +01:00
Vinayak Kariappa Chettimada
85790c95a9 Bluetooth: Controller: Introduce EVENT_MAFS_MIN_US value
Introduce Controller dependent EVENT_MAFS_MIN_US value to
use as the value when populating the aux offset between
Extended Advertising primary and auxiliary channel PDUs.

This can be used as workaround for peers having difficulty
receiving Extended Advertising PDUs with near 300 us MAFS
values used in aux offset calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:46:48 +01:00
Vinayak Kariappa Chettimada
4dbfb22a7e Bluetooth: Controller: Relax radio packet pointer assignment deadline
Relax the radio packet pointer assignment deadline assertion
until access address being transmitted. The PDU buffer is
probably only needed just after access address is being
transmitted or received by the radio. This will give some
more breathing room for slow CPUs like in nRF51x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
642d4be940 Bluetooth: Controller: Fix regression using speed optimization
Fix regression using speed optimization introduced in
commit 1b7fe792e0 ("Bluetooth: Controller: Support Link
Time Optimizations (LTO)").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
b9a7a64563 Bluetooth: Controller: nRF51x: Fix regression in encrypted connection
Fix regression in encrypted connection introduced in
commit f3deccda91 ("Bluetooth: Controller: CCM read data
to early when DF enabled on PHY 1M").

Due to this nRF51x SoC hang waiting to encrypt and/or
check MIC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
40b71c9773 Bluetooth: Controller: Fix PDU length in case of ISR latency issue
In case of ISR latencies, if packet pointer has not been
set on time then we do not want to check uninitialized
length in rx buffer that did not get used by Radio DMA.
This would help us in detecting radio ready event being
set? We can not detect radio ready if it happens twice
before Radio ISR executes after latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
e36ddffa7a Bluetooth: Controller: Fix empty PDU buffer overrun under ISR latency
Only 3 bytes (PDU_EM_LL_SIZE_MAX) is required for empty PDU
transmission, but in case of Radio ISR latency if rx packet
pointer is not setup then Radio DMA will use previously
assigned buffer which can be this empty PDU buffer. Radio
DMA will overrun this buffer and cause memory corruption.
Any detection of ISR latency will not happen if the ISR
function pointer in RAM is corrupted by this overrun.
Increasing ISR latencies in OS and CPU usage in the
ULL_HIGH priority if it is same as LLL priority in
Controller implementation then it is making it tight to
execute Controller code in the tIFS between Tx-Rx PDU's
Radio ISRs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
8ef919a7a4 Bluetooth: Controller: Fix ISR profiling for single timer use
Fix ISR profiling when using single timer for tIFS radio
switching wherein in the timer is cleared on every radio
end. Hence, the captured timer value is the latency and
does not required the radio end timestamp to be subtracted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
53b6bc56fc Bluetooth: Controller: Verbose radio is ready assertion
Provide Radio ISR latency in microseconds when asserting due
to high ISR latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
409402f0cc Bluetooth: Controller: Add ISR profiling using ticker ticks
Add ISR profiling using ticker ticks, hence profile ISR
CPU use outside radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
56ca9b873d Bluetooth: Controller: Use uint16_t to store ISR profiling value
Use uint16_t to store ISR profiling value to avoid overflow
in case of higher latencies.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
90bc2b2064 Bluetooth: Controller: Fix in-system ISR profiling for adv and conn
Fix in-system ISR profiling for advertiser and connection
role for the missing implementation when there is CRC error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Emil Gydesen
ba62c8d876 Bluetooth: BAP: Support setting different values per dir in CIG
The interval and latency for a CIG are set for each direction now,
allowing applications to use e.g. 10ms for sink ASEs and 7.5ms for
source ASEs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-14 09:42:16 +02:00
Reto Schneider
b03fcfa0cf net: lib: lwm2m: Add name to choice symbol
Add name to choice symbol, so that default value can be changed
downstream.

Developed-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-08-14 09:40:34 +02:00
Pisit Sawangvonganan
d5a458df2e net: l2: ppp: ensure proper null-termination in ppp_fsm_close
- Remove the `strlen`, as it is unnecessary for safe copying.
- Limit the `strncpy` to `sizeof(fsm->terminate_reason) - 1`
  to ensure the last byte is reserved for null-termination.
- Add an explicit null terminator to guarantee correct string termination.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-14 09:40:23 +02:00
Tom Finet
5e834cc4b6 net: capture: Add packet capture stats for dropped packets
Cloning a packet for a capture may fail due to insufficient memory.
In such a case, the networking statistics should be updated
to reflect this processing error. This commit updates the processing
error count on the capture tunnel network interface because this is
the interface that the captured packet would have been assigned to.

Signed-off-by: Tom Finet <tomfinet@outlook.com>
2024-08-14 09:39:09 +02:00
Mikhail Kushnerov
e50d1190fa profiling: Add perf tool
Add profiling subsystem.

Add perf util based on periodic stack unwinding. Perf from Linux
was taken as a reference.

The operation of module is based on frame pointer usage and saving
registers during interruption handling.
The unwinding function stay in timer as expiry functioin so is called
during interruption handling. Thus the function have access to saved
registers (program counter and frame pointer in particular) of the current
thread and use it to unwind the thread stack.
Timer starting and results printing function are made as shell commands
for conveniency.

Originally-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
Signed-off-by: Mikhail Kushnerov <m.kushnerov@yadro.com>
2024-08-13 18:28:44 -04:00
Muhammad Haziq
9958a2e3c3 net: wifi: replace (1 << xyz) with BIT(xyz)
Refactor (1 << xyz) to use the BIT(xyz) macro.
The change aims to enhance code readability.

Signed-off-by: Muhammad Haziq <muhammad.haziq@zintechnologies.com>
2024-08-13 18:19:33 -04:00
Alberto Escolar Piedras
e3da5c3d39 Bluetooth: Mesh: Fix build warning with gcc 13
gcc 13 thinks  max_adv_duration may be used unitialized
and warns accordingly (see below)
It seems the reason is the goto, which confuses it.
In any case, pacifying this warning is trivial,
so let's just do so.

The warning:
```
In function ‘gatt_proxy_advertise’,
inlined from ‘bt_mesh_proxy_adv_start’ at
subsys/bluetooth/mesh/proxy_srv.c:1214:9:
subsys/bluetooth/mesh/proxy_srv.c:842:44: error: ‘max_adv_duration’ may
be used uninitialized [-Werror=maybe-uninitialized]
subsys/bluetooth/mesh/proxy_srv.c: In function ‘bt_mesh_proxy_adv_start’
zephyr/subsys/bluetooth/mesh/proxy_srv.c:786:17: note:
‘max_adv_duration’ was declared here
  786 |         int32_t max_adv_duration;
      |                 ^~~~~~~~~~~~~~~~
```

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-08-13 18:18:00 -04:00
Grygorii Strashko
965ca96c77 testsuite: coverage: fix arm64 build with gcov enabled
On ARM64 the build will fail with coverage and GCOV enabled:

  CONFIG_COVERAGE=y
  CONFIG_COVERAGE_GCOV=y
  CONFIG_FORCE_COVERAGE=y

west build -b rpi_5 -p always samples/hello_world -- \
 -DCONFIG_COVERAGE=y -DCONFIG_FORCE_COVERAGE=y

Failure:
 "linker_zephyr_pre0.cmd:181: undefined symbol `__gcov_bss_end' referenced
in expression"

Fix build of ARM64 platforms with coverage and GCOV enabled by adding for
ARM64 the same gcov linker sections as it is done for ARM.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
2024-08-13 14:57:50 +02:00
Piotr Kosycarz
2fd7ab7b97 testsuite: coverage: allow disabled multithreading
k_sched* are not avaliable when there is CONFIG_MULTITHREADING=n

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2024-08-13 14:57:18 +02:00
Krzysztof Chruściński
e18254901c logging: When strings are stripped keep source name pointers
90ab94f61d added a change that source name pointers were not stored
in the const data structure associated with a logging source. That was
done because those string pointers were invalid (on purpose pointing to
non-existing memory) and reading those strings could lead to a fault.
However, those pointers are used by scripts which are building the
dictionary database and after this change script was no longer
able to retrieve source names from elf file and database was incomplete.

This patch brings back storing of source name string pointers but in
API for reading those source names guards are added to not return
invalid addresses.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-13 14:56:14 +02:00
Dawid Niedzwiecki
c2151ad1e3 ztest: undefine _POSIX_C_SOURCE before defining it
Undefine _POSIX_C_SOURCE before defining it to avoid double
definition

The previous version, changed in this PR
https://github.com/zephyrproject-rtos/zephyr/pull/70363, did the undef.
Make sure to do the same for all files in the current dir.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-08-13 14:56:06 +02:00
Krzysztof Chruściński
530b8ccbed debug: coresight: Add coresight_trace_deformatter
Add module which decodes data encoded using Coresight Trace
Formatter.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-12 19:23:19 -04:00
Yago Fontoura do Rosario
42c8732dda Bluetooth: Gatt: Make CCC_STORE_MAX configurable
- Made CCC_STORE_MAX configurable under the BT_SETTINGS
- Added a buffer overflow check on ccc_save

Fixes: #76838

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2024-08-12 15:54:28 +02:00
Jan Peters
b8bef42add device_dt_metadata: handle dt_meta being NULL
Using  DEVICE_DEFINE, a device without a corresponding DT node can be
defined (for example CRYPTO_MTLS), Z_DEVICE_INIT() does not initialize
dt_meta for such devices, leaving the field as NULL.
device_get_dt_nodelabels() and functions calling it have to handle
dev->dt_meta == NULL to prevent fatal errors.

Signed-off-by: Jan Peters <peters@kt-elektronik.de>
2024-08-12 15:54:22 +02:00
Robert Lubos
086faa56aa net: lib: http_server: Clear http1_headers_sent flag on new request
http1_headers_sent flag has to be cleared when entering
HTTP_SERVER_REQUEST_STATE and not only on the client init. Otherwise,
serving multiple HTTP1 POST requests over the same connection does not
work as intended (headers were not sent for the second and further
requests).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-08-12 15:54:03 +02:00
Niklas Fabian
72f90ee063 logging: fs backend: optional append to latest file
Make appending to the newest log file in the fs logging backend optional.
By default, if there is still free space in the latest log file,
the fs logging backend appends to it on startup. This is useful for saving
space and avoiding the removal of older log files, if the maximum number
of log files has been reached. The drawback of this behavior is,
that log files that got appended can not be decoded, if the firmware
has changed between startups, for instance by an update,
since the log_dictionary.json used for decoding has also changed.
Therefore, it may be desirable to deactivate appending to log files.

Signed-off-by: Niklas Fabian <niklas.fabian@lemonbeat.com>
2024-08-12 12:44:11 +02:00
Jonathan Rico
8a2fe27c00 Bluetooth: Host: Free ACL RX fragments on disconnection
This function call frees the buffer kept by the host for reassembling L2CAP
PDUs into.

Without this call, the current buffer will eventually be
leaked, leading to a non-functional host due to lack of RX buffers.

The effect is worse when host flow control is not enabled, as the RX
buffer pool is shared with events, which means communication with the
controller is essentially dead.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-12 10:10:48 +02:00
Jonathan Rico
5a4fdfbf3e Bluetooth: hci_common: Add assert on buf allocation
`net_buf_alloc(K_FOREVER)` can now return NULL if running in the system
workqueue. `bt_hci_evt_create()` is called in that context in a few cases.

Since we can't really do anything about it, add a (default-on) assert.

This should ideally never fail. I saw it fail because of a leak in the ACL
buffer pool, which is also shared with events when host flow control is not
enabled.

In that particular case, the host is rendered non-functional, so trying to
recover using error handling is futile.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-12 10:10:48 +02:00