Fixes changing a SoC selection for all devices when one of the
devices being tested is not that SoC
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Change the twister definitions so we can refer to them from the bsim
tests yaml directly.
We merge the nrf52bsim and 5340bsim entries into a common one using
platform exclusive config overlays.
As a sideeffect we also now build using sysbuild for the nrf52_bsim, but
that is not a problem beyond a minimal buildtime overhead.
Meaning, instead of there being 4 entries, duplicated by platform, now
there is only 2, based solely on the actual application being built.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
test_parsing_success iterated over a 59-entry table of PCT byte
inputs and expected IQ samples inside one ZTEST body. A failure
reported as a single opaque test, with the offending vector only
identifiable from the printed loop index.
Convert the test to ZTEST_P so the framework runs the body once
per vector. The table is hoisted to file scope as a named
pct_test_vector type and reused as the parameter value set, and a
name_cb labels each case with the raw PCT bytes (e.g. 0xEFCDAB),
so a regression names the exact failing input. The vectors and
assertions are otherwise unchanged.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The set_value btp command incorrectly evaluated the cp->attr_id
against SERVER_MAX_ATTRIBUTES before using it as an index to a
server_db array. When running GATT/SR/GAN/BV-01-C qualification
test case, valid handle (e.g. 52) exceeded the maximum attribute
count limit which resulted in BTP command failure.
Fixes GATT/SR/GAN/BV-01-C qualification test case.
Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
Initialize all broadcast stream parameters across
subgroups and attach per-BIS channel allocation
codec data. This fixes PTS reporting of audio
channel count/BIS count as zero in broadcast
source streaming
Signed-off-by: Alex Ciascai <ext-alexandru.ciascai@nordicsemi.no>
This was added in early days, now there is proper API for this in
Zephyr so there is no need for custom wrappers.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
struct bt_uuid was used for storage instead of struct bt_uuid_any
resulting in overflow when converting BTP UUID to bt_uuid.
==3608402==ERROR: AddressSanitizer: stack-buffer-overflow on address
0xe02f5da2 at pc 0x0805a750 bp 0xe14e2048 sp 0xe14e2038
WRITE of size 2 at 0xe02f5da2 thread T7
#0 0x805a74f in btp2bt_uuid zephyr/tests/bluetooth/tester/src/btp_gatt.c:212
#1 0x805d31c in get_handle_from_uuid zephyr/tests/bluetooth/tester/src/btp_gatt.c:2149
#2 0x804f12c in cmd_handler zephyr/tests/bluetooth/tester/src/btp.c:122
#3 0x807c582 in z_thread_entry zephyr/kernel/sys/thread_entry.c:60
#4 0x807cdd2 in posix_arch_thread_entry zephyr/arch/posix/core/thread.c:124
#5 0x80ff2bd in nct_thread_starter zephyr/scripts/native_simulator//common/src/nct.c:291
#6 0xeb1949a3 in asan_thread_start ../../../../../src/libsanitizer/asan/asan_interceptors.cpp:234
#7 0xeaea5136 (/lib32/libc.so.6+0x8b136) (BuildId: 798ae816ef14b98dc77560340190445fb200634a)
#8 0xeaf39de7 (/lib32/libc.so.6+0x11fde7) (BuildId: 798ae816ef14b98dc77560340190445fb200634a)
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This test creates a custom logging Kconfig option using the template as
done in many other places in tree, but wrapped the logging module's
name in quotes for the `module-str` variable which is not correct.
Update the test's Kconfig to drop the quotes.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Rename the test metadata file(s) in this area from testcase.yaml to
tests.yaml so sample and test metadata share one consistent filename
across the tree. Pure rename, no content change.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The text states that the minimum is 1, but it is possible to
set the value to 0 even when CONFIG_BT_SMP=y.
This commit changes this so that the option and text matches.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.
This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
`grep -rsl "#include \"zephyr/" tests/`
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Compare the actual values of the codec configuration
or qos configuration when in the codec configured state,
the QoS configured state or the enabling state.
In the case that the stream is one of the these states
and the parameters to set differ from what is already there,
the appropriate actions should be taken to set the right
values, even if it does not mean an actual state change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit fixes 2 bugs:
1) Bad/missing err return from bt_bap_stream_reconfig
2) Missing handle of codec_cfg fields that are not part of the
ASCS notifcations: path_id, ctlr_transcode, target_latency and
target_phy.
To be able to set these, we need to store them somewhere, and it
makes sense to attach the ep->codec_cfg earlier so that we can store
them in there.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set the number of objects to 20 as that is number of objects
that the media player need to register.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Providing a number of objects as decimal (e.g. 48) is
more intuitive than hex (e.g. 0x30) for humans.
Additionally the max number of objects when the directory
listing object is support has also been changed to more
accurate depict the actual maximal number of objects based on
CONFIG_BT_OTS_OBJ_MAX_NAME_LEN instead of using the absolute
max value. Since Kconfig does not support such calculations,
this maximum has been moved to a BUILD_ASSERT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The command did not count correctly in the unicast_streams
array, and the number of streams support did not match the
audio configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add unittests for the bt_cap_handover_register_cb
and bt_cap_handover_unregister_cb functions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify several places to use bluetooth.audio correctly
Add sample.bluetooth.audio to the tests under the MAINTAINERS file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
CONFIG_LINKER_USE_PINNED_SECTION is the second half of the selective
kernel-pinning model removed in issue #108773. With the kernel image
now always resident at boot (previous commit), the __pinned_*
attribute family is a no-op: every page they would have segregated is
already pinned by z_mem_manage_init()'s whole-image loop, so the
tagging contract neither adds safety nor remains maintainable.
Drop it.
Mechanical removals:
* All ~219 in-tree uses of __pinned_text, __pinned_rodata,
__pinned_data, __pinned_bss, __pinned_noinit, and __pinned_func
across arch/x86, drivers/interrupt_controller, drivers/timer,
arch/common, kernel, lib/libc, subsys/portability/posix, tests, and
the syscall code generator (scripts/build/gen_syscalls.py).
* The assembly aliases PINNED_TEXT/RODATA/DATA/BSS/NOINIT used in
arch/x86/core/ia32/*.S and drivers/interrupt_controller/
intc_loapic_spurious.S become plain TEXT/RODATA/DATA/BSS/NOINIT.
* K_KERNEL_PINNED_STACK_DEFINE, K_KERNEL_PINNED_STACK_ARRAY_DEFINE,
K_KERNEL_PINNED_STACK_ARRAY_DECLARE, K_THREAD_PINNED_STACK_DEFINE,
and K_THREAD_PINNED_STACK_ARRAY_DEFINE are removed. The few
in-tree callers (kernel/init.c, arch/arm/core/cortex_a_r/smp.c,
arch/arm64/core/fatal.c, arch/rx/core/prep_c.c,
arch/x86/core/prep_c.c, kernel/include/kernel_internal.h,
tests/bluetooth/hci_uart_async) move to the corresponding
non-pinned macros.
Machinery removals:
* Kconfig.zephyr drops CONFIG_LINKER_USE_PINNED_SECTION.
qemu_x86_tiny and qemu_x86_atom_virt drop their =y overrides.
* include/zephyr/linker/section_tags.h drops the __pinned_* macro
definitions (both arms). __isr collapses to an empty macro since
its only purpose was to alias __pinned_func.
* include/zephyr/linker/sections.h drops PINNED_TEXT_SECTION_NAME,
PINNED_BSS_SECTION_NAME, etc. and the bare PINNED_TEXT/RODATA/etc.
forwarders, plus the _APP_SMEM_PINNED_SECTION_NAME constant.
* include/zephyr/linker/linker-defs.h drops the lnkr_pinned_*
externs, the _app_smem_pinned_* externs, and the lnkr_is_pinned()
/ lnkr_is_region_pinned() inline helpers.
* include/zephyr/linker/utils.h drops the lnkr_pinned_rodata branch
in linker_is_in_rodata().
* include/zephyr/linker/app_smem_pinned{,_aligned,_unaligned}.ld
are deleted; cmake/linker/ld/target_configure.cmake stops
configuring them.
* boards/qemu/x86/qemu_x86_tiny.ld and
include/zephyr/arch/x86/ia32/linker.ld drop their pinned-section
blocks and the now-redundant #ifndef CONFIG_LINKER_USE_PINNED_SECTION
conditionals throughout the body. The
LIB_KERNEL_IN_SECT / LIB_ARCH_X86_IN_SECT / LIB_ZEPHYR_IN_SECT /
LIB_C_IN_SECT / LIB_DRIVERS_IN_SECT / LIB_SUBSYS_LOGGING_IN_SECT /
LIB_ZEPHYR_OBJECT_FILE_IN_SECT / ZEPHYR_KERNEL_FUNCS_IN_SECT macros
in qemu_x86_tiny.ld are deleted; they existed only to feed the
pinned text/rodata/data/bss/noinit sections.
* kernel/mmu.c drops the mark_linker_section_pinned(lnkr_pinned_start,
...) call. The mark_linker_section_pinned() helper survives but is
now gated only on CONFIG_LINKER_USE_BOOT_SECTION.
* arch/common/init.c and include/zephyr/arch/common/init.h drop
arch_bss_zero_pinned(); arch/x86/core/ia32/crt0.S drops the call
to it.
* arch/x86/core/userspace.c drops the eager k_mem_page_in() of the
thread's privileged stack on user-mode entry. With the kernel
image fully resident the stack is already mapped.
* arch/x86/gen_mmu.py drops map_region("lnkr_pinned") and the
set_region_perms() calls for lnkr_pinned_text / lnkr_pinned_rodata.
* CMakeLists.txt drops the LINKER_USE_PINNED_SECTION block that
generated APP_SMEM_PINNED_* variables and the
pinned_partitions target property feeding gen_app_partitions.py.
cmake/modules/extensions.cmake removes the PINNED_RODATA /
PINNED_RAM_SECTIONS / PINNED_DATA_SECTIONS zephyr_linker_sources()
location keywords and their snippet files.
scripts/build/gen_app_partitions.py drops --pinoutput /
--pinpartitions arguments and the pinned-output branch.
subsys/testsuite/coverage/CMakeLists.txt drops its
CONFIG_DEMAND_PAGING-conditional fork.
* scripts/build/gen_kobject_list.py drops the
app_smem_pinned_start / _end fallback for kobject placement
validation.
* tests/arch/x86/pagetables and tests/kernel/mem_protect/userspace
drop their lnkr_pinned_text / lnkr_pinned_rodata branches.
* include/zephyr/arch/x86/ia32/arch.h folds IRQSTUBS_TEXT_SECTION
to the unconditional ".text.irqstubs" form.
* tests/subsys/llext/src/syscalls_ext.c drops a stale comment about
syscalls landing in .pinned_text.
Targeted retentions:
* arch/x86/core/bootargs.c keeps multiboot_cmdline and efi_bootargs
in .noinit (was __pinned_noinit, which decayed to __noinit when
LINKER_USE_PINNED_SECTION was unset). The multiboot and zefi loader
paths write these buffers before Zephyr's BSS-zero step, so
zeroing them at boot loses the cmdline.
* arch/x86/core/ia32/fatal.c keeps _df_esf and _df_stack in .noinit.
They are scratch space written by the double-fault handler and have
no zero-init requirement; keeping them in .noinit also preserves
the historical post-noinit alignment that gen_mmu.py relies on
(z_mapped_size is computed before CMake-injected iterable sections
are appended to the linker script, so the post-noinit page padding
is what keeps those sections within the mapped region).
* include/zephyr/arch/x86/ia32/syscall.h and
include/zephyr/arch/x86/arch.h wrap the per-arch
arch_syscall_invoke* / arch_is_user_context / arch_k_cycle_get_*
implementations in @cond INTERNAL_HIDDEN. The public Doxygen
contract lives on the prototypes in
include/zephyr/arch/arch_interface.h; the per-arch implementations
are internal. Without this, removing the __pinned_func attribute
exposes the implementations to the doxygen-coverage delta check
as 10 newly-undocumented APIs.
Documentation updates are deferred to a separate commit.
Issue: #108773
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This function has some complex state tracking. Adding a unit
test will therefore make it easier to check the correctness.
The unit test case
two_interleaved_chains__first_chain_has_unavailable_last_buffer
shows that there is something missing in the implementation:
Step 3 and 4 now report buffers from advertiser B.
Step 5 and 6 report the partial reports from advertiser A. This
makes the host believe that these advertising reports from
step 1. This will be fixed separately.
The implementation of this API was added in PR #106374.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Add test_chunk_alloc_by_data_len to verify that chunk allocation
is based on actual data length and not buffer capacity.
Fix test_chunk_reallocation to reset the reused buffer between
bt_mesh_delayable_msg_manage() calls since the function drains
buf->len via net_buf_simple_pull_mem().
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This enables Bluetooth Core 6.3. No functional changes but enables
some addition tests specific for 6.3 Core version.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Replace the two-line pattern:
bt_conn_unref(conn);
conn = NULL;
(and equivalent if-guarded variants) with bt_conn_drop(&conn) which
performs both operations atomically in a single step. The guard is
unnecessary because bt_conn_drop() handles a NULL pointer internally.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Add a new bt_conn_drop() function that atomically drops a connection
reference and clears the source pointer in a single step. This mirrors
the recently added net_buf_drop() API and replaces the common pattern:
bt_conn_unref(conn);
conn = NULL;
The new API handles a NULL pointer internally, so any guard around it
is unnecessary.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
- Add BTP_SERVICE_ID_RFCOMM to supported services when CONFIG_BT_RFCOMM
is enabled
- Replace hardcoded response length (4U) with calculated
SUPPORTED_SERVICES_RSP_LEN macro based on BTP_SERVICE_ID_COUNT
It ensures the supported services response properly scales with the
number of services and correctly reports RFCOMM support.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Remove nrf5340ns from memory leak testcase
The memory leak test case assumes CONFIG_MBEDTLS_PSA_CRYPTO_C is enabled
This cannot be the case for a non secure application
Signed-off-by: Gal Raifen <galraifen15@gmail.com>
Remove Kconfig settings in tests/ .conf files that have no effect:
- Driver/subsystem enables that are already `default y` and gated by a
`DT_HAS_<compat>_ENABLED` dependency.
- Board/SoC overlay (boards/<board>.conf, socs/<soc>.conf) lines that
duplicate, with the same value, an option already set in the test's
prj.conf.
Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Most HCI drivers have never handled the return value from the
driver-to-host receive path in any way, and they haven't really needed to
either since the buffer was always consumed regardless of success or
failure.
To be aligned with Zephyr coding guidelines without having to add
minimal value code to every driver, change bt_hci_recv() to return void
instead. A new bt_hci_recv_err() API is also added for any use case where
access to the error is needed.
There's also a related semantic change to the recv callback (passed to
bt_hci_open()) in that it's now expected to *not* consume the buffer in
case of error. There was only a single place in the host that needed an
update for this, while e.g. HCI raw always returned success.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
There's no point in having driver specific data structs if the only thing
they contain is the common data struct. Just declare the common data struct
directly as dev->data.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Now that we have a common data struct, we can take advantage of it and
move the recv callback into it. This way the common layer takes care of
assigning, dispatching and clearing the callback. Drivers now have to use
the new bt_hci_recv() API to pass data to the layer above them (typically
a host stack). Additionally, the drivers no longer get a recv parameter as
part of their open() callback, since that's all handled by the common
layer.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Introduce a new header file for ASCS as a step
towards decoupling ASCS and BAP.
BAP has a depdendencey on ASCS, but ASCS does not have one
for BAP, and the code should reflect that.
This is a first step that simply removes the requirement
of the BAP Unicast Server in ASCS with minimal changes.
Tasks to follow up with:
- Remove any depedency on bap.h from ascs.c
- Rename everything from ascs.h from bt_bap to bt_ascs where
applicable
- Add unit tests specific for BAP unicast server
- Move any BAP-only requirements from ASCS to the BAP unicast
server implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To allow specifying a different TF-PSA-Crypto paths when using
CONFIG_TF_PSA_CRYPTO_CUSTOM.
This is useful as Mbed TLS automatically compiles with include
directories pointing to TF_PSA_CRYPTO_DIR.
The Kconfig option is made available even when CONFIG_MBEDTLS
is disabled because there are tests that manually make use
of the TF-PSA-Crypto path, and enabling CONFIG_PSA_CRYPTO
makes them crash somehow (at least net.lwm2m.lwm2m_engine
on mps2/an385).
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Replace the hardcoded calculation of DATA_POOL_COUNT with a new Kconfig
`CONFIG_BTTESTER_L2CAP_DATA_POOL_COUNT`. This allows users to configure
the data pool size based on their specific requirements.
The new configuration is only available if both `BT_CLASSIC` and
`BT_L2CAP_RET_FC` are enabled. And the default value of the configuration
equals to `BT_L2CAP_MAX_WINDOW_SIZE`, with a valid range from
`BT_L2CAP_MAX_WINDOW_SIZE` to `255` (`UINT8_MAX`).
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
One of the tests is purposedly overwriting the stream pointer to NULL.
Which means it is lost and can't be free'd.
To avoid a memory leak warning, let's make sure we free it at the end
of each test by keeping the cap_streams ptr in the fixture.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Apply the U suffix to unsigned integer literal constants used in
contexts involving unsigned types (uint8_t, uint16_t, uint32_t,
uint64_t, size_t, etc.) with coding guideline 40 which requires that
"A u or U suffix shall be applied to all integer constants that are
represented in an unsigned type".
In addition to this requirement, this commit also ads U to any unsigned
literal integer for the sake of completeness.
Changes are limited to literal values in assignments, initializations,
comparisons, and for-loop bounds where the context is unambiguously
unsigned.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_conn_lookup_addr_le() increments the reference count of the returned
connection object. get_attr_val() was not calling bt_conn_unref() after
use, causing a connection reference leak.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix expressions where increment or decrement operators are combined
with other side effects in the same full expression, violating
MISRA-C Rule 13.3.
Separate the increment and decrement operations into standalone
statements to ensure each full expression contains at most one
side effect.
Assisted-by: GitHub Copilot
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The characteristic name and definitions in the TBS spec for
the values are "optional opcodes" instead of "support features".
Additionally, the field is 16-bit, instead of the current 8-bit
in the register parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing error checks for any function calls in the
affected files, as that is required by the Zephyr coding guidelines.
Assisted-by: Copilot:claude-sonnet-4.6
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This is the old way of doing things, it's used as a means
to enable PSA Crypto as historically it was the only way.
But other PSA Crypto implementations than Mbed TLS are
available (for example, TF-M) and since CONFIG_PSA_CRYPTO
has been introduced it's what should be used when wanting
to enable PSA Crypto.
The build system automatically takes care of choosing
the correct implementation (and enabling
CONFIG_MBEDTLS_PSA_CRYPTO_C when relevant) under the hood.
Replace all occurrences by `CONFIG_PSA_CRYPTO` instead
(or just remove it in cases where nothing is needed).
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
It doesn't really serve a purpose since the addition of
CONFIG_PSA_CRYPTO.
Replace remaining uses of the former by the latter.
TF-M now implies CONFIG_PSA_CRYPTO the same way as
CONFIG_MBEDTLS because otherwise we get build failures
if we build Mbed TLS without CONFIG_PSA_CRYPTO enabled.
Hopefully we can remove these two in a later PR.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>