Commit graph

9855 commits

Author SHA1 Message Date
Emil Gydesen
1c004a08c3 Bluetooth: CCP: Client: Add support for get provider name
Add support for getting the remote bearer provider
name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-13 08:43:47 +02:00
Lyle Zhu
3ac4f92625 Bluetooth: Classic: OBEX: Optimize MOPL configuration
Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX
server.

Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection
request.

Check if the MOPL of client exceeds MTU of transport when server
receives the connection request.

Check if the MOPL of server exceeds MTU of transport when client
receives the connection response.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:59:56 -04:00
Lyle Zhu
26065ecee3 Bluetooth: Classic: GOEP: Support multiple OBEX sessions
Split the structure `struct bt_obex` into two parts.
Part 1 `struct bt_obex`, it is the common part and shared by all OBEX
sessions which share the same one transport.
Part 2 `struct bt_obex_server` and `struct bt_obex_client`. The
`struct bt_obex_server` is used to manage the OBEX session of server
role. The `struct bt_obex_client` is used to manage the OBEX session
of client role.

Add function `bt_obex_server_register()` to register the OBEX server
with specific uuid.

Add function `bt_obex_server_unregister()` to unregister the OBEX
server.

Add function `bt_obex_make_uuid()` to make UUID.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:59:56 -04:00
Lyle Zhu
6d77949698 Bluetooth: GOEP: Fix L2CAP segmented RX data handling issue
The receiving segmented L2CAP data can not be handled properly. Due to
the `struct bt_l2cap_chan_ops::alloc_buf` is NULL, the partial data
will be notified through callback `struct bt_l2cap_chan_ops::recv`.
The GOEP does not consider this issue and handles it as a completed
packet. It causes the L2CAP disconnecting due to the partial packet
cannot be processed by OBEX.

Add a RX pool, and set `struct bt_l2cap_chan_ops::alloc_buf`. The
L2CAP will allocate the buffer from the pool to buff the segmented
data. Only the completed packet will be notified through
`struct bt_l2cap_chan_ops::recv`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:58:54 -04:00
Christophe Dufaza
60c3de2722 bluetooth: host: remove useless internal flag BT_ADV_PERSIST
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed,
and the internal bit flag BT_ADV_PERSIST is now always false.

The behavior it used to configure (to keep advertising after a
connection has been established as long as there are connections
available) has also been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
a1dd571f11 bluetooth: host: remove no longer used internal API bt_le_adv_resume()
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed,
as well as all calls to bt_le_adv_resume().

Also remove adv_get_options() whose bt_le_adv_resume()
is the only caller.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
9b5ad2f8df bluetooth: host: do not attempt to resume terminated advertising sets
Automatic advertiser resumption is publicly deprecated
since Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
731e581174 bluetooth: host: do not resume periodic connectable advertisers
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
b3a4ff0109 bluetooth: host: do not use freed connection to resume advertising
In bt_conn_unref(), if we remove the last reference to the connection,
we notify listeners that a connection object has been freed
and can be taken, then immediately reuse this freed slot
to resume advertising.

This behavior is source of errors, and automatic advertiser resumption
is publicly deprecated since Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
5762ff5b58 bluetooth: host: remove transitional option _BT_LE_ADV_OPT_ONE_TIME
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].

To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:

- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
   as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
   as BT_LE_ADV_CONN_ONE_TIME (deprecated)

The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.

We can assume _BT_LE_ADV_CONN_ONE_TIME is true for connectable
advertisers, and meaningless for non-connectable advertisers.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
e24d3b92a3 bluetooth: host: remove transitional option _BT_LE_ADV_OPT_CONNECTABLE
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].

To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:

- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
   as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
   as BT_LE_ADV_CONN_ONE_TIME (deprecated)

The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.

We can substitute BT_LE_ADV_OPT_CONN for _BT_LE_ADV_OPT_CONNECTABLE
when testing if an advertising set is connectable.

Note: to fix a ClangFormat warning raised by check_compliance.py,
this commit also includes a formatting change next to the lines
actually edited (subsys/bluetooth/host/id.c:810).

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Emil Gydesen
d4afa1989f Bluetooth: Host: Change WRN->DBG for not connect for TX
The bt_conn_tx_processor logged connections not in the
connected state as LOG_WRN, but this is a case that is handled
and could occur during regular behavior.
For this reason the log statement was changed to LOG_DBG,
as the developer/user does not need to worry about it.
Also modifies the statement to log the conn->state for
debugging purposes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-10 12:55:28 -04:00
Make Shi
528e732aad Bluetooth: Shell: BR: Add SDP discovery support for AVRCP CT/TG
Add SDP discovery handlers for AVRCP CT/TG roles and corresponding
discovery parameters and a common result handling function.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-10-09 12:42:45 -04:00
Vinayak Kariappa Chettimada
9b26e967ca Bluetooth: Controller: nRF54L: Fix to improve decryption speed
Fix to improve decryption speed. Decryption starts after
payload reception, hence use fastest mode to decrypt PDUs.
nRF54Lx only supports decryption after payload reception,
this implementation was already there in the code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Vinayak Kariappa Chettimada
a5e1f59686 Bluetooth: Controller: Revert relaxed radio packet assignment deadline
Reverts relaxed radio packet assignment deadline as it is
too risky and can cause invalid bits be transmitted and/or
cause MIC failures.

