Commit Graph

47298 Commits

Author SHA1 Message Date
Fabio Utzig 7cc84af393 doc: fix broken text search
Require Sphinx<3.4.0 to avoid the issue described in:

https://github.com/sphinx-doc/sphinx/issues/8603

This requirement can be relaxed once a new sphinx-rtd-theme is
released.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-04 07:57:07 -05:00
Jordan Yates d0a56690a4 net: buf: document fragment limitations
Document limitations on the FIFO queuing functions when fragments are
used. Namely that the `get` functions are not thread-safe when fragments
are present.

This is due to multiple independent calls to `k_fifo_get/sys_slist_get`.
A second thread can interrupt the retrieval before all fragments have
been removed. The second thread can then read from the FIFO, obtaining
the trailing fragments as a 'new' `net_buf`. The first thread will then
either assert or pull in the next `net_buf` on the queue as part of the
first `net_buf`.

Fixes #28355

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-04 14:14:04 +02:00
Daniel Leung 6ab4886506 timing: fix timing_stop() ref counting
When there are more timing_stop() calls then timing_start(),
the reference counter will go negative, resulting in the next
timing_start() call not starting the timer. Without timer
running, getting cycles elasped would not work. So fix
the ref counting so it won't dip below zero.

Fixes #30397

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-01-04 12:15:30 +01:00
Daniel Leung c6253fbe1a tests: latency_measure: fix mis-matched timing start/stop calls
Inside the semaphore tests, there are mis-matched pair of timing
start/stop calls. One called start without calling stop, another
one calling stop twice. So fix them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-01-04 12:15:30 +01:00
Peter Bigot d489765be4 net: dhcp: correct timeout scheduling with multiple interfaces
If there are multiple interfaces a change to the timeout for one
cannot determine the correct delay until the next timeout event.  That
can be determined only by checking for the next event over all
interfaces, which is exactly what's done by the timeout worker.

Refactor interface timeout configuration to just set the start time
and request time, and trigger the worker to calculate the next
scheduled event.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot b4ed597afe net: dhcp: fix timeout on entry to bound state
When a renewal occurs the client enters RENEWING, sends a request,
then sets a short timeout (about 4 s) for the response.  In the common
case the response will arrive immediately, which will trigger an
attempt to reset the timer with T1 which is generally large.

However the check for updating the timer performs the update only if
the new deadline is closer than the currently set one.  Thus the timer
fires at the time the RENEWING request would have been retransmitted,
and only then updates to the correct deadline (T1) for the current
machine state.

Remove the extra timeout by unconditionally setting the timeout to the
new value.

This works when there is one interface; it could be wrong if there
were multiple interfaces one of which had a closer deadline, but
multiple interfaces are mishandled anyway and will be fixed next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 65183422c7 net: dhcp: correct timeout calculation with multiple interfaces
When there is only a single interface the timeout infrastructure can
correctly calculate time to next event, because timeouts only occur
when an event for that interface is due.  This is not the case when
multiple interfaces are present: the timeout is scheduled for the next
event calculated over all interfaces.

When calculating the next event for an interface where the timeout is
not due the current code returns the original absolute delay
associated with its current state, without accounting for the time
that has passed since the start time.

For example if interface A's T1 is 3600 s and is due at 3610, but at
3605 a timeout for interface B occurs, the contribution of A to the
delay to the next scheduled event would be 3600 rather than 5,
preventing the renewal from occurring at the scheduled time.

Fix this by replacing the boolean timed-out state with the number of
seconds remaining until the interface event will occur, and
propagating that through the system so the correct delay over all
interfaces can be maintained.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 2c813bc620 net: dhcp: fix invalid timeout on send failure
If send_request() fails it would return UINT32_MAX as the next
timeout.  Callers pass the returned value to update_timeout_work
without validating it.  This has worked only because
update_timeout_work will not set a timeout if an existing timeout
would fire earlier, and the way the state is currently structured it
is likely there will be an existing timeout.  However, if work thread
retransmission from REQUESTING failed the timer would not be
rescheduled, causing the state machine to stop.

A more clean solution, which matches the behavior of send_discover(),
is to return the timeout for the next transmission even in the case
when the send fails.  The observed behavior is the same as if the
network, rather than the sender, failed to transport the request.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 508496f73b net: dhcp: rename variable for clarity
A variable named "timeout" is used to represent the current time in
comparisons against timeouts calculated from a start time and an
interval.  Since this current time is not the timeout change its name
to "now" to reduce maintainer confusion.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 07c5d2fe18 net: dhcp: avoid undefined behavior when assertions disabled
If assertions are disabled the send operation would continue on to
transmit a message.  Stop it from doing so.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 5da984e890 net: dhcp: fix bounds check in timeout
The flag value UINT32_MAX is returned from manage_timers() when a send
operation did not succeed.  This indicates that the timeout should not
be rescheduled, but because it will never replace the starting update
value UINT32_MAX-1 the check will never pass, and in cases where it
should work will be submitted to run at UINT32_MAX-1 seconds.

