Commit graph

15409 commits

Author SHA1 Message Date
Jonathan Rico
ea9449979b Bluetooth: L2CAP: Mark user_data as owned by the stack
Storing stuff in user_data? That's a paddlin'

We have been debugging issue after issue because ownership of this
"user" data is not clearly defined. Now it is. L2CAP owns the user_data
field entirely, as soon as `send()` is called.

Also add a warning and retval using CHECKIF.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-01 16:49:37 +01:00
Fabio Baltieri
e466efaf74 libc, console: declare __stdout_hook_install in libc-hooks.h
Declare __stdout_hook_install in libc-hooks.h and use it in the console
drivers rather than redeclare it every time.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-08-01 16:49:08 +01:00
Martin Stumpf
77eafac1bf linker: section_tags: fix missing include
If using `<zephyr/linker/section_tags.h>` without including
`zephyr/linker/sections.h` as well, we get a warning an the linker fails
to place the data in the desired section.

Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2024-08-01 16:44:05 +02:00
Jakub Zymelka
bb5b98f16c ipc: icmsg: Align to NO MULTITHREADING
Adapting icmsg to work without the MULTITHREADING functionality.
Dependencies for kernel work_queue, mutexes and other functions
related to running multithreaded applications have been 'ifdefed'.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2024-08-01 13:31:53 +02:00
cyliang tw
5b921c53b0 soc: nuvoton: numaker: add poweroff for m46x
Add support of sys_poweroff API on m46x series.
It could support SPD standby or DPD deep power down mode.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2024-08-01 12:37:47 +02:00
Bjarki Arge Andreasen
2b007ab784 drivers: i2c: enforce i2c stop flag in last i2c_transfer_cb msg
The i2c_transfer API specifies that the I2C_MSG_STOP flag implicitly
is set for the last message in a i2c_transfer(). This is identical to
explicitly setting the I2C_MSG_STOP flag in the last message, which is
what every driver which properly adheres to this specification does.

The i2c_transfer_cb API is seemingly identical to the i2c_transfer_api,
it references it using @see i2c_transfer(), while providing a callback,
and being available from isr context. This commit extends the wrapper
to provide the following guarantees also present in the i2c_transfer API:

- If num_msgs is 0, no transfer will occur
- The last message of the transfer implies a stop condition

This allows for users to use both functions interchangeably, while
removing handling of num_msgs = 0 and last message missing stop cond
from device drivers.

Additionally a check for num_msgs == 0 is added to prevent any transfer
and immediately call back with success then return without invoking
the transfer_cb API.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-08-01 12:37:40 +02:00
Bjarki Arge Andreasen
e7487f1777 drivers: i2c: enforce i2c stop flag in last i2c_transfer msg
The i2c_transfer API specifies that the I2C_MSG_STOP flag implicitly
is set for the last message in a i2c_transfer(). This is identical to
explicitly setting the I2C_MSG_STOP flag in the last message, which is
what every driver which properly adheres to this specification does.

This commit updates the i2c_transfer() API wrapper to explicitly set
the flag before calling the drivers API implementation, which ensures
the specification is followed, while moving this additional complexity
from the device drivers themselves.

Additinally it checks for the num_msgs being 0, in which case no
transfer shall occur, nor shall any stop condition be set. This removes
an additional check from device drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-08-01 12:37:40 +02:00
Felipe Neves
804db65928 drivers: input: cst816s: read the gesture-ID register
And report the gestures as specific device  event type
to the input subsystem.

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
2024-08-01 09:14:19 +01:00
Felipe Neves
acaee9f019 dt-bindings: input: introduce INPUT_EV_DEVICE input code
For reporting specific input device events.

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
2024-08-01 09:14:19 +01:00
Matt Rodgers
47fbb8512f net: coap_client: allow application to add block2 option to requests
Allow an application to add a Block2 option to an initial request for a
resource. For any subsequent requests as part of a blockwise transfer,
drop the application-added Block2 option since the coap_client must
append a Block2 option with updated NUM and SZX fields based on the
server response.

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
2024-08-01 09:13:32 +01:00
Nicolas Pitre
d3bf90e641 arm64: linker: remove ARM32 remnants
- .glue7, .glue7t, .vfp11_veneer and .v4_bx are ARM32-isms

- ARM64 needs 8-bytes alignment

- remove useless/unsuited comments

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-08-01 09:12:36 +01:00
Henrik Brix Andersen
9af6ae50f4 usb: device_next: add usbd_device_set_bcd_device()
Add usbd_device_set_bcd_device() for setting the bcdDevice device
descriptor value.

