Commit graph

15409 commits

Author SHA1 Message Date
Evgeniy Paltsev
e1efafa31d ARC: don't align ROM region end if not required
This extra MPU alignment of RAMABLE_REGION is only required
if we put ROMABLE_REGION and RAMABLE_REGION into the same
(continuous) memory (i.e. SRAM) - so we won't get beginning of the
RAMABLE_REGION in the end of ROMABLE_REGION MPU aperture.

If we use different regions (ICCM & DCCM, FLASH & SRAM, etc...)
we don't need this extra MPU alignment.

Let's drop it to decrease ROM memory usage.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-06-14 17:42:54 -04:00
Pierce Lowe
2019c044ba Bluetooth: hci: Add 5.4 HCI error codes
Add new bluetooth hci error codes from Bluetooth 5.4 specification

Signed-off-by: Pierce Lowe <pierce.lowe@nordicsemi.no>
2023-06-13 13:32:17 -04:00
Pieter De Gendt
5cdbd59c67 include: crypto: Remove duplicate assignment line
The crypto hash context has a reference to the crypto device,
but the assignment was duplicated.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-06-13 10:43:00 -04:00
Mykola Kvach
2756c9b9a5 arch: arm64: cache: fix usage of extern C linkage specification
Reorder preprocessor condition endings in arm64/cache.h,
this eliminates the breaking of the 'extern "C"' construction.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-06-13 07:06:46 -04:00
Siyuan Cheng
24efa6720d drivers: pinctrl_emsdp: fix definition location
Mux Control Register Index are internals of driver, now
moved from dt-binding header to driver itself.

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-06-13 07:02:08 -04:00
Siyuan Cheng
1a6b6e7b84 drivers: pinctrl_emsdp: add dummy mux for unmuxed peripheral
ARC EMSDP board has some peripherals are internal connected,
such as DW spi1 and DFSS i2c0. They are unmuxed and have fix
connection to spi-flash or sensor. For these peripheral, add
dummy mux type to avoid pinctrl ENOENT error.

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-06-13 07:02:08 -04:00
Carles Cufi
22f73992b2 Bluetooth: Rework the HCI header set
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:

- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h

Fixes #58214.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Emil Gydesen
e9c1be88ca Bluetooth: CAP: Add Initiator cancel procedure
Add function to cancel any current proecedure. This is useful
in cases where the connection to one or more acceptors is lost
or if some acceptor does not respond to our requests for whatever
reason.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Nikolay Agishev
6e940c513c ARC: Fix portability.posix.common.arcmwdtlib test
portability.posix.common.arcmwdtlib test fails with ARCMWDT libc.
This path fixes the test.

STDIN_FILENO and others macroses are used in libc-hooks.c only. So they
defined localy.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-06-09 14:17:50 -04:00
Christopher Friedt
89cf4cea56 posix: pthread: mitigate include order sensitivity
Previously, the `posix_internal.h` header needed to be exposed
to the application because we had non-trivial details for
most posix types (pthread, mutex, cond, ...). Since most of
those have been simplified to a typedef'ed integer, we
no longer need to expose that header to the applicaiton.

Additionally, it means that we can adopt normalized
header order in posix.

Additionally, keep more implementation details hidden
and prefer the static keyword on internal symbols where
possible.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Christopher Friedt
f35fb33b94 posix: pthread: reimplement pthread_barrier using zephyr objects
Previously pthread_barrier_t was implemented in terms of wait
queues and internal scheduler functions.

This introduced some obstacles and inconsistency. In order
to be more consistent, rely only on Zephyr's public API and
reuse as many concepts as possible.

Deprecate `PTHREAD_BARRIER_DEFINE()` since it's non-standard.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Carlo Caione
8eeb5c992e riscv: Move directory to *-privileged
Because the spec is "privileged" not "privilege".

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-09 11:46:29 -04:00
Carlo Caione
edd3437826 riscv: Rename Kconfig symbol to *_PRIVILEGED
Rename SOC_FAMILY_RISCV_PRIVILEGE to SOC_FAMILY_RISCV_PRIVILEGED because
the spec is "privileged".

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-09 11:46:29 -04:00
Luca Fancellu
c8a9634a30 arch: arm64: Use atomic for fpu_owner pointer
Currently the lazy fpu saving algorithm in arm64 is using the fpu_owner
pointer from the cpu structure to understand the owner of the context
in the cpu and save it in case someone different from the owner is
accessing the fpu.

