Commit graph

58 commits

Author SHA1 Message Date
Artur Hadasz 4400540d15 modules: hal_nordic: nrf_802154: RNG xor-shift algorithm
The LCG method used earlier in the random number generator was problematic,
as the lowest bits repeated periodically (for example, the generated number
always resulted in an odd-even-odd-even-.. sequence, or the last three bits
formed an cycle of the length 8). This is because the LCG was done module
2^32. Any LCG using a power of 2 as the modulus will cause the same issue.
The used RNG method was changed to Marsaglia's xor shift-algorithm,
which does not have this issue.

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
2023-01-04 11:44:07 +00:00
Reto Schneider cb7791baf1 soc: nrf52: Kconfig option for nRF52840 anomaly 198
Enabling by default (if SPI3 used) because it affects all revisions
since "Engineering B", including the most recent one as of today
(revision 3).

Size changes when enabled:
 - -Og: flash +160 bytes (+0.02%), RAM +8 bytes (+0.01%)
 - -Os: flash +144 bytes (+0.02%), no change to RAM usage

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-12-27 15:32:22 +01:00
Nikodem Kastelik 67718641bf modules: hal_nordic: nrfx: switch to 2.10 API
Switch to use newest 2.10 API version in nrfx by default.
It changes signature of user callback in the nrfx_ipc driver.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2022-11-08 10:48:38 +01:00
Rafał Kuźnia fe4ed1b871 boards: nrf5340dk_nrf5340: Add chosen node for nrf-802154 spinel
Currently, the nrf-802154-spinel IPC service requires that the IPC
service node has a specific name (ipc0). This makes it impossible to
overwrite the IPC service node to be used by the Spinel serialization
without completely redefining the ipc0 node. Create a `chosen` property
called nordic,802154-spinel-ipc that can be reassigned with any IPC
service node.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2022-11-05 19:57:25 +01:00
Adam Wojasinski f762aa9aa2 modules: hal_nordic: Add API version symbol to nrfx_config.h
This commit adds API version symbols. The symbol is used in nrfx
drivers, where new API-breaking changes are introduced. Symbol
guards conflicting API.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2022-11-03 11:39:01 +01:00
Artur Hadasz 2314d971e7 modules: hal_nordic: nrf_802154 serialization race condition fix
Fixed a race condition resulting in a serialization error.

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
2022-09-19 10:31:50 +00:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Gerard Marull-Paretas e0125d04af devices: constify statically initialized device pointers
It is frequent to find variable definitions like this:

```c
static const struct device *dev = DEVICE_DT_GET(...)
```

That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Kumar Gala 5fa1909141 modules: hal_nordic: Remove Kconfig.dt
Remove modules/hal_nordic/Kconfig.dt as we now autogenerate the
contents of this file based on the dts bindings in tree.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-17 08:06:55 +00:00
Gerard Marull-Paretas 2cfb5012db drivers: spi: nrfx_spim: move rx delay to DT
Move the RX (MISO) delaying capability information to Devicetree. It is
done using 2 properties:

- rx-delay-supported: enabled on SPI nodes that support delaying RX.
  This property can be used by the driver to determine if this
  capability is supported or not on a given instance.
- rx-delay: the actual RX delay value

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-07-19 13:20:00 -07:00
Kumar Gala b296abd605 modules: hal_nordic: Convert to use DEVICE_DT_GET
Move to use DEVICE_DT_GET_ONE instead of device_get_binding as
we work on phasing out use of DTS 'label' property.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-08 10:18:24 +02:00
Filip Zajdel fb8c86c59a modules: hal_nordic: Don't get DT Node when temp update is disabled
Avoid getting DT Node of temperature sensor when temperature update
is disabled.

Signed-off-by: Filip Zajdel <filip.zajdel@nordicsemi.no>
2022-06-29 10:26:36 +02:00
Andrzej Głąbek c08442c85a modules: hal_nordic: Adapt nrfx_busy_wait() for !SYS_CLOCK_EXISTS case
When the SYS_CLOCK_EXISTS Kconfig option is not enabled, k_busy_wait()
has no implementation, so in such case, call nrfx_coredep_delay_us()
directly.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-06-15 17:04:30 -05:00
Gerard Marull-Paretas 5f5a905784 modules: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all modules code to the
new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:57:47 +02:00
Andrzej Głąbek 451a6ed6ab modules: hal_nordic: Refactor nrfx related Kconfig options
Change dependencies of the Kconfig options that enable particular nrfx
drivers so that the drivers and their instances are available when
a devicetree node with a corresponding compatible property exists,
no matter if it is enabled or not.
Change the options that enable compilation of multi-instance drivers
to be promptless helpers only (not directly configurable for users),
as they need to be enabled only together with some options that enable
particular instances of a given driver, and those options select them
as needed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Emil Obalski d877e1dded ipc_service: Automatically include source files for backends
The purpose of this change is to allow to enable more than one
backend at once by removing choice from ipc-service backend Kconfig
and depending backend Kconfig option on existing of correct compatible.

