Commit graph

15409 commits

Author SHA1 Message Date
Dominik Ermel
aa5d20aaef storage/flash_map: Return -ENODEV from flash_area_open
The commit adds check, to flash_area_open, whether there is any
device driver attached and returns -ENODEV if there isn't any.
This works around a problem where flash_area_open succeeds but
consecutive read/write causes crash.
It is enough to check the condition, and return error, here as
the flash_area_open has to precede, and be checked for success,
any read/write operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:28:58 +02:00
Mark Holden
44c388fb33 coredump: drivers: Add coredump device
Add a pseudo device diver with device tree bindings for coredump.
The device tree bindings exposes memory address/size values to be
included in any dump. And the driver exposes an API to add/remove
dump memory regions at runtime.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-06-05 14:28:34 +02:00
Adrian Bonislawski
45e1d16f93 drivers: dai: extend dai properties
Extend dai properties with stream ID parameter

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-06-05 14:27:15 +02:00
Jordan Yates
4fd51d1c5a device: injected device handles query
Adds a function to query device handles that have been injected as a
dependency into a device.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Jordan Yates
57fa9121a1 scripts: gen_handles: injected device handles
Update the device handle array for injected devices to output device
handles, not device ordinals. This requires that the extra ordinals
provided to `DEVICE_DT_INST` map to an existing device in order to
appear in the final handle array.

This is required for the injected handles to be useful, no meaningful
operations can be done on device ordinals.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Wentong LI
f55a4b240d bluetooth: uuid: adding continuous glucose monitoring service uuids
AddBluetooth continuous glucose monitoring service (CGMS)-related uuid
BT_UUID_CGMS for Continuous Glucose Monitoring
BT_UUID_CGM_MEASUREMENT for CGM Measurement
BT_UUID_CGM_FEATURE for CGM Feature
BT_UUID_CGM_STATUS for CGM Status
BT_UUID_CGM_SESSION_START_TIME for CGM Session Start Time
BT_UUID_CGM_SESSION_RUN_TIME for CGM Session Run Time
BT_UUID_CGM_SPECIFIC_OPS_CONTROL_POINT for CGM Specific Ops Control Point
BT_UUID_RECORD_ACCESS_CONTROL_POINT for Record Access Control Point

Signed-off-by: Wentong LI <wentong.li@nordicsemi.no>
2022-06-05 14:14:33 +02:00
Emil Gydesen
edb30d53d9 Bluetooth: Audio: Fix issues with unicast audio group lifetime
The unicast audio group can not have streams removed after the
CIG has been created as part of the QoS set procedure.

The bt_audio_unicast_group_remove_streams function may
leave the unicast group without streams, and thus the
check for "free" group was not correct, and has been replaced
with a simple boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
57e1056bef Bluetooth: ISO: Guard sec_level with CONFIG_BT_SMP
The ISO security implementation works by verifying
against the acl (bt_conn) sec_level field. The
bt_conn sec_level field is only available
if CONFIG_BT_SMP is enabled, so this commit
adds guards for all ISO security checks as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen
b3cddc6d27 Bluetooth: ISO: Central security request
If the required_sec_level is lower than the
conn->sec_level, the central will now initialize the
security procecure to ensure that the CIS is encrypted
properly.

The algorithm implemented is as follows:
1) Check security levels for each (acl, iso) pair
2) For those with insufficient security,
   call bt_conn_set_security
3) For those with sufficient security, connect the CIS
4) Once the ISO from 2) has been encrypted, connect the
   CIS for the specific ACL

