Commit graph

8529 commits

Author SHA1 Message Date
Henrik Brix Andersen
b1b77c1774 drivers: can: change can_tx_callback_t function signature
Change the can_tx_callback_t function signature to use an "int" (not an
uint32_t) for representing transmission errors.

The "error" callback function parameter is functionally equivalent to
the return value from can_send() and thus needs to use the same data
type and needs to be able to hold negative errno values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-01 07:40:29 -05:00
Gerard Marull-Paretas
5dc6ed3ce3 pinctrl: require ; after PINCTRL_DT_(INST_)DEFINE macros
The PINCTRL_DT_(INST_)DEFINE macros already defined the trailing ;,
making its usage inconsistent with other macros such as
DEVICE_DT_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-01 07:39:08 -05:00
Mark Holden
7803a4e590 arch: riscv: ARCH_EXCEPT macro
Enable ARCH_EXCEPT macro for non-usermode scenario for RISC-V
Macro will now raise an illegal instruction exception so that mepc will
hold expected value in exception handler, and generated coredump can
reconstruct the failing stack

Coredump tests running on renode (for RISC-V) can now utilize fatal error
path through k_panic

Signed-off-by: Mark Holden <mholden@fb.com>
2022-01-01 07:38:20 -05:00
Piotr Pryga
61872da64e Bluetooth: host: Add API to run conn CTE response HCI command
Add host API to allow execution of HCI_LE_Connection_CTE_Response_-
Enable HCI command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-31 17:45:52 +02:00
David Brown
fac2c22824 storage/flash_map: Use larger type for alignment
In MCUboot:
    commit 4aa286d2db2d02a8f0ff29cdc3304f3185dbe261
    Author: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
    Date:   Wed Nov 24 14:54:56 2021 -0300

        flash_map: Increase minimum supported write align via
            flash_area_align

MCUboot changed the type of the alignment value in flash from a uint8_t
to a uint32_t.  Indeed, Zephyr contains flash devices that have a larger
alignment than will fit in an 8-bit value.  This generally means that
`flash_area_align` will just return 0 on these platforms.

Change call in Zephyr as well.

This shouldn't cause any observable behavior changes in Zephyr, other
than making some cases that don't work currently begin to work.  If a
client is storing these results in a u8, it will be truncated, the same
as things were previously.  If, however, the caller is prepared to
handle a larger type, this will result in having correct information,
instead of the truncated value.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-12-30 16:32:02 -05:00
Vinayak Kariappa Chettimada
1686551395 Bluetooth: Add defines for Periodic Advertising Receive Enable
Add defines for Periodic Advertising Receive Enable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Gerard Marull-Paretas
e8bcaff0ee device: deprecate SYS_DEVICE_DEFINE
Deprecate the SYS_DEVICE_DEFINE macro in favor of SYS_INIT.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-24 20:59:10 -05:00
Carlo Caione
67ef1df950 mbox: Enforce callback registration before enabling the channel
Specify in the API that the callback must be registered before the
channel is enabled, fix the NRFX IPC driver to be compliant and change
the MBOX sample.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-12-23 12:38:21 +01:00
Erwan Gouriou
18d35163b8 include/drivers/clock_control: stm32h7: Add missing symbol PLL SRC CSI
Symbol STM32_PLL_SRC_CSI was missing and was preventing the config
to be used.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-12-23 10:37:22 +01:00
Henrik Brix Andersen
f92542ecf3 drivers: can: deprecate the can_attach_workq() API call
Deprecate the can_attach_workq() API call.

This API is limited in its functionality (it does not work with
userspace, it uses one common buffer size for all work queue instances).

Similar functionality can easily be implemented using the
can_attach_msgq() API along with the generic triggered work API
(e.g. using k_work_poll_submit()).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-22 18:04:02 +01:00
Tomasz Bursztyka
c1bc5db795 drivers/pcie: Use the generic arch-interface for allocating IRQs
PCIE now uses the new interface. And pcie_alloc_irq() is only made
available when CONFIG_PCIE_CONTROLLER is unset. So only for x86 atm.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-12-22 12:16:52 +01:00
Tomasz Bursztyka
b99eaca729 sys/arch: Add new interfaces for allocating and checking IRQs
Current usage was being limited to PCIE but there are new use case
that demand for this feature to be generalized.

