Commit graph

15409 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
6dfbf7c110 Bluetooth: Remove BT_HCI_DATAPATH_ID_DISABLED define
Remove BT_HCI_DATAPATH_ID_DISABLED define as 0xFF, which is
reserved for future value for Data_Path_Id parameter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Maciej Baczmanski
a2e449b10a gpio: add gpio_pin_is_input_dt and gpio_pin_is_output_dt helpers
Add helpers to allow providing a `struct gpio_dt_spec` directly
to `gpio_pin_is_input` and `gpio_pin_is_output` functions.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-01-27 19:22:05 +09:00
Trent Piepho
43781ba2a0 i2c: Add an option to dump all I2C messages to the log
When turned on, the existing i2c dump code is use to log every I2C
transaction at debug level.

This can be very useful for detecting problems with I2C peripherals.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00
Trent Piepho
0c7ff3b728 i2c: Improve formatting of i2c dump function
If an i2c message is for just one byte, instead of logging it with a
hexdump after logging the other message info, just added the one byte to
the same log message.

Since most i2c messages are one byte, this significantly reduces the
number of messages and lines needed to log i2c transactions, from three
line per message to just one.  It's also a lot easier to read.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00
Trent Piepho
c09f6918fa i2c: Allow dumping the data of read messages
Add an argument to i2c_dump_msgs() to log the data from reads too.  And
then rename the function to i2c_dump_msgs_rw() so the API doesn't
change.  If the dump is done after a transaction is processed, as
opposed to before, then the read data is valid and can be very useful.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00
Cyril Fougeray
51fa86bb98 drivers: exti: stm32: expose STM32_EXTI_LINE_NONE
Common STM32_EXTI_LINE_NONE for declaration and setting
of wakeup EXTI line when configured.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2023-01-27 01:02:08 +09:00
Keith Short
6062914cf2 emul: Add support for backend APIs
The emulator structure currently initializes a bus-level API that is
used to communicated register accesses to the emulator from the parent
bus.

