Commit graph

50892 commits

Author SHA1 Message Date
Ioannis Glaropoulos
0856e4ba51 boards: nrf9160: use TF-M by default on non-secure builds
By default, when building for the non-secure version of the
board, use TF-M as the secure firmware binary.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-04-15 17:36:51 +02:00
Torsten Rasmussen
d95200447b cmake: warn if a Zephyr library is empty instead of CMake failure
Several driver libraries uses:
```
zephyr_sources_ifdef()
```
instead of
```
zephyr_library()
zephyr_library_sources_ifdef()
```
This results in a messy Zephyr lib as described in: #8825

One reason for drivers to use the first approach is because an empty
Zephyr library results in a CMake build failure which again leads to
twister issues when just enabling a driver and build for all known
boards and then process the DTS result.

Secondly, a CMake build failure prevents the user from launching
menuconfig and disable the driver that creates the empty library.
See #9573 for extra details.

This commit verifies all Zephyr libraries, and if a library is found to
have no source files it will be excluded from the build and a warning
will be printed to the user.

Printing a warning instead of a hard failure ensures that:
- menuconfig can still be opened
- CMake does not fail which allows twister to advance in the test case
- Makes it possible to cleanup CMakeLists driver files

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-15 17:23:05 +02:00
Peng Li
e28b7e04e2 driver: serial: fixed the buffer underflow issue when clearing the port.
Set DLAB bit before reading RDR to avoid buffer underflow.

Signed-off-by: Peng Li <lipengit@gmail.com>
2021-04-15 17:19:12 +02:00
Johann Fischer
5540fa0028 samples: mesh_badge: increase mesh loopback buf count
Similar to commit 24f34b1913
("Bluetooth: Mesh: Demo: Increase loopback buf count")'

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-04-15 17:18:27 +02:00
Dominik Ermel
eb37fd0b30 drivers/flash_simulator: Rename FLASH() macro to MOCK_FLASH()
The change is done to avoid redefinition errors while attempting
to enable flash_simulator with stm32 platform (stm32f4_disco)
which exports its own definition of FLASH macro, from stm32f407xx.h.
Unfortunately the stm32 definition is visible within flash_simulator
via inclusion of device.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-15 17:15:34 +02:00
Jukka Rissanen
283861cbfd tests: lib: fdtable: Fix invalid memory access
The vtable cannot point to address 1 as that is clearly not a
valid address and will fail when the code tries to access it
in various fdtable.c functions. Point the vtable in tests either
to NULL or to a valid vtable.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-15 07:16:51 -05:00
Jukka Rissanen
ef074d9786 tests: fdtable: Fix compilation as z_get_fd_obj_and_vtable() changed
3rd parameter (struct k_mutex *) was added to
z_get_fd_obj_and_vtable() so add it to calls in the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-15 07:16:51 -05:00
Jukka Rissanen
b0d9ea1308 sys: eventfd: Add locking to eventfd_read/write functions
The fdtable infrastructure provides a possibility to prevent
concurrent access to file descriptor. Use that functionality
in eventfd API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-15 07:16:51 -05:00
Jukka Rissanen
dde03c6770 net: socket: Add locking to prevent concurrent access
The BSD API calls were not thread safe. Add locking to fix this.

Fixes #27032

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-15 07:16:51 -05:00
Robert Lubos
a586f5818c drivers: ieee802154_nrf5: Remove unnecessary NULL pointer check
After changes in commit a42d6c98d3, the
pkt can no longer be a NULL pointer. Remove the unnecessary NULL pointer
check to silence the Coverity.

Coverity ID: 219536
Fixes #32912

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-15 14:45:50 +03:00
Peter Bigot
55c4db9c4c samples: boards: nrf: clock_skew: calculate corrected reference
The sample showed the error between the two clocks, but did not show
how to use the skew to reconstruct one clock from the other and the
resulting error.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-15 13:05:16 +02:00
Carlo Caione
26a65d8584 arm64: fvp_baser_aemv8r: Cleanup defconfig
Remove useless options.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-15 12:58:22 +02:00
Carlo Caione
04df0ddc88 arm64: Set AARCH64_IMAGE_HEADER and BUILD_OUTPUT_BIN to y
It doesn't hurt always having the image header and generating the binary
output. I find myself constantly setting those to 'y', so make it
definitive.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-15 12:58:22 +02:00
Carlo Caione
66b78162ce arm64: qemu_cortex_a53: Cleanup defconfigs
Remove useless entries and add some missing options.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-15 12:58:22 +02:00
Carlo Caione
013c8273ca arm64: gic: Enable access to ICC_* registers
Thi GICv3 driver is configuring the controller accessing the system
registers ICC_*. To be able to do that without trapping we have to
explicitly set at boot in EL3 the value of the ICC_SRE_EL3 register that
is architecturally set to UNKNOWN value on warm reset.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-15 12:26:39 +02:00
Artur Lipowski
bc2ad24d1a tests: Add base test for C++ exceptions handling.
Try to throw and catch C++ exception of int type.

