Commit Graph

57512 Commits

Author SHA1 Message Date
Emil Obalski 75c0f52cca usb: Add API for getting status of remote wakeup
This change adds a posibility to check the status of
remote wakeup feature.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2021-11-09 13:50:03 +01:00
Tomasz Bursztyka 404f67ab5e tests/net: Raise TLS timeout option on waitall checks
Previous timeouts values were done when local TCP replies wourd occur
within sender's thread. This was a known behavior: no context switch,
shorter timings for sending packets (locally only) thus shorter
timeouts.

Such behavior changed when local replies had to go through TCP's work
queue. See commit 798588e709

Fixes #40129

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-09 12:51:44 +01:00
Andrzej Głąbek 760adff120 drivers: spi_context: Correct alignment of LOG_DBG() parameters
so that the call looks nicer.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Andrzej Głąbek 688d81813e drivers: spi_context: Fix handling of zero-length buffers
In some cases, it is quite useful to have the possibility to also
include zero-length buffers in a buffer set used in transfers
(for example, when frames in a protocol consist of several parts,
of which some are optional). So far, the behavior of spi_context
update functions was that the transfer in a given direction was
finished when a zero-length buffer was encountered in the buffer
set. Change those functions to simply skip such buffers. Correct
in the same way also the spi_context_buffers_setup() function.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Andrzej Głąbek 3489ca9da2 drivers: spi_context: Do not use transfer timeout in slave mode
Do not use any timeout in the slave mode, as in this case it is not
known when the transfer will actually start and what the frequency
will be.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Dominik Ermel 3614f91887 fs: fs_open will only copy flags into fs_file_t structure on success
The fs_open copies open flags into fs_file_t structure for use with
other VFS API calls; the commit moves the operation into success path.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:58:12 +01:00
Erwan Gouriou 32f61c1d71 samples: Add a stm32wb sample code for ble shutdown
Target is shutdown after 4 sec advertisement.
Wake up using reset button.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-09 05:49:23 -05:00
Erwan Gouriou b834fbf538 soc: stm32wb: Implement ble shutdown sequence
Implement platform shutdown including BLE stack reset and shutdown.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-09 05:49:23 -05:00
Erwan Gouriou bd00d4f6f9 soc: stm32wb: Factorize power procedures
Provide some factorization in pm_power_state_set procedure
to prepare shutdown case introduction.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-09 05:49:23 -05:00
Henrik Brix Andersen 5bc0451f72 drivers: can: remove DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro
Remove the DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro and replace it with
DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus)) were possible.

Where both devicetree CAN controllers and Kconfig specified CAN loopback
controllers are supported, the macro is replaced with
DT_LABEL(DT_CHOSEN(zephyr_canbus)) for now.

This is the first pass for removing the requirement for devicetree
labels for CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-09 11:19:50 +01:00
Dominik Ermel e489bb18a4 fs: Fix fs_statvfs returning 0 when statvfs not implemented
The fs_statvfs is supposed to return, as all VFS functions, -ENOTSUP
error when underlying file-system driver does not implement the
API call.
The fs_statvfs was returning 0 for success and when API call is not
implemented, which means it is indistinguishable whether stat
structure has been filled by diver with any data or not touched at all.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:19:40 +01:00
Andrew Hedin a6f831fea6 net: lwm2m: Add IPSO filling sensor object
Add support for the filling sensor object used by the MG100
and BT610 LwM2M demo.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-11-09 11:19:12 +01:00
Ryan Erickson 270608139f modem: hl7800: remove NEWLIB_LIBC dependency
Zephyr LIBC minimal has definitions for struct tm.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-11-09 11:19:02 +01:00
Ruibin Chang e505f2476a ITE drivers/timer: update timer_init() definition
Update timer_init() definition.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2021-11-09 11:18:42 +01:00
Lukasz Maciejonczyk c930262fd8 drivers: ieee802154: nrf5: refactor storing mac keys
This commit makes nrf5_config_mac_keys function more generic.
Is uses lookup table for storing keys to override. It removes old keys
before storing new ones.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-11-09 11:18:31 +01:00
Lukasz Maciejonczyk 2d7328af99 net: openthread: fix setting mac keys during stack reset in RCP
During stack reset in RCP, the mac keys are resseting my calling
otPlatRadioSetMacKey with aKeyId == 0. aKeyId == 0 was not handling
properly since it is not valid for mac keys. This commit fixes it.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-11-09 11:18:31 +01:00
Dominik Ermel 8384fdd263 mgmt/mcumgr: Fix UART processing of TX frames
The commit fixes problem with UART TX frame processing, which was
caused by incorrect output buffer size evaulation, where input buffer
of certain len would cause entire output frame to be filled with no
place left for CRC causing a transmission to hang.
The commit, additionally, moves input buffer reminder processing out of
the input buffer processing loop.