Overwriting IPC_SERVICE_BACKEND option in some places is removes
as no longer needed.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-03-29 12:30:50 -07:00
Artur Hadasz 9f5c159c7c modules: hal_nordic: fixed wrong 802.15.4 NET core init level
The intialization level of 802.15.4 on NET core was set to APPLICATION,
which caused some applications to break during initialization. Changed
it to POST_KERNEL. CONFIG_NRF_802154_SER_RADIO_INIT_PRIO default value
was adjusted.

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
2022-03-22 12:29:01 +01:00
Andrzej Głąbek 222d42c22a modules: hal_nordic: Improve reservation of resources for BT_CTLR
Instead of including from nrfx_glue.h a specific Zephyr Bluetooth
controller header file that defines PPI and GPIOTE resources to be
reserved for exclusive use by the controller, include a file with
only a fixed name and expect the chosen Bluetooth controller to
provide the location of this file in include paths. This way, when
a different Bluetooth controller implementation is used downstream,
a different file can be easily pointed to.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-15 14:59:35 +01:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Gerard Marull-Paretas b2001388b7 modules: hal_nordic: obtain entropy device using DEVICE_DT_GET
The entropy device can be obtained at compile time.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Gerard Marull-Paretas 95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Rafał Kuźnia a8dd5bfe3a modules: hal_nordic: Select RPMSG backend by default
The nrf_802154 module should use the IPC_SERVICE_BACKEND_RPMSG
backend by default.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2022-03-07 10:55:16 +01:00
Artur Hadasz 5451c8b70f modules: hal_nordic: 802.15.4 make possible to disable CSMA-CA
Currently if an attempt to disable CSMA-CA in by setting an
appropriate flag in another (for example application)
CmakeLists.txt it caused lots of warnings. This fix allows
higher level CMakeLists.txt to disable CSMA-CA without
warnings.

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
2022-03-07 10:51:21 +01:00
Kamil Piszczek 3e5812cc5f modules: hal_nordic: Port nrf_802154 to ipc_service
The nrf_802154 Spinel serialization was ported to multi-instance
ipc_service.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-03-02 17:03:01 +01:00
Rafał Kuźnia 4635c0866f modules: hal_nordic: Remove nrf_802154_lp_timer platform
The nrf_802154_lp_timer_zephyr.c platform file is unused in the
opensource SL library variant.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2022-02-24 14:05:09 -08:00
Andrzej Kuros 7ce93ebfed modules: hal_nordic: nrf_802154_irq ZLI support
Parameter `prio` of `nrf_802154_irq_init` is now allowed to have
negative value what means use of ZLI priority or highest possible
priority if ZLIs are disabled.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
2022-02-23 11:18:17 +01:00
Paweł Kwiek 2c387c6a50 modules: hal_nordic: align & extend lp_timer platform
This commit aligns nrf_802154_lp_timer_zephyr platform to new API of
nrf_rtc_timer. Moreover, it implements lp_timer synchronization
functions using the new nrf_rtc_timer API.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2022-01-04 17:44:32 +01:00
Krzysztof Chruscinski 3457ebc667 modules: hal_nordic: Add NRFX_GPIOTE_NUM_OF_EVT_HANDLERS option
Add option to specifiy number of nrfx_gpiote user handlers in Kconfig.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-04 09:50:02 +01:00
Carles Cufi c7ec3db5e5 Revert "modules: hal_nordic: align & extend lp_timer platform"
This reverts commit 9cdd8cd168.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-20 21:04:26 +01:00
Paweł Kwiek 9cdd8cd168 modules: hal_nordic: align & extend lp_timer platform
This commit aligns nrf_802154_lp_timer_zephyr platform to new API of
nrf_rtc_timer. Moreover, it implements lp_timer synchronization
functions using the new nrf_rtc_timer API.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2021-12-20 16:25:49 +01:00
Paweł Kwiek f3fea0e6f1 modules: hal_nordic: Add CCA macros when nRF Radio Driver is enabled
This patch restricts access of CCA configuration related macros to
builds for which nRF 802.15.4 Radio Driver is enabled. This reduces
clutter and prevents misuse of CCA macros.

Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2021-12-16 10:12:36 +01:00
Krzysztof Chruscinski 5ef63d8313 Bluetooth: Controller: nordic: Rework hw resources files
Move all defines that specifies (D)PPI resources which are used
to dedicated files which have no include dependencies. This allow
to use them in nrfx_glue.h to specify fixed (D)PPI channels used
by the bluetooth.

Additionally, added mask with GPIOTE channels used by the bluetooth
controller. It was previously not defined which could lead to
conflicts since same channels could be allocated by the nrfx_gpiote
user

Updated nrfx_glue.h to use new approach.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-12-02 09:55:48 +01:00
Krzysztof Chruscinski 1345b2ddd4 modules: hal_nordic: nrfx: Set NRF_SKIP_FICR_NS_COPY_TO_RAM
Set NRF_SKIP_FICR_NS_COPY_TO_RAM for nrf53 and nrf91 until corresponding
memory region is excluded from use.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-12-02 09:55:48 +01:00
Krzysztof Chruscinski 7e0f1d08e4 modules: hal_nordic: Update nrfx to version 2.6.0
Update the hal_nordic module revision, to switch to nrfx v2.6.0.