The semantics for memory consistency across smp systems is quite prone
to errors and reworks on the current code might miss some barriers that
could lead to inconsistent state across cores, so to overcome the issue,
use atomics to hide the complexity and be sure that the code will behave
as intended.

While there, add some isb barriers after writes to cpacr_el1, following
the guidance of ARM ARM specs about writes on system registers.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-06-08 09:35:11 -04:00
Théo Battrel
cfd368fef1 Bluetooth: Host: Fix GATT server handling of CCC
GATT server was not doing enough check before udpating the CCC.

For example, a non-bonded client could update the CCC of a bonded client
by spoofing his address.

This fix the issue by dissociating the CCC configuration of a bonded and
a non-bonded peer. To do that, a new field is added to the CCC config:
`link_encrypted`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-08 04:10:58 -04:00
Jose Alberto Meza
8acfdaefe4 include: zephyr: drivers: ps2: Add missing err codes header
Fix compilation error when enabling PS2 driver and userspace.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2023-06-07 15:24:30 -04:00
Benjamin Cabé
e82e5a6513 doc: spi: fix doxygen comment for MISO Lines doc
Update SPI MISO Lines documentation to remove incorrect use of @kconfig.
Fixes #58912.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-06-07 04:41:04 -04:00
Seppo Takalo
a1cfe983b6 net: lwm2m: Allow overiding of default socket behaviour
In order to support external IP stacks that might have Connection
ID support, the LwM2M engine should allow client to bypass default
behaviour.

New set_socketoptions() callback added into client context
that allows overriding all socket opetions. This is called
after a socket is opened, but before the connect() is
called. This cannot be combined with load_credentials() callback
on all platforms as for example nRF91 requires modem offline
when credentials are written. This would cause socket to be closed
as well.

Second change is that we allow fine tuning of what we do with
socket handle when QUEUE mode is enabled and engine enters idle
state.

First option would be to close the socket. That would cause
TLS Alert(Close Notify) to be send. This is a band choice if
LTE modem was already in PSM or eDRX power saving mode.

Second option would be to delay socket closing until we
are going to send LwM2M update. There TLS Alert is also send,
but most probably lost due to NAT mapping timed out. This
is a best choice for LTE modem with DTL session cache enabled.

Two new options are to keep socket open, and either stop listening
or just keep listening. Both of these options work fine when
we have DTLS Connection ID support.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-06 09:40:16 -04:00
Erwan Gouriou
a75af34c3e include: sys: util_macro: Add UTIL_INC/DEC/X2
Add UTIL_INC, UTIL_DEC and UTIL_X2 macros

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-06-06 06:52:42 -04:00
Emil Gydesen
773198de89 Bluetooth: ATT: Add documentation for ATT error codes
Add the description of each error code as defined by the
core spec and the CSS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-06 06:51:18 -04:00
Emil Gydesen
c764c34232 Bluetooth: BAP: Improve handling of ASCS notification error
If the num_ase == 0xff then it is a special case that needs to be
handled like if num_ase == 0x01.

If there is an error with ase_id = 0x00 then the error cannot
be translated to a specific stream, so the callbacks may now get
NULL for the stream object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-06 09:35:16 +02:00
Gerard Marull-Paretas
e1a24204b0 display: cfb: move to utilities group
It is not a display interface, but a utility library.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
464eab3367 drivers: display/misc: move MicroBIT/Grove libraries to 3rd-party group
These are not really display interfaces but APIs for 3rd party
services/hardware features.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
619b285aa8 doc: doxygen: move data structure APIs to utilities group
These are utility APIs for data structures, so put them under the
utilities group.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
28b7a857f7 dt-bindings: display: fix lcd_interface ingroup
s/display_interfaces/display_interface

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
58c9c42ec5 drivers: emul: add to testing Doxygen group
Emulators are used in the context of testing, so add them there.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
044530c1be json/jwt: add to utilities Doxygen group
Remove the top-level "structured data" group as in practice it was used
only by JSON APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
e247ae5d3a retention: fixe bootmode ingroup
The retention group is called retention_api, not retention.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
97f219414a dox: doxygen: add third_party group
Add a new top-level group for APIs that interact with third-party
services or applications. Included in the group:

