Commit graph

46465 commits

Author SHA1 Message Date
Anas Nashif fe07d57e80 sanitycheck: error out if we do not find any tests
If we find no tests, error out instead of exiting silently.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-01 15:36:19 -05:00
Anas Nashif 743594faae sanitycheck: print pid of qemu process when debugging
For debugging, print the PID of the qemu running.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-01 15:36:19 -05:00
Peter Bigot 6918e3def3 devicetree: gpio: provide accessors for controller phandle
Provide a helper to extract the devicetree node_id for a GPIO
controller from a gpio phandle array.  This can be used with
DEVICE_DT_GET() to directly reference the corresponding controller
device.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 63638ceed6 shell: use public API to check device readiness
Avoid the private API now that there's a public equivalent.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot c2d852a171 device: refactor to allow direct access to devicetree device structures
When using a devicetree node as an identifier we know the identifier
used to define the device structure.  This allows code to directly
reference that structure, avoiding the need to look it up by label at
runtime.

Change the macros so DEVICE_DT_* device objects are globally visible
using the node identifier as the object identifier.

Also add the necessary API to verify that a device that was captured
at build time successfully completed initialization and any other
steps necessary before it can be safely used.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot d721b7a6ab drivers: spi: convert nrf drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot cf33927933 drivers: serial: convert nrf drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot f3db8f5acc drivers: sensor: ccs811: convert to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot d9e45b579a drivers: regulator: convert to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 63043bc5ac drivers: i2c: convert nrf drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 1240c28bce drivers: gpio: convert nrf driver to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 13048b1a5a drivers: flash: convert spi-nor drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 7f1b18da70 drivers: clock_control: convert nrf to dt device defines
Use the clock devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot 50d67838aa device: redefine devicetree device definition using a more generic API
For devices defined using devicetree nodes we need to pass the
devicetree node, and to infer names for the device and the driver from
it.  Devices defined in the classical way don't need this.  Introduce
another level of private abstraction that accepts the information from
either source, falling back to the old parameters when the provided
node is invalid.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Peter Bigot e643ee26a7 device: provide API that uses the devicetree node as identifier
The dev_name is the canonical DT node identifier encoding the
devicetree path; the drv_name is the label of the corresponding node.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Abhishek Shah 4d7e88b4dc drivers: pcie_ep: iproc: Remove sys_read8 from unmap API
Originally, sys_read8 to the mapped address was added part of
the unmap API to protect OMAP mapping, i.e. in case of PCIe writes,
OMAP should not be overwritten before writes are completed.

Now that we have added dummy PCIe read in the common APIs, namely
pcie_ep_xfer_data_memcpy and pcie_ep_xfer_data_dma, for the purpose
of flushing PCIe writes; the purpose of protecting OMAP *also*
gets satisfied, randering PCIe read in the unmap useless,
so remove the same.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Abhishek Shah f66e5c4cb0 drivers: pcie_ep: Add API to achieve data transfer with system DMA
Introduce common API to achieve data transfer using system DMA.
"System DMA" uses the outbound memory mapped Host address,
it cannot understand Host/PCIe address.

This API will take of mapping the Host address, completing
the data transfer to/from Host memory and unmapping the window;
thus providing abstraction to the user.

Since v1:
- refactored code for the cases where we have valid mapped_addr
  to improve error management logic

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Abhishek Shah 077522e6bb drivers: pcie_ep: iproc: Add support for PL330 DMA
Once host memory is mapped to outbound memory, PL330 can be used to
transfer data between outbound memory and local memory.

Add API for the same, we get pl330 device as well as channels to be
used for tx/rx from DT and use DMA public APIs for data transfer.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Abhishek Shah 7bce8406d6 pcie: endpoint: Add public API for data transfer with System DMA
For a given PCIe EP device, data transfer to/from Host memory can be
achieved with "System DMA" between mapped Host memory
(PCIe outbound memory) and EP device's local memory if EP is equipped
with a "System DMA controller".
Add public API to enable such DMA transfers.

The term "System DMA" is used to clarify that we are not talking about
dedicated "PCIe DMA"; rather the one which does not understand PCIe
address directly, and uses the mapped Host memory.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Abhishek Shah c382376bdf dts: arm: viper: Add tx/rx pl330 channels for iProc PCIe node
Add tx/rx pl330 channel IDs for the iProc PCIe client usage.
pl330 channel 0 is allocated for Tx DMA (Device to Host write) and
pl330 channel 1 is allocated for Rx DMA (Host to Device read).

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Abhishek Shah 0ffea47bca dts: bindings: pl330: add dma-cells property
Add dma-cells property in pl330 dma binding document.
Currently only one integer cell with "channel" name is
added in order for the client to specify channel id
to be used for data transfer out of available channels.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-12-01 14:56:59 -05:00
Carles Cufi 0d02de6113 doc: script: Default to empty string in DT docset env var
Windows does not default to an empty string when an env var is not
declared, like Linux does. Instead, explicitly default to one in order
for the .strip() call to work properly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-12-01 14:55:19 -05:00
Peter Bigot 7a23490087 drivers: counter: stm32_rtc: remove dependency on maximal libc
mktime() was being used to convert from struct tm to time_t, but
Zephyr now has functions for that.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 14:54:12 -05:00
Peter Bigot 509a26304b drivers: counter: stm32_rtc: clarify epoch for time_t vs RTC
time_t always measures as seconds since 1970-01-01T00:00:00Z.  Fix a
comment that identified the wrong epoch year, and document what the
value of the offset means.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 14:54:12 -05:00
Robert Lubos b27c14e355 net: lwm2m: Verify if block transfer is used before skipping TLV parsing
Verify if block tranfer is used and not an initial block when skipping
directly to data processing during FW update in PUSH mode.

