Commit Graph

9248 Commits

Author SHA1 Message Date
Lukasz Stepnicki
68e15f4598 include: riscv: linker: add missing generate linker sections from dt
Riscv platfrom includes linker dt regions (LINKER_DT_REGIONS)
but was missing functionality to generate linker sections
from zephyr,memory-region dt nodes.

Signed-off-by: Lukasz Stepnicki <lukasz.stepnicki@nordicsemi.no>
2022-06-27 08:37:44 -04:00
Keith Packard
2d20faab47 lib/os: Replace cbvprintf and printfcb family when using picolibc
Picolibc already provides the functionality offered by cbprintf, so
there's no reason to use the larger and less functional version included
in zephyr.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-27 12:47:25 +02:00
Daniel Leung
d7f6733b2d kernel: remove old deprecated work queue API
The old work queue API has been deprecated since 2.6 release
so it is time to remove time.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-27 12:46:21 +02:00
Tom Burdick
cf658c8262 dma: Buffer alignment property macro helper
Adds a small macro to help people get the dma buffer alignment
property for a particular DMA controller.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-27 12:46:11 +02:00
Ederson de Souza
b56088ba6d drivers/clock_control: Add cAVS clock driver
Simple driver that allows one to choose the clock speed of xtensa cores.
It's basically a shim layer on top of SOC level driver.
Also, a really simple test case was added, mainly to ensure things are
build and are sane.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-06-27 12:42:04 +02:00
Keith Packard
ecee708e4b lib/printk: Use picolibc's snprintf/vsnprintf for snprintk/vsnprintk
Replace wrapper functions that use cbprintf with direct calls to picolibc
stdio functions.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-24 20:30:03 +02:00
Robert Lubos
4ec098ac5a doc: net: Document POSIX wrappers for socket operations
Document POSIX wrappers for socket operations, by referencing a
corresponsding `zsock_*` function. The documentation will generate a
link where user can read the actual documentation on the socket
operation.

In order to include the POSIX wrappers in to the documentation however,
it's needed to add CONFIG_NET_SOCKETS_POSIX_NAMES to predefined symbol
list in zephyr.doxyfile.in.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-24 20:29:37 +02:00
Christopher Friedt
f88264d7ca drivers: gpio: mcux: support port_get_direction
Support querying the direction of GPIO.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-06-24 16:19:58 +02:00
Christopher Friedt
27c431ff7e api: gpio: add gpio direction query functions and driver api
Some services require the ability to query whether a GPIO pin
is configured as an input, output, both, or neither prior to
performing any operations at the service level. This is done
in order to reduce state tracking within the service.

To that end, this change adds
* `gpio_port_get_direction()`
* `gpio_pin_is_input()`, and
* `gpio_pin_is_output()`

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-06-24 16:19:58 +02:00
Christopher Friedt
e527ed3c4f include: drivers: gpio: use __unused instead of void cast
The __unused attribute is the preferred way of marking
a variable as unused when assertions are disabled.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2022-06-24 16:19:58 +02:00
Krzysztof Chruscinski
9833ca61c9 logging: Removing v2 suffix from logging names
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 15:46:37 -04:00
Lauren Murphy
b034711f59 arch: xtensa: implement ARCH_EXCEPT
Triggers CPU exception with illegal instruction when z_except_reason
is called (e.g. in k_panic, k_oops). Creates exception stack frame
for use by coredump. Adds unique cause code for ARCH_EXCEPT. Disables
test case failure for qemu_xtensa.