nrfx 2.6.0 includes extended API in nrfx_gpiote which can be
used by the zephyr shim.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-12-02 09:55:48 +01:00
Krzysztof Chruscinski 9886bdc0c8 drivers: pwm: pwm_nrf5_sw: Use runtime resources allocation
Use nrfx_gpiote and nrfx_ppi allocators to allocate channels
at runtime instead of fixed, device-tree based allocation which
is harder to maintain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-11-26 09:31:54 +01:00
Gregers Gram Rygg d47bd60933 soc: nordic_nrf: Add Kconfig option for enabling trace port
Add Kconfig option to enable the hardware trace port in the SystemInit()
function.

Signed-off-by: Gregers Gram Rygg <gregers.gram.rygg@nordicsemi.no>
2021-09-28 20:11:40 -04:00
Joakim Andersson fb90113dc8 modules: hal_nordic: Add nrf51 MDK defines needed to apply nrf51 erratas
Add nrf51 MDK defines needed to correctly select the nrf51 erratas
needed on the specific SoCs. The nrf51_erratas.h header file only uses
these defines to check which erratas should be applied.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-30 15:48:19 +02:00
Andrzej Głąbek 72e3bfe1c0 soc: nordic_nrf: Add Kconfig options for APPROTECT handling
Add Kconfig options that allow users to select the way the APPROTECT
mechanism is handled in the SystemInit() function.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-24 07:27:12 -04:00
Paweł Kwiek da8f9d77c4 modules: hal_nordic: Increase number of serialization buffers
This commit increases number of available serialization buffers to
account for possible delays caused by serialization itself and
processing on the application core.

Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2021-08-11 11:47:10 +02:00
Paweł Kwiek b7bd1be622 hal_nordic: Rework nRF IEEE 802.15.4 temperature update module
This commit reworks nRF IEEE 802.15.4 temperature update module to save
resources, otherwise used to create thread, by using work queue.

Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2021-08-09 17:52:58 +02:00
Przemyslaw Bida 082efb4e9d hal_nordic: Adjust temperature sensor stack size.
This commit extends size of stack used by IEEE 802.15.4 radio
temperature sensor. This commit fixes stack overflow issue in
echo_server sample for OpenThread.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2021-07-31 14:57:19 -04:00
Pawel Kwiek b2487e3c88 manifest: Update hal_nordic
This commit adds temperature platform used by the IEEE 802.15.4 Radio
Driver. The new platform requires an enabled temperature sensor.
The new hal_nordic revision updates the nRF 802.15.4 component.

Signed-off-by: Pawel Kwiek <pawel.kwiek@nordicsemi.no>
2021-07-23 15:54:59 -04:00
Lukasz Maciejonczyk 4185e8e515 modules: hal_nordic: add Kconfig option for frame auth and encryption
New option enables/disables frame encryption module, security writer
module and IE writer module.

The new hal_nordic revision updates the nRF 802.15.4 component.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-06-22 08:22:02 -04:00
Aurelien Jarno cbb2a9be77 logging: Enable SWO support for nRF SOCs
The nRF SOCs declare support for SWO using the HAS_SWO define. In
addition, the SWO pin has to be configured at runtime, which is done
through the Nordic HAL by defining ENABLE_SWO.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-05-18 12:28:25 -05:00
Jedrzej Ciupis 0a75e0551f modules: hal_nordic: nrf_802154: Fix RADIO IRQ handling configuration
This commit fixes nRF 802.15.4 radio driver IRQ management
configuration.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2021-04-07 14:17:22 +02:00
Rafał Kuźnia 9638876bde modules: hal_nordic: change the SL type prompt
The SL type choice option prompt was renamed to be short and concise.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2021-04-01 14:08:08 +02:00
Rafał Kuźnia 859952f590 modules: hal_nordic: add new nrf-802154 glue cmake
Update revision of hal_nordic which introduces new radio driver
integration scheme.

The glue cmake has been updated to use the new integration scheme
for the nrf-802154 component.

Added config option to exclude radio driver in hal_nordic from the
build process. This allows the radio driver to be supplied from
other sources.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-01 14:08:08 +02:00
Rafał Kuźnia 88b1d1f047 modules: hal_nordic: Remove default from SL type choice
The default value is not needed because there is only one choice.
This allows the default choice to be set in a different module.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2021-04-01 14:08:08 +02:00
Krzysztof Chruscinski ab49673bc8 drivers: timer: nrf_rtc_timer: Change type of channel argument
There was an inconsistency in the API as z_nrf_rtc_timer_chan_alloc
returned int but other function were using uint32_t for channel
argument. Updated api to use int32_t everywhere.

Update nrf_802154 driver which was using this api to use int32_t.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-03-25 15:54:49 +01:00