The idea behind this was to implement similar support
for autonomous encryption as we have for L2CAP.
It is more complex for ISO as we are dealing with
an array of (acl, iso) pairs, meaning more can go
wrong.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Chen Peng1
d8fa857b19 LLVM: add built-in lld linker support for x86.
add support to use LLVM built-in lld linker to build
zephyr applications for x86 platforms.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-05 14:10:25 +02:00
Stephanos Ioannidis
2bcb713371 libc: Define Z_LIBC_DATA macro globally
This commit globally defines the `Z_LIBC_DATA` macro, which is used to
place variables into the libc memory partition, so that it can be
re-used.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 11:03:38 +02:00
Robert Lubos
4e38ddb3ec net: pkt: Add flag indicating if pkt has already been processed by L2
Add a new flag, indicating if packet has already been processed by L2 or
not. This can be used with AF_PACKET sockets, to select a proper socket
type for currently processed packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Fabio Baltieri
e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Carlo Caione
accc73b56b riscv: Remove unused defines.
Silly cleanup. Remove unused defines.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-27 11:56:21 -07:00
Stephanos Ioannidis
6448546553 timing: Fix symbol extern for C++
This commit adds `extern "C"` to `timing.h` so that C function names do
not get mangled when including this header file from a C++ source file.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-26 13:02:53 -07:00
Andrei-Edward Popa
d82c10f197 include: drivers: changed API function names for reset controller
assert API function needed to be changed because of newlib assert
macro name conflict

Signed-off-by: Andrei-Edward Popa <andrei.popa105@yahoo.com>
2022-05-26 13:02:19 -07:00
Stephanos Ioannidis
51b30a5694 toolchain: Override __[U]INT{FAST,LEAST}N__ macros
This commit overrides the following toolchain type macros to match the
respective base types overridden by the `zephyr_stdint.h`:

* __INT_FAST32_TYPE__
* __INT_FAST64_TYPE__
* __UINT_FAST32_TYPE__
* __UINT_FAST64_TYPE__

* __INT_LEAST32_TYPE__
* __INT_LEAST64_TYPE__
* __UINT_LEAST32_TYPE__
* __UINT_LEAST64_TYPE__