Without an ARCH_EXCEPT implementation, z_except_reason calls
z_fatal_error directly with a null ESF and bypasses
xtensa_excint1_c's error logging. An ESF is required to coredump.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2022-06-23 15:44:45 -04:00
Nicolas Pitre
00a9634c05 riscv: new TLS-based arch_is_user_context() implementation
This reverts the bulk of commit c8bfc2afda ("riscv: make
arch_is_user_context() SMP compatible") and replaces it with a flag
stored in the thread local storage (TLS) area, therefore making TLS
mandatory for userspace support on RISC-V.

This has many advantages:

- The tp (x4) register is already dedicated by the standard for this
  purpose, making TLS support almost free.

- This is very efficient, requiring only a single instruction to clear
  and 2 instructions to set.

- This makes the SMP case much more efficient. No need for funky
  exception code any longer.

- SMP and non-SMP now use the same implementation making maintenance
  easier.

- The is_user_mode variable no longer requires a dedicated PMP mapping
  and therefore freeing one PMP slot for other purposes.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

5f65dbcc9dab3d39473b05397e05.
2022-06-23 13:12:05 -04:00
Nicolas Pitre
3f8e326d1a riscv: stop preserving the tp register needlessly
The tp (x4) register is neither caller nor callee saved according to
the RISC-V standard calling convention. It only has to be set on thread
context switching and is otherwise read-only.

To protect the kernel against a possible rogue user thread, the tp is
also re-set on exception entry from u-mode.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-23 13:12:05 -04:00
Maximilian Deubel
ba59262425 sensors: add trigger types for motion detection
This patch adds the new trigger types SENSOR_TRIG_MOTION
and SENSOR_TRIG_STATIONARY to distinguish these common
motion detection events.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-06-23 10:28:34 -05:00
Krzysztof Chruscinski
041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Nicolas Pitre
7084b5c9de arm64: native arch_proc_id() implementation
Return the hardware mpid value directly. Guard against values that
wouldn't fit in the returned uint32_t. If that ever happens then
reverting to the Zephyr sequential CPU number should be considered.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-23 09:10:52 +02:00
Krzysztof Chruscinski
7f1b4f88e3 logging: Rename files and test from log_msg2 to log_msg
Renaming log_msg2 files to log_msg.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 09:10:33 +02:00
Emil Gydesen
7148146348 Bluetooth: CSIS: Implement ordered access procedure for CSIS client
the CSIS client now has a ordered access procedure function.
The function implements the procedure as per the CSIP spec,
where it will verify that 1 or more members are unlocked,
and the execture a procedure on each member in ascending
order of rank.

The procedure can be anything (even a non-BT procedure),
and it will be up to the applicaiton to implement
what to do in that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
d995901a76 Bluetooth: CSIS: Remove const for members in API
Having the members array being const causes a lot of
limitations in the implementatation, and was
occasionally even disregarded. Removed to make the
implementation more flexible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Dmytro Firsov
a76b492f04 xenvm: evtchn: expand Xen event channel driver functionality
This commit adds new functions, which can be used for Xen event channel
management (allocation, interdomain binding etc.). Such functionality
is needed for Xen PV driver development in Zephyr.

Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
2022-06-22 17:53:45 +02:00
Keith Packard
d0c75f3b96 lib/libc: Add picolibc support (aarch32, aarch64 and RISC-V) [v21]
Picolibc is a fork of newlib designed and tested on embedded systems. It
offers a smaller memory footprint (both ROM and RAM), and native TLS
support, which uses the Zephyr TLS support.

By default, the full printf version is included in the executable, which
includes exact floating point and long long input and output. A
configuration option has been added to switch to the integer-only
version (which also omits long long support).

Here are some size comparisons using qemu-cortex-m3 and this application
(parameters passed to printf to avoid GCC optimizing it into puts):

void main(void)
{
    printf("Hello World! %s %d\n", CONFIG_BOARD, 12);
}

                       FLASH    SRAM
    minimal             8696    3952
    picolibc int        7600    3960
    picolibc float     12304    3960
    newlib-nano int    11696    4128
    newlib-nano float  30516    4496
    newlib             34800    6112

---

v2:
	Include picolibc-tls.ld

v3:
	Document usage in guides/c_library.rst and
	getting_started/toolchain_other_x_compilers.rst

v4:
	Lost the lib/libc/picolibc directory somehow!

v5:
	Add PICOLIBC_ALIGNED_HEAP_SIZE configuration option.
	Delete PICOLIBC_SEMIHOST option support code

v6:
	Don't allocate static RAM for TLS values; TLS
	values only need to be allocated for each thread.

v7:
	Use arm coprocessor for TLS pointer storage where supported for
	compatibility with the -mtp=cp15 compiler option (or when the
	target cpu type selects this option)

	Add a bunch of tests

	Round TLS segment up to stack alignment so that overall stack
	remains correctly aligned

	Add aarch64 support

	Rebase to upstream head

v8:
	Share NEWLIB, NEWLIB_NANO and PICOLIBC library configuration
	variables in a single LIBC_PARTITIONS variable instead of
	having separate PICOLIBC_PART and NEWLIB_PART variables.

v9:
	Update docs to reference pending sdk-ng support for picolibc

v10:
	Support memory protection by creating a partition for
	picolibc shared data and any pre-defined picolibc heap.

v11:
	Fix formatting in arch/arm/core/aarch64/switch.S

v12:
	Remove TLS support from this patch now that TLS is upstream
	Require THREAD_LOCAL_STORAGE when using PICOLIBC for architectures
	that support it.

v13:
	Merge errno changes as they're only needed for picolibc.
	Adapt cmake changes suggested by Torsten Tejlmand Rasmussen

v14:
	Update to picolibc 1.7 and newer (new stdin/stdout/stderr ABI)

v15:
	Respond to comments from dcpleung:
	* switch kernel/errno to use CONFIG_LIBC_ERRNO instead of
          CONFIG_PICOLIBC
	* Add comment to test/lib/sprintf as to why the %n test
	  was disabled for picolibc.

v16:
	Switch picolibc to a module built with Zephyr. This eliminates
	toolchain dependencies and allows compiler settings for Zephyr
	to also be applied to picolibc.

v17:
	Provide Zephyr-specific 'abort' implementation.
	Support systems with MMU

v18:
	Allow use of toolchain picolibc version.

v19:
	Use zephyr/ for zephyr headers

v20:
	Add locking
	Use explicit commit for picolibc module

v21:
	Create PICOLIBC_SUPPORTED config param. Set on arc, arm, arm64,
	mips and riscv architectures.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Nicolas Pitre
0a386dbe6c build: make Zephyr stdint convention enforcing configurable
There are  few cases where removing this enforcement is desirable:

- linking against binary C++ libs with incompatible type mangling

- linking against system provided headers i.e. native_posix

- compiling with legacy code that assumes a different convention

So let's create a Kconfig symbol for it. This is IMHO a good compromize
compared to using the %"PRId32" abomination everywhere otherwise.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-22 12:26:46 +02:00
Ola Tangen Kulseng
38628f409e net: lwm2m: Add LwM2M shell commands for start&stop
Added start, stop and update to the shell.
Refactored the event_cb of the rd_client_info struct into the ctx,
as it was needed in the shell script.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-06-22 12:17:52 +02:00
Nicolas Pitre
052192f6b0 riscv: native arch_proc_id() implementation
Return the hardware hartid value directly.

Redefine arch_curr_cpu() in terms of arch_proc_id() to remove
the hartid reading duplication. The code assumed a linear hartid
space already so add a comment to that effect.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-22 11:35:02 +02:00
Carlo Caione
b55e6dbfce irq: Add extern define to _isr_wrapper
When CONFIG_GEN_IRQ_VECTOR_TABLE and CONFIG_GEN_SW_ISR_TABLE are enabled
the generate IRQ table is trying to reference the _isr_wrapper function.

Add an extern to that to avoid a failure when compiling and remove the
previous arch-specific declarations.

arch/common/isr_tables.c:48:38: error: '_isr_wrapper' undeclared here
				(not in a function)

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-21 20:30:20 -04:00
Thomas Stranger
2bd80c6fb1 dts/arm/st: fix stm32g0 STM32_PERIPH_BUS_MAX
All STM32G0 SoCs have two sets of APB registers(APB1 and APB2).
Therefore set STM32_PERIPH_BUS_MAX to 0x40 (STM32_CLOCK_BUS_APB2)
for this series.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-06-21 10:48:46 +02:00
Anas Nashif
8fd777552e arch: add arch_proc_id() to get processor ID
Add a new interfaces for getting processor ID. On some of the
architectures, implement by means of arch_curr_cpu().

On xtensa, we get this via the PRID register.

Doxygen string by Andy Ross.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-21 10:48:28 +02:00
Audun Korneliussen
db78d04a96 Bluetooth: ISO: Add function for reading TX sync
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2022-06-21 10:46:56 +02:00
Juha Heiskanen
6d42ded565 net: lwm2m: LwM2M message allocation update
Allocated own message buffer for RD client interface.
This helps to cover if all messages are queued and need to do
registration or update.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 8dca91109d73a4a697e074c58ee9430d56c01a51)
2022-06-20 09:13:41 -04:00
Aleksandr Khromykh
507fa6fa2c Bluetooth: Mesh: RFU fixed group addresses can be used for subscription
Mesh 1.0.1 specification doesn't prohibit to use full range of
the fixed group addresses for subscription.
The immediate use case is upcoming IPT transport models
which will also work on Mesh 1.0 devices. The models
declare their own fixed group addresses.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-06-20 10:27:36 +02:00
Stephanos Ioannidis
828a56e906 kernel: thread_stack: Add K_THREAD_STACK_DECLARE and its friends
This commit adds the following new thread stack declaration macros that
replace the now-deprecated thread stack "extern" macros:

  K_KERNEL_STACK_DECLARE
    * replaces K_KERNEL_STACK_EXTERN.
    * accepts a stack size parameter.

  K_KERNEL_STACK_ARRAY_DECLARE.
    * replaces K_KERNEL_STACK_ARRAY_EXTERN.

  K_KERNEL_PINNED_STACK_ARRAY_DECLARE.
    * replaces K_KERNEL_PINNED_STACK_ARRAY_EXTERN.

  K_THREAD_STACK_DECLARE
    * replaces K_THREAD_STACK_EXTERN.
    * accepts a stack size parameter.

  K_THREAD_STACK_ARRAY_DECLARE
    * replaces K_THREAD_STACK_ARRAY_EXTERN.