- MCUboot image control API
- Hawkbit
- UpdateHub

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
3506a7925a pm: add s2ram and cpu_ops APIs to PM Doxygen group
While these APIs are kind of independent from the PM subsys (why?), they
all belong to the "power management" domain, so add them to the
subsys_pm group.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
721f829e01 doc: doxygen: add some OS services to os_services group
- Crypto
- Retention
- Settings
- Storage
- Memory management
- Heap management
- Flash access
- Coredump
- Timing
- Thread analyzer

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
866c176410 doc: doxygen: create utilities group
Add a new top-level for general utilities, like utility functions,
linear range API, time utils, etc. This category should be used by stuff
that is not strictly bound to the OS, like are OS services.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
f4615f16dc bluetooth: mesh: add RPR to bt_mesh Doxygen group
Otherwise the group was shown as a top-level group.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
30946d46fd usb: create top-level usb Doxygen group
Create a USB Doxygen group, part of the top-level connectivity group.
Added some existing groups to the usb group, note that USB Doxygen needs
to be improved, though.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Gerard Marull-Paretas
9a806e9c8a doc: doxygen: add new connectivity group
Add a new connectivity group and add to it the following other groups:

- LoRaWAN
- Networking
- Bluetooth

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Kai Vehmanen
9db44fa281 toolchain: xtensa: enable C11 features with xt-clang
If XCC toolchain is clang based, enabled C11 features by
defining TOOLCHAIN_HAS_C_GENERIC and TOOLCHAIN_HAS_C_AUTO_TYPE.
Mirror the definitions in include/zephyr/toolchain/llvm.h

This is required to build Zephyr with features requiring
tagged arguments like LOG_MIPI_SYST_USE_CATALOG.

Suggested-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-06-05 13:53:12 -04:00
Nick Stoughton
228d1e9a40 drivers: clock_control: STM32F7: clock support should not be limited to F4
The include/zephyr/drivers/clock_control/stm32_clock_control.h header
file treats F2X, F4X and F7X as all being supported by the stmf4_clock.h
header. However, the F7 has additional clocks that are available as domain
clocks for devices (such as the stm32 uart) and these do not work with
the f4 header.

Signed-off-by: Nick Stoughton <nstoughton@logitech.com>
2023-06-05 10:48:12 -04:00
Aleksander Wasaznik
a4e7b53d4b Bluetooth: Host: Fix bt_addr_from_str for str starting with ':'
The previous implementation would read from `addr->val[0]` before it was
initialized if the input string started with a colon ':'.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-05 08:31:06 -04:00
Emil Gydesen
de3e709b50 Shell: Add shell_strtoull
Add a shell_strtoull function that works similar to
shell_strtoul except that it calls strtoull instead
of strtoul.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Emil Gydesen
9dd2f03d1d Bluetooth: OTS: Add ULL to ID MIN, MAX and DIR_LIST
Mark them as being unsigned long long values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Christopher Friedt
7f2a7ed2de posix: remove inaccurate comment re initializers
A dangling `FIXME` comment was left in the `pthread.h` header
about how it would be difficult to implement
`PTHREAD_MUTEX_INITIALIZER` and `PTHREAD_COND_INITIALIZER`.

They were both implemented months ago, so let's retire
that comment.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 10:39:41 +02:00
Christopher Friedt
3e27c7f4a7 posix: eventfd: deprecate non-public EFD macros
Deprecate `EFD_IN_USE` and `EFD_FLAGS_SET` as they are not
specified as part of any public `eventfd()` API.

While those are being deprecated, use `_INTERNAL` variants.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
e6eb0a705b posix: eventfd: revise locking, signaling, and allocation
TL;DR - a complete rewrite.

