Commit graph

41120 commits

Author SHA1 Message Date
Andrei Emeltchenko
105e0997f2 usb: usb_dc_native_posix: Refactor similar code to function
Use skip_setup() function helper in a place we need to skip setup
data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko
0957f4978c usb: usb_dc_native_posix: Use return code for skip_setup()
Use return code for usbip_skip_setup()

Fixes #20840

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko
80dbcfa306 usb: usb_dc_native_posix: Check return code in handle_usb_data()
Fixes coverity complaints dealing with send()

Fixes #20839
Fixes #20841

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko
1d81c0cf31 usb: usb_dc_native_posix: Fix buffer and max data 0 case
When both buffer and max data to read are zero return
the available data in buffer.

Fixes #20838

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko
5b22c88184 usb: usb_dc_native_posix: Check return values in dc_write()
Fixes coverity issue:

Fixes #20836
Fixes #20837

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko
959b833f91 usb: usb_dc_native_posix_adapt: Check correct size
Fixes Coverity issues

Fixes #20842

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Anas Nashif
e4a9be94c0 kernel: init: simplify boot banner printing
Just use printk directly instead of going over defines.

For some reason, this change lets us pass on master when running
tests/kernel/timer/timer_monotonic test. This test started failing after
rc2 was tagged, just because the changing git version string passing to
BUILD_VERSION. This is still under investigation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-29 07:52:16 -05:00
Mieszko Mierunski
b7ae41779d drivers: nrf: Add CTS and RTS pins to UART and UARTE PM
Add gpio management for CTS and RTS pins in UART and UARTE drivers

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-11-29 09:04:55 +01:00
Johann Fischer
04d962b00b test: pwm_api: fix test for nRF based boards
Fix pwm_api test for nRF based boards.

Fixes: #20176

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-11-28 15:54:56 -05:00
Peter Bigot
ccfdc3c34b drivers: nrf_clock_calibration: wait for sensor initialization
When using the RC clock source a periodic calibration is invoked that
involves reading from the die temperature sensor.  The code did not
protect against execution order that caused the periodic calibration
to be invoked before the temperature sensor was initialized.

Update the temperature sensor to detect that it has not been
initialized and so should reject attempts to fetch a reading.

Update the calibration code to do nothing when temperature reading
fails.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-28 14:21:49 -05:00
Johann Fischer
021ee7ade3 usb: hid core: fix call by reference
Fix call by reference.

Fixes: #20872
Coverity CID :205779

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-11-28 14:04:31 -05:00
Andrei Gansari
6d1e10635d drivers: flash_handlers fixes stray semicolon
z_vrfy_flash_get_page_count defined as a function prototype in place of
a real function due to a stray semicolon.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-11-28 13:39:00 -05:00
Johan Hedberg
1e831befea Bluetooth: host: Fix ordering of TX sent callbacks
Now that the TX callbacks happen from the system workqueue but fixed
channels get processed from the RX thread there's a risk that the
ordering of these gets messed up. This is particularly bad for ATT
when it's trying to enforce flow control.

To fix the issue store the completed TX packet information in a
per-connection list and process this list before processing any new
packets for the same connection. We still also schedule a workqueue
callback, which will simply do nothing for this list if bt_recv()
already took care of it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 19:55:59 +02:00
Daniel Leung
12948fdf37 counter: mchp_xec: fix logical/bit-wise AND
Coverity discovered that a logical AND was used in place of
a bit-wise AND. So fix it.

Fixes #20489

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-28 07:14:02 -05:00
Johan Hedberg
6ef3442434 Bluetooth: Deprecate and fix BT_BUF_USER_DATA_MIN
This define has no more internal users and has no particular use
because of the system-wide user data size that gets set through
Kconfig. Therefore, deprecate it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Johan Hedberg
5cf540adb4 net: buf: Fix NET_BUF_USER_DATA_SIZE value for Bluetooth
For 32-bit architecture Bluetooth only requires 4 bytes for the user
data. There are places that store a pointer in it, so we need to make
an exception for 64-bit architecture. The code contains relevant build
asserts, so it's sufficient to set a conditional default in Kconfig
but let the range definition be simpler (unconditional).