The term "declare" has been chosen in place of "extern" in order to
align with the existing terminology used throughout the kernel code.

Note that the K_{KERNEL,THREAD}_STACK_DECLARE macro accepts a new stack
size parameter so that the `sizeof` operator can be used with the
external stack symbols declared using it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
7931fffdb3 kernel: thread_stack: Remove redundant def command
This commit removes the `@def` command in the Doxygen documentation
because Doxygen is smart enough to figure out that a comment block is
for the following `#define`, and it is completely redundant.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
2eec48beab kernel: thread_stack: Enforce consistent terminology
This commit updates the thread stack API documentation such the
terminology used by the documentation matches that of the actual macro
and function names.

For instance, the term "declare" in the context of "defining" a stack
has been changed to "define."

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
96c926f47b kernel: thread_stack: Fix macro documentation group
This commit ensures that all thread stack API macros are included in
the `thread_stack_api` documentation group.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Krzysztof Chruscinski
c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Carlo Caione
b6a3d598f3 device_mmio: Introduce DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME
Currently the device MMIO APIs is only able to map single DT-defined
regions and also the _NAMED variant is assuming that each DT-defined
device has only one single region to map.

This is a limitation and a problem when in the DT are defined devices
with multiple regions that need to be mapped.

This patch is trying to overcome this limitation by introducing the
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME macro that leveraged the 'reg-names'
DT property to map multiple regions defined by a single device.