The default bcdDevice is set to the version of Zephyr being used, which may
or may not be what a downstream USB device wants it to be.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-08-01 09:11:44 +01:00
Henrik Brix Andersen
196c9635d8 usb: device_next: rename usbd_device_set_bcd()
Rename usbd_device_set_bcd() to usbd_device_set_bcd_usb() to make room for
other BCD encoded values being set.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-08-01 09:11:44 +01:00
Fabio Baltieri
6d1b880fdc input: add a INPUT_CALLBACK_DEFINE_NAMED macro
Add a INPUT_CALLBACK_DEFINE_NAMED macro, same as INPUT_CALLBACK_DEFINE
but with custom struct name, useful for declaring multiple callbacks
with different user_data on the same callback function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-31 12:55:11 +02:00
Fabio Baltieri
716fa268f4 input: add a user_data pointer to the callback
Add a void *user_data pointer to the input callback structure. This is
useful for driver to get back the driver data structure and avoid
defining wrapper functions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-31 12:55:11 +02:00
Manuel Argüelles
6c7d836b0c drivers: nxp: convert SIUL2 drivers to native
Convert pin control, GPIO and external interrupt controller drivers
based on SIUL2 peripheral to native drivers. This must be done in a
single commit to preserve atomicity, as these drivers depend on each
other.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-07-31 10:08:24 +02:00
Gerhard Jörges
e55278a87b net: lib: http_server: add static fs resource
adds filesystem as a resource for the http_server which serves static
(gzipped) files from a filesystem to the client.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-07-31 10:08:16 +02:00
Fabian Pflug
31e91794de net: l2: ieee802154: mgmt: allow beacons without association bit
The Association permit bit shall be set to zero if the coordinator does
not accept association requests.
Not accepting association request ist not a reason to filter the
beacons from this coordinator during network scan. It is still a
network, just one you cannot associate with.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-07-31 10:08:03 +02:00
Rubin Gerritsen
d8f7f2deb7 Bluetooth: Document the execution context of bt_ready_cb_t
This should make it more clear for users that they shouldn't
run blocking code in the callback.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-31 10:07:37 +02:00
Bjarki Arge Andreasen
0a735dce52 drivers: gnss: api: Update docs to allow for leap second
Update the struct gnss_time millisecond member to specify
that a leap second is a valid value.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-31 10:07:19 +02:00
Pieter De Gendt
92019b1dac emul: Support UART device emulation
Add support to the existing UART emulated bus, to have a client device
emulator.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-30 18:28:17 +01:00
Johann Fischer
67caae3aca usb: device_next: introduce UDC_BUF_POOL_*_DEFINE macros
Introduce UDC_BUF_POOL_*_DEFINE macros based on NET_BUF_POOL_*_DEFINE
macros but use our own version of alloc and unref callbacks to get
buffers with specific alignment and granularity. Also, do not use ref
callback because it breaks alignment.
Also introduces helper macros for defining and checking UDC
driver-compliant static buffers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-30 18:26:04 +01:00
Jyri Sarha
1b6e0f6479 debug: thread_analyzer: Option to analyze threads on each core separately
Add implementation to analyze threads on each cpu separately. This
feature can be enabled with THREAD_ANALYZER_AUTO_SEPARATE_CORES Kconfig
option. If enabled, an analyzer thread is started for each cpu, and
the threads will only analyze thread on the cpu its running on.

This feature is needed for Intel ADSP platform, where cpu specific
caches are not synchronized between the cpu. It is also probably
needed by other platforms having CONFIG_KERNEL_COHERENCE=y, so default
to THREAD_ANALYZER_AUTO_SEPARATE_CORES=y for those platform.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
2024-07-30 18:25:40 +01:00
Jyri Sarha
28215fc788 kernel: thread: Add k_thread_runtime_stats_cpu_get()
Add k_thread_runtime_stats_cpu_get() to get runtime statistics of
the specified core.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
2024-07-30 18:25:40 +01:00
Jyri Sarha
b8a1a62048 kernel: thread: Add k_thread_foreach_filter_by_cpu() and unlocked version
Add functions k_thread_foreach_unlocked_filter_by_cpu() and
k_thread_foreach_filter_by_cpu() to loop through the threads on the
specified cpu only.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
2024-07-30 18:25:40 +01:00
Ryan McClelland
147df87fa4 drivers: i3c: add ddr, ibi tir, direct ccc def byte support
Revision 1p7 of the silicon added support for IBI TIR, full word fifo
while target usage, defining byte with direct CCCs. This also adds
support of HDR-DDR.

This also fixes short ccc commands where multiple targets in a
payload for the same ccc.