Fix the upper bound.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot d44b4252b7 net: dhcp: clear option state when selecting
When a connection is lost the client will first attempt to renew, and
then to rebind, and finally to select.  Options like gateway may have
been provided by the original connection, but not the new connection,
resulting in an inconsistent configuration for the new network.

Remove the partial state clearing when entering INIT, and expand the
state cleared when entering SELECTING to be more comprehensive.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 403c4974b0 net: dhcp: remove incorrect sign check
The start time is negative only if the interface came up in the the
first milliscond since startup; even then changing the sign of the
start is not appropriate.  Presumably a left-over from signed 32-bit
timestamps.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:02:58 +02:00
Peter Bigot 7e77370acb net: dns: review use of k_work APIs
It is documented that using transient information like whether a work
item is pending or a delayed work item has time left to determine the
state of the work item before subsequent reconfiguration is prone to
race conditions, and known to produce unexpected behavior in the
presence of preemptive threads, SMP, or use of the work item from
interrupts.  As a best practice such pre-validation steps should be
avoided unless algorithmically necessary.

All comparisons of remaining delayed time before canceling a delayed
work item in this module appear to be optimizations subject to the
above race conditions.  Remove the checks so that only the inherent
race conditions in the implementation of canceling a work item remain.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-04 10:01:47 +02:00
Peter Bigot 5358a11687 boards: sam_e70_xplained: default enable EEPROM source for MAC address
The SAME70-XPLD board comes with an EEPROM that holds the MAC address
to be used with its Ethernet interface.  Enable that feature by
default, so the application doesn't have to.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-28 13:07:46 +02:00
Andy Ross 3805286769 boards/intel_adsp_cavs15: Add --no-history argument to adsplog.py
The default behavior of the log reader is to dump the full device trace
buffer.  But that can contain output from a previous run and the state
parser in twister can get confused.  Add a "--no-history" argument that
emits only new log data, which corresponds more closely to the way a
hardware UART would work.

(Code change is just two lines, everything else is comments & docs)

Fixes #30979

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-12-27 18:20:35 +01:00
Luiz Augusto von Dentz 64cc5a3746 Bluetooth: GATT: Fix BT_GATT_AUTO_DISCOVER_CCC
When using BT_GATT_AUTO_DISCOVER_CCC if the ccc_handle is not set
bt_gatt_subscribe would initiate a discovery to locate the CCC handle
but instead of awaiting it to complete the code does proceed to call
gatt_write_ccc even with ccc_handle being 0x0000 which is invalid.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-12-27 18:20:28 +01:00
Enjia Mai 3026df2a24 tests: spinlock: add some error test cases
Add some error test cases for spinlock, include:
1.Validate indentical spinlock cannot be used recursively.
2.Validate unlocking incorrect spinlock will trigger assertion.
3.Validate releasing incorrect spinlock will trigger assertion.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-12-27 18:19:42 +01:00
Vinayak Kariappa Chettimada ead41bcb49 boards: nrf5340dk_nrf5340: Fix some indentation
Fixed some code indentations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-27 18:19:34 +01:00
Peter Bigot 26927fcc2c gpio: esp32: retrieve pinmux from devicetree reference
Need to declare the device before the pointer can be obtained, and to
validate the device before trying to use it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:19:27 +01:00
Peter Bigot 8c1bef535b device: support generating defines from devicetree nodes with no label
The existing code only worked for nodes that had a label property,
which is every device except ESP32 pinmux.  However, a label property
should not be necessary for defining a device from devicetree.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:19:27 +01:00
Andy Ross c2c6bee036 drivers/timer: Remove legacy APIC driver
For a while now, we've had two APIC drivers.  The older was preserved
initially as the new (much smaller, "new style") code didn't have
support for Quark interrupt handling.  But that's long dead now.  Just
remove it.

Note that this migrates the one board using this driver (acrn) to
CONFIG_APIC_TIMER instead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-12-27 18:19:17 +01:00
Eugeniy Paltsev 3134bc1ea0 runners: nsim: allow to use runner if gdb is missing
As of today we check for gdb presence in 'do_create' method and
raise an exception in case of gdb is missing. That makes nsim
runner unusable without gdb even for the commands which don't use
it (like 'flash' command).

Fix that.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-12-27 18:19:10 +01:00
Guennadi Liakhovetski bc90256423 cavs: unify defconfigs for v15, v18, v20 and v25
Unify default configurations to support both SMP and UP:

1. make SMP default, although it's currently disabled in prj.conf
2. use CAVS timer by default in both UP and SMP configurations
3. make MP_NUM_CPUS, IPM and IPM_CAVS_IDC depend on SMP

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-12-27 18:19:00 +01:00
Peter Bigot 264d81257f power: fix Kconfig defaults
Some SoCs try to select power management in a way that can bypass the
dependency on system clock.  Make the selection conditional on the
dependency.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:18:52 +01:00
Peter Bigot 19cb44bab7 kernel: idle: fix builds with PM but no system clock
PM depends on SYS_CLOCK_EXISTS in Kconfig but several boards have
Kconfig overrides that allow the dependency to be ignored, so
CONFIG_PM=y even though CONFIG_SYS_CLOCK_EXISTS=n.  Fix the code so
that the true dependency is reflected in the generated code.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:18:52 +01:00
Ningx Zhao 187697c2d7 tests: stack: add some testcases
Add some testcases for stack source code coverage,
and add a fatal handler function to hand the error
by null parameter.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-12-27 18:17:22 +01:00
Christopher Friedt 05a08a3b66 tests: kernel/k_malloc: tests for k_aligned_alloc
This change adds tests for k_aligned_alloc.

Fixes #29519

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:17:07 +01:00
Christopher Friedt 135ffaff74 kernel/k_malloc: add k_aligned_alloc
This change adds z_heap_aligned_alloc() and k_aligned_alloc()
and changes z_heap_malloc() and k_malloc() to be small wrappers around
the aligned variants.

Fixes #29519

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:17:07 +01:00
Martin Åberg 6788d867f2 tests: can.frame: use enums for rtr and id_type
Make use of the the enums for rtr and id_type as described in
drivers/can.h.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-12-27 18:16:58 +01:00
Martin Åberg 265d848cbb tests: can.frame: enable can test on qemu_leon3
Enable CAN frame test which does not require a driver implementation
or a network.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-12-27 18:16:58 +01:00
Francois Ramu 8cb7777d87 boards: arm: stm32 nucleo boards support dma feature
This will add the corresponding tests/drivers/dma/ tests
to the sanity check

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-12-27 18:16:47 +01:00
Francois Ramu 64da50f45b tests: drivers: dma: adapt test applications on stm32l476 nucleo board
The dma test applications for MEM-to-MEM transfers are modified
to run on the stm32l476 with a DMA.
The CONFIG_DMA_LOOP_TRANSFER_DRV_NAME is either DMA_1 or DMA_2
CONFIG_DMA_LOOP_TRANSFER_CHANNEL_NR from 1 to 7 for DMA_1
CONFIG_DMA_LOOP_TRANSFER_CHANNEL_NR from 1 to 5 for DMA_2

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-12-27 18:16:47 +01:00
Francois Ramu 0a3437d4ca tests: drivers: dma: adapt test applications on stm32wb55 nucleo board
The dma test applications for MEM-to-MEM transfers are modified
to run on the stm32wb55 with a DMAMUX
loop_transfer on any CONFIG_DMA_LOOP_TRANSFER_CHANNEL_NR from 0 to 13
chan_blen_trasnfer on CONFIG_DMA_TRANSFER_CHANNEL_NR_0 from 0 to 13
and on CONFIG_DMA_TRANSFER_CHANNEL_NR_1 from 0 to 13

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-12-27 18:16:47 +01:00
Francois Ramu 445c8936e7 tests: drivers: dma adapt the dma tests applications for stm32 devices
It adds flexibility to test different dma channels
The chan_blen_transfer is modified
like the loop_transfer application to support stm32xx devices
with dma and/or dmamux.
On the stm32 devices, the first dma channel is 1.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-12-27 18:16:47 +01:00
Peter Bigot a1885602bc samples: littlefs: use DT-defined mount information
Extend the nrf52840dk_nrf52840 sample overlay with a fstab entry for a
littlefs file system on the storage partition.

This eliminates the need for application configuration of the file
system parameters and mount data.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot 5b544e115b fs: littlefs: define mount point structures for file systems
Use the devicetree filesystem bindings to populate an fs_mount_t
object that is preconfigured for a particular set of file system
properties on a specified partition.

At this time the mount point data is accessed by reference using the
partition's devicetree node identifier.

Note: While a file system can register itself before its devices
are available, it cannot do the automount.  In this commit the
initialization priority is increased to compensate, but that's not
a long-term solution.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot 4080b7727f fs: provide access to DT-defined mount structures
Use a devicetree fstab entry node identifier to provide a unique
identifier for a fs_mount_t structure that is defined with everything
necessary to mount the file system associated with a partition.