Related to: #32448 and #34229


Signed-off-by: Artur Lipowski <Artur.Lipowski@hidglobal.com>
2021-04-15 12:26:11 +02:00
Jordan Yates
18d3f4dc36 linker: cc13x2_cc26x2: CCFG to linker snippets
Move the TI_CCFG linker section code into a dedicated snippet in the soc
directory.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-15 12:25:55 +02:00
Jordan Yates
8fb37b94fd linker: cc13x2_cc26x2: CCFG registers as partition
Define the FLASH_CCFG memory region from a devicetree partition instead
of from math in the linker file. Removing the special math case results
in the FLASH_CCFG region overlapping the FLASH region, but the linker
accepts this until the FLASH region actually starts placing variables
in the FLASH_CCFG region.

As a result, applications that don't fit in (FLASH_SIZE - 88) bytes will
still fail to link, just with an overlapping memory region error instead
of an overflow error.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-15 12:25:55 +02:00
Jordan Yates
a4150c0483 linker: stm32wb: move IPC RAM definition to DT
Move the definition of the two IPC RAM blocks from `#define`'s in family
linker scripts to proper devicetree nodes. Use the devicetree nodes to
generate the memory regions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-15 12:25:55 +02:00
Jordan Yates
ddc25b4bdf linker: aarch32: simplify memory region generation
Simplify the linker script by using the helper macros introduced in
<linker/devicetree_regions.h>. The conditional checks on the Kconfig
symbols are discarded as their default values are typically set via
the status="okay" property of the nodes, and hence the behaviour doesn't
change.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-15 12:25:55 +02:00
Jordan Yates
3979eda93b linker: macros for memory regions from devicetree
Adds a public macro for creating memory regions from devicetree nodes.
`DT_REGION_FROM_NODE_STATUS_OKAY` declares the memory regions for
consumption by ld, assuming the node exists and has `status = "okay"`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-15 12:25:55 +02:00
Sergey Ustinov
73db443320 drivers: can: can_mcp2515: fix BRP bits value
Fixes #33978.
8b6c1bd commit set 'presacaler' in BRP(Baud Rate Prescaler) bits.
It's wrong, because these bits from CNF1 register use 'prescaler - 1'.
MCP2515(DS20001801J) datasheet 'REGISTER 5-1: CNF1: CONFIGURATION
REGISTER 1 (ADDRESS: 2Ah)'.

Signed-off-by: Sergey Ustinov <originalustinov@gmail.com>
2021-04-15 12:25:23 +02:00
Andrzej Puzdrowski
13883c76f3 manifest: mcuboot update
- added an option to use GPIO to enable USB DFU.

Patch required as wait_for_usb_dfu() function started to
take time argument since was #30015 merged.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-04-15 12:25:15 +02:00
Kumar Gala
6b8fa2a85e arm: nxp: kinetis: Remove explicity setting of pincfg to GPIO
Remove board code and a few associated samples/tests that explicitly
call pinmux_pin_set() to set a given pin as GPIO.  This is handled as
part of gpio_mcux_configure() so we don't need to do it again.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-15 12:25:05 +02:00
Kumar Gala
b55ad01898 drivers: gpio: mcux: Set pin mux config to GPIO
Set the PCR[MUX] field to kPORT_MuxAsGpio as part of configuring a GPIO
pin.  This removes the need to explicitly call pinmux_pin_set() in board
code.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-15 12:25:05 +02:00
Arvin Farahmand
e4a349ff76 net: icmpv4: fix broadcast ping reply bug
If `CONFIG_NET_ICMPV4_ACCEPT_BROADCAST` is enabled ICMPv4 should reply
to request packets sent to the broadcast address of an interface with
the unicast address of that interface from the same subnet.