Modification of the i3c_target_tx_write had to be done in order to
distinguish the difference for each fifo to be written to.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-07-29 14:23:43 +02:00
Miguel Gazquez
f712f9554b dts: bindings: add DT binding for lsm9ds1
This commit adds a description for the lsm9ds1 sensor,
with a .h file containing all configuration options.

Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
2024-07-29 14:21:24 +02:00
Tomasz Leman
230709e4ae include: dai: Introduce runtime DAI configuration update API
This patch introduces a new API function, `dai_config_update`, in the
DAI driver API to enable runtime updates to the DAI configuration. This
function allows bespoke configuration parameters to be set, enabling
updates that are specific to the DAI implementation and can be applied
outside of the regular configuration flow.

The addition of this API provides greater flexibility for adjusting DAI
settings at runtime, which is particularly useful in scenarios where
only specific parameters need to be modified without the need to
reconfigure the entire DAI interface.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2024-07-29 14:20:18 +02:00
Bjarki Arge Andreasen
372c7183ef modem: pipe: Add explicit timeout to sync APIs
The modem pipe APIs include synchronous calls to open/close,
which internally use a fixed timeout of 10 seconds. The timeout
should be configurable through the APIs, anywhere from K_NO_WAIT
to K_FOREVER.

This commit adds timeout parameters to the open/close APIs, and
updates in-tree usage of the open/close APIs to explicitly
provide the previously implicit timeout of 10 seconds.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-07-29 14:14:42 +02:00
Yong Cong Sin
88c13020aa posix: fs: mark _POSIX_SYNCHRONIZED_IO as supported
The `_POSIX_SYNCHRONIZED_IO` option group is now fully
supported.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-07-29 14:14:33 +02:00
Yong Cong Sin
91abf0e329 posix: fs: implement fdatasync()
`fdatasync()` is basically equivalent to `fsync()` according
to the standards.

Added test for it.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-07-29 14:14:33 +02:00
Théo Battrel
f477d9d7eb Bluetooth: Gap: Add missing AD types
Add the following AD types:
- `BT_DATA_DEVICE_CLASS`
- `BT_DATA_SIMPLE_PAIRING_HASH_C192`
- `BT_DATA_SIMPLE_PAIRING_RAND_C192`
- `BT_DATA_DEVICE_ID`
- `BT_DATA_PAWR_TIMING_INFO`
- `BT_DATA_ESL`

Note that `BT_DATA_DEVICE_ID` has the same value as
`BT_DATA_SM_TK_VALUE` (0x10), this is not a mistake from the author but
a mistake in the Core Specification, specifically the Assigned Numbers
document with the version date 2024-04-10.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-07-29 14:13:34 +02:00
Adrien Ricciardi
b09972b445 fs: nvs: Allow application to switch sector to get free space
Add an API function allowing the application to determine the amount of
free bytes in the current sector.

Add a second API function allowing the application to switch to the next
NVS sector, calling the garbage collector on such sector.

The goal is togive more granularity to the application to control when
the garbage collector is triggered.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2024-07-28 07:31:44 +03:00
Emil Gydesen
38d09af445 Bluetooth: BAP: Scan delegator add src without PA sync
Modify the bt_bap_scan_delegator_add_src to take an address and
a sid instead of a PA sync object, so that the scan delegator
can add a source without syncing to the PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-28 07:31:06 +03:00
Andreas Ålgård
a5850b794c net: lib: dhcpv4_server: Add callback to allow user to set address
This functionality is useful to allow for conditional or static leases.

Signed-off-by: Andreas Ålgård <aal@ixys.no>
2024-07-28 07:30:48 +03:00
Pisit Sawangvonganan
444e135679 net: if: streamline interface name checking logic
This commit reduces `#if / #endif` pairs by leveraging the
`IS_ENABLED` macro:
- Removed `#ifdef / #endif` around `NET_L2_DECLARE_PUBLIC` in `net_l2.h`,
  enabling compilation without affecting link time if the configuration
  is unavailable.

`set_default_name` function:
- Replaced multiple `if` statements with `else if` to use the last `else`
  without indirectly checking `name[0] == '\0'`.
- Since `snprintk` guarantees null-termination if `sizeof(name) > 0`,
  the `-1` subtraction is unnecessary, eliminating the need for
  zero initialization in `char name[CONFIG_NET_INTERFACE_NAME_LEN + 1];`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-28 07:29:01 +03:00
Vineeta S Narkhede
232c802c05 net: hostname: Add a function to set the hostname postfix as is.
Fixes: #72363