Fixes #37893

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:17:29 +01:00
Dominik Ermel 5c9984baf7 mgmt/mcumgr: Simplify mcumgr_serial_tx_pkt
Removed some of variables used within the function, and some of
the redundant arithmetic operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:17:29 +01:00
Emil Gydesen e748e76988 Bluetooth: Audio: Move csis.h to include/bluetooth/audio
Move the header file csis.h from the internal location to
the public include directory. This file is supposed to provide
the public API for CSIS and the CSIS client, but is not fully
complete yet.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Emil Gydesen fa1a7a723e Bluetooth: Audio: Add CSIS BSIM tests
Add a couple of babblesim tests for the CSIS server
and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Emil Gydesen dd519f2a10 Bluetooth: Audio: Add CSIS client shell
Add support for the CSIS client shell to interactively
use the CSIS client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Emil Gydesen 9f728d54de Bluetooth: Audio: Add CSIS shell
Adds the CSIS shell implementation, to interactively control
the CSIS server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Emil Gydesen c7b49cf1e4 Bluetooth: Audio: Add coordinated sets identification service client
Adds the coordinated set identification service (CSIS) client.

    This is still a work in progress and thus there are no public
    API for it yet, and some code changes will still be needed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Emil Gydesen d55aeb4a1e Bluetooth: Audio: Add coordinated sets identification service server
Adds the coordinated set identification service (CSIS) server.

This is still a work in progress and thus there are no public
API for it yet, and some code changes will still be needed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-09 11:17:20 +01:00
Erik Brockhoff 613ff42277 Bluetooth: controller: support not passing invalid SDUs on HCI datapath
Adding a KConfig to allow for disabling of the passing of invalid SDUs
through the ISOAL HCI data path.

Defaults to keeping current behavior.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2021-11-09 11:16:49 +01:00
Andrzej Głąbek f7466d28fd drivers: spi_nrfx_spim/spi: Fix initialization of CS GPIOs
This is a follow-up to commits 99daca9bba
and ae03c0a6bf.

nRF SPI driver shims cannot use devicetree instance indexes, they need
to use the DT_NODELABEL macro and SoC peripheral instance indexes.
Correct the macros used in initialization of CS GPIOs in those shims.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 11:11:19 +01:00
Gerard Marull-Paretas 6d269fcedc doc: reference: api: overview: fix reference to pinctrl
A space between :ref: and the actual reference prevented the reference
to be rendered correctly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-09 11:05:51 +01:00
Gerard Marull-Paretas f6bff715a9 doc: guides: pinctrl: fix DT sample code
Pre-defined nodes need to be children of the pin controller device.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-09 11:05:51 +01:00
Andy Ross 1238410914 arch/x86_64: Add hook for CONFIG_SCHED_THREAD_USAGE accounting in ISRs
Call into z_thread_usage_stop() before ISR entry to avoid including
interrupt handling totals in thread usage stats.