It is made arch-specific since allocation policy may vary
per-architecture.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-12-22 12:16:52 +01:00
Gerson Fernando Budke
1212ea0c39 riscv: linker.ld: Fix undefined reference linker error
The commit a28830b aligned the data and rename some symbols.  However
there are two symbols at riscv linker script that were missing, which
causes below linker error:

kernel/xip.c:28: undefined reference to `__itcm_load_start'
kernel/xip.c:43: undefined reference to `__dtcm_data_load_start'

Rename below symbols to fix the issues.

__itcm_rom_start -> __itcm_load_start
__dtcm_data_rom_start -> __dtcm_data_load_start

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-12-21 17:07:20 +01:00
Nicolas Pitre
a3a31257df net: npf: add the ability to do MAC address masked matching
Add the ability to do matching on partial MAC addresses.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-12-21 17:06:35 +01:00
Nicolas Pitre
faa0b2a848 net: introduce a network packet filter framework
This provides the infrastructure to create network packet filter rules
and to apply them to the RX and TX packet paths. Rules are made of
simple condition tests that can be linked together, creating a facility
similarly to the Linux iptables functionality.

A couple of generic and Ethernet-specific condition tests are also
provided.

Additional tests can be easily created on top of this.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-12-21 17:06:35 +01:00
Michal Ciesielski
8b3d7f2a43 net: lwm2m: Add LWM2M object 9 software management
Adds support for LWM2M object 9 Software management.
This is implemented according to this release:
http://openmobilealliance.org/release/LWM2M_SWMGMT/V1_0_1-20200616-A/

Note that the XML is lacking some resources and for that reason those
resources are not included. This is a known problem by OMA and will be
fixed in a later releases.

This uses the lwm2m_pull_context to pull binaries in case
FIRMWARE_PULL_SUPPORT is enabled

Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
2021-12-21 13:36:50 +01:00
Krzysztof Chruscinski
62b57651e8 logging: Cleanup in log_instance
Cleanup in log_instance.h:
 - prefixing internal macros with Z_
 - adding doxygen documentation
 - using COND_CODE_1 instead of ifdefs

Additionally, added LOG_INSTANCE_PTR macro which allows to get
pointer to instance. It can be used to reuse single instance
for multiple module layers when doing instance logging.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-12-21 09:36:09 +01:00
Carles Cufi
38ce8d615d Revert "drivers: timer: extend nrf_rtc_timer"
This reverts commit 26e297572a.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-20 21:04:26 +01:00
Yong Cong Sin
26f7b9c1ea drivers: sensor: Add MH-Z19B CO2 sensor driver
Add MH-Z19B CO2 sensor driver.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Co-Authored-By: Azamlukman <azamlukmanabdullah@gmail.com>
2021-12-20 18:47:47 +01:00
TOKITA Hiroshi
5c7a0ef888 drivers: interrupt-controller: add Nuclei ECLIC driver
Add support for the ECLIC interrupt controller
which is used with the Nuclei processor core.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2021-12-20 17:51:30 +01:00
TOKITA Hiroshi
949d4b91d9 drivers: pinctrl: Support pinctrl with GD32VF103
Change the settings to support pinctrl on the GD32VF103.

- Split soc/arm/gigadevice/common/pinctrl_soc.h
  and put it into include/dt-bindings.
- Leave some definitions that can't handle with device tree compiler
  in pinctrl_soc.h.
- Remove dependency to SOC_FAMILY_GD32 because always enabled it
  if GD32_HAS_AF(IO)_PINMAX was selected.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2021-12-20 17:51:30 +01:00
TOKITA Hiroshi
d79d4f0bea riscv_machine_timer: Enable to use divided clock for the machine timer
GD32V SoC uses divided clock from core-clock for machine timer clock.
Add config of clock divide factor to support GD32V.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2021-12-20 17:51:30 +01:00
Hou Zhiqiang
2fafd8559f net: socket: packet: Add EtherCAT protocol support
Add EtherCAT protocol support, now applications can
transmit/receive EtherCAT packets via RAW socket.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
2021-12-20 17:49:10 +01:00
Lukas Gehreke
53dea67733 drivers: modem: Added simcom sim7080 modem driver.
Implemented driver for the simcom sim7080 modem.
This driver features Socket offloading, TCP, UDP, DNS,
SMS, GPS and FTP.

Signed-off-by: Lukas Gehreke <lk.gehreke@gmail.com>
2021-12-20 17:48:47 +01:00
Martí Bolívar
4f8f55e0d9 device.h: clean up doxygen comments
The doxygen comments contain errors, grammar problems, and other
issues. Additionally, some internal macros have doxygen comments
instead of "plain" C comments. The docstrings also sometimes omit
important information.

