GCC 14.3 will happily delete any code that appears before
__builtin_unreachable that isn't separated with an obvious branch. That
includes __asm__ statements, even those which generate traps.
The failure case that I debugged was on x86 in
z_check_stack_sentinel. There is a store to restore the sentinel to the
correct value just before the ARCH_EXCEPT, and that macro emits 'int $32'
followed by CODE_UNREACHABLE. Because the compiler didn't understand that
ARCH_EXCEPT was changing execution flow, it decided that the sentinel
restoring store 'couldn't' be reached and elided it.
I added the "memory" clobber to the asm statement in ARCH_EXCEPT before
CODE_UNREACHABLE to enforce that all pending store operations be performed
before the asm statement occurs. This ensures that they are not deleted by
the compiler.
I think this might be a GCC bug. The GCC documentation explicitly documents
that asm statements which change the flow of control should be followed by
__builtin_unreachable.
Signed-off-by: Keith Packard <keithp@keithp.com>
A public API call that sends ACL data — for example, `bt_gatt_notify` —
can be invoked from a preemptive thread context. This API, in turn,
calls the `raise_data_ready` function, which adds an L2CAP channel to
the `l2cap_data_ready` list.
The atomic variable used to create a critical section around
`l2cap_data_ready` did not work, because a preemptive thread can be
pre-empted at any time. This means that regardless of the `atomic_set`
result, we cannot trust it — the thread could be preempted after the
call, and the atomic variable state could be changed (specifically by
the TX processor in this case). The same issue applies to
`bt_conn_data_ready`, which is called next.
When making an L2CAP channel ready for sending data, we need to use a
critical section when appending a channel to the `l2cap_data_ready`
list. The same applies to the `conn_ready` list.
Since cooperative threads can only be rescheduled explicitly, we must
ensure there are no rescheduling points when accessing either the
`l2cap_data_ready` or `conn_ready` lists.
For `l2cap_data_ready`, this occurs in `get_ready_chan`, which is called
from `l2cap_data_pull`, which in turn is called by the TX processor. For
`conn_ready`, it occurs in `get_conn_ready`, which is also called from
the TX processor. Both functions have no rescheduling points when
working with their respective lists, so they do not require a critical
section.
This change removes the atomic variables previously used to create a
critical section for both lists, as they were ineffective. Instead,
`k_sched_lock`/`k_sched_unlock` are used where code may be executed from
a preemptive thread context. The `sys_slist_find` function is used to
check whether a channel or connection is already in the corresponding
list.
Fixes#89705
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The function should stop iterating if the callback provided to
bt_cap_unicast_group_foreach_stream returns true.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the function bt_bap_broadcast_source_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get reference to other broadcast streams in
the same group as any other stream via the stream->group pointer
or a broadcast source pointer directly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add new API to save and restore SCB context. This is typically useful when
entering and exiting suspend-to-RAM low-power modes.
The scb_context_t and the backup/restore functions are designed to only
handle SCB registers that are:
- Mutable: Their values can be changed by software.
- Configurable: They control system behavior or features.
- Stateful: Their values represent a specific configuration that an
application might want to preserve and restore.
Registers excluded from backup/restore are:
1. CPU/feature identification registers
Motivation: These registers are fixed in hardware and read-only.
2. ICSR (Interrupt Control and State Register)
Motivation: Most bits of ICSR bits are read-only or write-only
and represent volatile system state. STTNS is the only read-write
field and could be considered part of the system state, but it is
only present on certain ARMv8-M CPUs, and Zephyr does not use it.
3. CFSR (Configurable Fault Status Register)
HFSR (HardFault Status Register)
DFSR (Debug Fault Status Register)
AFSR (Auxiliary Fault Status Register)
MMFAR (MemManage Fault Address Register)
BFAR (BusFault Address Register)
Motivation: These registers are read/write-one-to-clear and
contain only fault-related information (which is volatile).
Co-authored-by: Mathieu Choplain <mathieu.choplain@st.com>
Signed-off-by: Michele Sardo <msmttchr@gmail.com>
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Removes the BT_LE_ADV_OPT_USE_NAME and BT_LE_ADV_OPT_FORCE_NAME_IN_AD
advertiser options and related flags, macros and functions. The
application now needs to include the device name explicitly.
The API was deprecated in
https://github.com/zephyrproject-rtos/zephyr/pull/71700
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
If a project has enabled the clang-tidy check
readability-math-missing-parentheses,
then warnings are raised on usage of
some macros (e.g ARRAY_SIZE and K_MSEC).
Signed-off-by: Sandro Scherer <sand.scherer@gmail.com>
Add PWM driver support for Renesas RZ/A3UL
Signed-off-by: Hieu Nguyen <hieu.nguyen.ym@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
Fix an issue where IPV6_RECVPKTINFO was used instead of IPV6_PKTINFO
when insert_pktinfo was called.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Add IP_RECVTTL or IPV6_RECVHOPLIMIT BSD socket options
that can be used to extract ttl/hop limit from ancillary data
in recvmsg() call.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
When rendering an overlay on top of something like a video stream on a
monochrome display, the only way to achieve this right now is by using
ARGB8888 and discarding two of the colors, which is not ideal.
This introduces the new AL_88 pixel format, which is much more efficient
for this usecase.
This change is somewhat inspired by LVGL, which also supports AL_88
natively.
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
There are two main issues found with using DLC TX thread,
Issue 1, the RAM consumption. Every DLC will have a dedicated thread
and thread stack.
Issue 2, the thread stack overflow issue. There is no way to strike a
balance between stack size and RAM consumption. Since the deep of call
stack is depended on the upper layer, the thread stack needs to set by
application. Due to the thread stack of DLC is dedicated, RAM
consumption is the product of the added value and the number of DLCs.
Use a TX worker to replace DLC TX thread.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a Kconfig `BT_L2CAP_CONNLESS` to enable the feature.
Add an API `bt_l2cap_br_connless_register()` to register the monitor
to receive the unicast connectionless data.
Add an API `bt_l2cap_br_connless_unregister()` to unregister the
registered callbacks.
Add an API `bt_l2cap_br_connless_send()` to send unicast
connectionless data.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Added tag protocol definition and binding. Also introduced
zephyr,dsa-port compatible for future tag protocol driver Kconfig
dependency checking.
Updated existed dts.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Add docs about what main/sub mode combinations are considered valid
by spec.
In hindsight it would've been smarter to expose only one enum for both,
such that the user can't select invalid combinations.
Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
Wait acts as a boolean, make this clear to avoid implementations
interpreting this as a duration to wait for.
Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
The FUEL_GAUGE_BATTERY_CUTOFF enum property was never used and never tested
nor was it intended to be. This property unfortunately made it past review.
Remove it. This is unlikely to cause a breakage since no upstream driver
ever implemented it as a property.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Use the Android Bluetooth SBC encoder and decoder.
The Android Bluetooth SBC is put as external library (libsbc).
sbc.c/sbc.h implement the interface that is compliant with
Zephyr style and can be used by Zephyr's other modules (
like A2DP).
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The spi_mcux_flexcomm driver uses a special last DMA blk_cfg
to trigger a release of the SPI chip select. This transfer
is always a 4-byte transfer, regardless of the width specified
during dma_configure().
The way the spi_mcux_flexcomm driver communicated this special
transfer was kind of a hack, where the dma_mcux_lpc driver would
assume that when a blk_cfg with source_addr_adj and dest_addr_adj
both set to NO_CHANGE was for this SPI_TX special case.
However, this is an unsafe hack since it is perfectly valid
to have dma use cases for both src/dest_addr_adj to be NO_CHANGE
that is not for SPI_TX. One example is when transmitting a
fixed/repeating value to a periperhal address (e.g. send 100
bytes of the same value from a single memory address over SPI).
This CL introduces a dma_mcux_lpc specific dma channel_direction
which the two drivers now use to cleary request this special
transfer case.
Signed-off-by: Mike J. Chen <mjchen@google.com>
It might come in handy to access non-initialized devices throuhg the
shell. I.e. devices which 'zephyr,deferred-init' DTS attribute was set.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Added scmi_cpu_pd_lpm_set api for nxp imx scmi interface
This api set the lpm setting for some peripherals applied
when cpu enter a low power mode, such as keep iMX95 wakeup mix
power on when M7 core enter suspend mode, scmi agent record and
deal with this request
Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
SCMI supports both polling and interrupt modes for message completion.
Previously, the scmi_send_message() API used a 'pre_kernel' flag to
determine which mode to use_polling during the pre-kernel phase and
interrupts post-kernel.
This approach tightly coupled the decision logic with kernel state,
limiting flexibility. In particular, certain power management (PM)
related SCMI APIs require polling mode even in post-kernel context
to avoid unintended CPU wakeups caused by interrupts.
This patch replaces the 'pre_kernel' with a more generic
'use_polling' parameter, allowing callers to explicitly specify
the desired behavior. Typical usage can still rely on k_is_pre_kernel()
to determine polling mode in higher level api, while PM related
calls can directly enforce polling regardless of kernel state.
Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
the commit adds sys_mm_drv_map_page_safe and sys_mm_drv_map_region_safe
functions, wrappers for sys_mm_drv_map_region and sys_mm_drv_map_region,
with additional check if a mapped region fits into given memory range
Using of those prevents collisions and/or hijacking of virtual memory
Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
this marker is an address of the very first byte not used by the linker,
with alignment to cacheline
Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
Implement the unicast to broadcast handover procedure,
as per the Bluetooth CAP specificiation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
- There are linker file directives that must come at the
start of the noinit region. For example, the directive
that allow that section to not exist in RAM before a
certain address (. = MAX(ABSOLUTE(.), 0x34002000);).
- Before this update, those could only be added to the end
of that region. They will now have the option to be at the
beginning or the end.
Signed-off-by: Bill Waters <bill.waters@infineon.com>
The `sysconf()` implementation in Zephyr can be macro-based or
library-based. Both approaches use the same set of runtime-invariant
definitions in `sys/sysconf.h`.
These were previously fine, as long as POSIX limits were
guaranteed to be defined. However, some C libraries omit definitions
for runtime-invariants values and instead force the application to
query values via `sysconf()`.
The specification formally supports that approach [1]. Normally,
definitions are allowed to do so "on specific implementations where the
corresponding value is equal to or greater than the stated minimum, but
is unspecified." In practice, that is not always the case, but we need
to be able to compile `sysconf()` anyway.
Notable constants that are missing in Picolibc or Newlib include:
- AIO_LISTIO_MAX
- AIO_MAX
- AIO_PRIO_DELTA_MAX
- CHILD_MAX
- DELAYTIMER_MAX
- HOST_NAME_MAX
- IOV_MAX
- LOGIN_NAME_MAX
- MQ_OPEN_MAX
- MQ_PRIO_MAX
- OPEN_MAX
- PAGESIZE
- PAGE_SIZE
- PTHREAD_DESTRUCTOR_ITERATIONS
- PTHREAD_KEYS_MAX
- PTHREAD_THREADS_MAX
- RTSIG_MAX
- SEM_NSEMS_MAX
- SEM_VALUE_MAX
- SIGQUEUE_MAX
- SS_REPL_MAX
- STREAM_MAX
- SYMLOOP_MAX
- TIMER_MAX
- TTY_NAME_MAX
For greater portability, define those values using
1. a Kconfig-derived definition,
2. a symbolic minimum value (required by the spec), or
3. a numeric minimum value (if the required symbolic minimum is missing).
[1]
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Ensure that minimum values are numeric and align with the specification.
Define runtime invariant values using Kconfig options or constant
minimum values.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The MWDT linker has a specific input section sorting mechanism,
designated as x$y. Some prebuilt ARC libraries actually use it,
causing a lot of warnings when the linker decides where to place
their symbols. Provide explicit instructions in the linker script
instead of making the linker guess.
Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
After the #93703 PR was merged we get a possibility to remove _node field
from bt_conn_cb struct if the BT_CONN_DYNAMIC_CALLBACKS option is disabled.
The list conn_cbs can also be safely removed by more macro usage.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
In most circumstances, GPIO pins identified in devicetree are
assigned to the SIO function at initialization. However, there
are cases where pin assignments change in alternate pinctrl
configurations. This commit adds the necessary definitions to
specify GPIO opration in pinctrl.
Signed-off-by: Steve Boylan <stephen.boylan@beechwoods.com>
It's not very clear about the function of ptp_clock_rate_adjust in doc.
Previously, all device drivers used it to adjust rate ratio relatively
based on current frequency.
When PI servo was introduced in PTP and gPTP stacks, NXP ENET PTP driver
started to use it to adjust rate ratio based on its nominal frequency.
Rate ratio adjustment based on nominal frequency with PI servo could
get stable frequency control. So, let's clarify ptp_clock_rate_adjust
adjusting rate ratio based on nominal frequency, and convert other
device drivers.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Add a structure `struct bt_obex_tlv` to pass/save the one TLV info.
Use a array of `struct bt_obex_tlv` as the set of all TLV-triplets.
Update the following functions to support the feature, including
`bt_obex_add_header_app_param`, `bt_obex_add_header_auth_challenge`,
and `bt_obex_add_header_auth_rsp`.
Add a function `bt_obex_tlv_parse` to parse the encoded TLV-triplets.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a Kconfig BT_GOEP to control the GOEP feature.
Implement the GOEP protocol and transport, both for GOEP 1.1 and GOEP
2.x.
For GOEP transport, OBEX over RFCOMM, and OBEX over L2CAP are
supported.
For GOEP protocol, `put`, `get`, `abort`, `setpath`, and `action` are
supported. And only one operation can be processed at the same time.
The feature `Reliable Session` is unsupported.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
L2CAP channels will now, along with the ident, store the opcode of the
pending request. This commit expands the ident lookup function to also
compare received response types to this opcode, and will ignore
unsolicited responses.
Setting of idents for channels are moved after verification of buffer
allocation for the request to be sent. A TODO is added for improving
this functionality at a later time.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Add the extended operations to the Andes XIP flash driver.
The extended operations supports:
- reading status registers of the flash chip
- changing status registers of the flash chip
- software lock of the status registers
- modifying SPI read command used in memory-mapped mode
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>