This fixes a bug, which caused TLV not to be processed when the FW
object was updated as a whole, and actual resource number was encoded in
a TLV (for instance when writing FW Update URI).

Fixes #30135

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-01 11:26:55 -05:00
Flavio Ceolin b6ef0c0d94 random: ctr_drbg: Fix the error path in sys_csrand_get
When ctr_drbg_initialize fails the function returns without unlock irq
that was previously locked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-12-01 10:20:06 -06:00
Flavio Ceolin 6ac3d0b5b1 random: ctr_drbg: Check entropy_get_entropy return
entropy_get_entropy return is not being checked what may result in a
vulnerability because tc_ctr_prng_reseed will not get proper entropy
data.

Fixes #29869

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-12-01 10:20:06 -06:00
Robert Lubos 1c8f52a670 net: lwm2m: Rework bootstrap DELETE operation
Rework the bootstrap DELETE operation, to support deletion of multiple
resources.

Current implementation had several oversimplifications, making it not
spec-compliant:
* DELETE `/` removed only Security object instances (!= 0)
* DELETE `/x` was handled as DELETE `/x/0`, therefore not removing all
  of the object instances.

Since the above is only supported during bootstrap and not regular
Device management, this functionality was implemented in the
`bootstrap_delete` function, which now will be called for all DELETE
operations initiated during bootstrap. The regular LwM2M DELETE handler
will only be called during regular Device management, as it has more
strict limitations on what can be deleted.

Additionally, handle empty URI Path option as `/`, therefore indicating
deletion of all resources.

Fixes #29964

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-01 11:17:12 -05:00
Marcin Niestroj 03ce61004b drivers: wifi: esp: control CWMODE depending on current needs
So far ESP chip was configured directly into STA mode. This works fine,
but consumes lots of power because of enabled WiFi radio, even when it
is not actively used.

Enter NONE mode during initialization, so WiFi radio will be
disabled. Switch between NONE, STA, AP and STA+AP modes depending on
what driver is currently doing (e.g. enable STA only when scanning,
connecting and being connected to AP).

AT+CWAUTOCONN=0 command fails when in NONE mode, so workaround that by
entering temporarily into STA and then switching back to NONE.

Add also a warning log when switching mode was not successful, to ease
debugging possible issues.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:16:36 -05:00
Marcin Niestroj 575fe89303 drivers: wifi: esp: improve readability of CWMODE changes
AT+CWMODE command controls in which mode (NONE, STA, AP, STA+AP) ESP
chip is operating. Add helper macros to replace usage of magic
numbers (0-3), hence improve readability. Add also a esp_mode_switch()
helper function, which allows to conveniently switch to chosen mode.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:16:36 -05:00
Marcin Niestroj 964775fafc drivers: wifi: esp: change internal API to work with multiple flags
Change internal API operating on ESP driver flags to support multiple
bitwise ORed flags at once. This allows to improve resulting code when
multiple flags are read or modified at once.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:16:36 -05:00
Marcin Niestroj 347c2501d7 drivers: wifi: esp: add esp_cmd_send() helper function
All except one invocations of modem_cmd_send() pass the same interface,
command handler and semaphore. Create a helper function in order to make
invocations slightly more readable.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:16:36 -05:00
Marcin Niestroj 135bbd5ae4 drivers: wifi: esp: stop locking scheduler when sending data
Locking scheduler was a workaround for issue that was just solved.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:15:19 -05:00
Marcin Niestroj 9fe279f744 drivers: modem: don't clear out cmd handlers if they were not setup
There is no point in clearing out command handlers if they were not
setup properly. Just skip to next instruction.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:15:19 -05:00
Marcin Niestroj eae32b7e7a drivers: modem: fix race condition when waiting on cmd reply
Command was sent first, then a semaphore was reset. This semaphore could
be released by received reply even before semaphore was reset. This is
quite unlikely, but possible result of race condition.

Move k_sem_reset() call before attempt to send command over modem
interface. This makes sure that receiving reply momentarily after
sending request will always be handled properly.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:15:19 -05:00
Marcin Niestroj 67976f8686 drivers: modem: verify send semaphore before taking any action
Semaphore argument is checked only after requested command is already
sent over modem interface. It makes little sense to return -EINVAL when
half of the requested operation (send) has already been done.

Check timeout and semaphore arguments just on the beginning of
function. Return -EINVAL early, before sending any data or taking any
locks.