This is in preparation for adding the `PRIx{FAST,LEAST}N` macros in the
Zephyr minimal libc `inttypes.h`, which assumes the types defined by
the `zephyr_stdint.h`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-26 17:38:50 +02:00
Nicolas Pitre
6ac751e7ef ring_buffer: fix designated initializer order in RING_BUF_ITEM_DECLARE
Commit a36995e2a3 ("ring_buffer: fix designated initializer order
in RING_BUF_DECLARE") missed the RING_BUF_ITEM_DECLARE case.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-26 12:26:06 +02:00
Fabio Baltieri
449516c135 doc: add pwm_interface tag to dt-bindings/pwm/pwm.h
Add Doxygen tags to dt-bindings/pwm/pwm.h so that the binding macros
show up on the documentation page.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-25 17:16:55 -07:00
Gerard Marull-Paretas
ef98b767e7 drivers: adc: add instance versions of the ADC_DT_SPEC* helpers
The instance based version macros were not added when the new
ADC_DT_SPEC* helpers were introduced. This means drivers are forced to
make usage of DT_DRV_INST(inst) macro to obtain a node identifier, the
parameter required by existing macros. Following other driver classes,
provide the ADC_DT_SPEC_INST* family of macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-25 10:40:55 -07:00
Gerard Marull-Paretas
ef3d5e0461 drivers: pwm: add instance versions of the PWM_DT_SPEC* helpers
The instance based version macros were not added when the new
PWM_DT_SPEC* helpers were introduced. This means drivers are forced to
make usage of DT_DRV_INST(inst) macro to obtain a node identifier, what
is required by existing macros. Following other driver classes, provide
the PWM_DT_SPEC_INST* family of macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-25 10:40:42 -07:00
Georgij Cernysiov
3d035a71fe includes: shell: uart: fix legacy includes
Adds `zephyr/...` prefix to `smp_shell.h` include.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-05-25 14:19:28 +02:00
Aleksander Wasaznik
1c872829f8 Bluetooth: Host: Update doc user_data type in bt_gatt_discover_func_t
Before this change, the doc on `bt_gatt_discover_func_t` gives the
impression that the type of `user_data` depends on `attr->uuid`. That is
partially incorrect. It is more accurate to say that the type depends on
the discovery type because that determines the ATT operation, which in
turn determines if the data is available.

Add documentation on `user_data` for the discovery type
`BT_GATT_DISCOVER_STD_CHAR_DESC`.

Add a hint `bt_gatt_discover_func_t` that `bt_gatt_read` can do a
different kind of attribute lookup, read-by-type, which may be
more convenient in some cases.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-05-25 13:15:54 +02:00
Yuval Peress
86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Anatol Ivanov
cd4b6e1575 arch: arm: cortex_r: Fix MPU_RASR_S_Msk
Fix typo to match specification.

Signed-off-by: Anatol Ivanov <Anatoleech@mail.ru>
2022-05-25 11:13:17 +09:00
Reto Schneider
cf30e38c46 fcb: Convert to Doxygen comment
Doxygen comments are introduced by a second start after the slash.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-20 19:21:32 -07:00
Dylan Hung
7b340d26fb include: fix the size of IRQn_Type
IRQn_Type is compiled to int8_t if __NVIC_PRIO_BITS is not set.  It
implies the maximum postive value of the peripheral irq is 127.  This
would lead to an irq number turns into a nagtive value if it is greater
than 127.

For example:
The input argument `irq` of arch_irq_enable is 130. But the input
argument of NVIC_EnableIRQ becomes (IRQn_Type)130 = -126 and results
error.

```
void arch_irq_enable(unsigned int irq)
{
	NVIC_EnableIRQ((IRQn_Type)irq);
}
```

By adding a maximum IRQ number, the bit width of IRQn_Type is guaranteed
to cover all IRQ numbers of the system.

Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com>
2022-05-20 12:36:30 +02:00
Krzysztof Chruscinski
468218a547 lib: os: cbprintf: Fix potential Coverity issue
Seen in some Coverity runs that it was complaining about unused
variable. Variables are used only in one path of _Generic.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-19 11:04:39 +02:00
Krzysztof Chruscinski
1fb8364c4c lib: os: cbprintf: Reduce stack usage when no optimization
Use single fixed size on stack array instead of compile time fitting.
When compiler is optimizing it can pick smallest array but with no
optimization there is an increased stack usage.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-19 11:04:39 +02:00
Reto Schneider
79935d5324 settings: Remove duplicated comment
Has been here since the very first implementation of this functionality.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-18 10:54:59 +02:00
Nicolas Pitre
6051ea7d3c riscv: clarify stack size and alignment parameters
The StackGuard area is used to save the esf and run the exception code
resulting from a StackGuard trap. Size it appropriately.

Remove redundancy, clarify documentation, etc.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Nicolas Pitre
1e006e3777 kernel/thread_stack.h: fix Z_THREAD_STACK_SIZE_ADJUST usage coherency
There are legitimate cases where both ARCH_THREAD_STACK_SIZE_ADJUST()
and ARCH_THREAD_STACK_RESERVED() may be defined at the same time.
It is important for the former to be exposed to the later in that case,
so add K_THREAD_STACK_RESERVED to the argument instead of the result.

Similarly for Z_THREAD_STACK_OBJ_ALIGN() which needs the adjusted size
to provide the proper result. That's what K_THREAD_STACK_LEN() does
already anyway, so fold Z_THREAD_STACK_SIZE_ADJUST() into the definition
of Z_THREAD_STACK_OBJ_ALIGN() directly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Jonas Otto
a36995e2a3 ring_buffer: fix designated initializer order in RING_BUF_DECLARE
Change order of designated initializers for ring_buf struct in the
RING_BUF_DECLARE macro, to match the order in the struct definition.
This fixes compilation when using C++, which requires using the same
order as in the struct definition.
Fixes #45697

Signed-off-by: Jonas Otto <jonas@jonasotto.com>
2022-05-18 10:53:57 +02:00
Adrian Bonislawski
7d76dc53d5 drivers: dma: return einval if specified channel not found
chan_filter is used when a specified channel is required
so a specified channel needs to be returned,
otherwise it should return einval instead of the last channel tried

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-05-18 10:53:22 +02:00
Reto Schneider
e4340c1dfc fcb: Remove superfluous comma
It is obviously an error to have two consecutive commas.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-18 10:53:05 +02:00
Carlo Caione
11f0bb9d1a ipc: static_vrings: Add -ENOMEM case
Sometimes it is important to know when the backend fails to send out
data because no memory / buffers are available. Return -ENOMEM in that
case.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-16 16:56:33 +02:00
Sjors Hettinga
ae31773ddd drivers: net: loopback: Add counting of number of dropped packets
When the loopback drops driver packets, the number of dropped
packets is counted and can be requested externally.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-16 16:55:51 +02:00
Asbjørn Sæbø
bf361aff21 Bluetooth: Gatt: Replace callback in gatt subscription callback.
Add a "subscribe" callback in the bt_gatt_subscribe params, and
deprecate the "write" callback.

The purpose of this is to be able to return the subscription
parameters in the callback.  The write callback
- (in principle) returns write parameters
- in fact returns nothing - the pointer is set to NULL

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-16 16:54:27 +02:00
Jordan Yates
e83e9b08b5 pm: device_runtime: return -ENOTSUP if PM not supported
Return `-ENOTSUP` on calls to device_runtime functions if the underlying
device does not support power management.

Fixes #45648.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-15 21:34:46 +02:00
Martin Jäger
2554f04464 doc: services: storage: add flash_img API
Doxygen comments were existing, but they were not rendered anywhere in
the docs. The code is located under DFU, but I think it makes sense
to document it under storage, next to similar flash-related APIs.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-05-15 21:33:54 +02:00
Emil Gydesen
54fac0323c Bluetooth: ISO: Expose can_send and can_recv in bt_iso_chan_get_info
The application can get the information about can_send
and can_recv in the bt_iso_chan_get_info function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen
b88b25adac Bluetooth: ISO: Extract and store information about RX and TX
Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.

This is useful to help determine which data paths to setup,
and whether to reject requests to send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Andrzej Głąbek
3e0679f01c include: drivers: adc: Add macros for reading channel configs from DT
Add macros that allow reading configuration for ADC channels from
child nodes of ADC controllers in devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-05-13 12:46:06 -07:00
Andrzej Głąbek
77edc2c852 dts: Include ADC DT binding headers from nRF SoC dtsi files
Add inclusions of header files with devicetree related ADC definitions
to the nRF SoC dtsi files so that those definitions can be used also
for nRF SoC based boards.
Provide definitions of nRF ADC and SAADC analog inputs suitable
for use in devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-05-13 12:46:06 -07:00
Yasushi SHOJI
bc35b1340c doc: uart: Make sure uart_poll_in is non-blocking
The documentation has wrongly stated that the function uart_poll_in() is
also a blocking function.  The uart_poll_out() is indeed a blocking
function but uart_poll_in() has never been since day one.

Make it clear that the uart_poll_in() is a NON-blocking function, and
uart_poll_out() IS a blocking.

This fixes #45468.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2022-05-13 10:03:31 -07:00
Mariusz Skamra
2d87443a4a Bluetooth: has: Add support for Read Presets Request operation
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Reto Schneider
233afcb719 doc: SETTINGS_REGISTER_STATIC got renamed
Renaming this reference got forgotten in
5f19c8160a [subsys/settings: Update
bluetooth module]

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-13 10:12:20 -05:00
Christoph Coenen
b3dfc244ad arch: arm: Add support for multiple zero-latency irq priorities
Add the ability to have multiple irq priority levels which are not
masked by irq_lock() by adding CONFIG_ZERO_LATENCY_LEVELS.

If CONFIG_ZERO_LATENCY_LEVELS is set to a value > 1 then multiple zero
latency irqs are reserved by the kernel (and not only one). The priority
of the zero-latency interrupt can be configured by IRQ_CONNECT.

To be backwards compatible the prio argument in IRQ_CONNECT is still
ignored and the target prio set to zero if CONFIG_ZERO_LATENCY_LEVELS
is 1 (default).

Implements #45276

Signed-off-by: Christoph Coenen <ccoenen@baumer.com>
2022-05-13 08:38:28 -05:00
Jordan Yates
0976bdb3c9 devicetree: additional STRING_TOKEN macros
Add a variety of missing `DT_INST` and `_OR` variants for working with
`STRING_TOKEN` and `STRING_UPPER_TOKEN` macros.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 14:17:08 +02:00
Keith Packard
4fc00cae7a kernel: Allow Zephyr to use libc's internal errno
For a library which already provides a multi-thread aware errno, use
that instead of creating our own internal value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-12 19:06:48 -04:00