The existing function to set the postfix is converting postfix
string to hexadecimal. Adding a new function to handle a use case
where the provided postfix should be used as is without any conversion.

Signed-off-by: Vineeta S Narkhede <VineetaSNarkhede@Eaton.com>
2024-07-28 07:28:51 +03:00
Pisit Sawangvonganan
b5fdbc21bf modem: cmux: optimize modem_cmux_frame structure padding
Downsize `dlci_address` field from `uint16_t` to `uint8_t` in
`modem_cmux_frame` for better memory alignment.

Note: The maximum value of `dlci_address` is 63, which fits
within `uint8_t`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-27 20:51:42 +03:00
Pisit Sawangvonganan
ba30e7b350 modem: pipe: make modem_pipe_api a pointer to constant
Changed the `api` field in the `modem_pipe` structure to be
a pointer to constant.

This ensures that the `api` field remains immutable after
initialization.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-27 20:51:42 +03:00
Bas van Loon
85f6409043 net: if: Add net_if_ipv4_get_gw as helper function.
Most set functions have a get function as well, add the missing
function to get the set gateway IPv4 address.

Signed-off-by: Bas van Loon <basvanloon@betronic.nl>
2024-07-27 20:51:21 +03:00
Pisit Sawangvonganan
d5cd47fbb2 shell: introduce shell_xxx_impl wrapper functions for output macros
Refactor shell output macros to minimize caller overhead by eliminating
direct `color` parameter passing:
- Introduce wrapper functions: `shell_info_impl`, `shell_print_impl`,
  `shell_warn_impl`, `shell_error_impl`.
- Replace `shell_fprintf` in macros with these new wrappers.
- Update `shell_hexdump_line` to use the new wrappers,
  minimizing caller overhead.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-27 20:50:12 +03:00
Emil Gydesen
8be6db67fc Bluetooth: ISO/BAP: Refactor BIS bitfield
Refactors teh BIS bitfield values used for ISO
and BAP.

Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.

Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.

This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:19:46 +03:00
Chris Friedt
6cf557d64a posix: posix_types.h: simplify conditions on pthread types
Simplify the conditions for pthread type declaration

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-27 15:17:24 +03:00
Chris Friedt
6667b500c6 posix: sys/stat.h: move declarations to posix_types.h
A number of types such as uid_t, gitd_t, etc, were defined in
sys/stat.h to workaround compatibility issues many years ago.

Since posix_types.h is slated to become equivalent to
sys/types.h in terms of standard headers, move these types
to where they belong.

For more information, please see

https://pubs.opengroup.org/onlinepubs/9699919799/\
 basedefs/sys_types.h.html

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-27 15:17:24 +03:00
Chris Friedt
81f5205006 net + posix: avoid host includes when building for native_sim
A corner case involving C++, posix, networking, and native_sim
was causing problems.

Even though C and C++ builds should include zephyr/posix/.. in
the default search path with `CONFIG_POSIX_API=y`, for some
reason, the native compiler pulls in /usr/include first anyway.

The stat.h header pulled in <sys/types.h> (which is normally
fine) but due to the native build, it was pulling in
/usr/include/sys/types.h, from the host toolchain.

Explicitly include <zephyr/posix/posix_types.h> instead of
<sys/types.h> from stat.h, and continue using the workarounds
for native builds (explicitly including zephyr/posix/arpa/net.h
from net/sockets.h .

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-27 15:17:24 +03:00
Chris Friedt
6a0593d554 Revert "net: socket: fix sys/_timespec.h not found error"
This reverts commit 269729a5db.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-27 15:17:24 +03:00
Gerard Marull-Paretas
4ba5ad99cc drivers: i3c: fix/improve Doxygen
- Use references whenever possible instead of literals (e.g. `@c`)
- Remove incorrect usages of `@see`
- Fix incorrect usage of INTERNAL_HIDDEN blocks
- Detail Kconfig-dependent options with `@kconfig{}`
- Other minor enhancements

Ref. https://www.doxygen.nl/manual/autolink.html

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 15:13:27 +03:00
Gerard Marull-Paretas
003244e069 drivers: i3c: avoid duplicating BCR/LVR docs
Instead use Doxygen anchors to reference to a single source of truth.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 15:13:27 +03:00
Gerard Marull-Paretas
6f0b470bba drivers: i3c: use GENMASK/FIELD_GET if possible
This avoids the need to define a position shift macro, and makes code less
verbose.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 15:13:27 +03:00
Gerard Marull-Paretas
6ce0b0aab2 drivers: i3c: improve/fix include list
Include what is strictly needed.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 15:13:27 +03:00