Previously the code blindly copied the ICMP source address which meant
it would reply to broadcast packets with a broadcast source address.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-04-15 10:43:51 +03:00
Arvin Farahmand
835b875c17 drivers: ethernet: eth_sam_gmac: allow changing mac address
Support setting MAC address manually at runtime for Atmel SAM Ethernet
driver. The MAC address can be set using an ethernet management
request, e.g. (`net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, ...)`).

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-04-15 10:43:21 +03:00
Nicolas Pitre
0dc7b9ee46 k_current_get(): make it a "const" function
This function always returns the same value for a given thread.
Add the const attribute to it so the compiler won't call it over and
over needlessly each time _current is referenced, making for far more
efficient code.

The __attribute_const__ symbol is used to mimic the Linux equivalent.
We want to make it clear that this is distinct from the const keyword.

Fix the test_x86_cpu_scrubs_regs where the compiler wasn't told that a
bunch of registers are being clobbered as highlighted by this change.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-14 20:32:05 -04:00
Alexander Wachter
a0905efa80 MAINTAINERS: add more collaborators to the can-bus area
Add Martin Jäger, Nick Ward and Abram Early as collaborators.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-04-14 18:23:22 -04:00
Pieter De Gendt
40c25b931d samples: modules: nanopb: fix encode buffer size
A bug was introduced when encoding/decoding moved to separate
functions where sizeof no longer had the correct argument.

The size of the encode buffer is passed to the encode function.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-04-14 14:45:26 -05:00
Erwan Gouriou
089f907305 boards: stm32g0316_disco: pinmux init clean up
Remove useless function call on in board pinmux init.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-04-14 14:43:27 -05:00
Robert Lubos
19e7451c34 net: lwm2m: Fix unitialized variable error in Link Format writer
The `init_string` array could have been used uninitialized, fix this
by initializing it as an empty string, which is a desired content in
case it's not overwritten.

CID: 220302
Fixes #33839

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-14 14:36:35 -05:00
Carlo Caione
a57a69b61a dts: virt: Move sram node to DT board files
Currently the SRAM location is fixed for all the boards derived from
qemu_cortex_a53. While this is acceptable when the image is directly
loaded in SRAM by QEMU, in some cases Zephyr can be loaded in RAM by
another piece of software or by semihosting at a different address
before jumping into it.

When for example TF-A is used and Zephyr is run as BL33 payload using
QEMU, in this case the default location in RAM is at a different
address (when preloaded BL33 base address is not used).

To address these cases, move the SRAM location into the board-specific
DTS so that it can be adjusted on a board by board basis.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-14 14:20:00 -05:00
Nicolas Pitre
88477906f0 arm64: hold curr_cpu instance in tpidrro_el0
Let's fully exploit tpidrro_el0 by storing in it the current CPU's
struct _cpu instance alongside the userspace mode flag bit. This
greatly simplifies the code needed to get at the cpu structure, and
this paves the way to much simpler multi cluster support, as there
is no longer the need to decode MPIDR all the time.

The same code is used in the !SMP case as there are benefits there too
such as avoiding the literal pool, and it looks cleaner.

The tpidrro_el0 value is no longer stored in the exception stack frame.
Instead, we simply restore the user mode flag based on the SPSR value.
This way, more flag bits could be used independently in the future.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-14 15:06:21 -04:00
Nicolas Pitre
2bed37e534 mem_slab: move global lock to per slab lock
This avoids contention between unrelated slabs and allows for
userspace accessible slabs when located in memory partitions.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-14 14:20:19 -04:00
Yasushi SHOJI
2b32e47a9a scripts: coccinelle: Fix parse error
The commit coccinelle/coccinelle@47bd4cae52 changed a behavior of
parsing right before coccinelle v1.1.0.  With the commit, the current
scripts under scripts/coccinelle/ errors out with:

   minus: parse error:
     File ".../zephyr/scripts/coccinelle/deref_null.cocci",
     line 25, column 42, charpos = 666
     around = '...',
     whole content =  (E != NULL && ...) ? <+...E->f@p1...+> : ...

I've already raised an issue upstream coccinelle/coccinelle#257.  But
Debian is already shipping v1.1.0 and we need a fix.