This has to go into the assembly immediately before the callback-based
dispatch.  Note that the dispatch code was putting the vector number
in RCX, which was unfortunate as that's a caller-saved register.
Would be nice to clean this up in the future so it lives in a
preserved register but it's mildly complicated to make work with the
way we do the stack layout right now.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 76b848e38c arch/sparc: Add hook for CONFIG_SCHED_THREAD_USAGE accounting in ISRs
Call into z_thread_usage_stop() before ISR entry to avoid including
interrupt handling totals in thread usage stats.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross c815996606 arch/arc: Add hook for CONFIG_SCHED_THREAD_USAGE accounting in ISRs
Call into z_thread_usage_stop() before ISR entry to avoid including
interrupt handling totals in thread usage stats.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 35af02fe3d arch/arm64: Add hook for CONFIG_SCHED_THREAD_USAGE accounting in ISRs
Call into z_thread_usage_stop() before ISR entry to avoid including
interrupt handling totals in thread usage stats.

This is pretty much exactly where we want it, just after the context
saving steps (which we can't elide since the hook is in C) and
immediately before the tracing hook for ISR entry.  And as I'm reading
the code, this is purely for Zephyr-registered interrupts, meaning
that software exceptions will be accounted for (correctly) as part of
the excepting thread.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 410f911018 kernel/sched: Separate idle from app thread stats in THREAD_USAGE
It turns out that we have a sample (though not a test) that really
does want to use "k_thread_runtime_stats_all_get()" to measure system
uptime.

Instead of breaking this needlessly, separate the accounting for idle
and non-idle threads.  The legacy API can report their sum, and the
more useful value is available via the kernel struct for future
analysis.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 904a6c0319 tests/thread_apis: Fix whitebox assumptions in runtime_stats test
The thread_apis tests of the RUNTIME_STATS feature weren't really
testing the right behavior.

+ It assumed that accounting would only happen at context switch time
  and required that the returned values not change for running threads
  (even CLEARLY running threads like _current!).  But that's not a
  documented feature!  It's actually sort of a wart that we'd like to
  be able to fix (and have fixed, the new backend returns realtime
  values so you can track CPU-bound processes on another CPU).

+ It assumed that k_thread_runtime_stats_all_get() would return time
  that includes idle time (or conversely it forgot that
  k_thread_foreach enumerates over idle threads).  This was sort of a
  bug in the original (because it means that the result is always the
  system uptime multiplied by the number of CPUs)

Broadly, instead of testing the result of a "time" function for
equality (never a good idea) test it via appropriate bounds given the
usage.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross f169c5bc13 kernel: Swap RUNTIME_STATS implementation
Clean up RUNTIME_STATS to separate the API from the individual data
backends.  Use the SCHED_THREAD_USAGE tracking instead of the original
for execution_cycles.  Move the kconfig for that into the runtime
stats menu, since it's part of the family now.

Also remove a lot of needless #if's around the declarations.  Unused
structs and uncalled functions don't need to be explicitly hidden.  An
attempt to access a non-existent field (e.g. "execution_cycles" if
that isn't configured) provides all the build time validation we need.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 52351458f4 kernel/sched: Add timing.h support to thread_usage
The runtime stats feature has always supported this, so use the same
kconfig to indirect the timing source in the same way.

(Personally I'm not a fan of the "timing" API, which really doesn't do
anything that the existing core "cycles" API does not except add a
bunch of code due to the separate implementation of frequency
management and conversion routines.  It comes from an era where
"cycles" were fixed to a MHz frequency clock on platforms like x86 yet
we had benchmarks that wanted to use the TSC.  Those days are behind
us and "cycles" can be fast everywhere.)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross b62d6e17a4 kernel/sched: Add an optional "all" counter for thread_usage
Tally the runtime of all non-idle threads.  Make it optional via
kconfig to avoid overhead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 4ae3250301 sched: Hook SCHED_USAGE from existing tracing hook
On older architectures, we don't have the
architecture-independent/scheduler-internal hooks (which require
USE_SWITCH) but there is a hook shared by the tracing layer we can use.

This is sort of a layering violation (stat tracking is a core feature,
tracing is supposed to be optional), but simple and lightweight.  And
eventually it will go away as these architectures migrate.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 884f1bf39d arch/xtensa: Add hook for CONFIG_SCHED_THREAD_USAGE accounting in ISRs
Call into z_thread_usage_stop() before ISR entry to avoid including
interrupt handling totals in thread usage stats.

Note that this hook is after the register save and stack swap has
happened, so it still incldues some overhead.  But calling out from
the interrupted stack on Xtensa gets really, really hairy due to the
weird intermediate states we leverage (once we've saved enough context
to make a C call safely, we've lost the ability to use register
windows per the C ABI!).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Andy Ross 40d12c142d kernel/sched: Add "thread_usage" API for thread runtime cycle monitoring
This is an alternate backend that does what THREAD_RUNTIME_STATS is
doing currently, but with a few advantages:

* Correctly synchronized: you can't race against a running thread
  (potentially on another CPU!) while querying its usage.

* Realtime results: you get the right answer always, up to timer
  precision, even if a thread has been running for a while
  uninterrupted and hasn't updated its total.

* Portable, no need for per-architecture code at all for the simple
  case. (It leverages the USE_SWITCH layer to do this, so won't work
  on older architectures)

* Faster/smaller: minimizes use of 64 bit math; lower overhead in
  thread struct (keeps the scratch "started" time in the CPU struct
  instead).  One 64 bit counter per thread and a 32 bit scratch
  register in the CPU struct.

* Standalone.  It's a core (but optional) scheduler feature, no
  dependence on para-kernel configuration like the tracing
  infrastructure.

* More precise: allows architectures to optionally call a trivial
  zero-argument/no-result cdecl function out of interrupt entry to
  avoid accounting for ISR runtime in thread totals.  No configuration
  needed here, if it's called then you get proper ISR accounting, and
  if not you don't.

For right now, pending unification, it's added side-by-side with the
older API and left as a z_*() internal symbol.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Flavio Ceolin 0c1835052a tests: pm: power_mgmt: Check device runtime pm integration
Check if the system power management does not interfere with a device
when it has enabled device runtime PM.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-08 19:54:12 -05:00
Flavio Ceolin 9452650aff pm: Handle devices with device runtime enabled
Do not suspend a device if it has device runtime enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-08 19:54:12 -05:00
Flavio Ceolin b2aa5feb9d pm: device: runtime: Add API to check if it is enabled
Add a new API to check if a device has device runtime feature enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-08 19:54:12 -05:00
Kevin Townsend a8c9cf0b0a west.yml: Add zscilib reference
Adds a reference to zscilib, now that it's available under
zephyrproject-rtos/zscilib.

Signed-off-by: Kevin Townsend <kevin@ktownsend.com>
2021-11-08 19:11:31 -05:00
Benjamin Lindqvist 0ab1bf42b3 drivers: sensor: lis2dh: Level triggered interrupts
Both DRDY and motion interrupts behaves like level signals since they
remain asserted until they're cleared. Configuring them as edge
interrupts is dangerous because if we ever miss an interrupt, it may
never get cleared and thus will never trigger again.

Treating them as edge signals seems to have no advantages, other than
being marginally simpler to implement.

The patch has gotten many hours of run-time on real hardware using a
nRF52-based board and a LIS3DH with both interrupts connected and
heavily utilized.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2021-11-08 15:37:57 -06:00
Martin Jäger 3c450b103e MAINTAINERS: add task_wdt maintainer
Add myself (original author) as the maintainer of the task watchdog.

Also including myself as a collaborator to the hardware watchdog
driver, as task watchdog and hardware watchdog are closely related.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-11-08 16:29:08 -05:00
Torsten Rasmussen 9c74027a7b cmake: CMake linker script generator pass handling
To prepare for linker script creation with flexible number of linker
passes depending on system configuration then the Zephyr CMake linker
script generator has been updated to use pass names instead of pass
numbers.

This allows greater flexibility as a section can now be active based on
the settings on the pass and not the linking pass index number.

As part of this, the `PASS` processing in `linker_script_common.cmake`
has been adjusted so that it properly handles when a linking pass is
handling multiple settings, such as both `LINKER_APP_SMEM_UNALIGNED`
and `DEVICE_HANDLES_PASS1` in same linking pass.

As the number of linking passes are more flexible, then the PASS
argument in `zephyr_linker_section()` and
`zephyr_linker_section_configure()` has been updated to also support
a `NOT <name>` argument, for example: `PASS NOT LINKER_ZEPHYR_FINAL`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-08 20:45:07 +01:00
Torsten Rasmussen 47304d4167 cmake: CMakeLists.txt cleanup for kobj_hash
This commit clean up the creation and use of kobj_hash_output_lib and
kobj_prebuilt_hash_output_lib libraries.

It also removes the use of kobj_hash_output_lib_interface and
kobj_prebuilt_hash_output_lib_interface interface libraries.
The kobj_hash_output_lib_interface was originally introduced as part
of the KBuild re-write 12f8f76165 where
the interface lib was used to ensure compile definition order on build
invocation.
However, this became obsolete with the commit
4b3c7b3d17 as that commit moved the
compile flags from the interface lib to directly set them using the
`set_source_files_properties()` function.

Therefore the interface libs have now been removed and instead include
directories and compile definitions are added to the kobj hash libraries
using generator expression.
Using generator expressions further remove the need for `get_property()`
on the zephyr interface library.

The kobj hash libraries has been changed from a STATIC library because
it is not linked as a library anywhere. Only the object files
kobject_hash.c.obj and kobject_prebuilt_hash.c.obj are used by custom
commands. Using an CMake object library removes the need for knowing the
final location and name of the object file as this can be retrieved
directly from the object library when needed using: `TARGET_OBJECTS`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-08 20:45:07 +01:00
Torsten Rasmussen 1fa3f15137 cmake: update configure_linker_script() to prepend `-D` on defines
Currently all calls to `configure_linker_script()` specifies `-D<name>`
when calling `configure_linker_script()`.

This works well for the gcc pre-processed ld linker script templates,
but Zephyr also supports a CMake linker script generator which can be
used for ld scripts and armlink scatter files.

In this case, a `-D` must be stripped.

This commit changes this so that Zephyr CMake build system calls
`configure_linker_script()` without `-D`.
Thus the `LINKER_SCRIPT` choice can decide how this information should
be passed to underlying linker script functionality, that is `-D` for
linker script template and CMake variable for the CMake linker script
generator.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-08 20:45:07 +01:00
Christopher Friedt 43856f2dc6 samples: kernel: add cycle64 sample
The cycle64 sample is intended to complement
`test_clock_cycle_64()` in `tests/kernel/common`.

The sample demonstrates the upper 32-bits of the 64-bit cycle
counter incrementing when the bottom 32-bits roll over from
`UINT32_MAX` to 0.

If the upper 32-bits of the 64-bit cycle counter does not
increment, then an error message is printed.

```
west build -p auto -b qemu_cortex_a53 -t run \
	samples/kernel/cycle64
...
*** Booting Zephyr OS build v2.7.99-1124-gd7ba4e394832  ***
wrap-around should occur in 68s
[ddd:hh:mm:ss.0ms]
[000:00:00:00.020]: c64: 0000000000174258
[000:00:01:08.760]: c64: 000000010027f8bb
[000:00:02:17.490]: c64: 0000000200348c85
```

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-08 13:41:53 -05:00