Also simplify & fix the conditional defaults & ranges. E.g. separately
mentioning X86_64 is redundant since that option explicitly selects
the 64BIT option.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Johan Hedberg
39291fbbbe Bluetooth: Remove usage of BT_BUF_USER_DATA_MIN
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Johan Hedberg
be71e68fcb Bluetooth: L2CAP: Use fixed size for net_buf user data
The "sent" tracking doesn't have to be a signed integer. Use a fixed
size so that the consumed size doesn't change between different
architectures. Use a u16_t since bigger sizes are needed and because
this is mapped to an int function return higher up in the stack.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Kamil Piszczek
362f2299cd drivers: bluetooth: hci: rpmsg: fix handling of hci events
Fixed handling of HCI events in the HCI driver over RPMsg. Now,
the driver makes use of discardable buffer pool when allocating
memory for certain HCI event types (e.g. Advertising Report Event).
Applications that are flooded with Advertising Reports will run
much better after this change (e.g. Mesh applications).

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-11-28 10:55:32 +02:00
David Leach
64dbc3e610 release: Zephyr 2.1.0-rc2
Bumped to v2.1.0-rc2

Signed-off-by: David Leach <david.leach@nxp.com>
2019-11-27 19:27:31 -06:00
Ioannis Glaropoulos
32f0c165b5 doc: release: add note for new SoC series support in v2.1.0 release
Add a note about supporting new SoC Series in v2.1.0 release.
Style rework in the section for SoC support.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-27 15:56:38 -05:00
Erwan Gouriou
fc65ab137e samples/net: civetweb: Remove SOC_SERIES_SAME70=y in prj.cnf
For some reasons SOC_SERIES_SAME70 was selected in civetweb sample,
which prevents build on other platforms.
This issue was silent since sample yaml file limits sample testing on
sam_e70_xplained.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-11-27 15:18:31 -05:00
Trond Einar Snekvik
deeb4f320d Bluetooth: Mesh: Restructure doc
Adds a deeper hierarchy to the Bluetooth Mesh documentation by moving
the modules in separate pages with a brief description of the concepts
in each module.

Adds the full list of specification defined Health model faults.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-11-27 13:32:45 -05:00
Peter A. Bigot
73ed1bafd1 boards: hifive1*: fix ticks per second
The HiFive1 boards power up using a 32 KiHz low frequency kernel, so
have a cycle rate of 32768 Hz.  The board definitions have not been
revisited since the Zephyr default for ticks-per-second increased from
100 to 10000.  The timer system on the board does not operate
correctly at 4 cycles per tick, but does at 328 cycles per tick.

To support functional timers while keeping system milliseconds in sync
with clock time set ticks-per-second to 128.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-27 13:32:16 -05:00
Daniel Leung
ceb2303dd0 pwm: pwm_mchp_xec: fix potential out of bound access
Fix an issue discovered by Coverity where there is a potential
out of bound access on the divisor arrays.

Fixes #20495
Fixes #20496

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-27 13:00:13 -05:00
Andy Ross
5f63c9d907 drivers/timer: Clamp after tick adjustment, not before
Some early tickless drivers had a common pattern where they would
compute a tick maximum for the request (i.e. the maximum the hardware
counter can handle) but apply it only on the input tick value and not
on the adjusted final value, opening up the overflow condition it was
supposed to have prevented.

Fixes #20939 (Strictly it fixes the specific pattern that was
discovered in that bug.  It's not impossible that other drivers with
alternative implementations have a similar issue, though they look OK
to me via a quick audit).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-11-27 18:43:53 +01:00
Vinayak Kariappa Chettimada
44bbdd0a94 Bluetooth: controller: Fix llcp_rx check assert
If LL Connection Parameter Request or LL Connection Update
or LL PHY Update procedure is started by the local device
while a LL Length Update Request PDU has been sent by peer
then a Rx node has been stored in the llcp_rx place holder
for generation of Length Update procedure complete.

