Skip to content

Low power UART polling without interrupts #2482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1,058 commits into
base: main
Choose a base branch
from

Conversation

nordic-krch
Copy link
Contributor

FOR TESTING ONLY

LingaoM and others added 30 commits December 5, 2024 12:16
…h messages

When start to sending proxy advertising, will also process in
send_pending_adv, but the bt_mesh_adv_get_by_tag will directly return
buffer from bt_mesh_adv_queue or bt_mesh_relay_queue, which case
mesh messages sent on different sets, can cause peer replay attack.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
(cherry picked from commit b54f49c)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 962f615)
Makes sure that the Network Transmit state is used when using a Subnet
Bridge.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit b38773f)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit f263e73)
By default if CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME
or CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME is enabled, the mesh stack
will add BT_DATA_NAME_COMPLETE AD Type along with the Mesh Proxy Service
or Mesh Provisioning Service advertisements accordingly.

When BT_LE_ADV_OPT_USE_NAME was present and
CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the advertised name was
automatically updated by the host. This turned out to be a side-effect
rather than expected behavior and after #71700 this behavior waa
changed.

But customers use dynamic name feature.

This commit makes the mesh stack use bt_get_name to get the device name,
which returns runtime name if CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit ab346a1)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit f98c140)
…es to gatt.h

This moves GATT releated defines that are used by both Mesh Proxy
Service and Mesh Provisioning Service implementations to a common
header file.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit 684c94e)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 3ff85af)
…_work

Fix extracting role from k_work.
Hot fix for #78914

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit f5409bd)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 52c7aa8)
…ut data

This commit checks that config client doesn't pull out data outside of
the buffer.

Fixes #80012

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit e2a0faf)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit d8de6ce)
… CDP0 and 1

This commits puts in order log messages when unpacking CDP0 and CDP1 so
that it a bit more clear where the error happens.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit 1eeee01)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 7d31b72)
…et_idx != 0

Initializes the `net_idx` field of the ack context properly for KRP
functions in the Config Client.

This fixes a problem where `bt_mesh_cfg_cli_krp_get` and
`bt_mesh_cfg_cli_krp_set` would always fail the ack ctx comparison if
`key_net_idx` was != 0.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
(cherry picked from commit 88f62a1)
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 48cdbac)
The PEM Kconfig symbols is non-standard and isn't available for nRF
security, for now add a check to enable that only for MbedTLS builtin
which is not applicable for nRF security.

Fixes NCSDK-30762.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
(cherry picked from commit c21cc96)
Switch to released version with all of the Zephyr build fixes

Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit d5b6539)
(cherry picked from commit 126440b)
…d final build

Currently, the linker that is used when performing various cmake checks
(check_c_compiler_flag, for example) may be different than the linker that
will be used during the actual build. This happens as we currently specify
'-fuse-ld' to force the appropriate linker a) after many such checks have
already happened and b) in a way which is not automatically propagated to
check_c_compiler_flag (and friends). As a result, the toolchain's default
linker will generally be used for such checks regardless of which linker
was selected in Zephyr.

This can lead to a number of surprises when building Zephyr, particularly
when building with clang. For example:

- If the linker is misconfigured, where the build will fail can vary
  depending on whether the linker is the toolchain's default. When the
  configured linker happens to be the toolchain's default, the build
  (helpfully) fails quickly on the checks for a basic working toochain.
  When the configured linker isn't the default, the build won't fail until
  the final link steps.
- The build can fail due to issues with a linker other than the one
  configured by the user in Zephyr. For example, LLVM toolchains without
  lld will generally fail to build Zephyr (the checks for a basic
  working toochain will fail) for targets where lld is the default in LLVM
  even if GNU ld is configured in Zephyr and would otherwise be used in the
  final build.
- Flags which are only added if check_c_compiler_flag (or similar) succeeds
  may be unexpectedly omitted during the final build if the flag is
  supported in the configured linker but is unsupported in the toolchain's
  default linker (as check_c_compiler_flag will test using the default
  one).

Note that this isn't limited to clang--even when we are building with
Zephyr's SDK and force ld.bfd, we seem to use the 'ld' variant during the
cmake checks (though this generally seems fairly harmless compared to
mixing ld/lld or other proprietary linkers).