The fs_mount_t structure will be defined in the implementation for
each file system type.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot 0ea3272c2f dts: mtd: add support for a file system table in devicetree
Define a binding for zephyr,fstab which contains multiple child nodes
each of which identifies a file system type and configuration
parameters and associates it with a fixed partition.  The base entry
properties specify the mount point and other generic fs mount options,
while bindings specific to a file system type provide the
configuration parameters necessary to describe the file system.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot 2f3e18c2ff devicetree: flash-partitions: decode fstab entry mount flags
Add a helper to convert from zephyr,fstab-base mount options to the
corresponding fs subsystem mount flags.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot e571c88565 devicetree: flash-partitions: expose helper macros
Make generally available the macro that provides the flash device in
which a particular partition can be found.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot ba24cd2f0f fs: add a mount flag for automounting file systems
File systems can be described in a devicetree node which pre-defines a
mount structure.  A feature in that structure is that it can be
automatically mounted when the filesystem implementation registers
itself.  Add a flag that can be used to trigger this behavior.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Wojciech Sipak ff0dd82da0 boards: arm: add suport for Enclustra Mercury XU boards
This commit adds support for Enclustra's boards with ZynqMP SoC

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2020-12-27 18:16:00 +01:00
Wojciech Sipak 56c06e852b arch: arm: cortex_r: disable ECC on TCMs
This commit adds possibility to disable ECC in Tightly Coupled
Memory in Cortex-R.
Linker scripts places stacks in this memory and marks it as
.noinit section. With ECC enabled, stack read accesses without
previous write result in Data Abort Exception.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2020-12-27 18:16:00 +01:00
Christopher Friedt c0a2e41a75 gpio: emul: support configurable interrupt capabilities
This change adds support for configurable interrupt capabilities
in the emulated GPIO controller via Devicetree bindings.

Fixes #26477

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:15:33 +01:00
Christopher Friedt c313828eaf tests: gpio_api_1pin: support for emulated GPIO
This adds support for emulated GPIO (CONFIG_GPIO_EMUL=y) and
additionally allows BOARD=native_posix and
BOARD=native_posix_64 to run the gpio_api_1pin test suite.

Fixes #26477

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:15:33 +01:00
Christopher Friedt cc537b5a3a tests: gpio_basic_api: support for emulated GPIO
This adds support for emmulated GPIO (CONFIG_GPIO_EMUL=y) and
additionally allows BOARD=native_posix and
BOARD=native_posix_64 to run the gpio_basic_api test suite.

Fixes #26477

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:15:33 +01:00
Christopher Friedt 724ee49173 gpio: add driver for emulated GPIO
The emulated GPIO controller will aid in automated
integration testing.

Fixes #26477

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:15:33 +01:00
Mulin Chao f3ea7f5819 driver: i2c: add i2c support in npcx series.
The NPCX SMB modules provides full support for a two-wire SMBus/I2C
synchronous serial interface. Each SMBus/I2C interface is a two-wire
serial interface that is compatible with both Intel SMBus and Philips
I2C physical layer. There are 8 SMBus modules and 10 buses in NPCX7
series.

In NPCX7 series, the SMB5 and SMB6 modules contain a two-way switch to
support two separate SMBus/I2C buses (ports) with one SMB module
(controller) Please refer Section 4.7.2 in the datasheet. In order to
support it, this CL seperates the i2c driver into port and controller
drivers. The controller driver is in charge of i2c module operations
and internal state machine. The port driver is in charge of pin-mux
and connection between Zehpyr i2c api interface and controller driver.

All of modules have separate 32-byte transmit FIFO and 32-byte receive
FIFO buffers. These FIFO buffers reduce firmware overhead during long
SMBus transactions by allowing the Core to write or read more than one
data byte at a time to/from the SMB module.

The CL also includes:
— Add npcx i2c port/controller device tree declarations.
— Zephyr i2c api implementation.
— Add "i2c-0" aliases in npcx7m6fb.dts for i2c test suites.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-12-27 18:15:14 +01:00
Mulin Chao e258690655 driver: npcx: add glue module support in npcx series.
The System Glue module includes the three major functions:
— Power Switch Logic (PSL)
— SMBus multi-bus, wake-up support
— Simple Debug Port (SDP)

In NPCX7 series, the SMB5 and SMB6 modules contain a two-way switch to
support two separate SMBus/I2C buses (ports) with one SMB module
(controller). Since a single SMB module is able to serve only one
SMBus/I2C bus at a time, SMB_SEL registerin Glue module is used to
control theconnection of I2Cn_0 and I2Cn_1 interface pins to the SMBn
module (where n is 5, 6).

This CL provides a soc specific pin-control function called
"soc_pinctrl_i2c_port_sel" to switch buses (port) of the same SMB module
(controller). It will be used in the following i2c driver.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-12-27 18:15:14 +01:00