Clear out 'sem' variable when there is no need to wait. Use this
variable later on as an indication to actually wait on semaphore or not.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:15:19 -05:00
Maksim Masalski 555408d4e7 tests: access kernel object with private data using system call
When defining system calls, it is very important to ensure that
access to the API’s private data is done exclusively through system
call interfaces. Private kernel data should never be made available
to user mode threads directly. For example, the k_queue APIs were
intentionally not made available as they store bookkeeping
information about the queue directly in the queue buffers which are
visible from user mode.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2020-12-01 10:14:35 -06:00
Marcin Niestroj 5e3d542862 drivers: modem: hl7800: don't cleaup net_context members
There is no reason to clenaup members of net_context structure, as those
should be (and are) managed by net_context_put() implementation.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:13:48 -05:00
Marcin Niestroj 33a90f20e9 drivers: modem: wncm14a2a: don't cleaup net_context members
There is no reason to clenaup members of net_context structure, as those
should be (and are) managed by net_context_put() implementation.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 11:13:48 -05:00
Peng Fan 346ecb2a5a arch: arm64: correct vector_table alignment
The 2K alignment assembler directives should be under
'SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table)'
Otherwise the _vector_table is actually 0x80 bytes aligned.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-12-01 10:04:59 -06:00
Torsten Rasmussen 6ca2bf25cb cmake: manual handling of CMakeCheckCompilerFlag.cmake inclusion
Fixes: #30232

This is a workaround for #30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing #30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-01 08:46:41 -06:00
Jukka Rissanen 9028ecbc56 samples: net: zperf: Allow DHCPv4 or manually set addresses
If user has enabled DHCPv4, then allow to use its address instead
of giving error if static address cannot be set. Similar fix for
IPv6, so allow user to manually set an IPv6 address.

Because DHCPv4 has already set the IPv4 address to the network
interface, then zperf might not be able to add the pre-configured
address to it. So instead of returning immediately, try to use the
IP address that is already in the network interface. This way we
avoid this error print.

  uart:~$ zperf udp download 5001

  Setting IP address 2001:db8::1
  Setting destination IP address 2001:db8::2
  Cannot set IPv4 address 192.0.2.1
  Unable to set IP
  Setting destination IP address 192.0.2.2

  Cannot set IPv4 address 192.0.2.1
  Unable to set IPv4
  Binding to 192.0.2.1
  Cannot bind IPv4 UDP port 5001 (-2)

In this example, the network interface already had a proper and working
IPv4 address 192.168.0.2 in it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-12-01 16:32:07 +02:00
Jukka Rissanen 77a74414d1 samples: net: zperf: Convert to use usec directly
Currently the code uses hw cycles and tries to convert them
to usec. I noticed some failures with this, for example the test
duration was sometimes missed meaning that instead of testing 5
seconds, we bailed out after 2 sec etc. After the kernel k_timeout_t
changes, which added APIs to support usec accuracy, we can use usec
and ticks here. This simplifies the code a bit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-12-01 16:32:07 +02:00
Daniel Leung c8d7dcc897 linker: rename the section for emulators
The linker section for emulators (emulation drivers) is
incorrectly named "log_const_sections" possibly due to
simply copy-and-paste error. This section has nothing to
do with logging, so rename the emulators section.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-12-01 14:57:38 +02:00
Ioannis Glaropoulos a953ac8307 CODEOWNERS: add code owners for Kconfig.tfm
Add the TFM Module maintainers as
code owners for Kconfig.tfm.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-12-01 14:19:03 +02:00
Ioannis Glaropoulos 060f17a5af modules: tfm: add required selection and dependencies
BUILD_WITH_TFM needs to depend on
ARM_TRUSTZONE_M, which is selected
by the SoC or Board definition. In
addition to that we add an imply
statement for INIT_ARCH_HW_AT_BOOT
because Zephyr will be chain-loaded
by TF-M, and needs to cleanup its
core ARCH registers that might be
left in non-reset state.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-12-01 14:19:03 +02:00
Ioannis Glaropoulos 0924cb55df modules: tfm: cleanup redundant Kconfig symbol selection
When we select BUILD_WITH_TFM we do not
really need to enable by default the
options THREAD_NAME, THREAD_STACK_INFO,
INIT_STACKS and THREAD_MONITOR, so we can
clean them up. We also remove CMSIS_RTOS_V2
for the same reason.

We also cleanup the default value for
NUM_PREEMPT_PRIORITIES, which does not
seem to be needed.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-12-01 14:19:03 +02:00
Jukka Rissanen 04a421d1b8 net: shell: Fix statistics for network interface
We did not check that user has supplied network interface index
in "net stats iface <idx>" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-12-01 12:37:52 +02:00
Marcin Niestroj aa07f8a442 drivers: wifi: winc1500: remove unused send_cb and send_user_data
Both 'cb' and 'user_data' parameters for send/sendto were saved as
'send_cb' and 'send_user_data' members in socket information. None of
them are actually used, so drop them.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-01 10:06:43 +02:00
Jakub Rzeszutko 8f2ba929d2 tests: add more configurations for shell tests
Add configurations to test shell feature sets. It will be helpful
both to users and for ensuring the flags continue to work.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00