To fix this, ensure the appropriate 'fuse-ld' is set early enough and in
such a way that the same linker will be used throughout the entire build.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 9fe6c5e)
(cherry picked from commit d90a2c5)
Zephyr is a bare metal build where standard libs are disabled.

This means that c and runtime libraries must manually be linked in.

This has generally been handled by using CMake's link libraries handling
but the issue with that is both de-duplication but also library link
order.

Standard libraries must be linked at last location to ensure symbols
are always available, however this is not optimal with
target_link_libraries() because this would ultimately require every
library to know the c library to link with, which is not desired.

Therefore, setup standard C and runtime library linking in linker
CMake files for toolchains where this is required.

This commit expands the principle introduced with toolchain abstraction,
see PR#24851.

This means that a toolchain implementation may specify standard C,
runtime, C++, etc libraries, as well as their link order.
Because a property approach is used, then Zephyr modules, such as the
Picolibc module can adjust such properties.

An optional `zephyr_linker_finalize()` macro is called at the end of
Zephyr's CMakeList process and can be used by the toolchain
implementation to define the final linker invocation.

This aligns the linker handling flow to the principle introduced in
PR#24851 and improves the flexibility and robustness of Zephyr build
system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 2e3873a)
(cherry picked from commit a5c6e0a)
…nk libraries

Extend zephyr_link_libraries to allow an optional value together with
the `zephyr_link_libraries(PROPERTY <property> [<value>])`.

This allow setting linker property combined with a value when linking
Zephyr. The value will only be applied if the property is defined.

Extend zephyr_compile_options to support the same PROPERTY flag that
has been introduced for zephyr_link_libraries().
This remove the need for developers to write complex generator
expressions for compiler flags and thus minimizes mistakes.

The following syntax is now supported in addition to the existing
syntax: `zephyr_compile_options(PROPERTY <property> [<value>])`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 718b726)
(cherry picked from commit f819df8)
The `check_set_linker_property()` and `set_linker_property()` takes a
target argument. Make the target argument optional and use the target
`linker` as default target.

The function name `set_linker_property()` already implies that we are
setting a property and the linker target.

Remove the need to specify `TARGET linker` when using the default linker
property target.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 102b3fc)
(cherry picked from commit 185ea88)
…in properties

Moving specs argument to compiler and linker properties so that the
compiler and linker in use can decide how the flags are mapped / handled
for the compiler and linker in use.

This avoids specifying `--specs=spec.picolibc` for clang which prints a
warning about an unused argument.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 9d835fe)
(cherry picked from commit e14af53)
… property

This commit updates picolibc module to remove the need for hard-coding
linking with `-lgcc`.

Instead it sets the c_library linker property and thereby allows the
Zephyr toolchain infrastructure to properly handle the linking of
C and runtime libraries.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit b2eeef4)
(cherry picked from commit e5f3261)
Newlib or Picolibc libraries for LLVM may be compiled or installed from
pre-built sources independently of LLVM itself.

This means that always indicating that TOOLCHAIN_HAS_NEWLIB=OFF and
TOOLCHAIN_HAS_PICOLIBC=OFF are wrong. But it could be just as wrong to
always indicate suport for newlib or picolibc.

Some pre-built LLVM toolchains are provided with default picolibc
support, such as LLVM for Arm embedded, but can also be used with newlib
be installing newlib add-on package.

Unfortunately it's not possible to query LLVM regarding newlib or
picolibc support.

Developers have the option of `-DTOOLCHAIN_HAS_<NEWLIB|PICOLIBC>=ON`,
but this is not widely known and cumbersome to do for each build.

An indication of newlib or picolibc support is the presence of library
specific headers, so to improve current situation we check for library
specific headers, and if those are present we assume support for the
library.

This commit improves the current support for LLVM in Zephyr when
cross-compiling, especially for users of LLVM for Arm embedded.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 0274bcb)
(cherry picked from commit ce6eaf3)
Store informations regarding the current Zephyr build.
The following informations are stored during CMake configure:
- Board information
- Application source directory
- Application configuration directory
- Toolchain information
- Devicetree files
- Kconfig config files
- Zephyr version

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 09faf53)
(cherry picked from commit a9ba90a)
…le used.

Save information regarding SVD file in use in vendor-specific section
of the build info file.