The failing assert check is incorrect in the above scenario
hence remove. Instead a missing append of the allocated Rx
node to the llcp_rx list has been added to the controller
implementation.

This issue relates to commit d12c53f89f ("Bluetooth:
controller: split: Fix missing data len update event").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-11-27 18:43:02 +01:00
Ioannis Glaropoulos
c8b0b1a5f8 tests: drivers: watchdog: exclude platforms with SAM WDT from testing
On watchdog-triggered reboot, the SAM platforms
reset RAM, so the wdt_basic_api cannot be completed
successfully, as it relies on RAM retention (relies
on variables stored in RAM retaining their values
across different boot cycles). Exclude the platforms
with the SAM Watchdog from this test.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-27 12:21:24 -05:00
Markus Fuchs
1f2727c5fa net: tls: Add sendmsg
Add an implementation for `sendmsg`, so secure sockets can be used
together with the WebSocket module to implement secure WebSockets
("wss").

Fixes #20431

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2019-11-27 12:16:07 -05:00
Marcin Szymczyk
57f7801bc4 drivers: ipm: nrfx: add event_index assertion
event_index must be lower than NRFX_IPC_ID_MAX_VALUE.
As of now, maximum index is 16.

Fixes #20962, #20964, #20967

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2019-11-27 12:14:22 -05:00
Johan Hedberg
61cfab5acf CODEOWNERS: Remove sjanc from samples/bluetooth/
Szymon was removed from all Bluetooth paths a while ago, and this is
simply an overlooked leftover.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-27 19:12:02 +02:00
Johan Hedberg
0a925bdf9c Bluetooth: L2CAP: Process fixed channels in the RX thread
Now that the TX path and TX context (bt_conn_tx) has been redesigned
to free the contexts always in the system workqueue, it means the
system workqueue is the only context where their allocation may also
fail. This is particularly problematic with us having all L2CAP
channels (fixed & CoC alike) deferred to the system workqueue. It is
especially bad for fixed channels where being able to send responses
for SM, L2CAP signaling and ATT is critical to avoid timeouts for the
connection.

This patch moves the processing of all fixed L2CAP channels back to
the RX thread, thereby making it possible (and safe) to block while
waiting for a TX context to become available.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-27 17:44:59 +02:00
Johan Hedberg
a065e5782a Bluetooth: host: Move system workqueue special case to the right place
Now that we've removed the TX allocation dependency from the TX thread
we no longer have the need to do special-casing for the system
workqueue when allocating buffers. Instead, we do have to special-case
the system workqueue when allocating TX contexts since the system
workqueue is the only place where they get freed up.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-27 17:44:59 +02:00
Johan Hedberg
d8689cdc72 Bluetooth: host: Fix deadlocks with pending TX packet handling
This is a moderate redesign of the pending TX packet handling that
aims to eliminate potential deadlocks between the TX thread and the
system workqueue thread. The main changes are:

 - TX context (bt_conn_tx) is allocated during buffer allocation, i.e.
   not in the TX thread.

 - We don't allocate a TX context unless there's an associated
   callback. When there's no callback simple integer counters are used
   for tracking.

 - The TX thread is no longer responsible for TX callbacks or
   scheduling of TX callbacks. Instead, the callbacks get directly
   scheduled (k_work_submit) from the RX priority thread.

 - CONFIG_BT_CONN_TX_MAX defaults to CONFIG_BT_L2CAP_TX_BUF_COUNT,
   and in most cases wont need changing. The value now only indicates
   how many pending packets with a callback are possible.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-27 17:44:59 +02:00
Johan Hedberg
28f89478f6 Bluetooth: host: Shrink size of struct bt_conn_tx
The `node` and `work` members are never used simultaneously.
Additionally k_work already has built-in support for being in a linked
list, however a union makes this change a bit cleaner.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-27 17:44:59 +02:00
Tavish Naruka
0d64e8d06c disk: sdhc: reinitialize SPI SDHC always
Do not skip spi sdhc disk detect and interface
init, on subsequent calls.

Signed-off-by: Tavish Naruka <tavishnaruka@gmail.com>
2019-11-27 09:44:19 -06:00
Andrzej Głąbek
6f09c903ba boards: nrf5340_dk_nrf5340: Move buttons node from leds to root node
For consistency with all other boards, make the `buttons` node a child
of the root node, not the `leds` one.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-27 16:40:08 +01:00
Lingao Meng
a071957746 Bluetooth: Mesh: Fixes wrong return value
Fixes missing return value on `va_del`
Fixes wrong return value on `va_add`

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2019-11-27 11:22:20 +02:00
Maximus Liu
1050ef7932 Bluetooth: Mesh: Fixes seg_tx_reset adv buf unref
In seg_tx_reset() in transport.c, set the busy flag to 0U
before doing adv buf unref, which will avoid sending
unnecessary adv packets in case the adv buf is already put
in the mesh adv_queue.

Fixes #20970

Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
2019-11-27 11:21:46 +02:00
Oleg Zhurakivskyy
516525fcd8 samples: net: echo-server: Increase the stack size for the coverage
echo_server crashes if the coverage is enabled due to the insufficient
stack size.

Use bigger stack size when the coverage is enabled.

Fixes #20797

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-11-27 10:14:20 +01:00
Lingao Meng
c0cdd46adf Bluetooth: Mesh: Fixes Delete On Node
Fixes a issure where nodes could not be deleted.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2019-11-27 10:16:53 +02:00
Ioannis Glaropoulos
ea2324dd2a drivers: timer: SysTick: enforce proper min & max SysTick LOAD values
Similar to what we do in other timer drivers, the maximum ticks
supplied in z_clock_set_timeout(..) needs to be MAX_TICKS at
maximum, when K_FOREVER is supplied as argument to the function.

In addition to that, the value we load onto the SysTick LOAD
register shall be truncated to MAX_CYCLES. This is required
to prevent loading a trash value to LOAD register, as only
the lowest 24 bits may be safely written.

Finally, we move the enforcement of the minimum delay to be
programmed on LOAD (i.e. MIN_DELAY) at the end step of the
calculation of the cycles-to-be-programmed. This prevents
from misscalculating the delay, as any required adjustment
is applied at the end, after the delay is rounded up to
the next tick boundary.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Peter Bigot
3594f136d7 drivers: systick: avoid starving clock announcements
When setting a timeout measure the number of accumulated unannounced
ticks.  If this value exceeds half the 32-bit cycle counter range
force an announcement so the unannounced cycles are incorporated into
the system tick counter.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos
b3574bdad7 drivers: systick: fix calculation of absolute cycles count in ISR
The commit fixes the update of the absolute counter of HW cycles
in the SysTick ISR for TICKLESS mode.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Peter Bigot
f16a403e64 drivers: timer: SysTick: rework late overflow check
The previous solution depended on a magic number and was inefficient
(entered the second-wrap conditional even when a second wrap hadn't
been observed).  Replace with an algorithm that is deterministic.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos
f7aa227c07 drivers: timer: SysTick: document internal function and variables
Add detailed documentation for the internal 'elapsed()'
function, as well as for the local counter variables used
in the SysTick driver.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos
35886463dd drivers: timer: SysTick: remove unnecessary masking
Unsupported bits of the Current Value Register
are read as zero, so we remove the redundant
ANDing with the max supported counter value.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos
7dc061871d tests: kernel: add kernel and sleep tags in tests
Adding kernel tag in tests/kernel/early_sleep and sleep tag
in tests/kernel/sleep. So both early_sleep and sleep suites
have the same tags.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Jan Van Winkel
1182956cd8 tests: cpp: Extended c++ test case to cover new/delete
Extended c++ test case to cover the zephyr implementation of new and
delete.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-26 12:41:54 -06:00
Jan Van Winkel
8a98a67bf1 cpp: Use malloc/free instead of kernel variants in new/delete
Use malloc/free instead of k_malloc/k_free in operator new/delete
implementation or use libstdc++ implementation when available.

Further updated cpp_synchronization sample to enable minimal libc heap
as virtual destructor requires operator delete which depends on free.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-26 12:41:54 -06:00