Reverts commit 4dbfb22a7e ("Bluetooth: Controller: Relax
radio packet pointer assignment deadline"), and
commit 230df77993 ("Bluetooth: Controller: Relax radio
packet pointer assignment deadline").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Vinayak Kariappa Chettimada
1fe79a65a2 Bluetooth: Controller: Use CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET
Use CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET for nRF53 SoC
conditional compilations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Emil Gydesen
0abb23ffad Bluetooth: ISO: rm extra log statements in chan_send
bt_iso_chan_send and bt_iso_chan_send_ts would log
twice for each TX, which is unncessary. LOG_DBG statements
include the function name by default, so the 2nd log
statement was unncessary, and were removed.

Added logging of the ts in bt_iso_chan_send_ts which
would still make it possible to tell the 2 apart,
even if CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-08 18:25:17 -07:00
Vinayak Kariappa Chettimada
7fd5dea9cc Bluetooth: Controller: Cosmetic changes to Link Layer interface
Cosmetic changes to the Link Layer interface header file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-08 15:12:22 -04:00
Vinayak Kariappa Chettimada
8eae0bfbd0 Bluetooth: Controller: Fix single switch timer use in ISO Sync
Fix implementation of Broadcast ISO Synchronized Receiver
using single switch timer to consider minimum compare value
requirement.

This fix reduces latencies to setup radio receptions and
fixes an assertion in lll_sync_iso when radio_tmr_start_us()
is checked for latencies.

Relates to commit 5dfc58cff9 ("Bluetooth: Controller: Fix
single switch timer minimum compare value").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-08 15:09:33 -04:00
Emil Gydesen
4b9bc7d11b Bluetooth: Controller: Fix return types for ll_length
ll_length_req_send and ll_length_default_set were defined to return
a uint32_t, but only returned a uint8_t HCI error code and
was the return value was always stored as such.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-08 08:45:37 +02:00
Emil Gydesen
2140b55d29 Bluetooth: BAP: Shell: 0-init some global variables
0-init some non-static global variables to avoid
issues with uninitialized values. Also modify
the printing of the broadcast sources found slightly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-07 17:44:19 +03:00
Emil Gydesen
35909d7fdf Bluetooth: CAP: Mark err used for assert as __maybe_unused
If asserts are disabled, then `err` is unused can caused
a compiler warning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-07 12:47:30 +02:00
Jordan Yates
1f3ce818fc bluetooth: controller: ll_sw: nordic: constant latency req
When `CONFIG_NRF_SYS_EVENT` is enabled, route constant latency requests
through the reference counted API.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-07 10:59:38 +02:00
Emil Gydesen
6c870b071a Bluetooth: Remove CONFIG_BT_BUF_ACL_RX_COUNT
Remove the deprecated CONFIG_BT_BUF_ACL_RX_COUNT config
as it has been deprecated since 4.1

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-06 20:17:14 -04:00
Emil Gydesen
360880b7c7 Bluetooth: Host: Remove bt_le_set_auto_conn
Remove the deprecated function bt_le_set_auto_conn
as it has been deprecated since 4.1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-06 20:01:04 +03:00
Emil Gydesen
5d8170bba8 Bluetooth: BAP: Add conn check assert in bt_bap_iso_bind_ep
Adds assert for bt_bap_iso_bind_ep to ensure that endpoints
from different connection don't share a CIS (a bt_bap_iso).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Emil Gydesen
1dc98dd932 Bluetooth: BAP: Add check to verify that eps have correct iso
Add a check that verifies that 2 endpoints from different
connection don't share a CIS, which would be invalid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Emil Gydesen
4f2ef519b6 Bluetooth: BAP: UC: Move iso_bind_ep to config instead of QoS
We can actually already when we bind the endpoint to the stream
perform the call to bt_bap_iso_bind_ep, if the stream has been
added to a group.

If the stream has not yet been added to a group, then when
the stream is added to a group, then bt_bap_iso_bind_ep will
be done there (existing behavior).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Ashirwad Paswan
21da2d056d Bluetooth: Controller: Fix missing null pointer check
Added a check for null pointer in ull_sync_iso.c file
to avoid potential crashes.

Fixes: #81997

Signed-off-by: Ashirwad Paswan <ashi06712@gmail.com>
2025-10-01 08:27:33 +02:00
Loic Domaigne
bfbc6365ac Bluetooth: Controller: fix assertion check for ptc value
Fix the issue reported by Coverity CID 487708. The LL_ASSERT was
performed on lll->ptc, which is a 4-bit bitfield and therefore always
succeeds. Instead, the computation (lll->nse - nse) should be checked
to ensure it falls within the 4-bit value range before assigning it
to lll->ptc.

Signed-off-by: Loic Domaigne <tech@domaigne.com>
2025-09-30 15:28:36 +03:00
Emil Gydesen
87e6bff4ef Bluetooth: CAP: Shell: Change to use default_unicast_group
Use default_unicast_group everywhere in the CAP shell, and mark
all creation of it as default_unicast_group.is_cap = true.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Emil Gydesen
ca80d25bd9 Bluetooth: CAP: Shell: Move ac_create_unicast_group to CAP
Move the function bap_ac_create_unicast_group to the CAP
shell, as that was the only user of it, and rename it to
cap_ac_create_unicast_group, and make it use the CAP API.

Also rename bap_unicast_ac_param to cap_unicast_ac_param

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Emil Gydesen
bf19edc8d8 Bluetooth: BAP: Shell add common unicast_group struct
Add a common unicast_group struct for both the BAP and
CAP shell, similar to the broadcast_source.

The purpose of this is to be able to use the appropriate type
for both the CAP and BAP shells, instead of using the BAP
unicast group for the CAP shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Håvard Reierstad
ff17e601d0 Bluetooth: Host: Add userdefined fixed l2cap chans
Adds support for the user defining their own channels within the
fixed L2CAP channel range. To make this possible, the
`bt_l2cap_fixed_chan` struct and `BT_L2CAP_CHANNEL_DEFINE` macro
needed to converted to public API. In the process of doing so, the
`_destroy` parameter was removed from the `BT_L2CAP_CHANNEL_DEFINE`
macro as it was never used (fixed channels will not be destroyed over
the lifetime of the connection). `BT_L2CAP_CHANNEL_DEFINE` is renamed
`BT_L2CAP_FIXED_CHANNEL_DEFINE` to avoid confusion

The `bt_l2cap_chan_send` function is updated to be able to send data
on fixed l2cap channels.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2025-09-29 12:38:19 -04:00
Emil Gydesen
881a24270c Bluetooth: BAP: Rename and fix bt_bap_is_x_ep
Rename the bt_bap_is_x_ep functions to better match the
modules where they are implemented.

Additionally modify the check to use IS_ARRAY_ELEMENT
in the broadcast sink and source for a stricter check.
IS_ARRAY_ELEMENT cannot easily be used in the unicast
client and server, as the endpoints are part of another
structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:38:06 -04:00
Emil Gydesen
6c1cd61792 Bluetooth: BAP: Add missing check for unicast server ep
We check for all other roles when checking whether
an endpoint can send or receive, except for the unicast server.
It is technically implied, but if the ep is not a valid pointer,
then we may access invalid memory.

Add check for bt_bap_ep_is_unicast_server (which uses the new
bt_ascs_has_ep function).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:38:06 -04:00
Emil Gydesen
55a72f6103 Bluetooth: CAP: Implement broadcast to unicast handover
Implement the broadcast to unicast handover procedure,
as per the Bluetooth CAP specificiation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:36:00 -04:00
Mark Wang
e82a9951e8 bluetooth: a2dp: fix spelling error of STEREO
change A2DP_SBC_CH_MODE_STREO as A2DP_SBC_CH_MODE_STEREO

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-09-26 06:40:29 +02:00
Emil Gydesen
a738b2641e Bluetooth: BAP: Add NULL check in bt_bap_stream_detach
If stream->ep is NULL, which is really shouldn't be,
then we should not attempt to dereference it.
Add simple NULL check to ensure behavior, and make
Sonarcloud happy.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-25 11:01:10 +02:00
Mike J. Chen
c6206c220d bluetooth: BAP: fix select bug
Change 4c86a5cc8d moved a select
from Kconfig.asc to Kconfig.bap (amongst some other changes
from select to depends), but inverted the PAC_{SRC,SNK} from
ASCS_ASE_{SRC,SNK} condition.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-09-25 09:21:42 +02:00
Vinayak Kariappa Chettimada
15d3b57e90 Bluetooth: Controller: Fix inter-operability when BT_PHY_UPDATE=n
Fix inter-operability, when BT_PHY_UPDATE=n the feature bits
contained 2M and Coded PHY when Advertising Extensions where
enabled, and Central devices did not progress with any data
packet transfers when PHY_REQ was rejected as unknown PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-24 15:51:13 +01:00
Jiawei Yang
d5969f952d Bluetooth: HFP: Fix +BSIR=0 not being recognized issue
In HFP PTS, cases run fail with the log 'unsupported unsolicited
format: +BSIR=0' and 'FAIL: Expected to receive +BSIR: 0'.

Fixed issue by changing +BSIR=0 to +BSIR: 0.

Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
2025-09-23 09:38:37 +01:00
Jordan Yates
c3221f0420 bluetooth: host: conn: handle bt_le_create_conn_cancel error
Handle the `bt_le_create_conn_cancel` call in the deferred worker
failing due to insufficient command buffers.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-22 13:28:00 -04:00
Christophe Dufaza
69cab3f6a8 Bluetooth: Host: Fix some MISRA c:M23_112 warnings
Fix some "All if ... else if constructs shall be terminated
with an else clause" (c:M23_112) issues reported by SonarQube.

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-09-22 13:25:11 -04:00
Christophe Dufaza
c3f175825e Bluetooth: Host: Fix possible inconsistent access to connection state
An assertion in bt_conn_unref() accesses the connection's state
after decrementing its reference count.
This is not consistent since, if we removed the last reference,
the Bluetooth Host stack may reuse the connection object
before the assertion is checked.
Instead, retrieve the connection property tested by the assertion
before decrementing the counter, as we do for other properties.

Simplify the code path by returning early when we did not remove
the last reference.

Remind that automatic advertiser resumption is deprecated.

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-09-22 13:25:11 -04:00
Christophe Dufaza
51f57da387 Bluetooth: Host: Fix use of local variable as atomic target
In bt_conn_unref(), a local variable is used as atomic target:

    atomic_val_t old = atomic_dec(&conn->ref);
    /* Prevent from accessing connection object */
    bool deallocated = (atomic_get(&old) == 1);

Using atomic_get() to access a non-shared local variable
cannot prevent any data race on that variable,
and only causes confusion.

Moreover, this call to atomic_get() is incorrect: the API expects
an atomic_t* argument (target), not an atomic_val_t* (value).
This compiles and /works/ only because Zephyr defines both to be
the same integer type, and thus: atomic_get(&old) == old.
The equivalent C11 code, where _Atomic(T) and T are different types,
wouldn't compile.

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-09-22 13:25:11 -04:00
Szymon Janc
9354e06422 Bluetooth: SMP: Print extra state information on timeout
This gives some extra information on what could be a reason
for SMP timeout.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-22 11:17:59 +02:00
Ludvig Jordet
8720ab7390 Bluetooth: Mesh: Deprecate blob_io_flash erase cap options
The only reason to keep these would be to enable conditional compilation
of some parts of the code. However, we can't see enough benefit in doing
this, particularly since the flash driver itself will conditionally
handle certain paths depending on erase caps, so the options are
deprecated to reduce complexity.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-09-22 11:17:25 +02:00
Ludvig Jordet
db207b04a8 Bluetooth: Mesh: decouple blob_io_flash from internal flash
This fully decouples blob_io_flash from specific flash device details,
by not reading the write block size from a hard-coded device tree node,
instead pulling this from the actual flash device used.

The block write routine has been updated to be more generic and fix a
few bugs:

  * The write buffer is now sized based on a KConfig option instead of
    basing it off the device tree - this makes the module usable with
    any flash device, not just the internal memory. The configured value
    is checked during initialization, to ensure that the configured size
    will fit the write block size required by the device passed to the
    init function.
  * The erase value used to fill the buffer when using a device with
    explicit erase is now pulled from the flash parameters instead of
    being hard-coded to `0xff`.
  * An additional write block sized piece of buffer is allocated - the
    previous buffer sizing with rounding up only worked if
    `BLOB_RX_CHUNK_SIZE % WRITE_BLOCK_SIZE` was 0 or 1 (which
    coincidentally worked in all testing because the chunk size defaults
    to 161, and for internal flash w/write block size of 4,
    `161 % 4 == 1`).
  * The choice of whether to just write the chunk as-is or to
    write-block align it is now based on the erase cap pulled from the
    flash parameters, instead of checking the type of memory in the SOC.
    This means the module dos _not_ currently support the case where
    memory has to be written write-block aligned, but the memory does
    _not_ use explicit erase. It uses a trick of filling the write
    buffer with the erase value to avoid overwriting existing chunks,
    which will not work in this case. This trick is required to support
    random ordered chunks while still writing write-block aligned.
  * The code has been cleaned up a bit in general.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-09-22 11:17:25 +02:00
Ludvig Jordet
99190cb08f Bluetooth: Mesh: make blob_io_flash support smaller blocks
Only erase a page when starting the first block on that page.
This fixes a bug where, if the block size is smaller than the page size,
the entire page would be erased upon start of each block when writing,
meaning only the final block on each page would be retained. This works
because blocks are always received in order.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-09-22 11:17:25 +02:00