Information is stored under Nordic section.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 46a3e61)
(cherry picked from commit 22c1920)
Update build_info() calls to use `PATH` argument when values passed to
`build_info()` are user specified and thereby might use native path
separator, such as a single `\`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 2c1eae2)
(cherry picked from commit 7c1c2f4)
…specific gap fill

Deprecate BUILD_NO_GAP_FILL as it gives a false impression that gap
filling can be disabled in binary files.
Binary files are always gap filled due to the fact they contain no
address information. Only option for binary files is to control the gap
fill pattern. When no gap fill is enabled in binary files, then a
default pattern is used by the tool, which usually is 0x00.

Generally the pattern 0x00 leads to unnecessary flash writes, as a
flash generally contains 0xFF after an erase.
Therefore provide a gap fill pattern Kconfig setting instead, with
default value of 0xFF.

For hex-files, intel hex and s19, then gap filling is generally not
needed but in order to still support cases where gap filling is required
then this commit introduces BUILD_OUTPUT_HEX_GAP_FILL and
BUILD_OUTPUT_S19_GAP_FILL. Both settings are disabled per default.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 2e8868c)
(cherry picked from commit d62198c)
The llvm-objcopy doesn't support a gap-fill argument, therefore clear
the property to remove the error:
> llvm-objcopy: error: unknown argument '--gap-fill'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from commit 71fd4d9)
(cherry picked from commit b249f97)
…0 bus lib

The nrf wifi drivers include code related to qspi/spi bus. This work
moves bus related files to a new nrf70 bus library which is now
independent of the core driver and facilitlates building applications
directly using the bus APIs, agnostic to enabling wifi configs.

Upstream PR #: 82372

Signed-off-by: Bansidhar P.M <bansidhar.mangalwedhekar@nordicsemi.no>
(cherry picked from commit b515453)
Add ztests for nrf70 bus lib to help validate functional integrity
of the QPSI/SPI interface to nRF70 device via appropriate reads/writes
from host processor to relevant memory blocks of nrf70 device.
Note that this will NOT serve as a memory test for nrf70 device,
rather just a functional verification of the wiring between the host
processor and the nrf70 device.

Upstream PR #: 82372

Signed-off-by: Bansidhar P.M <bansidhar.mangalwedhekar@nordicsemi.no>
(cherry picked from commit bf4df4a)
…nnect

This fixes an issue that occurred if deferred_work is queued by another
procedure before we run bt_conn_set_state(BT_CONN_DISCONNECTED).
bt_conn_set_state yields to the system work queue in bt_conn_tx_notify,
and then deferred_work runs and handles the disconnected callbacks.
bt_conn_set_state then enqueues another deferred_work which calls the
disconnected callbacks again and causes an assert. k_work_cancel_delayable
will clear queued deferred work when we call
bt_conn_set_state(BT_CONN_DISCONNECTED), guaranteeing that the disconnect
callbacks will only be called once.

Upstream PR #: 82543

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
(cherry picked from commit 833b6d2)
…presence

Common symbol is defined by SoCs that support RAM control helper.

Upstream PR #: 82262

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
(cherry picked from commit 2e974fb)
…icit

Updated retained_mem driver variant exposes vendor-specific API,
rather than executing implicitly during boot.

Upstream PR #: 82262

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
(cherry picked from commit 0819c8e)
RAM retention is disabled for all RAM blocks
before entering System OFF to achieve lowest power consumption.
RAM retention can still be enabled using retained_mem driver.

Upstream PR #: 82262

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
(cherry picked from commit b0d7a30)
…argets

Using bare-metal approach for retention configuration
is no longer compatible with sys_poweroff() implementation.

Upstream PR #: 82262

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
(cherry picked from commit 15ffa30)
Updated manifest to include separate security types for 802.1X
in display of scan results when APs have EAP and PMF enabled.
BSS display limit based on user-configured non-zero values
set via CMD_INIT, along with support for few other regulatory
domain updates in firmware.

Upstream PR #: 81514

Signed-off-by: Karun Kumar Eagalapati <karun.kumar@nordicsemi.no>
Vge0rge and others added 26 commits January 13, 2025 11:03
This reverts commit 68fdeb1.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
…ble 64-bit timeouts"

This reverts commit 89fa63d.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
…clusion stricter

Some devices do not support nrf_clock HAL.

Upstream PR #: 83115

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
…or fast PWM"

This reverts commit 99faf47.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
Added clock control api for global hsfll used in fast PWM120 driver.

Upstream PR #: 82133

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
Fix image confirmed for Direct XIP.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
(cherry picked from commit e3f9356)
Fix failing tests for nRF54H20 target.

Upstream PR #: 82252

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
Fix platform radio state machine to be compliant with one shown in
OpenThread's `include/openthread/platform/radio.h`

Align twister tests to verify proper behavior of the
state machine.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
(cherry picked from commit b46f720)
Add possibility to set channel in diag mode by implementing
`platformRadioChannelSet` API.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
(cherry picked from commit 712da72)
After openthread/openthread#11055,
platform is not required to check diagnostics mode while
processing commands.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
(cherry picked from commit 74bbbdc)
…ines

Simplify string building and reduce line length.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
(cherry picked from commit 9ca1b0f)
…ace command

Latest version of nrfutil trace doesn't support setting
uart baudrate.
Remove --baudrate {baudrate_val} from command that executes nrfutil.

Also, combine pytest script for:
- samples.boards.nordic.coresight_stm,
- tests.boards.nrf.coresight_stm,
to minimize code duplication (fix compliance check R0801).

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
(cherry picked from commit 153f5b6)
In order to ensure that watchdog channels are freed in proper
driver state, synchronization in form of simple loop needs
to be added after stopping. In no irq variant, it is already done
on nrfx level. NRFY function can be replaced by NRFX one in
the future.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
(cherry picked from commit b578ffa)
…ers.

When RISCV_SOC_HAS_ISR_STACKING is used, it may
be needed to initialize custom hw stacked esf members.
Some initial values may need to be aligned with
hw stacking mechanism to avoid any side effects.

Upstream PR #: 84076

Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
…n nrf54*

Add test that checks reset cause reported by HWINFO.

Check that hwinfo_get_supported_reset_cause() returns
expected value.

Check that hwinfo_get_reset_cause() correctly detects:
- RESET_PIN,
- RESET_SOFTWARE,
- RESET_WATCHDOG.

Check that reset cause can be cleared
with hwinfo_clear_reset_cause().

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
(cherry picked from commit 8f83267)
…iable"

fixup! [nrf noup] cmake: modules: kconfig: Add hide child/parent variable

This reverts commit 2483870.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…ns twister

Enables forcing use of sysbuild to build nrf5340dk/nrf9160dk
non-secure board targets when using twister

Upstream PR #: 82907

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes some issues with samples/tests by adding configuration
files to satisfy TF-M requirements

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
fixup! [nrf noup] tree-wide: support NCS Partition Manager (PM) definitions

Removes a condition in the partition manager enabled check which
was for child/parent images and keeps the sysbuild one only

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Write-back cache after copying VPR's code and data to the destination
memory. It allows VPRs to run from RAM regions cacheable by its host.

It allows to use FLPR in nRF54H20.

Upstream PR #: 84104

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
EngB+ uses 32bit bus-width stacking sequence for all VPR cores.

Signed-off-by: Karsten Koenig <karsten.koenig@nordicsemi.no>
(cherry picked from commit 6201882)
…ing the first timeout

Ref: NCSDK-31290

This ensures that the system clock is correctly updated when the first
timeout is aborted, preventing unexpected early wake-up by the system clock
programmed previously.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
(cherry picked from commit dd5f11c)
Macros for determining is low power mode shall be used where incorrect.
UARTE_ANY_LOW_POWER was taking into account only instances which had
CONFIG_UART_x_NRF_ASYNC_LOW_POWER enabled. There are also instances
with property which also can use low power mode. Created
IS_LOW_POWER_INST macro which correctly determines if instance is using
low power mode.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Low power mode for non-asynchronous API case is only available when
RX is not used (RX pin is not defined). In that case TX starting
function was using uarte_enable_locked() which tracks if UARTE is
used by TX or RX and TXSTOPPED interrupt was disabling UARTE
unconditionally. Because of that following attempt to TX start
was assuming that UARTE is already enabled when it was disabled.
Fixing it by using uarte_disable_locked function in TXSTOPPED
handling.

Code reordering was required to make uarte_disable_locked()
available earlier.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add weak functions which allows to execute custom code during
suspend or resume.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add support for getting to the lowest power mode when polling is
used with property and interrupts are not used for
that UARTE. So far disabling of the UARTE peripheral was done in
the interrupt but in some cases interrupt may not be available
and in that case uart_poll_out shall wait until byte is transferred
and put UARTE into the lowest power state.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.