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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Fix an issue discovered by Coverity where there is a potential
out of bound access on the divisor arrays.
Fixes#20495Fixes#20496
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
A recent patch increased struct cmd_data from 8 to 12 bytes, which is
more than the default user data for Bluetooth. We generally don't want
the core stack to require more than 8, so instead of increasing the
requirement, move the data out from the buffer into its own array with
the help of the net_buf_id() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The instructions for samples/usb/dfu fail on Nordic platforms if the
erase is not progressive. Default to enable that on Nordic.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>