Add support for declaring a backend API for emulators. This provides
tests a common way to interact with emulators of the same device type.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-27 01:01:06 +09:00
Keith Short
2d53ce600a emul: add stub driver for emulators
Not all emulators correspond to a real driver.  Notably some tests don't
require a real driver.  Provide a macro that initializes a stub driver.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-27 01:01:06 +09:00
Raphael Treccani-Chinelli
3e937da264 bluetooth: host: Added extra options to PAST subscribe
allow disabling reports (synchronise but don't generate sync reports)
and allows enabling sync reporting with filtering of duplicates.
the default option remains to establish sync, with sync reports,
but without duplicate filtering.

Signed-off-by: Raphael Treccani-Chinelli <raphael.treccani@nordicsemi.no>
2023-01-26 07:29:19 -08:00
Jamie McCrae
4516e7161c mgmt: mcumgr: transport: smp_bt: Fix wrongly enabling Bluetooth
Bluetooth does not need to be enabled to register services,
therefore the newly introduced automatic bluetooth SMP transport
registration system can be simplified by returning enabling of
bluetooth back to the application.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 12:36:16 +00:00
Jonathan Rico
b30ce53e1c Bluetooth: host: clarify which GATT subscribe flags are internal
Add a note to the GATT subscription flags' docstring to indicate what flags
are used internally and are not part of the API.

We might want to move them in their own struct member, something like
`internal_flags` in a subsequent change.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-01-26 10:05:13 +00:00
Jonathan Rico
a7746ad55e Bluetooth: Host: Re-subscribe only after encrypt change
Wait until encrypt change to trigger the re-subscription quirk.
Otherwise it could fail with insufficient security.

Also gate it behind a kconfig to make apparent its dependencies:

If `add_subscriptions()` is executed in the first place, that means that
the device was bonded and thus that it has to encrypt the link eventually.

`BT_GATT_AUTO_SEC_REQ` should take care of that.

Also add a new flag to `bt_gatt_subscribe_params` to not send the same CCC
write multiple times in some cases.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-26 10:05:13 +00:00
romain pelletant
14bcc859ca kernel: k_msgq: add peek at function
Make message queue able to peek data at the specified index.
Related to issue #53360

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-01-26 10:00:29 +00:00
Björn Stenberg
0321ac8dbf json: Increase max number of descriptor elements from 30 to 62
The limiting factor is the output bitmask that says which elements have
been filled in by the parser. This patch changes the bitmask type from int
to int64_t.

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
2023-01-26 09:51:54 +00:00
Chamira Perera
ce49beb297 net: ethernet: Fixes for ethernet stats reporting.
The following fixes were applied:
 - Multicast Rx packets stats were not recorded due not parsing the
ethernet header. The function that tried to parse the ethernet header
was parsing the ethernet packet beyond the ethernet header.
 - Added a new stats for unknown protocol which gets updated when the
ethernet layer encounters an unknown ethernet packet type.

Fixes #53994

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-25 15:01:14 +00:00
Jordan Yates
34251808ac device: fixup doxygen parameter names
Fix several parameter references with incorrect names.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-25 14:58:52 +00:00
Keith Short
d2c598e784 docs: Add emulator API reference
Add the API reference section to the peripheral and hardware emulators
documentation.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-24 18:58:49 -08:00
Kumar Gala
1764e52b78 llvm: define __INT*_C() and __UINT*_C()
llvm based toolchains need the same fix as exists for xcc that was
introduced with commit:

commit 5ef8db8ac9
Author: Daniel Leung <daniel.leung@intel.com>
Date:   Wed Feb 3 14:23:51 2021 -0800

    xcc: define __INT*_C() and __UINT*_C()

Since llvm based toolchains don't define these macros either.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-01-24 20:29:49 -05:00
Daniel Leung
52f570b200 toolchain: add macro FUNC_NO_STACK_PROTECTOR
This provides a macro to disable stack protector for a function,
by specifying a function attribute. This is useful for boot
and early init code where we know for sure stack pointer and/or
stack content are being manipulated manually.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-01-24 13:04:45 -05:00
Jeppe Odgaard
a76b908f4c drivers: sensor: add mcux quadrature encoder
Add a driver for the NXP MCUX Quadrature Decoder. The driver
is simple and only implements the phase a and phase b inputs. The
module has additional features which can be added in future PRs.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-01-24 10:21:39 -06:00
Nicolas Pitre
a211970b42 riscv: improve contended FPU switching
We can leverage the FPU dirty state as an indicator for preemptively
reloading the FPU content when a thread that did use the FPU before
being scheduled out is scheduled back in. This avoids the FPU access
trap overhead when switching between multiple threads with heavy FPU
usage.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Nicolas Pitre
ff07da6ff1 riscv: integrate the new FPU context switching support
FPU context switching is always performed on demand through the FPU
access exception handler. Actual task switching only grants or denies
FPU access depending on the current FPU owner.

Because RISC-V doesn't have a dedicated FPU access exception, we must
catch the Illegal Instruction exception and look for actual FP opcodes.

There is no longer a need to allocate FPU storage on the stack for every
exception making esf smaller and stack overflows less likely.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Aleksander Wasaznik
4b675f34db Revert "Bluetooth: Host: Disable host-based RPA resolution when !BT_PRIVACY"
This reverts commit 5824ac90ecd8dd06d9ea117d345dbc6b069e5840.

The resulting revert takes into account changes to the predicate that
guards the use of `resp_addr`.

In the resulting revert, the predicate guarding the use of `resp_addr`
is differs from the naive revert because the intention of that predicate
is to know when `conn.c:bt_conn_le_create` decided to use the Host
resolver. And, the logic in `conn.c:bt_conn_le_create` has changed. The
changes to the logic in `conn.c` are in the following commits:

89780d715d
5a09325ba9

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Wouter Cappelle
aaefd3db7e net: http: Use poll for http timeout instead of shutdown
Change the http timeout mechanism to use poll instead of shutdown.
This should fix a problem where the shutdown will be called in a
different thread context which can lead to deadlocks on certain
driver implementations like offloaded modem drivers.
Fixes #53967

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2023-01-24 14:50:11 +01:00
Francois Ramu
210e0b76bf dts: bindings: pwm custom macro for STM32 vendor
Change the name of the custom macro defined for the stm32 devices
to fit the VND_PWM_xxx model
Keeping old deprecated macro, though.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-24 14:49:53 +01:00
Manuel Arguelles
642303ac7e drivers: eth: phy_mii: support Gigabit ethernet
Advertise Gigabit Ethernet if the PHY supports it. As with the
other speeds, it is assumed the PHY supports both duplex modes.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-01-24 14:37:20 +01:00
Tom Burdick
ec9d94e06d dma: Document expected behavior of start/stop
The DMA API expects drivers in effect to maintain their own internal
state of channels. A channel that is already started may have dma_start
called on it again without effect. A channel that is already stopped may
have dma_stop called on it without effect.

In essence, start and stop are expected to act like events a DMA channels
finite state machine reacts to and if the state is already at the desired
one then nothing is to be done and no error has occurred.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Chris Friedt
7f192c30dc include: posix: add c++ extern scope
`<fcntl.h>`, `<net/if.h>`, and `<netinet/tcp.h>` were missing
`extern "C" { .. }"` which is required to avoid C++ name
mangling.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
6ac402bb3a net: socket: additional POSIX constants
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`,
and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in
`<sys/socket.h>`. However, most of the existing socket
options and related constants are defined in
`<zephyr/net/socket.h>`.

For now, we'll co-locate them. It would be
good to properly namespace things.

Additionally, a no-op for setsockopt for `SO_LINGER` to
make things Just Work (TM) for now.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
b059f512f5 posix: netdb: provide NI_MAXSERV for reasonable app defaults
The `<netdb.h>` header typically defines `NI_MAXSERV` as a
reasonable default buffer size to use in applications that
use `getnameinfo()` to query a service name.

Most GNU and BSD systems define it by default so provide
it as a convenience so applications and 3rd-party libraries
do not encounter a compile error.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
92fdcaf18c posix: define struct linger in sys/socket.h
The spec requires `<sys/socket.h>` to declare
struct linger. Define it so that applications
and libraries do not get compile errors when
building against Zephyr.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
2e64f3b48c posix: ioctl: define FIONREAD as some applications require it
The `FIONREAD` ioctl is usually used to query how many bytes
are available to read immediately from a specific file
descriptor. It's quite useful.

Define it here so that it can be used by applications.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
d5d890ee24 posix: netdb: ensure that EAI constants are defined
Constants like `EAI_SYSTEM` should be defined in `<netdb.h>`
according to the spec.

In Zephyr, they should be defined via appropriately
namespaced z-variants (currently `DNS_EAI_SYSTEM` and so on).

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
ffe2fba4f1 posix: ensure in_addr_t and in_port_t defined via arpa/inet.h
The spec requires that `in_addr_t` and `in_port_t` are both
defined when `<arpa/inet.h>` is included.

They were added to `<netinet/in.h>` in the previous commit.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
5a4ec84df4 posix: define in_port_t and in_addr_t in netinet/in.h
The spec requires that these two types be defined in
`<netinet/in.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
a16c7eda3f posix: ioctl: actually declare a function prototype
The `<sys/ioctl.h>` header never actually declared
the `ioctl(2)` function prototype, so this fixes that.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
ed11614a87 posix: mqueue: do not typedef mq_attr
The specification actually requires this to be a plain
`struct mq_attr`, without the typedef.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
24cfb89753 posix: avoid redefinition errors in network and posix headers
The networking subsystem defines a rather large amount of POSIX
prototypes. However, it's done in a somewhat subversive way via

```
CONFIG_NET_SOCKETS_POSIX_NAMES
```

This option should be removed (or moved to POSIX) and the
networking implementations should be properly namespaced.

With that, the POSIX interface for network-related functions
can simply be a thin wrapper around the z-namespaced variants,
where applicable, or proper POSIX functions should actually
be moved to `lib/posix`.

This will also require a better solution to testing network
functionality on `native_posix` though. The ability to run
those tests and the supposed incompatibility between
`CONFIG_ARCH_POSIX` and `CONFIG_POSIX_API` was the main
motivation for adding `CONFIG_NET_SOCKETS_POSIX_NAMES`.

Eventually, with proper namespacing, these preprocessor
guards against redefining the same symbols can be
removed.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
b824039e98 posix: unistd.h: add declaration for _exit()
The `_exit()` function should be declared in `<unistd.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
8b0f7b3e36 posix: treat pthread_key.h as an implementation detail
The `pthread_key.h` header is nonstandard and is an
implementation detail of `pthread.h`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
e93f3c9b6d posix: rename posix_sched.h to sched.h
Rename the `posix_sched.h` to conform to the spec.

IEEE Std 1003.1

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Francois Ramu
48d4e017bd include: bindings: dma macro definition for stm32 dma driver config
Defines DMA macro to help channel configuration and feature for the stm32
devices. Add one default value for most of the usecases
of peripheral DMA settings.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-23 09:15:21 -06:00
Emil Gydesen
4a0d9d10e8 Bluetooth: Audio: Add missing audio metadata
Adds the BT_AUDIO_METADATA_TYPE_AUDIO_STATE and
BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE metadata types from
the LE Audio assigned numbers document.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 12:03:24 +00:00
Gerson Fernando Budke
647c48c574 mgmt: updatehub: Add userspace syscalls
The current updatehub version forces user application to run in kernel
mode. This add necessary api syscalls to isolate userspace from kernel.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
000257dad0 mgmt: updatehub: Move updatehub.h to header directory
This moves updatehub.h file from subsys to public header include
folder.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Robert Lubos
c6c2098255 net: iface: Add NULL pointer check in net_if_ipv6_set_reachable_time
In case the IPv6 context pointer was not set on an interface (for
instance due to IPv6 context shortage), processing the RA message could
lead to a crash (i. e. NULL pointer dereference). Protect against this
by adding NULL pointer check, similarly to other functions in this area.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-23 10:09:51 +00:00
Ajay Parida
ba39235275 net: wifi_mgmt: Add support for power save timeout configuration
Add support for configuring power save timeout in Wi-Fi chipsets.
Changes to configure power save inactivity timer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-23 10:08:01 +00:00
Martin Jäger
3b9ba15096 lorawan: services: add Application Layer Clock Synchronization
This service allows to synchronize the clock with the application
server.

Synchronization requests are initiated by the device in a regular
interval, configurable via Kconfig.

The implementation only supports TS003-2.0.0, as the previous revision
TS003-1.0.0 requested to temporarily disable ADR and and set nb_trans
to 1. This causes issues on the server side and is not recommended
anymore.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-23 10:05:49 +00:00
Nir Bar-Or
10130d8e6d sys: util: provide GENMASK64
GENMASK64 macro to create contiguous bitmask for 64bit

Signed-off-by: Nir Bar-Or <nirbaror@gmail.com>
2023-01-22 14:52:21 -05:00
Nir Bar-Or
72d041531f sys: util: provide BITS_PER_LONG_LONG
BITS_PER_LONG_LONG to enable 64bit manipulation

Signed-off-by: Nir Bar-Or <nirbaror@gmail.com>
2023-01-22 14:52:21 -05:00