So for example in the DT we can have a device like:

  driver@c4000000 {
    reg = <0xc4000000 0x1000>, <0xc4001000 0x1000>;
    reg-names = "region0", "region1";
  };

and then we can use DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME doing:

  struct driver_config config = {
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region0, DT_DRV_INST(0)),
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region1, DT_DRV_INST(0)),
  };

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-16 11:26:10 +02:00
Georgij Cernysiov
8a237848b0 include: bindings: ospi flash add dual, quad modes
Adds dual and quad mode defines.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-06-16 10:29:15 +02:00
Nicolas Pitre
f00573555b Z_POW2_CEIL: simplify implementation
Avoid potentially calling __builtin_clz() twice with non-constant
values. Also add a test for it.

Clang produces false positive vla warnings so disable them. GCC will
spot real vla's already.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-16 10:28:15 +02:00
Krzysztof Chruscinski
747d6ffdb0 shell: Remove support for logging v1
Remove support for logging v1 from shell log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Abramo Bagnara
ada9ca4c93 coding guidelines: comply with MISRA C:2012 Rule 7.2
MISRA C:2012 Rule 7.2 (A `u' or `U' suffix shall be applied to all
integer constants that are represented in an unsigned type)

Added missing `U' suffixes in constants that are involved in the
analyzed build, plus a few more not to introduce inconsistencies
with respect to nearby constants that are either unused in the
build (but implicitly unsigned) or are used and are immediately
converted to unsigned.

Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
2022-06-14 13:36:14 -04:00
Kumar Gala
f73a389e47 net: if: make driver name consistent for DT macros
Fixup how the drv_name field is set in NET_DEVICE_DT_OFFLOAD_DEFINE
and NET_DEVICE_DT_DEFINE_INSTANCE to be consistent with
NET_DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-14 09:31:39 +02:00
Luca Fancellu
58efbc6f4f drivers: xen: keep track of missed events on event channels
The current implementation for events channel is using an empty
callback for every unbind channel and the interrupt is clearing
every event and calling the callback.
However in a scenario where a domain fires a notification when
another has not yet bind the channel, the event will be missed.

To address this limitation, this commit is keeping track of
missed event channel notification when the empty callback is
used, a function to retrieve and clear the missed event is
introduced.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2022-06-14 09:31:03 +02:00
Jedrzej Ciupis
644da741f4 net: pkt: add IEEE 802.15.4 TX power field
This commit extends the `struct net_pkt` structure with
`ieee802154_txpwr` field that contains signed value of the desired
transmission power of a IEEE 802.15.4 frame in dBm.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Gerard Marull-Paretas
a44664e95b device: remove deprecated (z_)device_usable_check
The API was deprecated in favor of (z_)device_is_ready.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-14 09:30:22 +02:00
Gerard Marull-Paretas
659f23c01f device: remove deprecated SYS_DEVICE_DEFINE
The macro was deprecated in favor of SYS_INIT.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-14 09:30:22 +02:00
Daniel Leung
33f8d0df4e kernel: workq: add k_work_user_queue_thread_get()
This adds a simple function to get the thread pointer to the user
mode thread of the user work queue. This is useful for granting
that user mode thread additional access to kernel objects.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-13 16:19:34 -04:00
Dominik Ermel
194340b1a2 storage/flash_map: Fix typos in flash_area_open documentation
Fixed typos.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-13 11:28:18 -05:00
Martí Bolívar
d130160813 devicetree.h: clean up token API docstrings
Clean up the docstrings for the APIs related to converting property
values to tokens. I think the current language has a few issues and
could be made clearer in some cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-06-13 09:44:32 -04:00
Kumar Gala
bd2b7e9502 net: if: Fix NET_DEVICE_DT_DEFINE_INSTANCE macro
Fix NET_DEVICE_DT_DEFINE_INSTANCE to pass through the init_fn
argument to Z_NET_DEVICE_INIT_INSTANCE.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-13 12:12:35 +02:00