In OpenRISC 1000, the stack pointer is stored in the r1 register. This
patch stores the offset of this value within in the thread structure into
the thread info offsets.
Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
The vconn_en and vconn_discharge callbacks were invoked with the TCPC
device as the first argument. Application callbacks then called
usbc_get_dpm_data(dev) with the TCPC device, causing dev->data (which
is struct tcpc_data *) to be misinterpreted as struct usbc_port_data *.
This resulted in dpm_data->vconn_pol being written to an incorrect
memory offset, silently corrupting TCPC driver state.
Fix by adding a const struct device *usbc_dev parameter to
tcpc_vconn_control_cb_t and tcpc_vconn_discharge_cb_t, and propagating
it through set_vconn_cb and set_vconn_discharge_cb in the driver API.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
Introduces a new TC_STARTUP_STATE to handle the initialization phase of
the Type-C state machine.
Previously, the state machine was initialized to TC_DISABLED_STATE during
POST_KERNEL initialization. This state inherits from
TC_CC_OPEN_SUPER_STATE, which executes tcpc_set_vconn(false). Since
VCONN callbacks are typically registered in main() (which runs after
POST_KERNEL), this resulted in an error log and the statemachine
unexpectedly transitioning to TC_ERROR_RECOVERY_STATE.
The new TC_STARTUP_STATE has no parent state and performs no hardware
operations. The state machine now transitions:
1. Boot (POST_KERNEL): Initialize to TC_STARTUP_STATE.
2. Start (MAIN): When usbc_start() runs the thread, tc_init() transitions
to TC_DISABLED_STATE (ensuring VCONN/VBUS off with valid callbacks).
3. Run: Immediately transitions to TC_ERROR_RECOVERY_STATE to begin
protocol operation.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
Introduces DRP support to the USB-C subsystem, enabling dynamic
support for both Source and Sink power roles. Unattached devices
toggle between Source (Rp) and Sink (Rd) CC advertisements based
on the configured DRP period (tDRP) and duty cycle (dcSRC.DRP).
Once an attach is detected, the device enters the appropriate
Attached.SRC or Attached.SNK usbc_tc state and starts the
corresponding usbc_pe state machine to negotiate a power contract.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
Implement IPC backend for ZBus proxy agent, enabling
message forwarding between domains over IPC endpoints.
Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add core implementation for zbus communication between domains using
pluggable backend transports.
Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Function udc_buf_get_all() was intended to be a helper to remove all
requests from endpoint FIFO. While for just freeing all queue the
it may be argued that there may be some doubtful simplicity argument,
merging multiple submitted transfers into one is just enforcing
unnecessary complexity on class implementations.
At general level, every submitted (enqueued) request should get
corresponding completion (request callback) call. UDC drivers were
violating this sensible behavior when dequeuing (cancelling) requests by
merging all submitted requests into one.
Remove udc_buf_get_all() and replace all uses with simple loops. For
most classes (that submit just one request for an endpoint at a time)
this has no functional difference. For classes that implement double
buffering this simplifies completion handling.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Add a USB Video Class (UVC) host class implementation that enables
Zephyr-based systems to act as USB hosts for standard UVC cameras.
This allows applications to capture video streams from USB cameras
using the standard Zephyr video API.
The implementation follows the UVC specification for device enumeration,
format negotiation, and stream control. It handles the complexity of UVC
descriptor parsing, bandwidth management, and isochronous transfer
scheduling, presenting a clean video device interface to applications.
Support for common camera controls such as brightness, contrast,
exposure, focus, and zoom allows applications to adjust camera settings
at runtime. Dynamic format and frame rate changes are also supported,
making it suitable for various use cases from simple video capture to
more advanced computer vision applications.
Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
Characters not present in the font were replaced with a space character.
This is changed to draw **tofu** instead.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
When calling zsock_recvmsg()/zsock_sendmsg() system calls, check if
provided msg->msg_iovlen is valid, i.e. does not cause size_t overflow
when calculating memory needed for msg->msg_iov vector.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When reading the value of the vendor attribute, strlen was used instead
of sizeof, causing a unpredictable read size. This commit changes the
implementation to use sizeof instead.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Minor changes that are required in order to move from Mbed TLS 3.6.5
to TF-PSA-Crypto 1.x:
- "psa_crypto_driver_wrappers.h" has been relocated
- some extra include folders are required because they are directly
included from "psa_crypto_driver_wrappers.h" but not exported from
"mbedTLS" library since they are meant to remain private.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Both PK and TLS now rely on PSA generate random to get random data
so end users (i.e. sockets_tls in this case) don't need to manually
specify this anymore.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
If open is called before the backend is initilize then bounding
will stuck as works scheduled to the workqueue in the open function
are never executed. Return error if open is called too early, before
device initialization.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
If CONFIG_LOG_TIMESTAMP_64BIT is enabled, then the call to
log_set_timestamp_func in the Bluetooth monitor is type-invalid,
which may fail to build with -Werror.
To avoid this type inconsistency let's use the type `log_timestamp_t`,
which accounts for the correct size, depending on selected config.
Even though the monitoring protocol only seems to support 32b timestamps,
the rest of the module is already based on 64b timestamps, so the
truncation is only done when encoding the timestamp for transmission
to the host in encode_hdr()
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
Set unique names for the RTIO workqueue threads. If
`CONFIG_RTIO_WORKQ_THREADS_POOL` goes over 9, the numbers repeat. This
is not expected to occur in practice since the two defaults for this
config are `1` and `2`, and fully handling it is not worth the code
complexity.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Currently, ztest is primarily focused on unit testing. This commit
introduces a framework designed specifically for performance analysis.
Key features:
- Standardized API: ZBENCH_SUITE and ZBENCH macros.
- Low overhead: Uses Welford's online algorithm for statistics
to keep memory footprint minimal.
- Hardware agnostic: Built on top of <zephyr/timing/timing.h>.
- Clear output: Provides formatted console tables of results.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The way that ASCS registers and unregisters for the ASCS
unittests does not work properly with UUIDs and local variables.
Hotfix is to use a `static` backup instead of a stack-allocated
backup. A proper fix will be provided later.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Don't rely solely on disconnect events to determine writability, since
the socket can drop at any time. A send() to a closed socket fails and
the resulting error reaches the shell thread, where a failing __ASSERT
causes a crash.
Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
Guard the websocket shell backend's internal state with a mutex.
The disconnect callback executes on a different thread than the shell
and can interleave with sends, leading to writes on an invalid fd or
a disconnected socket.
Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
Preallocate and keep reusing the same buffer for SETUP data. This
ensures that USB stack will always be able to handle SETUP stage
regardless of UDC memory pool usage.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Allocating buffer in response to control transfer is part of processing
and therefore should not be done in UDC driver but rather in the stack.
Simplify UDC driver design by moving all control transfer buffer
allocations and processing to USB stack.
New control transfer handling flow is as follows:
1. USB stack allocates and queues buffer for Setup stage. This informs
UDC driver that USB stack is ready to process new transfer.
2. UDC driver completes enqueued Setup buffer. SETUP data may have
been received by device before Setup buffer was enqueued.
If multiple SETUP data was received, UDC driver must complete
request using last received SETUP data.
3. USB stack processes request. USB stack is responsible for:
* Stalling control endpoint when request cannot be processed
* Allocating and enqueueing Data stage buffer if necessary
- Depending on enqueued endpoint (IN/OUT), UDC driver is
expected to complete the transfer. If host sends new SETUP
data for any reason (e.g. timeout), then Data stage buffer
must be completed with -ECONNRESET code.
- UDC driver may postpone processing Data IN until USB stack
enqueues new Setup stage buffer.
* Handling status stage if applicable
- If Data IN was enqueued, stack immediately allocates and
enqueues Status OUT stage buffer.
- If Data OUT was enqueued, stack waits for Data OUT buffer
completion before doing any further processing.
- If control transfer handling fails, stack is expected to
STALL control endpoint.
* Allocating and enqueuing Setup buffer.
- This informs UDC driver that stack has finished processing
control transfer. UDC driver may choose to start processing
Data IN and/or Status OUT only after new Setup buffer is
enqueued.
4. UDC driver must fail (complete with -ECONNRESET) any enqueued and
not completed Data and Status buffers if host sends new SETUP data.
UDC driver must be able to buffer last received SETUP data until
USB stack is ready (enqueues Setup buffer).
5. UDC driver must complete all Data and Status buffers before it
completes Setup buffer.
6. UDC driver may keep ownership of Setup, Data and/or Status buffers
across USB bus resets. USB stack does not attempt to dequeue any
control transfer buffer it enqueued.
This approach implicitly synchronizes UDC driver against USB stack,
which ensures that only one set of Setup/Data/Status buffers is
allocated at a time.
Another advantage of the rework is drawing a clear line on buffer
ownership. The buffer responsibilities are as follows:
* USB stack is the only entity that both allocates and frees the
buffers. Only USB stack is allowed to set "setup", "data" and
"status" fields in struct udc_buf_info.
* UDC takes ownership of buffers handed to it in udc_ep_enqueue().
* UDC releases buffer ownership by calling udc_submit_ep_event().
Because there is just a single place where the buffer ownership changes,
and all buffers must go USB stack (alloc) -> UDC (perform requests on
the bus) -> USB stack (free) route it would be possible in the future to
implement a "tap" similar to Linux usbmon that would ease debugging.
This commit significantly changes how USB stack communicates with UDC
drivers. It was decided that supporting both the old and new model
simultaneously would require way too much effort. Therefore all UDC
drivers were reworked. Following people worked on driver rework:
* Tomasz Moń - ambiq, dwc2, kinetis, mcux ip3511, nrf, numaker,
renesas ra, rpi pico, smartbond, virtual
* Mathieu Choplain - stm32
* Mark Wang - mcux ehci
* Johann Fischer - sam0, stm32
* Ren Chen - it82xx2
* Brandon Hurst - max32
* Gerson Fernando Budke - sam udp, sam usbc, sam usbhs
Co-authored-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Co-authored-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Mark Wang <yichang.wang@nxp.com>
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Co-authored-by: Ren Chen <Ren.Chen@ite.com.tw>
Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
Co-authored-by: Brandon Hurst <brandon.hurst@analog.com>
Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
Co-authored-by: Gerson Fernando Budke <nandojve@gmail.com>
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
The usage of CHECKIF has been replaced with a regular
if. The reason for this is that higher layer may depend
on some of the checks defined by the API, and the higher
layers cannot do that properly if the checks can be
removed via a Kconfig option.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_uuid_compress() to compact a 128-bit Bluetooth UUID into its
16-bit or 32-bit short form when it matches the Bluetooth Base UUID.
If the UUID does not match the Base UUID pattern the 128-bit value is
copied unchanged and -ENOTSUP is returned, allowing callers to
distinguish compressible from non-compressible UUIDs.
16-bit and 32-bit source UUIDs are copied as-is.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Implement bt_uuid_from_str() function to convert string representations
to Bluetooth UUID structures. This provides bidirectional conversion
between UUID structures and their string representations, complementing
the existing bt_uuid_to_str() function.
Features:
- Supports 16-bit UUID format (4 hex characters, e.g., "180d")
- Supports 32-bit UUID format (8 hex characters, e.g., "abcdef12")
- Supports 128-bit UUID standard format (with hyphens)
- Comprehensive input validation and error handling
- Automatic UUID type detection based on string length
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Refactor the Bluetooth UUID module to use the generic UUID library
(lib/uuid) instead of hand-rolled byte manipulation.
Changes:
- Replace bt_uuid_128-based base UUID with struct uuid (RFC 9562 order)
- Replace uuid_to_uuid128() with bt_uuid_to_uuid() for BT-to-generic
UUID conversion using proper big-endian / byte-swap operations
- Simplify bt_uuid_to_str() 128-bit case via uuid_to_string()
- Add Kconfig 'select UUID' dependency for BT_HCI_HOST
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
This is useful if the application may wish to reject an address.
This works well alongside the address_provider callback, this way
you can enforce static leases based on the client id (MAC address).
Signed-off-by: Andreas Ålgård <aal@ixys.no>
Fix three command handlers that were incorrectly returning the result
of callback functions with void return type:
- avrcp_unit_info_cmd_handler
- avrcp_subunit_info_cmd_handler
- avrcp_pass_through_cmd_handler
Split the callback invocation and return statement to properly handle
the void return type, avoiding potential compiler warnings or errors.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The MQTT logging backend can cause the logging thread
to take over idle time when the used client disconnects/fails
to send the log messages.
Fixed by always returning the length of the log in every case.
Signed-off-by: Roland Lux <roland.lux@blue-zone.at>
- NET_EVENT_IF_UP can fire between the net_if_is_up() check and
net_mgmt_add_event_callback() in check_interface(). When this
happens (e.g. with CONFIG_SHELL_BACKEND_TELNET=y which starts a
same-priority thread that brings the interface up concurrently),
the event is missed and net_config_init_by_iface() blocks forever.
- Fix by always registering the callback first, then checking
net_if_is_up() after registration. If the interface came up in
the race window, remove the callback and signal the semaphore
immediately. Move the NET_INFO print to only fire when we are
genuinely going to wait.
Signed-off-by: Jjateen Gundesha <jjateen97@gmail.com>
The espressif toolchain variant (ZEPHYR_TOOLCHAIN_VARIANT=espressif)
has not been used for years. Espressif targets are now built using the
Zephyr SDK, which bundles the required Xtensa and RISC-V toolchains.
Remove the cmake/toolchain/espressif/ directory containing generic.cmake,
target.cmake, and Kconfig files that implemented this variant. Also
clean up references in the coredump xtensa gdb stubs, removing the
ESPRESSIF toolchain enum value and related handling code.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The bt_hci_cmd_create() function was deprecated several releases ago (in
Zephyr 4.2) and can therefore now be removed.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The 3GPP TS 27.010 section 5.3.4 specifies:
"DISC command sent at DLCI 0 have the same meaning as the
Multiplexer Close Down command"
Add a handler for this and do the same operation as in
modem_cmux_on_cld_command().
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add a check of the URI scheme length before comparing it
to any instance's supported URI schemes. If the incoming
URI scheme is longer than what we support, then there's
no point in checking if we support it, as we cannot.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BT_GATT_INCLUDE_SERVICE is always included in
BT_MCS_SERVICE_DEFINITION even when CONFIG_BT_OTS=n,
this fixes it such that it is only included when OTS is enabled.
Fixes zephyrproject-rtos#105345
Signed-off-by: Vedant Malkar <vedantitsme@gmail.com>
When the controller supports BR/EDR and CONFIG_BT_CLASSIC is
enabled, call bt_br_init() to perform the full BR/EDR Classic
initialization (SSP mode, inquiry mode, local name, Class of
Device, etc.).
For non-Classic builds that still need BR/EDR buffer sizes,
gate the hci_read_buffer_size() fallback with
IS_ENABLED(CONFIG_BT_CONN) to make the build-time condition
explicit at the call site.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
When CONFIG_BT_CLASSIC is enabled and the controller is ready,
push the updated device name to the BR/EDR controller via
bt_br_write_local_name() inside bt_set_name(). This ensures
runtime name changes are properly synchronized to the BR/EDR
transport.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
When CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, write the device name
(restored from flash or the compile-time default) to the BR/EDR
controller during commit_settings().
Replace the bt_set_name() call with a direct strncpy into bt_dev.name
to avoid an unnecessary flash write, then explicitly push the name to
the BR/EDR controller via bt_br_write_local_name().
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Extract the HCI Write Local Name command into a reusable
bt_br_write_local_name() helper and use it in bt_br_init().
When CONFIG_BT_DEVICE_NAME_DYNAMIC and CONFIG_BT_SETTINGS are
both enabled, skip writing the compile-time default here since
the settings commit callback will push the correct name (either
restored from flash or the default) to the controller.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Replaces usage of these deprecated macros with ones that support
fixed and mapped partition compatibles. Also includes an update to
hal_espressif which also (rightly or wrongly) has zephyr specific
code in it
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>