Give the header a once-over to try to improve the situation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-20 17:42:08 +01:00
Jedrzej Ciupis
26e297572a drivers: timer: extend nrf_rtc_timer
This commit introduces the following changes:

* nrf_rtc_timer is extended with a capability to handle RTC overflow,
allowing it to operate on absolute RTC ticks, rather than relative
ticks.
* overflow handling is ZLI-proof and relies on the sys clock
handler being executed twice every RTC counter's overflow.
* callbacks are given an absolute RTC tick value as a parameter instead
of CC register's value. The absolute RTC tick value is the RTC counter
value set during CC channel configuration extended to 64 bits.
* in case the timer's target time is in the past or is the current tick,
the timer fires as soon as possible, however still from the RTC's ISR
context.
* in case an active timer is set again with the same target time, it is
not scheduled again - only its event data is updated. Otherwise, the
timer is scheduled as usual.
* a scheduled timer can be aborted.
* system clock functions are now using 64 bit values internally.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Paweł Kwiek <pawel.kwiek@nordicsemi.no>
2021-12-20 16:25:49 +01:00
Damian Krolik
3aedda9852 lib: os: add heap event listener
* add generic heap event listener module that can be used
  for notifying an application of heap-related events
* use the listener module in newlib libc hooks
* add a unit test

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2021-12-18 07:49:15 -05:00
Jimmy Johnson
5c28b218fa drivers: sensor: add ti tmp108 driver support
Adding support for the TI TMP108 temperature sensor. This includes
over/under temp interrupt support as well as one shot, continuous
conversion and power down modes.

Signed-off-by: Jimmy Johnson <catch22@fastmail.net>
2021-12-17 21:15:25 +01:00
Gerard Marull-Paretas
14860d8a97 devicetree: add DT_INST_PARENT helper
Provide the instance based version of the DT_PARENT macro.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 11:10:01 -06:00
Gerard Marull-Paretas
91b8abfb4d pm: device_runtime: suspend device on enable
The pm_device_runtime_enable did not suspend devices, so it assumed that
the device was in a physically suspended state. This change makes sure
that device is left in a suspended state if the device is initially
active.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 10:41:04 +01:00
Gerard Marull-Paretas
d6ebab55f3 pm: device_runtime: add pm_device_runtime_init_suspended
By default device state is initialized to PM_DEVICE_STATE_ACTIVE. In
general, this makes sense because the device initialization function
will resume and configure a device, leaving it operational. However,
when device runtime PM is enabled, the device may not be resumed and the
init function will just enable device runtime PM. If that is the case,
this function can be used to set the initial device state to
PM_DEVICE_STATE_SUSPENDED.

Documentation has been updated to comment on this case, and example code
has been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 10:41:04 +01:00
Gerard Marull-Paretas
59b455eb9c pm: device_runtime: simplify error handling for get/put
In case runtime PM is not enabled (or not built-in), the get/put
functions always return 0 (instead of -ENOTSUP/-ENOSYS). When runtime PM
is disabled, a device is left into active state. Similarly, when device
runtime PM is not built-in, it is safe to assume that a device will
be active when it is called. If a user implements a custom solution, it
is its responsability to make sure that a device is active when using
it. For all these reasons, the -ENOTSUP/-ENOSYS are error codes that
should always be ignored by devices using get/put, since in practice it
means that: device is active, function is a no-op. The example below
illustrates how error handling is simplified:

```c
/* before: safe to ignore -ENOSYS/-ENOTSUP since device is active (we
 * can continue)
 */
ret = pm_device_runtime_get(dev);
if ((ret < 0) && (ret != -ENOSYS) && (ret != -ENOTSUP)) {
	return ret;
}

/* now */
ret = pm_device_runtime_get(dev);
if (ret < 0) {
	return ret;
}
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 10:41:04 +01:00
Michał Narajowski
ef1fcd0e82 Bluetooth: Mesh: Fix Config/Health Client async API
The previous PR was not fully baked, so this PR fixes issues by:
- Adding checks when dereferncing pointers stored in params.
- Clearing ack context if a return argument is NULL to not block and
wait for response.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-16 10:15:36 +01:00
Tom Burdick
0513b242d4 docs: Adds syscall tracing to tracing docs
Tracing guide in the docs was missing references to the added tracing
syscall macro hooks. This adds those.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2021-12-15 16:51:31 -05:00
Andy Ross
6dfb16a3d9 arch/xtensa: Fix cache.h include dependency
This file started using ALWAYS_INLINE from <toolchain.h> but didn't
include it.  Transitive inclusions were hiding the problem most
places, but at least one test case exposes it.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-12-15 16:50:11 -05:00
Flavio Ceolin
94647d8e67 pm: device: Account state locked in action_run
Similar what is done in pm_device_state_set, checking if the power
state for a given device in pm_device_action_run is locked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-12-15 16:47:01 -05:00
Chris Trowbridge
ac28f8ddde boards: arm: Add NXP i.MX8M Plus EVK board support
Add board support for NXP i.MX8M Plus EVK. This board has the following
features:

Processor    : i.MX8M Plus Quad applications processor
Memory       : 32-bit LPDDR4 w/6 GB
               eMMC 5.0/5.1 w/32 GB
               SD/MMC connector
               QSPI w/32 MB
Connectivity : MIMO 2x2 Wi-Fi 802.11b/g/n/ac and BT 4.2
               2x Ethernet (1x w/ TSN)
               PCIe M.2
               2x CAN FD DB9 Female connectors
USB          : USB 3.0 Type C for Power
               USB 3.0 Type A
               USB 3.0 Type C
Debug        : JTAG connector
               MicroUSB for debug console

More information about this board can be found in NXP website: https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/evaluation-kit-for-the-i-mx-8m-plus-applications-processor:8MPLUSLPD4-EVK

Signed-off-by: Chris Trowbridge <chris.trowbridge@lairdconnect.com>
2021-12-15 13:15:00 -06:00
Gerard Marull-Paretas
4cc018bcd6 pm: policy: header cleanup
Include just the necessary headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-15 11:27:39 +01:00
Andy Ross
79746d701b arch/xtensa: Make cache utilities ALWAYS_INLINE
These are tiny functions always declared as "inline" per C99, but
that's just a hint.  In practice, they tend to be (c.f. intel_asdp)
called from very early boot circumstances where main application
symbols aren't yet available.  That obviously doesn't work, or even
link.

Make them ALWAYS_INLINE.  In practice they're so small that we don't
want them called anyway just for stack space reasons.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-12-14 18:43:05 -06:00
Flavio Ceolin
18b932f10d pm: device_runtime: Return possible error on enable
Change the function pm_device_runtime_enable() to return 0 on
success or an error code in case of error.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-12-14 19:23:05 -05:00
Flavio Ceolin
0a32eadd13 pm: Account device pm state lock
Do not execute pm operations on devices that the device pm state is
locked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-12-14 19:23:05 -05:00
Flavio Ceolin
097e08c71a pm: device: Add device pm state lock
Add a new API to lock a device pm state.

When the device has its state locked, the kernel will no longer
suspend / resume devices when the system goes to sleep and device
runtime power management operations will fail.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-12-14 19:23:05 -05:00
Bartosz Bilas
0bd304f9d9 drivers: sensor: ina23x: add support for INA237
Add the new driver for INA237 variant which is
quite similar to the already supported INA230.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-12-14 13:48:54 -06:00
Bartosz Bilas
2df7140947 drivers: sensor: ina230: driver refactoring
Create an explicit ina230 driver which is supposed to
work with 230 and 231 variants. While at it switch
to i2c_dt_spec helpers and change device-tree node
names to use - instead of _ in order to follow
convention.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-12-14 13:48:54 -06:00
Yuval Peress
7b86137b6c fatal: fix missing extern "C"
This was causing an error when building with pigweed as a module.

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00
Yuval Peress
56beca3828 sys: cbprintf: Fix unused arg warning
Missed unused arg, throws warning when compiling with
-Wunused-parameter.

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00
Yuval Peress
9103bf8230 assert: Add missing include
printk is used if CONFIG_ASSERT_VERBOSE is set but was missing an import

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00
Yuval Peress
e84a48d8b8 cbprintf: Fix unused arg warning
This was found when building with `-Wextra` enabled.

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00
Yuval Peress
50a89ce287 zephyr: fix errors when building with -Wundef
Several points check the value of CONFIG_s without first checking that
they're defined. This causes an warning when adding -Wundef to the
build.

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00
Yuval Peress
8aa2c3f3d1 sys: Fix warning for stripped const qualifier
This causes an issue when compiling with `-Werror=cast-qual`

Signed-off-by: Yuval Peress <peress@google.com>
2021-12-14 11:47:13 -06:00