Previously, the prototypical `eventfd()` usage (one thread
performing a blocking `read()`, followed by another thread
performing a `write()`) would deadlock Zephyr. This shortcoming
has existed in Zephyr's `eventfd()` implementation from the
start and the suggested workaround was to use `poll()`.

However, that is not sufficient for integrating 3rd-party
libraries that may rely on proper `eventfd()` blocking
operations such as `eventfd_read()` and `eventfd_write()`.

The culprit was the per-fdtable-entry `struct k_mutex`.

Here we perform a minor revision of the locking strategy
and employ `k_condvar_broadcast()` and `k_condvar_wait()`
to signal and wait on the holder of a given `struct k_mutex`.

It is important to note, however, that the primary means of
synchronizing the eventfd state is actually the eventfd
spinlock. The fdtable mutex and condition variable are mainly
used for the purposes of blocking io (r,w,close) and are not
used in the code path of non-blocking reads.

The `wait_q` and `k_poll_signal` entries were removed from
`struct eventfd` as they were unnecessary.

Additionally, switch to using a bitarray because it is
possibly faster than linear search for allocating and
deallocating eventfd resources.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
90343a1f6d posix: eventfd: un-inline eventfd_read() and eventfd_write()
There is no major benefit to haveing `eventfd_read()` and
`eventfd_write()` as `static inline` functions and it is
arguably much easier to solve the deadlock bug when they
are not `inline`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
0014dd05f0 lib: os: add k_condvar for each fdtable entry
Complement the `struct k_mutex` in each fdtable entry
with a `struct k_condvar`. The reasoning for this should be
self-evident.

For a bit of history, `fdtable` was introduced in
commit 06eb489c45 ("kernel: add condition variables")
which predates `struct k_condvar`, introduced in
commit f484bbaa26 ("lib: posix: Implement generic file descriptor table")
by almost 2 years.

Additionally, provide a new accessor function,
`z_get_obj_lock_and_cond()`, that (optionally) gets the mutex
and condition variable associated with the provided object and
vtable.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Andrei Emeltchenko
cd2fe8c186 doc: smbus: Correct syntax in sources and headers
Correct syntax in SMBus sources and headers used to generate the SMBus
documentation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-06-01 18:04:58 -04:00
Henrik Brix Andersen
c9f97cf386 drivers: can: mcan: move header file to public includes
Move the Bosch M_CAN header file to include/zephyr/drivers/can/can_mcan.h
for use in out-of-tree drivers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-06-01 18:04:42 -04:00
Daniel Leung
4da3fc9c32 logging: fix format strings not being put in log_strings_area
Commit caea9dc196
("logging: Use TYPE_SECTION macros for log strings") changed to
use TYPE_SECTION macros for log strings. However, the data type
was changed from char[] to (char *), resulting in the pointer
to log strings are being put in the log_strings_area section
instead of the actual strings. Fix this by reverting the data
type change back to before that commit but semantically uses
TYPE_SECTION_ITERABLE() by expanding it manually.

Fixes #58476

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-01 14:59:23 +02:00
Krzysztof Chruscinski
edbff3121e serial: Update documentation regarding RX buffer handling
Relax the expected behavior of the RX path. So far it was stated
that UART_RX_BUF_RELEASED event is generated when one buffer is
completely filled. Now, it is relaxed so that buffer can be
released even when not completed (e.g. after the first timeout).

This approach does not violate the API and may be more convenient
for some devices where on timeout a switch between DMA buffers
must occur.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-06-01 06:34:53 -04:00
Robert Lubos
f3bdac91b2 net: ieee802154: Remove IEEE802154_2015 option usage
The IEEE802154_2015 option is misleading, as it does not introduce full
802.15.4-2015 standard compliance but only random bits, plus it's
defined at the radio driver level, which brings yet another confusion.
Because of that, the option will be deprecated, and respective parts of
code that made use of it converted to use more specific configurations:

* nRF driver will now use CONFIG_NRF_802154_ENCRYPTION to specify
  whether to compile in TX security
* net_pkt will only add extra 802.15.4 control block fields if
  OpenThread is used, as they were solely used by this L2
* OpenThread radio layer will now use the OpenThread version to
  determine whether to compile in TX security.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-01 04:53:02 -04:00