The proposed fix doesn't change the semantics, it just explicitly
states that the rule is an expression.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-04-14 14:18:02 -04:00
Francois Ramu
962d6b1082 drivers: serial: uart_stm32 converted to use the new kwork API.
The structure is now k_work_delayable.
The init function is now k_work_init_delayable.
The submit function is now the k_work_reschedule.
The cancel function is now the k_work_cancel_delayable.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-04-14 18:21:33 +02:00
Marek Pieta
cc21ff5a8c Bluetooth: GATT: Fix undefined symbols
Change fixes build issues for configurations without Bluetooth.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-04-14 18:19:42 +02:00
Azizah Ibrahim
d9fa9c6e1c Bluetooth: samples: Remove workqueue stack configuration
Fixed value used is too low causing overflow in nrf53.  Use default
value instead.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2021-04-14 18:19:32 +02:00
Shlomi Vaknin
703d396956 tests: dma: add stm32h7 to loop_transfer
Add nucleo h743zi board to loop_transfer test.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-14 18:18:12 +02:00
Shlomi Vaknin
cb1b231766 tests: dma: add stm32h7 to chan_blen_transfer
Add nucleo h743zi board to chan_blen_transfer test.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-14 18:18:12 +02:00
Shlomi Vaknin
95143fc98e drivers: dma: stm32: add support for stm32h7
Add the missing parts for adding support
to stm32h7 dma driver.
The fix is to make dmamux driver work with
dma v1 driver.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-14 18:18:12 +02:00
Shlomi Vaknin
084a3debc4 dts: stm32: h7: add missing dma properties
Add dma-offset and dma-requests missing
device tree properties.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-14 18:18:12 +02:00
Bob Recny
6f3b30ecb5 boards: arm: Add support for BMD-360-EVAL
Add support for u-blox BMD-360-EVAL which uses the nRF52811.
This board is functionally equivalent to the nRF52dk with a
nRF52811 mounted in place of the nRF52832 with the exception
of not having debug-in and the shield SWD header.
DEVELOP_IN_NRF52832 is *not* required since the IC
used is the nRF52811.

Note that header pin numbers noted in index.rst are shown with
respect to the pin 1 markings on the BMD-3xx-EVAL boards, and are
flipped from the nRF52dk_nrf52811.

Tested with blinky, button, and Bluetooth peripheral_hr
Edited to include changes similar to those requested in
https://github.com/zephyrproject-rtos/zephyr/pull/33850
(nRF52810 there vs. nRF52811 here)

Signed-off-by: Bob Recny <bob.recny@u-blox.com>
2021-04-14 18:17:53 +02:00
Asger Munk Nielsen
b9b1c7e19b Bluetooth: controller: ISO adaptation layer, Rx unframed
First design towards ISO adaptation layer, this PR introduces
data-structures and framework for Rx unframed PDUs (BT RX ingress).
Two callbacks are defined for the SDU production (BT RX egress), one for
SDU allocation as well as a callback for emitting a reassembled SDU.

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2021-04-14 18:17:09 +02:00
Paul Sokolovsky
958e826b69 net: socket: Workaround issue with recent GCC and fcntl macro
If we have CONFIG_NET_SOCKETS_POSIX_NAMES enabled (which is now
default), and also have CONFIG_NEWLIB_LIBC enabled, latest versions
of GCC throw a strange error like:

error: conflicting types for 'zsock_fcntl'
  692 | #define fcntl zsock_fcntl

After enough consideration, it seems that when Newlib is used, its
fcntl.h header is used, which declares fcntl() with POSIX prototype:
"int fcntl(int fd, int cmd, ...)". It seems that recent GCC, when
seeing the #define like above, checks that its right-hand side
(zsock_fcntl(int, int, int) above) is compatible with an existing
LHS prototype. That doesn't make sense from the point of view of
the C preprocessor semantics, and yet that's what apparently happens.

Make GCC happy by defining an inline wrapper function with
signature compatible with POSIX fcntl prototype, and use it in
the define, instead of zsock_fcntl directly.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2021-04-14 11:10:16 -05:00
Justin Morton
35f598ba93 net: http: add numeric http status code to response struct
Add numeric http status code to the response struct to allow for
easier processing by the caller.   Textual status already exists.

Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
2021-04-14 18:46:47 +03:00
Eduardo Montoya
4289e46ae7 net: openthread: switch radio off when stopping diags
This commit puts the radio in sleep mode when the diagnostics are
stopped.

This fixes an assert on MAC code when `ot diag stop` command is
issued while `ot diag send` is still ongoing.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-04-14 17:38:27 +03:00
Kumar Gala
21c29cc504 boards: arm: frdm_kw41z: Add pinctrl dts properties
Add pinctrl-0 properties for configuration of peripherals like UART,
I2C, ADC, etc.  These settings are based on what is defined in
the board/pinmux.c file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-14 09:06:36 -05:00
Kumar Gala
e14b78c3ff boards: arm: frdm_kl25z: Add pinctrl dts properties
Add pinctrl-0 properties for configuration of peripherals like UART,
I2C, ADC, etc.  These settings are based on what is defined in
the board/pinmux.c file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-14 09:06:36 -05:00