Compare commits

...

295 Commits

Author SHA1 Message Date
Anas Nashif
5ad3f4a693 release: bump release to 1.14.0-rc2
We are now on rc2

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-08-20 20:19:30 -04:00
Peter Bigot
3caa1ca92d logging: avoid buffer overrun extracting arguments
The number of arguments for a format string is approximated by the
number of conversion specifications.  This count may exceed the maximum
supported argument count.  Limit the extraction to the available space.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-20 19:21:03 -04:00
Alberto Escolar Piedras
61e084f102 arch: POSIX: Fix race with unused threads
Fix a race which seems to have been presenting itself
very sporadically on loaded systems.
The race seems to have caused tests/kernel/sched/schedule_api
to fail at random on native_posix.

The case is a bit convoluted:
When the kernel calls z_new_thread(), the POSIX arch saves
the new thread entry call in that new Zephyr thread stack
together with a bit of extra info for the POSIX arch.
And spawns a new pthread (posix_thread_starter()) which
will eventually (after the Zephyr kernel swapped to it),
call that entry function.
(Note that in principle a thread spawned by pthreads may
be arbitrarily delayed)
The POSIX arch does not try to synchronize to that new
pthread (because why should it) until the first time the
Zephyr kernel tries to swap to that thread.
But, the kernel may never try to swap to it.
And therefore that thread's posix_thread_starter() may never
have got to run before the thread was aborted, and its
Zephyr stack reused for something else by the Zephyr app.

As posix_thread_starter() was relaying on looking into that
thread stack, it may now be looking into another thread stack
or anything else.

So, this commit fixes it by having posix_thread_starter()
get the input it always needs not from the Zephyr stack,
but from its own pthread_create() parameter pointing to a
structure kept by the POSIX arch.

Note that if the thread was aborted before reaching that point
posix_thread_starter() will NOT call the Zephyr thread entry
function, but just cleanup.

With this change all "asynchronous" parts of the POSIX arch
should relay only on the POSIX arch own structures.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-08-20 19:20:42 -04:00
Joakim Andersson
5fcaeaa93c Bluetooth: Host: Fix unable to connect using host resolution
Fix issue unable to connect to bonded peer when host resolution is used
either because the controller does not support privacy, or the
controller resolving list was exceeded.
In this case we need to use the RPA from the advertising report
directly, there is a small chance of the peer cycling the RPA here, in
which case the connection might be unsuccessful.

Bug introduced here: 45da629b24

Fixes: #18306

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-20 19:20:26 -04:00
Luiz Augusto von Dentz
96d56cc84d Bluetooth: GATT: Fix not clearing out of sync flag
When the database changes and a client becomes change unware it should
also clear the out of sync flag as the following request should return
an error:

Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching:

  'The error response is sent only once after the client becomes
  change-unaware, unless the client disconnects or the database changes
  again before the client becomes change-aware in which case the error
  response shall be sent again.'

Fixes: #18183

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-20 19:20:05 -04:00
Luiz Augusto von Dentz
3f19a2e020 Bluetooth: GATT: Fix assert when storying CCCs
This fixes the following crash:

ASSERTION FAIL [0] @ ZEPHYR_BASE/subsys/logging/log_core.c:180
	argument 2 in log message "%s: Stored CCCs for %s (%s)"
	missing log_strdup().

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-20 19:20:05 -04:00
Johan Hedberg
0d5640ecd7 Bluetooth: Mesh: Fix discarding messages with many segments
The code for checking space in the Friend queue was faulty in the case
that we receive a message with more segments than the configure Friend
Queue size. This is not an issue for the default configuration but
still a possible one. Move the check for exceeding Friend Queue Size
to the per-LPN function, so that bt_mesh_friend_queue_has_space()
iterates all LPNs before delivering its verdict. This allows us to
return success in case no LPN matched (which is how the code was
intended to work).

Fixes #18522

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-20 19:19:46 -04:00
Johan Hedberg
ce83a7c0ae Bluetooth: Mesh: Fix adhering to the configured Friend Queue size
Qualification test case MESH/NODE/FRND/FN/BV-08-C requires that we do
not store more messages than the reported Friend Queue size. The
implementation was so far opportunistic and stored more if it could
(it would later discard if necessary to make sure all queues can store
the required amount). The spec also requires the queues to have new
messages overwrite old ones (in the style of a circular buffer), so we
have to keep track of which buffers are part of the same segmented
message (so we discard all buffers belonging to the same message).

To pass the test case, add APIs to check for space in the Friend
queue, and track the number of buffers for each incoming segmented
message.

Fixes #18090

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-20 19:19:46 -04:00
Johan Hedberg
31842cc9e4 Bluetooth: Mesh: Remove unused code
The bt_mesh_trans_resend() function had no users, and had in fact not
even a prototype in a header file. Just remove it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-20 19:19:46 -04:00
Johan Hedberg
4ec14cc693 Bluetooth: Mesh: Fix missing call to send_cb_finalize
When sent solely to the Friend Queue the send callbacks were not
getting called for unsegmented messages.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-20 19:19:46 -04:00
Trond Einar Snekvik
07964c23f1 Bluetooth: Mesh: Use define for no prov pdu
Adds a prov PDU type define for cases when no PDU is expected.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-08-20 19:19:20 -04:00
Trond Einar Snekvik
98d3225492 Bluetooth: Mesh: Prov confirm tx after confirm rx
According to Mesh Profile Specification 1.0.1 Figure 5.17, the
unprovisioned device should send its confirmation value after the
provisioner sends theirs. Previously, the confirmation value would be
sent immediately after OOB input complete. Now it first waits for the
input data, then from confirmation from the provisioner before sending
the confirmation.

Fixes: #18178.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-08-20 19:19:20 -04:00
Kumar Gala
3a42ff922f cmake: Support SDK versions more broadly
The SDK version is of the form X.Y.Z.  Change the cmake scripts to be
based on X.Y of the version.  This allows us to easily support newer
toolchains without having to explicitly add cmake files for the version
as well as removes duplication between those files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-08-20 19:18:56 -04:00
Johan Hedberg
1b397ddef2 Bluetooth: Remove bogus files
These files got inadvertently added to the 1.14 branch with the
manual backport commit d7d9988d55.
Remove these since they're not supposed to be in the 1.14 branch and
there are not even any hooks to build them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-19 07:56:06 -04:00
Marti Bolivar
ccb2844ec7 scripts: west build: fix pristine builds
There's a couple of missing imports from when the
203021bedb backport was added to this
branch.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-17 06:05:37 -04:00
Jukka Rissanen
93874f0cca net: ipv4: Drop pkt if src address is unspecified
If we receive IPv4 packet where source address is unspecified
(all zeros), then we need to drop it.

Fixes #17427

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:13:33 -04:00
Tomasz Bursztyka
7ddd15c289 net/udp: Accept UDP packet with missing checksum
Having a checksum of zeros in UDP means "missing checksum" and is a
valid case as per RFC 768:

"An all zero transmitted checksum value means that the transmitter
generated no checksum (for debugging or for higher level protocols
that don't care)."

Such support is made possible by adding a new Kconfig option named
CONFIG_NET_UDP_MISSING_CHECKSUM.

However, that is valid only for IPv4. For IPv6, see the RFC 2460
section 8.1:

"Unlike IPv4, when UDP packets are originated by an IPv6 node, the UDP
checksum is not optional."

So the UDP checksum will always be verified in IPv6.

Fixes #16375

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-08-15 18:13:12 -04:00
Tomasz Bursztyka
caacf7caef net/udp: Computed checksum field should not be 0
From RFC 768, in "Fields":
"If the computed  checksum  is zero,  it is transmitted  as all ones"

Fixes #16379

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-08-15 18:13:12 -04:00
Cami Carballo
2fc4a1d94e tests: base64: add tests for error paths
line coverage was only at 72.7% due to untested error paths

Signed-off-by: Cami Carballo <cami.carballo@intel.com>
2019-08-15 18:12:45 -04:00
Jukka Rissanen
be4de1a60a net: sockets: Do not call NULL socket callback function
Before calling socket callback function, make sure the callback
function exists so that we do not get NULL pointer reference.

Fixes #18021

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:12:11 -04:00
Marcin Sloniewski
689d63b1a0 requirements.txt: change package name "hub" to "git-spindle"
Package "hub" has been renamed some time ago to "git-spindle".
Recently package with the same name "hub" has been released on PyPi
page, which causes installing pip requirements.txt to fail since
it is trying to install different package.

Signed-off-by: Marcin Sloniewski <marcin.sloniewski@gmail.com>
2019-08-15 18:11:58 -04:00
Michael Scott
ad4afacff9 net: lwm2m: fix error message in load_tls_credential()
Copy/paste issue was showing the wrong error message when a TLS
credential failed to be added.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-15 18:11:39 -04:00
Jukka Rissanen
9d16440356 net: pkt: Allow larger packets for IPv6 fragmentation
If the allocated net_pkt is larger than the network interface MTU,
then check if the IPv6 fragmentation is enabled and allow larger
net_pkt length as the IPv6 fragmentation will split the packet into
suitable parts.

Fixes #16354

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:11:21 -04:00
Jukka Rissanen
3204df2903 net: ipv6: Fix fragmentation
The next header was not properly set in the de-fragmented
packet.

Fixes #16354

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:11:21 -04:00
Jukka Rissanen
6f21f39b47 net: pkt: Move everything up when pulling data
The net_pkt_pull() needs to move all the remaining data in the
net_buf instead of just the pull amount.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:11:21 -04:00
Andrzej Puzdrowski
baae719e3f fs/nvs: preserve the previous ate searching
Previous ATE searching is accelerate by reading sector
close ate, which allow to skip reading whole storage.

ATE is already covered by crc8. That patch introduce
check on correctness offset read form close ate. This
increases meta-data integrity check level.
This also preserves against possible looping when read
incorrect or not a NVS storage image.

fixes #16899

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:11:03 -04:00
Wentong Wu
83f71a2caf scripts: make mpu align in sections for code reloation
make mpu align inside sections instead of outside to avoid
overlap for code relocation feature.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-15 18:10:39 -04:00
Wentong Wu
36684b4519 linker: move scripts generated code at the beginning of .text
When code relocation enabled, there will be serval regions holding
text. And then there will be function call between these .text
regions, when distance between caller and callee is too far, linker
will automatically generate and insert veneer functions. And these
veneer functions will be located right after the last instruction
in the .text region by the linker. So these code will be put in the
memory reserved for priv_stacks text and kobject text if they don't
consume all the reserved memory. Or the veneer functions will be put
before the reserved memory if there isn't code in the reserved
memory. And then in the user mode building process, there will be
different memory layout and it will cause usr mode not working.
And moving the memory reserved for priv_stacks text and kobject text
at the beginning of .text will avoid above problem. The detailed
analysis for this issue can be found on Github issue #17038.

Fixes: #17038.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-15 18:10:39 -04:00
Andrzej Puzdrowski
d216624615 fs/nvs: skip deletion on non existing entry
No need to write deletion entry for non-existing entry.
Furthermore such a write to filled up storage will make another
writes impossible as it occupied delete nvs_ate space, but it
does not remove anything.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:10:10 -04:00
Andrzej Puzdrowski
e54f97e5e9 fs/nvs: fix initialization hang if sector is full
During initialization NVS analyzes open sector for
find write addresses. It was possible to infinite loop
in case when there was no space for any new ATE in the sector.

This patch introduce check for space available in the sector which
fix the issue.

fixes #17891

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:10:10 -04:00
Andrzej Puzdrowski
d5ea318c8b fs/nvs: fix delete ate accommodation
NVS always leave space for deletion ate in a full sector.
Even that it was not possible to write delete nvs_ate to the
full sector. Because of that it was possible to fill up NVS,
and be able to delete nothing.

This patch introduce recognition of case
the delete ate is writing, and allow to write such nvs_ate to
opened full sector.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:10:10 -04:00
Wentong Wu
662a5425e5 scripts: elf_helper: correct kernel object address check range
kernel object should not located in app_smem area.

Fixes: #17338.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-15 18:09:18 -04:00
Jukka Rissanen
7dded23a84 net: ipv6: Drop pkt if src address is unspecified
If we receive IPv6 packet where source address is unspecified
(all zeros), then we need to drop it.

Fixes #17450

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:09:00 -04:00
Andrzej Puzdrowski
c59da31415 doc/reference: add FCB page
Added page for description FCB subsystem.
Content was ported from MyNewt.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:08:36 -04:00
Andrzej Puzdrowski
3dae810785 fs/fcb: add API documentation to the header
Added doxygen documentation for FCB API.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-15 18:08:36 -04:00
Wentong Wu
040ecf154a driver: timer: loapic_timer: fix compile issue
fix compile issue when DEVICE_POWER_MANAGEMENT enabled.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-15 18:08:14 -04:00
Nicolas Pitre
0d983a3d56 realloc(): fix possible memory leak
If size is equal to zero, and ptr is not NULL, then the call must be
equivalent to free(ptr).

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-15 18:07:53 -04:00
Jukka Rissanen
97996f3abe tests: net: trickle: Adjust config options to avoid error prints
Noticed this error print when running in mps2_an385 platform.

   <err> net_if: There is no network interface to work with!

Adding CONFIG_NET_LOOPBACK=y removes this error. After this
the CONFIG_NET_IPV6_MLD=n needed to be added in order to avoid
crashes when IPv6 MLD is done which is not needed for this test.

Removed also the whitelisting as that is not really needed and
we want to run these in as many platforms as possible.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:07:10 -04:00
Robert Lubos
4ef8660b9a net: lwm2m: Ignore close return value
Explicitly ignore return value from `close` call.

Coverity-CID: 198870

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-08-15 18:06:37 -04:00
Michael Scott
5ff798407f net: lwm2m: remove IP CONFIG checks in lwm2m_parse_peerinfo()
CONFIG_NET_IPV* checks are not needed in lwm2m_parse_peerinfo().
The functions used are always available.  Worse, having these checks
forces the need to enable CONFIG_NET_IPV4 or IPV6 when it's not really
needed (LwM2M could be using an offloaded IP stack).

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17401

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-15 18:06:08 -04:00
Michael Scott
0a09250d92 net: lwm2m: remove IP CONFIG checks in lwm2m_sprint_ip_addr()
CONFIG_NET_IPV* checks are not needed in lwm2m_sprint_ip_addr().  The
functions used are always available.  Worse, having these checks
forces the need to enable CONFIG_NET_IPV4 or IPV6 when it's not really
needed (LwM2M could be using an offloaded IP stack).

NOTE: Also fixes an issue where a NULL is returned when the IP address
is unknown.  This usually ends up with a crash/abort in the logging
code.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17401

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-15 18:06:08 -04:00
Jukka Rissanen
f078060387 net: tcp: Adjust data length if TCP options are present
Skip the TCP options before giving the data to application.
Without this, the TCP options would be passed to the application.

Fixes #17055

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-15 18:05:46 -04:00
Michael Scott
3f402ba529 net: lwm2m: dont select MBEDTLS or set MBEDTLS options in subsys
If a sample wants to use the Zephyr implementation of mbedtls, it
enables CONFIG_MBEDTLS and sets any needed Zephyr-specific mbedtls
options.

Currently, the LwM2M subsystem selects MBEDTLS automatically when
LWM2M_DTLS_SUPPORT is enabled.  Let's remove this and let the
LwM2M client sample enable mbedtls and it's options.

This mimics the behavior of several other network-related samples
and removes conflicts when selecting alternate implementations of
MBEDTLS.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17399

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-15 18:05:22 -04:00
Marti Bolivar
896085abc5 doc: getting_started: west init --mr v1.14.1
That is, specifically fetch v1.14.1, which will be the release tag to
check out on the LTS branch the next time a point release is cut.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-15 18:04:59 -04:00
Marti Bolivar
c38ec879f6 doc: getting_started: recommend west v0.5.x
West is moving on. While later versions of west will remain compatible
with Zephyr LTS as long as it's supported, let's still recommend the
best tested version.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-15 18:04:59 -04:00
Johan Hedberg
e41dd6d3d3 Bluetooth: Mesh: Fix reference count imbalance in bt_mesh_net_resend()
The commit 1c7b668804 tried to fix
resending segments to the GATT bearer, however it got the buffer
refernce counting wrong. The bt_mesh_net_resend() function doesn't
own a reference to the buffer, i.e. it's not responsible for unrefing
it. E.g. bt_mesh_adv_send() takes its own reference.

What was missing however was the handling of the callbacks. Use the
recently introduced send_cb_finalize() helper to make sure they're
called.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
c86c1b19a0 Bluetooth: Mesh: Introduce a helper for send callback finalization
There are several places that require the send callbacks to be called
immediately. Reduce the code a bit by introducing a helper for this.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
30f4fcb039 Bluetooth: Mesh: Fix starting IV Update when not on primary subnet
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes #17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
d6679e7739 Bluetooth: Mesh: Fix canceling publication retransmission timer
This branch is inherited from old code that used to start the timer as
soon as a message was queued for transmission rather than when it was
actually transmitted (the case today). It'll also cause a race in case
the publication goes over the GATT layer since the "sent" callback
happens synchronously in that case.

Fixes #17821

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
3be43c5e22 Bluetooth: Mesh: Fix resending segments on correct bearer
The GATT bearer is a reliable one so there should theoretically never
be a need to resend segments. If however for some strange reason the
proxy client doesn't immediately ack all segments we should do the
resending on the GATT bearer, rather than sending them over
advertising.

Fixes #17907

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
650475e7ad Bluetooth: Mesh: Fix not sending all segments through the Friend Queue
The code was incorrectly bailing out with "return 0" rather than
continue. Also, it was incorrectly making a reference to
tx->seg[seg_o] since when a PDU goes through the friend queue we don't
use the usual retransmission mechanism.

Fixes: #17932

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
f5ab2a897b Bluetooth: Mesh: Fix canceled buffer memory leak
In case a queued buffer is canceled before sending we have to unref
it, since that's what adv_send() would do as well.

Fixes #17936
Fixes #18013

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
9d6617dcc3 Bluetooth: Mesh: Fix heartbeat sending on Friendship established/lost
Mesh Profile 3.6.7.2 Publishing Heartbeat messages:

"
Triggered publishing of Heartbeat messages is enabled by
the Heartbeat Publication Features state (see Section 4.2.17.5):
...
- If the Low Power bit is set to 1, a Heartbeat message shall be
 published when the node establishes or loses Friendship (see Section
 3.6.6.1).
"

Fixes #18194

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
c62e43aee4 Bluetooth: Mesh: Fix checking for active heartbeat publication
When sending heartbeat messages triggered by feature changes the code
was trying to look up the configured publication subnet, in an
apparent attempt to figure out if publication is enabled or not. A
more appropriate way is to check for the heartbeat publication
destination address, and since we have a helper function this can be
done in a single place.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Johan Hedberg
8f6a0d7a67 Bluetooth: Mesh: Move heartbeat sending to transport layer
The heartbeat is a transport layer feature, so move it to transport.c.
This also opens the way to properly fix Friendship-established/lost
triggering for LPN role.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 18:04:36 -04:00
Rich Barlow
bf5d17a862 Bluetooth: Mesh: LPN: Remove msg from cache on rejection
When in Low Power mode an LPN may receive messages sent by nodes other
than its friend during its brief receive window. These messages get
rejected by the transport layer. At some point in the future the LPN
will receive these messages from its friend, however they will have
already been added to the network message cache earlier.

When the transport layer rejects a message due to it being received from
a non-friend node while in Low Power mode it must be removed from the
network message cache so that it can be correctly received from its
friend in the future.

Fixes #17809

Signed-off-by: Rich Barlow <rich@bennellick.com>
2019-08-15 18:04:36 -04:00
Joakim Andersson
e7ea607b6b Bluetooth: Host: Set Kconfig RPA timeout in controller
Use the RPA timeout provided by Kconfig in the controller

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
ef725487e2 Bluetooth: Host: Fix RPA timer not running
The RPA timer should always be running, even with privacy supported by
the controller. In order to select an IRK to generate the private
the controller is instructed by provided an identity address.
If we want to advertise privately without providing an identity address
the host has to set the private address.

Fixes: #18150

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
9866122685 Bluetooth: Host: fix missing interval_min copy
Fix missing interval min copy in bt_conn_set_param_le. Application is
unable to override BT_GAP_INIT_CONN_INT_MIN for interval_min.

Fixes: #17789

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
6715b80abf Bluetooth: controller: Fix assert in RPA timeout for advertiser
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Arthur Crepin-Leblond
6cc836df3b Bluetooth: gatt: Reuse existing handles from a previously added service
When removing a service using bt_gatt_service_unregister, its attributes
handles will keep their value which can cause a problem when adding the
service again to the GATT database.
When re-adding, the gatt_register routine is taking the last handle of
the GATT database to compare it with the handles of the service to be
added.
If a service has handles with a lower value than the last handle of
the database an error will occur.
If we add/remove/add the last service, no error will occur as its
handles are always greater than the last one of the database.

Instead of resetting the handles when unregistering a service and
reassign new ones we make sure that the handles of the services are
not in use in the GATT database in order to place the service back
where it used to be.

Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
2019-08-15 18:04:36 -04:00
Findlay Feng
3283cabb70 bluetooth: Fix an undefined behavior
The original creates a pointer to a compiler-generated temporary that is
destroyed when the scope is exited. The pointer is stored in a structure
defined in an enclosing scope and is invalid by the point it's used.

The fix holds the structure in a variable with the same lifetime as
the pointer.

Signed-off-by: Findlay Feng <i@fengch.me>
2019-08-15 18:04:36 -04:00
Joakim Andersson
2fd43e4617 Bluetooth: SMP: Fix peripheral security request with authenticated keys
The call to bt_conn_security will send a SMP security request for
peripheral, and for central it will initiate LL encryption.
A call to bt_conn_security with no IO capabilities but authenticated
keys has been distributed, would succeed on central side, but fail on
peripheral side with error code -22.

The keys could have been either:
 - Preprogrammed
 - IO capabilities may have changed.
 - OOB bonding may been used.

Fix so that Peripheral can send a security request if the bond
information is already established.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
0695270d3a Bluetooth: Settings: Fix generated identity not persistently stored.
Fix an issue where the generated identity was not permanently stored.
This resulted in being unable to reconnect after bonding when using
privacy, since a new local IRK was generated on reboot.

When settings is enabled the application is responsible for loading
identities and possible creating its own identities.
When settings_load is called and no identities has been created or found
in persistent storage a new identity will be created.
Since bt init has not been finalized bt_id_create will not make a call
to bt_settings_save_id. So we need to make sure that this identity will
be stored.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
1e783c649d doc: Bluetooth: Update PICS to ICS
PICS is changed to ICS by BTI.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
326727dc54 doc: Bluetooth: Add ICS for Mesh Profile
This patch adds the ICS for Mesh Profile based on 7.4.1.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
da83659d36 doc: Bluetooth: Update SM ICS to 7.4.1
This ptach updates the SM ICS to 7.4.1.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
da3cfaff90 doc: Bluetooth: Update L2CAP ICS to 7.4.1
This patch updates the L2CAP ICS to 7.4.1.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
788399bb8b doc: Bluetooth: Update GATT ICS to 7.4.1
This patch update the GATT ICS to 7.4.1.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Tedd Ho-Jeong An
657b2f51f6 doc: Bluetooth: Update GAP ICS to 7.4.1
This patch updates the GAP ICS to 7.4.1.
It updates the Bluetooth Spec to 5.1 and added missing ICS tables.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-08-15 18:04:36 -04:00
Joakim Andersson
6c26811d56 Bluetooth: GATT: Fix segfault discover descriptors all UUIDs
Handle optional argument UUID in bt_gatt_discover with type
DISCOVER_DESCRIPTOR, bt_uuid_cmp doesn't check for NULL pointer.
On system with MMU (nrf52_bsim) this can result in segfault.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Luiz Augusto von Dentz
b5ea0989b6 Bluetooth: GATT: Use atomic_t for subscribe flags
This makes use of atomic_t helpers to set, test and clear flags.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-15 18:04:36 -04:00
Luiz Augusto von Dentz
500d85c26b Bluetooth: GATT: Fix not canceling on unsubscribe
This introduces a new flag (BT_GATT_SUBSCRIBE_WRITE_PENDING) which is
set when a write operation requires canceling before the parameters can
be reused.

Fixes #17534

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-15 18:04:36 -04:00
Luiz Augusto von Dentz
d80c0500e5 Bluetooth: ATT: Fix bt_att_req_cancel clearing outstanding request
This adds a dummy cancel request which is used instead of NULL when
clearing and outstanding request thus prevent new request to take
place before a response is received while allowing the original request
to be reused.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-15 18:04:36 -04:00
Joakim Andersson
11d60f9661 Bluetooth: Host: Fix advertiser state flags
Set advertisers state flags so that previous advertise params does not
affect the current advertiser state.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
c367281156 Bluetooth: host: Fix gatt indicate when conn is NULL
Fix gatt indicate when conn is NULL and called with characteristic
declaration as the attribute argument. In this case the handle was not
advanced to the characteristic value. This is inconsistent with the rest
of the notify and indicate API

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Arthur Crepin-Leblond
a8578ea2aa Bluetooth: gatt: Fix DB corruption when adding/removing service
Fix an issue in the gatt_register routine where removing a service and
adding it again would cause the database to have non-ascending
orderdered handles numbers and lead to an incomplete service discovery.

Fix: Go through the database and look for a place where to insert
the new service.

Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
b23f856c5d Bluetooth: SMP: Fix SMP identity distributing IRK for ID 0 always
Fix an issue in the SMP identity distribution where the IRK for the
default identity was always distributed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
a6737bb8d9 Bluetooth: Mesh: Fix rejecting invalid remote public key
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).

This fixes issue that d4fd267086
supposed to fix. The problem is bt_dh_key_gen is async.
Local public key cannot be sent from the same context
the bt_dh_key_gen is called because we don't know yet
if remote key is valid.

Fixes MESH/NODE/PROV/BI-13-C.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Joakim Andersson
84bf14d682 Bluetooth: Host: Fix bug in creating connection with wrong own address.
Fix bug introduced by: 45da629b24
Mistakenly set the own address type to the destination address type.
Also this uses the RPA_OR_RANDOM in case local IRKs exists in the
controller.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
2b1a8dd77a Bluetooth: Controller: Fix privacy advertiser connect peer address type
Fix an issue with enhanced connection complete event raised by the
advertiser role. The advertiser reported that it has resolved the
the identity address of the peer, even when the peer is connecting
using it's identity address.
The host will not have the correct on-air address type i.e public.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Joakim Andersson
0c57ca579b Bluetooth: Host: Fix wrong init address when controller resolved address
The init addr should contain the on-air address used to establish the
connection. The dst address contains either the current RPA of the
unknown peer, or the identity address after identity information has
been exchanged.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
b3a4d9c308 Bluetooth: Shell: Fix unregister GATT Metrics vendor service
The 'registered' flag was not cleared when 'gatt metrics off'
was called so that one was unable to register the service again.
Remove 'registered' variable that is actually not needed as there
is no tracking if service is already registered in similar
cmd_register_test_svc command. If the service is already registered,
the host will log an error.

Fixes: #17882
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
66edcfcefb Bluetooth: GATT: Add BTP Discover All Primary Services command handler
This will handle BTP Discover All Primary Services command.

Related TC: GATT/CL/GAD/BV-01-C
Fixes: #17861
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
7a9ad1f741 Bluetooth: GATT: Fix byte order for database hash
Core 5.1, Vol 3, Part F, 3.3.1
"Multi-octet fields within the GATT profile shall be sent least
significant octet first (little-endian) with the exception of the
Characteristic Value field. The Characteristic Value and any fields
within it shall be little-endian unless otherwise defined in the
specification which defines the characteristic."

Fixes: GATT/SR/GAS/BV-02-C
Fixes: #17857
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
9077f6d2cc Bluetooth: tester: Change RPA timeout
This changes RPA timeout so that the address is changed every 60
seconds. This change is needed to speed up privacy related test cases.
Currently, the new RPA was initiated on request that was a bit hackish
and could be done via BT_RPA_TIMEOUT Kconfig option.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
9dae70c137 Bluetooth: tester: Enable GAP writable device name
This enables support for GAP writable device name in tester application
for testing purposes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
3fa36b23e6 Bluetooth: tester: Update to recent conn param related changes in BTP
This updates tester application to recent changes in BTP related
to Connection Parameters Update.
Connected event has been extended with connection parameters.
Connection Parameters Update command and event have beend added to
initiate and track current connection parameters.
Needed to automate qualification test GAP/CONN/CPUP/BV-06-C

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
bd46765601 Bluetooth: shell: Fix L2CAP connect parameters count
This fixes mandatory parameters count.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
fbf9ac1ad7 Bluetooth: tester: Enable Mesh Friend support
Enable Mesh Friend support in tester application.

Fixes: #17600
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Mariusz Skamra
4d47ece3e6 Bluetooth: Add BT_SMP_ENFORCE_MITM option
Having this option disabled, MITM flag state can be controlled by
bt_conn_security state. This option is enabled by default to not
change the current implementation behavior.
Related to SM/MAS/SCPK/BV-01-C.

Fixes #17463

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-08-15 18:04:36 -04:00
Michael Scott
868ca61b51 net: lwm2m: firmware: add log_strdup to remove logging errors
When performing OTA using the LwM2M subsys, several logging errors
regarding log_strdup were noted.  Let's fix these.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-15 18:03:59 -04:00
Wentong Wu
8ec8a58fe8 kernel: timeout: do not active time slicing if idle thread ready
zero slice_ticks when can't time slice so that next_timeout will
ignore slice_ticks of _current_cpu and system can stay low power
state longer time.

Fixes: #17368.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-15 18:03:28 -04:00
Robert Lubos
af4effd9de net: openthread: Verify iface in net_mgmt event handler
OpenThread did not verify if the interface provided in the net_mgmt
handler is actually an OpenThread interface. In result, when multiple
network interfaces were used, different interfaces were processed by the
OpenThread handler, ending up in a crash.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-08-15 18:02:59 -04:00
Marti Bolivar
4afa7739db scripts: runners: check for required programs
Add self.require() checks before running commands. Increase test
coverage, including for this feature, while we are here.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-15 18:02:35 -04:00
Marti Bolivar
95e056b196 scripts: runners: abstract jlink's missing program support
The runners/jlink.py script has a mechanism for erroring out if a host
tool is not installed. Abstract it into runners/core.py and handle it
from run_common.py. This will let it be used in more places.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-15 18:02:35 -04:00
Wayne Ren
ed0c8812ee arch: arc: fix the bug caused by hardware sp switch in interrupt
* if thread switchs in interrupt, the target sp must be in
thread's kernel stack, no need to do hardware sp switch

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-08-14 17:32:38 -04:00
Joakim Andersson
6b726c0260 Bluetooth: controller: Fix assert in RPA timeout for advertiser
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.

Relates to #18091 and #17846.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
0c5593a05f Bluetooth: controller: Decorrelate address generation from resolution
Changes related to Bluetooth TSE 11068.

Fixes BT LL TS 5.1.0 test:
LL/SEC/ADV/BV-03-C [Privacy - Non-connectable Undirected
Advertising, Resolvable Private Address]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
0420e0646d Bluetooth: controller: Fix nRF52840 Coded PHY timings
Fix the nRF52840 Coded PHY radio timings based on testing
with conformance tester.

Fixes the following conformance tests:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI Change]
LL/CON/MAS/BV-54-C [Slave Receiving Data, LE Coded, CI Change]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
d19c19da28 Bluetooth: controller: Fix regression in Coded PHY CI Change
Fix the regression in Coded PHY CI change implementation
introduced by reverting the commit 9d1ca9c390 ("Bluetooth:
controller: remove redundant PPI channel and TIMER CC").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
e5823dcf5d Bluetooth: controller: Add PA/LNA support on NRF_P1 GPIO pins
Added support for using NRF_P1 GPIO pins on nRF52840 SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
2829372121 Bluetooth: controller: Fix cond compile of DLU event generation
Fix the conditional compile of Data Length Update event
generation on PHY Update Procedure when Data Length
Extensions are not supported.

The regression was introduced in
commit 70a89876d0 ("Bluetooth: controller: Fix missing
data length update event")

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
e584837d1e Bluetooth: controller: Update Bluetooth version to 5.1
Update the Bluetooth HCI Version to 5.1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
c93673fbec Bluetooth: controller: Fix DLE during data transmission
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
95c84b25a8 Bluetooth: controller: Add deferred procedure complete event
Added implementation to defer procedure complete event until
actual on-air connection event instant.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
069b7d3ef8 Bluetooth: controller: Enable Fast Enc and RSSI features
Enable the Fast Encryption design and connection RSSI
measurement when CONFIG_BT_HCI_RAW is selected.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
3d112a6c72 Bluetooth: controller: Fix post DLE/PHY update event length
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.

This fix with avoid states/roles from stepping on each
others event length. Connection would have supervision timed
out or have stalled data transmissions due to insufficient
reserved air time.

Relates to #15171.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
9fa7db868c Bluetooth: controller: Fix missing data length update event
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.

Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
5f455a6e66 Bluetooth: controller: Fix packet timing restriction reset
Fixed a bug related to missing reset of packet timing
restriction variable.

Fixes BT LL TS 5.1.0 test:
LL/CON/SLA/BV-55-C [Initiating PHY Update Procedure - Packet
Time Restrictions, LE Coded]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Vinayak Kariappa Chettimada
0ce629178d Bluetooth: controller: Fix PHY update proc symmetric rsp
Fix PHY update procedure to correctly handle master
requesting asymmetrical and slave symmetrical.

Fixes BT LL TS 5.1.0 conformance test:
LL/CON/MAS/BV-117-C [PHY Update Procedure - Master
Requests Asymmetrical, Slave Symmetrical]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-08-14 17:31:55 -04:00
Ioannis Konstantelias
105ff0446f drivers: flash: stm32: Fix insufficient wait time
flash_erase cannot erase a page from the STM32xx SOC flash. It seems
that the erase wait time is not enough and against to what the SOC's
datasheet states. As a result this patch doubles the wait time.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
2019-08-14 17:30:49 -04:00
Andrei Gansari
d3f50fb6a7 soc: k64f MPU configured to always allow ENET
Because NXP MPU's regions are dynamically enabled/disabled, ENET
device's access maybe restricted when switching out of a task.
Background DMA transfers from RAM to MAC/PHY may happen during MPU
region reconfiguration or core idling.
Enabled ENET (Kinetis MPU Master 3) to always have access to RAM address
space.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-08-14 17:29:51 -04:00
Andrew Boie
1117710ffc tests: force stack canaries off for two user tests
Stack canaries require that the z_libc_partition be added to
the memory domain, otherwise user thread access to the
stack canary value will result in an MPU/MMU fault.

These tests define their own domains to test specific userspace
features. Adding another partition to them would be invasive,
would potentially break some platforms with a limited number
of MPU regions, and these tests are not designed to validate
stack canaries anyway, we have other tests for that.

Fixes: #17595

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-08-14 17:28:51 -04:00
Nicolas Pitre
e7ae2f17ca mempool: fix corruption of the free block bitmap and beyond
In z_sys_mem_pool_block_alloc() the size of the first level block
allocation is rounded up to the next 4-bite boundary. This means one
or more of the trailing blocks could overlap the free block bitmap.

Let's consider this code from kernel.h:

  #define K_MEM_POOL_DEFINE(name, minsz, maxsz, nmax, align) \
       char __aligned(align) _mpool_buf_##name[_ALIGN4(maxsz * nmax) \
                              + _MPOOL_BITS_SIZE(maxsz, minsz, nmax)]; \

The static pool allocation rounds up the product of maxsz and nmax not
size of individual blocks. If we have, say maxsz = 10 and nmax = 20,
the result of _ALIGN4(10 * 20) is 200. That's the offset at which the
free block bitmap will be located.

However, because z_sys_mem_pool_block_alloc() does this:

        lsizes[0] = _ALIGN4(p->max_sz);

Individual level 0 blocks will have a size of 12 not 10. That means
the 17th block will extend up to offset 204, 18th block up to 216, 19th
block to 228, and 20th block to 240. So 4 out of the 20 blocks are
overflowing the static pool area and 3 of them are even located
completely outside of it.

In this example, we have only 20 blocks that can't be split so there is
no extra free block bitmap allocation beyond the bitmap embedded in the
sys_mem_pool_lvl structure. This means that memory corruption will
happen in whatever data is located alongside the _mpool_buf_##name
array. But even with, say, 40 blocks, or larger blocks, the extra bitmap
size would be small compared to the extent of the overflow, and it would
get corrupted too of course.

And the data corruption will happen even without allocating any memory
since z_sys_mem_pool_base_init() stores free_list pointer nodes into
those blocks, which in turn may get corrupted if that other data is
later modified instead.

Fixing this issue is simple: rounding on the static pool allocation is
"misparenthesized". Let's turn

	_ALIGN4(maxsz * nmax)

into

	_ALIGN4(maxsz) * nmax

But that's not sufficient.

In z_sys_mem_pool_base_init() we have:

        size_t buflen = p->n_max * p->max_sz, sz = p->max_sz;
        u32_t *bits = (u32_t *)((u8_t *)p->buf + buflen);

Considering the same parameters as above, here we're locating the extra
free block bitmap at offset `buflen` which is 20 * 10 = 200, again below
the reach of the last 4 memory blocks. If the number of blocks gets past
the size of the embedded bitmap, it will overlap memory blocks.

Also, the block_ptr() call used here to initialize the free block linked
list uses unrounded p->max_sz, meaning that it is initially not locating
dlist nodes within the same block boundaries as what is expected from
z_sys_mem_pool_block_alloc(). This opens the possibility for allocated
adjacent blocks to overwrite dlist nodes, leading to random crashes in
the future.

So a complete fix must round up p->max_sz here too.

Given that runtime usage of max_sz should always be rounded up, it is
then preferable to round it up once at compile time instead and avoid
further mistakes of that sort. The existing _ALIGN4() usage on p->max_sz
at run time are then redundant.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-14 17:28:23 -04:00
Andy Ross
0000746002 lib/os/mempool: Fix corruption case with block splitting
The block_fits() predicate was borked.  It would check that a block
fits within the bounds of the whole heap.  But that's not enough:
because of alignment changes between levels the sub-blocks may be
adjusted forward.  It needs to fit inside the PARENT block that it was
split from.

What could happen at runtime is that the last subblocks of a
misaligned parent block would overlap memory from subsequent blocks,
or even run off the end of the heap.  That's bad.

Change the API of block_fits() a little so it can extract the parent
region and do this properly.

Fixes #15279.  Passes test introduced in #16728 to demonstrate what
seems like the same issue.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-08-14 17:28:23 -04:00
Krzysztof Chruscinski
4dfcb881e9 logging: Fix corruption in log panic when scheduler was active
Logger had false assumption that once log_panic is called then
context switch will never occur and was not protecting against
reentrancy in panic mode. Added interrupt locking when accessing
unprotected part.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-08-14 17:27:47 -04:00
Ioannis Glaropoulos
8b0fdf54ac arch: arm: userspace: don't use the default stack in z_arm_do_syscall
z_arm_do_syscall is executing in privileged mode. This implies
that we shall not be allowed to use the thread's default
unprivileged stack, (i.e push to or pop from it), to avoid any
possible stack corruptions.

Note that since we execute in PRIV mode and no MPU guard or
PSPLIM register is guarding the end of the default stack, we
won't be able to detect any stack overflows.

This commit implement the above change, by forcing
z_arm_do_syscall() to FIRST switch to privileged
stack and then do all the preparations to execute
the system call.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-08-14 17:26:55 -04:00
Ioannis Glaropoulos
113924134e userspace: minor typo fixes in various places
System call arguments are indexed from 1 to 6, so arg0
is corrected to arg1 in two occasions. In addition, the
ARM function for system calls is now called z_arm_do_syscall,
so we update the inline comment in __svc handler.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-08-14 17:26:55 -04:00
Ioannis Glaropoulos
37b867b08a arch: arm: userspace: correct inline comment for bad syscalls
We need to correct the inline comment in swap_helper.S,
which is suggesting that system call attempts with
invalid syscall IDs (i.e. above the limit) do not force
the CPU to elevate privileges. This is in fact not true,
since the execution flow moves into valid syscall ID
handling.

In other words, all we do for system calls with invalid
ID numbers is to treat them as valid syscalls with the
K_SYSCALL_BAD ID value.

We fix the inline documentation to reflect the actual
execution flow.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-08-14 17:26:55 -04:00
Andrew Boie
6cec0bcc6b toolchain: allow 0.10.1 SDK
Code coverage gathering is broken on qemu_x86 with the
0.10.0 SDK.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-08-14 17:26:39 -04:00
Daniel Leung
233c6d8540 tests/kernel/device: extends test for code coverage
device_get_binding() compares pointers first before doing strcmp().
However, enabling coverage forces -O0 to disable any compiler
optimizations. There would be multiple copies of the same string,
and the code pathing doing pointer comparsion would not be tested
at all. So add this flag to merge string constants such that
the pointer comparison would be exercised.

This also adds a bad driver which fails initialization. This is
to make sure that execution path is covered.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-08-14 17:26:39 -04:00
Andrew Boie
a5a7831f4e tests: crc: convert to regular test case
The special 'unittest' target has largely been supersesed by
native_posix, and converting this to a regular test will allow
us to see code coverage for the CRC functions in our coverage
reports.

Fixes: #16943

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-08-14 17:26:39 -04:00
Benoit Leforestier
ab5c2e3d0e codeowner: add codeowners for /test/lib
Add codeowners for /test/lib

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2019-08-14 17:26:39 -04:00
Andrew Boie
5ba8569470 tests: mem_alloc: don't set main thread size
This test uses ztest, there is no need to set this and it
was breaking builds with CONFIG_COVERAGE=y

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-08-14 17:26:39 -04:00
Declan Traill
5b8488a936 Settings: Fixes for compiler warnings
Warnings were due to due to possibly uninitialized variables.

Signed-off-by: Declan Traill <declan.traill@setec.com.au>
2019-07-31 05:49:33 -04:00
Anas Nashif
03a52401c6 release: bump version to 1.14.1-rc1
Bump version to 1.14.1-rc1

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-05 12:07:55 -04:00
Andrew Boie
a3db646ee7 tests: fatal: test failed assertion
Covers assert_post_action() which was previously uncovered.

Partial fix for #16011

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:58:18 -04:00
Andrew Boie
45a1852ce7 tests: json: improve code coverage
Adds coverage for the uncovered json_calc_encoded_len()
and covers a bunch more error cases.

This gets us up to 90.1% line coverage and 100% function
coverage.

Fixes: #16944
Partial fix for: #16011

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:57:58 -04:00
Andrew Boie
eaf7c2f4c2 kernel: fix CONFIG_THREAD_NAME from user mode.
This mechanism had multiple problems:

- Missing parameter documentation strings.
- Multiple calls to k_thread_name_set() from user
  mode would leak memory, since the copied string was never
  freed
- k_thread_name_get() returns memory to user mode
  with no guarantees on whether user mode can actually
  read it; in the case where the string was in thread
  resource pool memory (which happens when k_thread_name_set()
  is called from user mode) it would never be readable.
- There was no test case coverage for these functions
  from user mode.

To properly fix this, thread objects now have a buffer region
reserved specifically for the thread name. Setting the thread
name copies the string into the buffer. Getting the thread name
with k_thread_name_get() still returns a pointer, but the
system call has been removed. A new API k_thread_name_copy()
is introduced to copy the thread name into a destination buffer,
and a system call has been provided for that instead.

We now have full test case coverge for these APIs in both user
and supervisor mode.

Some of the code has been cleaned up to place system call
handler functions in proximity with their implementations.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:57:41 -04:00
Andrew Boie
d5b83ae461 arc: use different load instruction
If the offset within the thread struct to the
ARC arch-specific 'relinquish_cause' member is too
large, ld_s instructions referencing it will not
compile. This happens easily if CONFIG_THREAD_NAME
reserves a name buffer within the thread struct, since
all the arch-specific members come last.

Use the regular 'ld' instruction instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:57:41 -04:00
Andrew Boie
c9f0148e3c tests: schedule_api: cover priority checks
Some cases, such as for the idle thread, were uncovered.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:57:15 -04:00
Andrew Boie
f0f74e4f0e tests: common: add tests for extra sflist APIs
sflists have a couple APIs related to sfnodes that aren't
present for slists. There were uncovered, write some tests
for them.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:56:44 -04:00
Andrew Boie
dfb96f40d6 kernel: test coverage for sflist
We were testing all the slist APIs, but not the sflist
variant. Make a copy of the slist tests for sflist,
with the names properly changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:56:44 -04:00
Andrew Boie
4899c096ae lib: os: fix slist code coverage
Some of the slist APIs were only being indirectly exercised;
add to the slist test case to cover everything explicitly.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-05 10:56:44 -04:00
Vinayak Kariappa Chettimada
528f787ddd Bluetooth: controller: Fix handling zero length L2CAP start frame
Added a fix handling L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-07-04 09:25:40 -04:00
Andrew Boie
db50b4ec2a lib: os: exclude z_arch_printk_char_out()
This function doesn't do anything, and only exists so that
it can be overridden later, exclude from coverage reports.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 17:06:33 -04:00
Andrew Boie
d3ca4bdbdb lib: os: fix vsnprintk coverage
vsnprintk() was uncovered. Simply adjust snprintk() to use
it, instead of duplicating logic.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 17:06:33 -04:00
Tedd Ho-Jeong An
301558a433 tests: bluetooth/tester: Add support Read Using Characteristic UUID
This patch adds an API to support Read Using Characteristic UUID.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-07-02 16:56:47 -04:00
Mariusz Skamra
919aa1785a Bluetooth: gatt: Fix infinite read_by_uuid procedure
The attribute handle used to read next attribute has to be incremented
to not loop reading the same attribute.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-07-02 16:56:47 -04:00
Luiz Augusto von Dentz
0f01fe754c Bluetooth: GATT: Fix not parsing result of Read by Type
When using the procedure Read By Type the response may contain multiple
instances so it needs to be parsed properly. When dealing with long
values only the beggining will be read, for the remaining bytes the
application should issue another bt_gatt_read with offset so Read Blob
procedure is used as recommended by the spec:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F page 2312:

The Read Blob Request would be used to read the remaining octets of a
long attribute value.

Fixes #16107

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-07-02 16:56:47 -04:00
Tedd Ho-Jeong An
fb199a2ac5 Bluetooth: GATT: Add support for Read Using Characteristic UUID
This patch adds support for Read Using Characteristic UUID which is one
of the procedure to read the characteristic value especially when the
client only knows the characteristic UUID and does not know the handle
of the characteristic.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-07-02 16:56:47 -04:00
Marti Bolivar
3c6f0742a7 scripts: fix pyocd runner --flash-opt help
This doesn't work. Fix the example.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-07-02 16:56:20 -04:00
Andrew Boie
5bbae10490 kernel: offsets: exclude from coverage
None of this is runtime code.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:55:59 -04:00
Johan Hedberg
24d7e9e03f Bluetooth: Mesh: Fix provisioning send error handling
Log all send errors, but don't try to call e.g. prov_send_fail_msg()
since that'll almost certainly fail as well.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
d4fd267086 Bluetooth: Mesh: Fix rejecting invalid remote public key
Mesh Profile Spec v1.0.1 | Section 5.4.2.3:
"The Provisioner and the device shall check whether the public key
provided by the peer device or obtained OOB is valid (see Section
5.4.3.1).

When the Provisioner receives an invalid public key, then provisioning
fails, and the Provisioner shall act as described in Section 5.4.4.
When the device receives an invalid public key, then provisioning
fails, and the device shall act as described in Section 5.4.4."

This is also in Erratum 10395 which is Mandatory for Mesh v1.0.

The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).

Fixes MESH/NODE/PROV/BI-13-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
9fb22af194 Bluetooth: Mesh: Generate new public key for each provisioning session
Mesh Profile Spec v1.0.1 Section 5.4.2.3: "If the public key was not
available using an OOB technology, then the public keys are exchanged
between the Provisioner and the unprovisioned device. For each
exchange, a new key pair shall be generated by the Provisioner and the
unprovisioned device."

This allows passing MESH/NODE/PROV/BV-12-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
f35dc9c018 Bluetooth: Fix public key callback management
Clear the callback list once generation is complete and we've done
calling all callbacks. This lets us use bt_pub_key_gen() multiple
times, which before this patch could have resulted in a corrupt linked
list.

Also remove redundant callback dispatching from bt_pub_key_gen() since
the function checks for the PUB_KEY_BUSY flag in the beginning, i.e.
there cannot be other pending generation actions at this point in the
code.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
2761887b20 Bluetooth: SMP: Make public key handling more robust
Update code to handle other users of the public key generation APIs
by fetching the current public key at the beginning of each SMP
session. This is particularly important if someone creates the (rather
odd) combination of Mesh and SMP where Mesh will regenerate a new
key pair after provisioning.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
de50834455 Bluetooth: Mesh: Rename reset_link() to reset_adv_link()
This is a PB-ADV specific internal helper, so rename it appropriately
to avoid any confusion.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
683e14cc94 Bluetooth: Mesh: Fix Public Key mismatch error handling
Mismatch in Public Key type will cause device to send Invalid Format
error, and treat any further PDU's as unexpected.

This affects MESH/NODE/PROV/BI-03-C test case.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
ee793280f3 Bluetooth: Mesh: Fix missing protocol error timeout
Provisioning errors shouldn't cause device to close link. Upon error,
device will send Provisioning Failed PDU, and any further PDU's will
be considered as unexpected as per Mesh Profile section 5.4.4.

Also a timer is started every time device sends or receives a PDU.
This affects MESH/NODE/PROV/BV-10-C test case.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:55:33 -04:00
Johan Hedberg
8c2c5618de Bluetooth: Introduce separate pool for discardable events
Introduce a separate buffer pool for events which the HCI driver
considers discardable. Examples of such events could be e.g.
Advertising Reports. The benefit of having such a pool means that the
if there is a heavy inflow of such events it will not cause the
allocation for other critical events to block and may even eliminate
deadlocks in some cases.

Also update all mesh samples not to specify explicit RX buffer counts
anymore. Instead, create appropriate defaults in Kconfig so that we
only need to override this in the app for cases like the bbc:microbit
with limited memory.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:54:49 -04:00
Johan Hedberg
d7d9988d55 Bluetooth: Add dedicated pool for HCI_Num_Completed_Packets HCI event
This event is a priority one, so it's not safe to have it use the RX
buffer pool which may be depleted due to non-priority events (e.g.
advertising events). Since the event is consumed synchronously it's
safe to have a single-buffer pool for it. Also introduce a new
bt_buf_get_evt() API for HCI drivers to simplify the driver-side code,
this effectively also deprecates bt_buf_get_cmd_complete() which now
has no in-tree HCI driver users anymore.

Fixes #16864

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 16:54:49 -04:00
Andrew Boie
7e37ef4a7c tests: sys_mutex: improve code coverage
Test error cases and alternative implementation to bring code
coverage up to 100% file / 100% line.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:54:27 -04:00
Ravi kumar Veeramally
47588913d3 net: sockets: Add timeout to socket connect call
Current socket connect call implementation always takes
K_FOREVER timeout value, which blocks TCP connections
in case failure. TCP connections waits until it receives
SYN ACK. If there is no SYC ACK means, connect call is
blocked forever.

Added a Kconfig option to define timeout value. Default
value is 3000 milliseconds. User can modify it.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-07-02 16:54:00 -04:00
Jukka Rissanen
b1991f9d12 tests: net: dns: Add tests for dns_unpack_answer()
Make sure that dns_unpack_answer() works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:53:19 -04:00
Jukka Rissanen
686f3d21b4 net: dns: Make dns_unpack_answer() to check non-compressed answers
Modify dns_unpack_answer() function to check if the answer is
compressed or not, and return correct values regardless.

Fixes #16594

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:53:19 -04:00
Andrew Boie
a92a530465 tests: thread_apis: exercise some system calls
We had no system call coverage for k_thread_suspend
and k_thread_resume.

Some unnecessary cleanup tasks in the test case have
been removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:52:53 -04:00
Andrew Boie
2ae7f09dad tests: device: cover device_get_binding()
We had no coverage for invoking this from a system call.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:52:09 -04:00
Andrew Boie
a880994e06 tests: common: cover k_cycle_get_32() syscall
We had plenty of coverage for k_cycle_get(), but not its
32-bit variant. Run a case in user mode so that the system
call handler gets covered.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:49:20 -04:00
Jukka Rissanen
f06bb3f1cd tests: net: mgmt: Verify that info_length is correct
If info is sent by net_mgmt, make sure it contains correct data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:48:37 -04:00
Jukka Rissanen
ea02a080a6 net: mgmt: Send event with info when applicaple
If the net_mgmt event has some info, like IP address, that
could be sent, then send it the same time. This is very useful
for the receiver of the event in order to know that is happening
in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:48:37 -04:00
Jukka Rissanen
1ab6102343 net: mgmt: Add info length to event wait API
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:48:37 -04:00
Andrew Boie
0608aa8ffe kernel: exclude stubs from code coverage
These are stub functions that do nothing. Exclude from
coverage reports.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:46:06 -04:00
Andrew Boie
618a2a7ea3 tests: userspace: cover z_object_recycle()
We didn't have code coverage for this function anywhere
except indirectly through some network tests; exercise it
in the suite of userspace tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:15:49 -04:00
Andrew Boie
a51247e5fc tests: dynamic_thread: cover thread_idx_free()
Address a coverage gap in kernel/userspace.
Unfortunately, in the process of fixing this, a bug was
discovered, see #17023.

This test is user mode specific, filter the testcase
on whether userspace is available instead of ifdefing
the code.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:15:49 -04:00
Andrew Boie
5a418dd8f8 tests: userspace: cover missing/bad syscalls
We were missing code coverage for bad or unimplemented
system call IDs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 16:15:49 -04:00
Jukka Rissanen
15a830a1ef net: sntp: Ignore return value from close
Return value from close() can be ignored in sntp_close()
as it is not returning value to caller anyway.

Coverity-CID: 198863
Fixes #16584

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 16:14:56 -04:00
Andrew Boie
f3e094afe3 tests: schedule_api: skip test assert if COVERAGE
This test case is so timing sensitive that gathering code
coverage data screws up the results.

Since this is an abnormal execution environment anyway,
just skip the assertions if CONFIG_COVERAGE=y.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 08:45:07 -04:00
Andrew Boie
bd49769964 tests: schedule_api: test syscalls from usermode
We didn't have any coverage of the system call handlers for
k_wakeup() and k_is_preempt().

Increase RAM requirements due to stack alignment constraints
on MPU platforms when user mode is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 08:45:07 -04:00
Andrew Boie
3472eeaed4 tests: schedule_api: exercise SCHED_MULTIQ
This option should work on any arch, don't reserve
this just for native_posix.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 08:45:07 -04:00
Andrew Boie
c9af4aa4a8 tests: schedule_api: fix extern tstacks
Fix how the tstacks array was declared extern so this
actually compiles on all platforms with user mode enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 08:45:07 -04:00
Johan Hedberg
08c4c32e91 Bluetooth: Fix expiring RPA when different local identities are used
When advertising with different identities we need to flag any
programmed RPA as invalid if it was generated using a different
identity.

Fixes #16893

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 08:44:31 -04:00
Ryan C Johnson
d3f926f73f drivers: flash: w25q: erase operations must be erase-size aligned
- Erase operations must be aligned to the erase-size.
 - Don't need to perform an alignment check on a full erase. The offset
   is not used in this case.
 - Don't need to perform alignment check on a sector sized erase, as
   this alignment is checked on entrance to the function.
 - Removed some whitespace.

Signed-off-by: Ryan C Johnson <ryan.johnson@flex.com>
2019-07-02 08:43:32 -04:00
Luiz Augusto von Dentz
7cf70968fc Bluetooth: shell: gatt: Add discover command
This adds discover command which can be used to discover all attributes
using BT_GATT_DISCOVER_ATTRIBUTE:

uart:~$ gatt discover
Discover pending
Descriptor 2800 found: handle 1
Descriptor 2803 found: handle 2
Descriptor 2a00 found: handle 3
Descriptor 2803 found: handle 4
Descriptor 2a01 found: handle 5
Descriptor 2800 found: handle 6
Descriptor 2803 found: handle 7
Descriptor 2a05 found: handle 8
Descriptor 2902 found: handle 9
Descriptor 2803 found: handle a
Descriptor 2b29 found: handle b
Descriptor 2803 found: handle c
Descriptor 2b2a found: handle d
Descriptor 2803 found: handle e
Descriptor 2b2b found: handle f

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-07-02 08:42:48 -04:00
Luiz Augusto von Dentz
e3f71020d3 Bluetooth: GATT: Fix bt_gatt_discovery with BT_GATT_DISCOVER_DESCRIPTOR
Fix iterating past the response which causes an invalid memory to be
accessed and passed over to the callback as if there were more
attributes found.

Fixes #16602

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-07-02 08:42:48 -04:00
Johan Hedberg
6e96c8abca Bluetooth: Mesh: Fix segmented message RPL behavior
Update the Replay Protection List handling for segmented messages to
be more in line with Figure 3.43 in Mesh Profile Specification 1.0.
This means that the RPL check and update need to be split into two
independent steps rather than always doing these together.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-02 08:40:47 -04:00
Andrzej Puzdrowski
39121ae854 fs/nvs: fix startup for 2-sectors configuration
This patch fixes following bug:

After first GC operation the 1st sector had become scratch
and the 2nd sector had became write sector. After that NVS
was initialize (via reboot) again - it recognized the 1st
sector as write sector and 2nd as undone GC destination sector,
therefore it cleared 2nd sector and  re-run GC, which implied data loss.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-07-02 08:39:28 -04:00
Anas Nashif
21609c2562 CODEOWNERS: remove non-existing path
arch/arm/include/cortex_m/cmse/ does not exist in the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-25 22:20:14 -04:00
Andrew Boie
1c18dc7b2f tests: poll: expand userspace coverage
The syscall handler for k_poll() returns error values
instead of killing the caller for various bad arguments,
cover these cases.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
bdf05c01e3 lib: os: remove dead code
If multithreading is disabled, thread_entry() never runs
since we cannot create threads; the non-multithreading case
was simply dead code.

Indicate to code coverage that CODE_UNREACHABLE should be
skipped.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
99ddf9ce0c kernel: idle: exclude no-op funcs from coverage
These get overridden anyway.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
6712db44b9 tests: queue: test k_queue_alloc_*pend()
These were never getting called anywhere from user mode,
except for k_queue_alloc_append(), but only by virtue of
some workqueue tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
17b2abec79 kernel: allow k_sleep(K_FOREVER)
Threads that are sleeping forever may be woken up with
k_wakeup(), this shouldn't fail assertions.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
4f52e63153 kernel: init: exclude unreachable code
LCOV/gcovr doesn't understand what CODE_UNREACHABLE means.
Adding LCOV_EXCL_LINE to the macro definition unfortunately
doesn't work.

Exclude a bit of code which spins endlessly when multi-
threading is disabled that runs after the coverage report
is dumped.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
ed5625a837 kernel: init: fix coverage gap
We don't get any coverage past when we dump the coverage data,
so exclude the end of the function and move setting the main
thread as nonessential to immediately before the coverage dump.
The comment was also amended.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
344e275f31 kernel: init: exclude some funcs from coverage
data copying and bss zero are called from arch code
before z_cstart(), and coverage data gathering doesn't
work properly at that point. Not all arches use this
code anyway, some do it in optimized assembly instead.

Weak main() is also excluded; it does nothing and every
test overrides it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Andrew Boie
e2b31e6c29 tests: mutex_api: run in user mode
Addresses coverage gaps. Some changes were made so that exited
threads do not have k_thread_abort() called on them.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 18:55:19 -04:00
Jukka Rissanen
52cecb5148 net: if: Fix null pointer deref when selecting IPv4 address
It is possible that iface is NULL when selecting IPv4 destination
address for a sent packet.

Coverity-CID: 198877
Fixes #16570

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-18 18:54:53 -04:00
Ioannis Glaropoulos
92ebf5e6a8 arch: arm: fix start of MPU guard in stack-fail check (no user mode)
When building without support for user mode (CONFIG_USERSPACE=n)
we need to correct the starting address of the MPU Guard, before
passing it to the function that evaluates whether a stack
corruption has occurred. The bug was introduced by commit
(60bae5de38) in
PR-13619, where the start address of the MPU guard was properly
corrected, but the guard start at the corresponding stack-fail
check was not adjusted accordingly.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-18 18:54:17 -04:00
Rich Barlow
3bbcdc79d0 Bluetooth: Mesh: LPN: Clear sent_req on failure
When trying to establish friendship the Friend must respond to the
initial Friend Poll with a Friend Update. If this initial Friend Update
response is not received the Friendship establishment process must start
again.

When starting a second Friendship establishment processes the `sent_req`
field of the `lpn` struct was left set to `TRANS_CTL_OP_FRIEND_POLL`.
This prevented the initial Friend Poll being sent out on the second
attempt. Since the Friend Poll was not sent, no timeout is set and
nothing happens ever again. No more Friendship Requests are sent.

This commit clears `sent_req` back to zero when no Friend Update
response has been received after the initial Friend Poll.

Fixes #16678

Signed-off-by: Rich Barlow <rich@bennellick.com>
2019-06-18 18:53:33 -04:00
Luiz Augusto von Dentz
2371a976d1 Bluetooth: L2CAP: Fix inverting of SCID and DCID on disconnect
For the request:

DCID shall map to rx.cid:
  'This field specifies the endpoint of the channel to be disconnected
  on the device receiving this request.'

SCID shall map to tx.cid:
  'This field specifies the endpoint of the channel to be disconnected
  on the device sending this request.'

For the response when receiving the roles are inverted.

Fixes #16799

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-18 18:53:04 -04:00
Anas Nashif
6d174a2b75 ci: add v1.14-branch to email integration
Configure 1.14 branch for notifications via email.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-18 15:52:06 -04:00
Anas Nashif
e798ae7e07 manifest: add ci-tools
Add a working version of ci-tools with this branch. We will need to be
kept compatible with 1.14.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-18 11:39:59 -04:00
Luiz Augusto von Dentz
6950a38cb3 Bluetooth: GATT: Fix assuming writes to CCC will always contain 2 bytes
Although unlikely it is possible that a remote may attempt to send just
1 byte as the write request allows to do that:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F
page 2320:

  'If the attribute value has a fixed length and the Attribute Value
  parameter length is less than or equal to the length of the attribute
  value, the octets of the attribute value parameter length shall be
  written; all other octets in this attribute value shall be
  unchanged.'

Fixes #16734

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-11 15:14:31 -04:00
Johan Hedberg
8fa76985b1 Bluetooth: Mesh: Fix missing implementation of Proxy SAR timeout
Mesh Profile 1.0 Section 6.6:
"The timeout for the SAR transfer is 20 seconds. When the timeout
expires, the Proxy Server shall disconnect."

This will let qualification test case MESH/SR/PROX/BV-05-C pass
without requiring an explicit disconnect.

Fixes #16600

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-06-11 15:13:52 -04:00
Jukka Rissanen
63841b5607 net: llmnr: Check that UDP header can be accessed
It is possible that UDP header cannot be accessed so we need
to check that we do not do null pointer dereference.

Coverity-CID: 198866
Fixes #16581

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-11 15:13:19 -04:00
Joao Cordeiro
6f2cf7986d samples: bluetooth: peripheral: Fix RX buffer size
GATT long messages require buffers to store multiple packets. The actual
configuration for the bluetooth peripheral sample defines only two
buffers to store these messages. As the default ATT payload size is
18 bytes, the maximum payload size for a long ATT message is 36 bytes.
As the variable `vnd_long_value[]` has a defined size of 74 bytes, it
cannot be fully modified due to the 36 bytes limitation.

Set CONFIG_BT_ATT_PREPARE_COUNT=5 so all the maximum payload size goes
to 90 bytes and all the 74 bytes can be written to `vnd_long_value[]`.

Signed-off-by: Joao Cordeiro <jvcc@cesar.org.br>
2019-06-11 12:40:43 -04:00
Andrzej Głąbek
a72f851d12 drivers: pwm_nrfx: Correct prescaler value for undivided clock
When there is no need to divide the PWM clock (i.e. the requested
period cycles fit the 15-bit PWM counter), the prescaler value
should be 0, not 1.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-11 12:40:14 -04:00
Loic Poulain
f5d9f0b2af net: ethernet: Fix build issue with C++
When compiling with CPP, compiler complains about implicit type
conversions. Fix them.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-06-11 12:39:46 -04:00
Andrzej Głąbek
38d186a878 boards: nrf52840_pca10059: Configure NFC pins as GPIOs by default
Since there is no NFC antenna connector on the dongle and the pins
P0.09 and P0.10 that are dedicated to NFC functionality are in the
group of just a few ones available for external connections, it seems
more reasonable to configure these pins by default as regular GPIOs,
as users will most likely want to use them in this way.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-11 12:39:13 -04:00
Nicolas Pitre
1b7b809f1d PTHREAD_MUTEX_DEFINE(): don't store into the _k_mutex section
The _k_mutex linker section is used to gather instances of
struct k_mutex into a list so that init_mutex_module() could iterate
that list to perform runtime initialization tasks. In this case, we're
not defining a struct k_mutex but rather a struct pthread_mutex which is
a completely different structure. Not only those struct pthread_mutex
would be corrupted with unexpected data, but since they're not the
same size as struct k_mutex, the actual struct k_mutex instances that
follow in the list would be misaligned and get corrupted too.

There is nothing that requires runtime initialization in the static
definition of a struct pthread_mutex so let's remove the section
attribute.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-11 12:38:42 -04:00
Michael Scott
42b8d0c747 net: openthread: fix off-by-one error in settings offset calculation
OpenThread uses CONFIG_OT_PLAT_FLASH_PAGES_COUNT to calculate the # of
pages at the end of flash to use for storing OpenThread settings.

This calculation has an off-by-one error which sets the offset for
the storage area as 1 page of flash too low.

For example, on nRF52840:
- default setting for CONFIG_OT_PLAT_FLASH_PAGES_COUNT is 4
- flash size is 1MB (0x100000)
- flash page size is 4096 (0x1000)
- expected offset is 0xfc000

Using the current logic we get an offset of: 0xfb000

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16339

Signed-off-by: Michael Scott <mike@foundries.io>
2019-06-11 12:38:19 -04:00
Johann Fischer
c55d817744 usb: usb_dfu: do not set bwPollTimeout dynamically
Partially revert commit ea177e785c
("usb: dfu: set bwPollTimeout dynamically")

Introduced fix does not work proper because there is no way to be
sure that a control stage had success before start erase process.
Instead IMG_ERASE_PROGRESSIVELY configuration should be used
if the erase of the flash takes longer time.

resolves: #15497

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-11 12:38:06 -04:00
Vinayak Kariappa Chettimada
9403dd3126 Bluetooth: controller: Fix Enc Setup overlap with Length Update
Fix the encryption setup queueing implementation to avoid
overlapping with local initiated Length Update Procedure.

Fixes #15733.
Relates to #15335, and #15186.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-11 12:37:41 -04:00
Sören Tempel
251f48682a drivers: serial: sifive: Fix UART extern interrupts
IRQ_CONNECT and irq_enable calls in the SiFive UART driver were
misconfigured when the conversion to DeviceTree support occurred.

See also: https://github.com/zephyrproject-rtos/zephyr/pull/10613

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
2019-06-11 12:37:18 -04:00
Krzysztof Chruscinski
9ca3f9a967 drivers: counter: nrfx_rtc: Fix lack of interrupt when CC=0
According to documentation Compare event will not be triggered
if CC=0 and CLEAR task is set. Added handling of that situation.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-06-11 12:36:53 -04:00
Krzysztof Chruscinski
bccaa9f4b7 drivers: clock_control: nrf: Fix lfclk source settings for nrf9160
Aligned lfclk source values for nrf9160.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-06-11 12:36:21 -04:00
Vinayak Kariappa Chettimada
c1191dec2d Bluetooth: controller: Add GPIO Debug Pins for HFCLK state
Add implementation to toggle GPIO Debug pins on HFCLK
request and release by the controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-11 12:35:58 -04:00
Vinayak Kariappa Chettimada
b504992306 Bluetooth: controller: Fix XTAL advanced feature
Fix XTAL advanced feature by adding the missing
implementation to calculate and, retain or release the XTAL
clock source after a Bluetooth state or role is stopped.

Fixes #15817.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-11 12:35:58 -04:00
Vinayak Kariappa Chettimada
9d00571faa Bluetooth: controller: Fix pin or key missing response
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.

Relates to #15570.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-11 12:35:40 -04:00
Wentong Wu
870429de9a linker: add no-flash system support
Non-XIP system with FLASH_SIZE = 0 is no-flash system. And no-flash
system makes text, rodata, and data all in SRAM, so define the marco
ROM_ADDR to RAM_ADDR.

Fixes: #16027.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-11 12:35:23 -04:00
Mariusz Skamra
14a1f91d1e Bluetooth: controller: Workaround CPR procedure collision at CPU instant
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.

Relates to #15366.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-06-11 12:34:55 -04:00
Georgij Cernysiov
581a8cf218 drivers: rtc: stm32: correct tm_mon conversion
tm_mon valid interval [0,11]
LL_RTC_DateTypeDef.Month valid interval [1,12]

Signed-off-by: Georgij Cernysiov <g.cernysiov@elco-automation.de>
2019-06-11 10:44:13 -04:00
Wentong Wu
7c44108677 scripts: make code relocation work for non-XIP system
on non-XIP system, loading address shouldn't be located on
FLASH memory region.

Fixes: #16090.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-11 10:43:41 -04:00
Wentong Wu
4d7977f31d scripts: mpu align for ro section of new memory region on non-XIP system
on non-XIP system, SRAM is the default region, and relocated .data
section and .bss section of SRAM shouldn't be inserted between
_image_rom_start and _image_rom_end, because the memory region between
_image_rom_start and _image_rom_end will construct the mpu ro region.
Also for the newly added memory region on non-XIP system, the
relocated .text secition and .rodata section should also be mpu aligned.

Fixes: #16090.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-11 10:43:41 -04:00
Benoit Leforestier
d01d68835e C++: Fix compilation error "invalid conversion"
When some header are included into C++ source file, this kind of
compilations errors are generated:
error: invalid conversion from 'void*'
	to 'u32_t*' {aka 'unsigned int*'} [-fpermissive]

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2019-06-11 10:43:16 -04:00
Sebastian Bøe
c5dca7f96a cmake: DT: Add support for out-of-tree binding root directories
Just like board's can be placed in out-of-tree BOARD_ROOT's, we now
support DeviceTree sources and bindings being placed in out-of-tree
DTS_ROOT's.

This required for out-of-tree drivers that use DeviceTree.

To implement this we get rid of various user-settable CMake variables
like DTS_APP_BINDINGS, DTS_APP_INCLUDE, and instead have ZEPHYR_BASE,
APPLICATION_SOURCE_DIR and out-of-tree directories conform to using
the same DTS_ROOT concept and directory structure.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-06-11 10:42:18 -04:00
Sebastian Bøe
6a3e7ac12c cmake: DT: Change from -Idts/common to -isystem dts/common
All DT include directories are system directories, except for
dts/common. There is no reason for dts/common to diverge, so we align
it with the other directories to be consistent.

Also, we move it closer to the other include directories.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-06-11 10:42:18 -04:00
Marek Pieta
3e142b4fd8 Bluetooth: host: Fix bt_keys_get_addr()
Change fixes issue causing multiple keys creation for given address
and identity.

Fixes: #16478

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2019-06-11 10:41:29 -04:00
Ryan QIAN
6bd02e3f33 boards: arm: mimxrt1020_evk: update board dts
- update board dts file to refer to nxp_rt1020.dtsi to include sram size
fix

Signed-off-by: Ryan QIAN <jianghao.qian@nxp.com>
2019-05-27 11:32:54 -04:00
Ryan QIAN
9430a7e4e6 dts: arm: nxp: Add dtsi for RT1020
The default flexram configuration for RT1020:
  - ITCM  0x0,         64KB
  - DTCM  0x200000000, 64KB
  - OCRAM 0x20200000,  128KB

Signed-off-by: Ryan QIAN <jianghao.qian@nxp.com>
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-05-27 11:32:54 -04:00
Alexander Wachter
5df0f30930 drivers: can: stm32: fix filter mode set
Bits are actually shifted by filter number instead of bank number.
This results in wrong mode and filter_index calculation.
Fix shifting of mode bits by using bank_number instead of filter_number.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-27 11:32:29 -04:00
Carles Cufi
d7189919c5 doc: west: Backport moving the build config opts doc
Backport to 1.14 the move of the configuration options that control the
west build command to the page where the command itself is described.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-27 11:32:09 -04:00
Marti Bolivar
012f1c7445 scripts: flake8 cleanup for west build
Clean up coding nits to match west's style.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-27 11:32:09 -04:00
Carles Cufi
203021bedb scripts: west: Run pristine.cmake directly instead of the target
When making a build folder pristine until now we were running the
'pristine' build target. The issue with that is that ninja/make or
whatever build tool is being used might decide to re-run CMake itself if
some of the dependencies have changes. This might trigger an error that
is unfriendly and unnecessary, since the user is explicitly asking for
the build folder to be wiped before starting a fresh build.
To avoid this issue restor to running directly the CMake script that the
'pristine' build target itself uses, so as to make sure that the build
folder is wiped unconditionally regardless of changes made to the tree.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-27 11:32:09 -04:00
Carles Cufi
0f8de841af west: build: Add new pristine cmd-line and config option
Add a new command-line and build config option, `pristine`, that the
user can pass to `west build` or set in its configuration file(s) in
order to automatically trigger a pristine build on every build or
whenever west considers it required.

The option can take the following values:

- never: Never run the target
- always: Always run the pristine target before building
- auto: Run the pristine target when required

With `auto`, the pristine target will be run when running
west with an existing build folder containing a build system and:

- Selecting a different board from the one currently in the build system
- Selecting a different application from the one currently in the build
  system

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-27 11:32:09 -04:00
Carles Cufi
7586e60a89 west: build: Use officially documented CMake options
The -B option has always existed but was first officially documented in
CMake 3.13.0. In that same release the -S option was introduced,
replacing the old undocumented -H. Switch to using the officially
documented options.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-27 11:32:09 -04:00
Greg S. Woods
fd4c012fd8 entropy: fix C++ compiler warnings
Move includes to outside of the extern "C" statements to fix C linkage
issue.
| /include/misc/util.h:53:1: error: template with C linkage
|  template < class T, size_t N >
|  ^~~~~~~~

Signed-off-by: Greg S. Woods <gwoods@lexmark.com>
2019-05-27 11:31:48 -04:00
Phil Erwin
2af72beaf5 cmake: Fix missing dependency
KOBJ_OTYPE should depend on any changes to the tool that generates it,
gen_kobject_list.py.

Signed-off-by: Phil Erwin <erwin@lexmark.com>
2019-05-27 11:31:30 -04:00
Johann Fischer
1f509d3baf boards: reel_board: enable pull-up on UART TX pin
Enable pull-up on UART TX pin to reduce power consumption.
If the board is powered by battery the SoC consumes more
power than expected.
The consumption increases because TX pin is floating
(High-Impedance state of pin B from Dual-Supply Bus Transceiver).

Similar to commit b5b728495b
("boards: reel_board: enable pull-up on UART RX pin")

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-05-27 11:31:11 -04:00
Sebastian Bøe
1973bfa703 cmake: Don't have users call zephyr_link_interface on mbedTLS
Libraries that use mbedTLS have been invoking
zephyr_link_interface(mbedTLS). It is not clear what the intent of
this code has been, but it is redundant with the mbedTLS build
scripts, so it can be safely removed.

In addition to being redundant, it causes problems as it introduces an
ordering dependency, with this code mbedTLS must be declared before
users of mbedTLS are declared. Since this code is redundant, this
ordering dependency is also unnecessary.

This code is believed to have been added early on by accident and
copied through cargo-cult programming since.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-05-27 11:30:26 -04:00
Thomas Stilwell
841df9aed2 cmake: fix regex for west version check in host-tools.cmake
'west --version' output has the path to the west manifest directory.
If there is a semantic version string in this path name, it will
raise a false version check failure.

Signed-off-by: Thomas Stilwell <Thomas.Stilwell@nordicsemi.no>
2019-05-27 11:30:09 -04:00
Benjamin Valentin
01e086c007 drivers: watchdog: sam0: Check if timeout is valid
The upper limit of the timeout should not be 0.
tests/drivers/watchdog/wdt_basic_api checks for this and fails as the
driver currently only checks that the timout does not exceed the upper
bound.
This also makes it check the lower bound, so that the test passes.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-05-27 11:29:49 -04:00
Vinayak Kariappa Chettimada
fc67da0f5c Bluetooth: controller: Fix advanced XTAL feature regression
Fix regression by the addition of CONFIG_BT_CONN conditional
compilation that disabled the advanced clock (crystal)
oscillator management when only observer and/or advertiser
states supported in the controller build.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-05-27 11:28:48 -04:00
Alexander Mihajlovic
8b0f062ff4 posix: Fix calculation of clock base in clock_settime
Previous version calculated rt_clock_base incorrectly by subtracting
clock_gettime from the specified time. Effectively the following
formula was used.

    rt_clock_base := new_time - clock_gettime()

This is clearly incorrect when we consider what should happen if we
call clock_settime with the result of clock_gettime. It ought to be
approximately a no-op, but instead we end up zeroing the clock.

    rt_clock_base := clock_gettime() - clock_gettime() = 0

This patch fixes clock_settime by instead using k_uptime_get to
calculate rt_clock_base, like so:

    rt_clock_base := new_time - k_uptime_get()

Trying the earlier thought experiment we get:

    rt_clock_base := clock_gettime() - k_uptime_get()

Using the definition of clock_gettime this expands to:

    rt_clock_base := (rt_clock_base + k_uptime_get()) - k_uptime_get()

The two k_uptime_get() terms cancel out, leaving:

    rt_clock_base := rt_clock_base

I.e. the no-op that we expect when calling clock_settime with
the result of clock_gettime.

Note: The bug is only observable when rt_clock_base is non-zero.
So when clock_settime is called for the first time, it will appear
to work correctly since rt_clock_base is initialized to 0.

Signed-off-by: Alexander Mihajlovic <alexander.mihajlovic@endian.se>
2019-05-21 15:15:25 -04:00
Jukka Rissanen
3f09b1293c net: if: Select global IPv4 address if needed
The net_if_ipv4_select_src_addr() should return global address
in the interface if nothing else is being found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 15:14:40 -04:00
Jukka Rissanen
2d05e7ab3f net: ipv4: Send multicast ICMPv4 reply with correct src address
If we receive a multicast ICMPv4 packet, then send the reply back
with correct source address and not with multicast address.

Fixes #16257

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 15:14:40 -04:00
Tomasz Bursztyka
eee12033e7 net/iface: Add a function to get IPv4 global address
As for IPv6, let's create the same function on IPv4 side.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-21 15:14:40 -04:00
Tomasz Bursztyka
cd8ccef8e4 net/iface: Modify function to get IPv6 global address
Let's filter out on a state parameter.

There is no impact as this function is not used anywhere yet.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-21 15:14:40 -04:00
Jukka Rissanen
ed6dc0ef13 net: ipv4: Allow UDP packets with broadcast dst address
Make sure we are able to receive UDP packets with broadcast
destination address. If CONFIG_NET_IPV4_ACCEPT_ZERO_BROADCAST
is set, then check here also non-standard broadcast address
that is described in RFC 1122 chapter 3.3.6.

Fixes #11617

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 15:13:36 -04:00
Wentong Wu
7526dab2d5 tests: kernel: increase stack buffer when code coverage enabled
increase stack buffer when code coverage enabled.

Fixes: #15794.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-05-21 15:13:04 -04:00
Wentong Wu
c73cf83d85 arch: arm: switching stack pointer with assembly code
With -O0 optimizion, gcc compiler doesn't inline "static inline"
marked function. So when function call return from function
set_and_switch_to_psp which is to switch sp from MSP to PSP, the
ending "mov sp, r7" instruction will overwrite the just updated
sp value(PSP) with the beginning stack pointer(should be MSP)
stored in r7 register, so the switch doesn't happen. And it causes
unpredictable problems in the initialization process, the backward
analysis for this problem can be found on Github issue #15794.

Fixes: #15794.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-05-21 15:13:04 -04:00
Andrew Boie
26357e8e99 kernel: fix k_stack_alloc_init()
k_stack_alloc_init() was creating a buffer that was 4 times
too small to support the requested number of entries, since
each entry in a k_stack is a u32_t.

Fixes: #15911

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-21 10:19:36 -04:00
Armando Visconti
6fe0f2a14a drivers/i2s_ll_stm32.c: (FIX) Avoid warning in LOG_ERR
The LL_I2S_ReadReg() function returns uint32_t, while %d requires
'int' as a type.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2019-05-21 10:19:10 -04:00
Jukka Rissanen
c90b6332dc samples: net: dumb_http_server: Check EOF while skipping headers
If recv() returns 0 bytes, then terminate the connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 10:18:30 -04:00
Jukka Rissanen
fdde0b06cf samples: net: dumb_http_server: Add net_pkt.h file inclusion
The function net_pkt_get_info() is found in net_pkt.h and not
in buf.h. This caused
"implicit declaration of function ‘net_pkt_get_info’"
warning if CONFIG_NET_BUF_POOL_USAGE was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 10:18:30 -04:00
Marcin Szymczyk
550e3165aa usb: add zero-length packet after MPS-sized IN transaction
Send ZLP when host asks for a bigger length and the last chunk
is wMaxPacketSize long, to indicate the last packet.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-21 10:18:06 -04:00
Wayne Ren
a4cc1f0fdc boards: iotdk: add mpu and fpu configuration
* iotdk supports fpu and mpu
* iotdk supports fast irq
* a fix in device tree

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-05-21 10:17:43 -04:00
Andrew Boie
85348add23 kernel: adjust default main stack for riscv
We are just at the knife edge with 512, with stack
overflows being observed with stack canaries enabled.
Given the special case for the idle thread stack size
on this arch, seems reasonable to increase it here
for that arch.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:54:29 -04:00
Andrew Boie
f8be489b2e tests: stackprot: don't set main stack size
This test uses ztest anyway, the default should be fine
just like any other test running under ztest.

k_thread_create() uses a lot of stack, and the main
stack size is very small if ztest is enabled. Do it in
another ztest task instead.

We don't need to mess with the main thread's priority,
just have the alt thread run cooperatively.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:54:29 -04:00
Andrew Boie
8812c7fd08 tests: timer_api: run in user mode
We didn't have any coverage of the timer APIs in user
mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:54:04 -04:00
Patrik Flykt
6cbdf40036 net/ip/dhcpv4: Set source IP address in DHCP Request
The source address in unicast DHCPv4 Request packets was found out
to be all zeros address 0.0.0.0. This address is only acceptable if
the destination is a multicast one, where the host in question is
acquiring a DHCP address lease. This is true for the DHCP Discover
and the initial DHCP Request message from the client towards the
server. As subsequent DHCP Request renewal messages are sent as
unicast to the server, the server will drop such packets.

Fix this issue by explicitely specifying what source IP address is
to be used, if none is specified, the all zeros address 0.0.0.0 is
used in multicast addresses. The source address in the other
unicast cases is identical to the 'ciaddr' in the DHCP message.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-05-08 14:53:44 -04:00
Andrew Boie
16a74a2fed testsuite: fix memory access
Depending on optimization level, the TC_RESULT_STR[]
array could actually be placed in memory instead of
being expanded at compile time, resulting in memory
access errors from user mode.

Just replace TC_RESULT_TO_STR() with an inline function
containing a switch statement instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:53:28 -04:00
Andrew Boie
c297c82039 kernel: increase workq sizes if COVERAGE=y
The defaults are too small if coverage is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:53:06 -04:00
Andrew Boie
1c5fa377a1 lib: cmsis_v1: set stack size larger if coverage
Use some large value, coverage targets have lots of RAM.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:52:42 -04:00
Andrew Boie
19b96e997e tests: cmsis_v1: properly set stack size
There are limits to CMSIS stack sizes, we can't just
add a number to it. Use the configured maximum.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:52:42 -04:00
Andrew Boie
28ae163885 lib: cmsis_v2: increase stack sizes if coverage
Set to 4096, coverage targets have lots of RAM.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:52:42 -04:00
Andrew Boie
b8c44c2ada lib: cmsis_v2: set default dynamic stack size
Set to same default as regular stacks. This doesn't use
any extra memory until CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT
is set. 0 is not a valid default if that is set.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:52:42 -04:00
Andrew Boie
41b07b1d86 tests: cmsis_v2: don't hard-code stack sizes
Just use the configured value.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:52:42 -04:00
Marek Pieta
88b82c8152 bluetooth: Fix bt_conn->id handling
Fixed bt_conn->id handling in bt_conn_create_slave_le function.

Fixes: #15698

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2019-05-08 14:52:05 -04:00
Andrew Boie
6bd361409e tests: pipe: fix error with optimization disabled
The various struct pipe_sequence were not located in memory
accessible to user mode. With optimization turned on, they
weren't in memory at all, but with code coverage enabled
the arrays were actually being read, resulting in memory
access failures from user mode.

Fix them by placing in ROM, they never get modified.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:51:12 -04:00
Andrew Boie
12d6aa8b44 newlib: fix user mode calls to _sbrk
Depending on configuration, this value could end up as
a variable and not an array symbol, causing a crash if
newlib decides to call _sbrk on behalf of a user thread,
which needs to perform arithmetic on it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-08 14:50:52 -04:00
Armando Visconti
2ddf341e40 boards: 96b_argonkey: upgrade documentation using official info
The 96Boards Argonkey mezzanine board has been officially
published on ST website:

  https://www.st.com/en/evaluation-tools/steval-mki187v1.html

Update documentation with official picture and website info.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2019-05-08 14:50:25 -04:00
Marcin Szymczyk
d4163bc17e cmake: fix support for out of tree shields
After the rework in #12403, specifying a shield which has overlay
out of the tree causes unnecessary inclusions of overlays.
For every board root, overlays that have same index as
expected overlay are being included.
Fix this by removing already included overlays from SHIELD list.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-07 16:58:12 -04:00
Loic Poulain
14fe45898f ext: mcux: csi: Fix wrong circular queue delta calculation
This error causes various instabilities during capture.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-05-07 16:57:46 -04:00
Josef Gajdusek
f1b0df08e9 drivers: usb_dc_stm32: Reinitialize the write semaphores on bus reset
If the user attempts to send data before the USB connection is
established (see the HID sample for an example of such code), the
DataInCallback never gets called which leaves the write semaphore in a
taken state forever.

Signed-off-by: Josef Gajdusek <atx@atx.name>
2019-05-07 16:57:24 -04:00
Josef Gajdusek
cea42e3554 drivers: usb_dc_stm32: Make pin remapping part of the device tree
The SYSCFG_CFGR1_PA11_PA12_RMP define is present even on packages where
the remap isn't strictly required. This commit makes the remap optional
based on a DT property.

Also fixes syntax error caused by a missing );.

Signed-off-by: Josef Gajdusek <atx@atx.name>
2019-05-07 16:57:24 -04:00
Derek Hageman
e2d715b319 soc: sam0: Fix SAMD20 IRQ assignments
SAMD20 does not have the DMA or USB peripherals and as a result
the IRQs for all subsequent lines are shifted down from SAMD21.
This splits the interrupt assignment for the SERCOMs into the
SoC specific DTS file and moves the USB definition to SAMD21 only.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-07 16:57:01 -04:00
Tobias Aschenbrenner
eb4fa6f000 fix: kw41z: Use correct mapping for dBm
The radio API expects the setting of the TX-power in dBm. The actual
TX-power is however set by a 6bit register, which mapping between
register value and power in dBm is a lookup-table in the datasheet.

This mapping for the kw41z was off, which not only lead to incorrect
output power, but also to a maximal output power of only -1.9 dBm
instead of the possible +3.5 dBm.

Signed-off-by: Tobias Aschenbrenner <tobias.aschenbrenner@blik.io>
Signed-off-by: Franco Saworski <f.saworski@posteo.de>
2019-05-07 16:56:08 -04:00
Bradley Bolen
a64cdc8388 cmake: Fix missing dependency
DRV_VALIDATION should depend on any changes to the tool that generates
it, gen_kobject_list.py.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2019-05-07 16:55:26 -04:00
Georgij Cernysiov
56481d9edd drivers: counter: stm32: fix LSE clock source for not F4 SoC
Fixes the STM32 counter driver when LSE is the clock source
and SoC is not F4.

Signed-off-by: Georgij Cernysiov <g.cernysiov@elco-automation.de>
2019-05-07 16:54:54 -04:00
Benjamin Valentin
8bf9538caf usb: sam0: Implement missing API functions
This implements three API functions that are required for
tests/subsys/usb/device to build:

 - usb_dc_ep_disable()
 - usb_dc_ep_halt()
 - usb_dc_ep_flush()

While halt and disable are trivial, flush is just a stub for now.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-05-07 16:54:19 -04:00
Benjamin Valentin
756ae3d542 usb: sam0: Ensure API arguments are valid
Make sure the parameters for the API functions are valid, return error
otherwise.

This is expected by the tests/subsys/usb/device test case.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-05-07 16:54:19 -04:00
Kwon Tae-young
fb5bde6f70 boards: stm32f4_disco: Fix yaml ram size
Total RAM is 192, including 64K CCM.

Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
2019-05-07 16:53:36 -04:00
Sören Tempel
6993ee3cbf net: slip: fix compilation without NET_L2_ETHERNET
For example it should be possible to compile and use the SLIP module
with NET_L2_DUMMY. This required the following changes:

* Fix a typo in the initializer for struct dummy_api
* Only define eth_capabilities if CONFIG_NET_L2_ETHERNET is defined to
  silence a -Wunused-function compiler warning
* Unconditionally include net/dummy.h

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
2019-05-07 16:50:34 -04:00
Sören Tempel
8d72bbdc79 net: slip: allow compilation without CONFIG_NET_LLDP
Without this change compilation of the SLIP module would fail if LLDP
wasn't enabled. There is also no need to include net/lldp.h explicitly
as net/ethernet.h will include it conditionally if CONFIG_NET_LLDP is
defined.

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
2019-05-07 16:50:34 -04:00
Sören Tempel
a4afa13a7a soc/riscv32-fe310: add label for uart1
Without this label cmake fails when attempting to enable this uart.

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
2019-05-07 16:50:18 -04:00
ling wei
93558f2fb9 net: trickle: Re-init trickle timer for multiple triggerings
We need to re-initialize the trickle->timer delayed work to use
trickle_timeout() if there are multiple triggerings.

Fixes #15606

Signed-off-by: ling wei <lingwei@cisco.com>
2019-05-07 16:49:50 -04:00
Bub Wei
23b54e42c3 samples: net: zperf: Add __packed for zperf_udp_datagram
UDP packet from net is not 4-byte aligned.
So we have to add __packed for zperf_udp_datagram.

Fixes #15605.

Signed-off-by: Bub Wei <bub.wei@unisoc.com>
2019-05-07 16:49:28 -04:00
Henrik Brix Andersen
ee9d7a960b gpio: rv32m1: enable GPIO port clocks
Enable the clock for GPIO ports on the RV32M1 SoC before attempting to
access the port controller registers.

Fixes: #15339

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2019-05-07 16:49:10 -04:00
Tomasz Gorochowik
a68fd9c733 libc: minimal: fix realloc function
Excerpt from the manual:

  If ptr is NULL, then the call is equivalent to malloc(size) [...]

Without this commit, such calls end with a BUS FAULT.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-05-07 16:48:51 -04:00
David B. Kinder
ed47cf92cb doc: fix watchdog API documentation
There was a stray close group comment @} that was causing a large chunk
of the watchdoc API documentation to be missing.

Fixes: #15678

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-05-07 16:48:28 -04:00
Krzysztof Chruscinski
25b00e8b6d lib: os: ring_buffer: Fix C++ compilation warning
Fix warning when header file is included by C++ source file.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-05-07 16:48:06 -04:00
Krzysztof Chruscinski
1a9ef5ef4a logging: Allow logger usage in C++ files
Allow usage of LOG_MODULE_REGISTER and LOG_MODULE_DECLARE in
C++.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-05-07 16:48:06 -04:00
Andrew Boie
349cc71d63 arc: arm: fix support for MPUs on non-XIP systems
The size of the ROM region is now rounded up to the
nearest power of two; we no longer assume that RAM
is in a different part of memory.

Fixes: #15558

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-07 16:47:18 -04:00
Patrik Flykt
bdcc09ff2c net: ethernet: Send sender IP address in ARP announce packets
In addition to checking that the ARP entry does not exist as the
implementation is done currently, also check if the ARP packet
is due to IPv4 link local address configuration. In both cases
use the provided IPv4 address instead of the one set for the
interface.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-05-07 16:46:57 -04:00
Patrik Flykt
c6325a66ca net: ethernet: Set NET_ETH_PTYPE_ARP for IPv4 link local packet type
IPv4 link local uses ARP to detect conflicting addresses. Properly
set the ethernet packet type to NET_ETH_PTYPE_ARP when probing
for address duplicates.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-05-07 16:46:57 -04:00
Pawel Dunaj
29c3fe5d77 bluetooth: host: Unref conn on direct adv start error
Unref conn when direct adv start exits with an error.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2019-05-07 16:46:35 -04:00
Pawel Dunaj
82f176311d bluetooth: host: Use correct identity when direct advertising
When starting direct advertising use correct identity during
connection lookup.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2019-05-07 16:46:35 -04:00
Johan Hedberg
1b099c3e13 Bluetooth: Mesh: Fix postponing storage deadline indefinitely
If the local node keeps getting bombarded with messages, it's possible
that the storage timer gets rescheduled over and over again and never
expires. Add the necessary code to only reschedule the timer if the
new deadline is earlier than an existing one.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-05-07 16:46:06 -04:00
Johan Hedberg
9132dcc697 Bluetooth: Mesh: Fix RPL storage timeout handling
The default values for the timeouts, as well as non-defaults in most
Mesh samples, use a higher value for the RPL than then generic mesh
storage timeout. This hasn't had any effect in practice since the code
only uses the RPL timeout if it is *smaller* than the generic one.

The original intention of the code was to use the RPL timeout,
regardless of what the generic one is, whenever the RPL is the only
thing that needs updating. Add some helper macros to track the various
groups of pending flags, and perform the appropriate checks to apply
the RPL timeout whenever it's smaller than the generic timeout, or if
there are no other items to store besides the RPL.

Fixes #15904

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-05-07 16:46:06 -04:00
Anas Nashif
d8236589e9 ci: only build on specified branches
Do not start CI on random branches created in the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-17 08:57:40 -05:00
Brett Witherspoon
247330d62a net: fix errno returned without promiscuous mode support
If promiscuous mode support is disabled in Kconfig and promiscuous.h is
included the build will fail. The returned errno should be ENOTSUP.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
2019-04-17 08:35:18 -05:00
320 changed files with 6619 additions and 1881 deletions

View File

@@ -48,7 +48,11 @@ build:
else
./scripts/ci/run_ci.sh -s -b ${BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS};
fi;
branches:
only:
- master
- v*-branch
- topic-*
integrations:
notifications:
- integrationName: slack_integration
@@ -70,5 +74,6 @@ integrations:
- net
- bluetooth
- arm
- v1.14-branch
on_success: never
on_failure: never

View File

@@ -719,6 +719,7 @@ add_custom_command(
${ZEPHYR_BASE}/scripts/gen_kobject_list.py
--validation-output ${DRV_VALIDATION}
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS ${ZEPHYR_BASE}/scripts/gen_kobject_list.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(${DRIVER_VALIDATION_H_TARGET} DEPENDS ${DRV_VALIDATION})
@@ -852,6 +853,10 @@ endif()
if(CONFIG_CODE_DATA_RELOCATION)
set(MEM_RELOCATAION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
set(MEM_RELOCATAION_SRAM_DATA_LD
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_data_relocate.ld")
set(MEM_RELOCATAION_SRAM_BSS_LD
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_bss_relocate.ld")
set(MEM_RELOCATAION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
add_custom_command(
@@ -863,6 +868,8 @@ if(CONFIG_CODE_DATA_RELOCATION)
-d ${APPLICATION_BINARY_DIR}
-i '$<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS>'
-o ${MEM_RELOCATAION_LD}
-s ${MEM_RELOCATAION_SRAM_DATA_LD}
-b ${MEM_RELOCATAION_SRAM_BSS_LD}
-c ${MEM_RELOCATAION_CODE}
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
)

View File

@@ -10,7 +10,7 @@
/arch/arc/ @vonhust @ruuddw
/arch/arm/ @MaureenHelm @galak
/arch/arm/core/cortex_m/cmse/ @ioannisg
/arch/arm/include/cortex_m/cmse/ @ioannisg
arch/arm/include/cortex_m/cmse.h @ioannisg
/soc/arm/ @MaureenHelm @galak
/soc/arm/arm/mps2/ @fvincenzo
/soc/arm/atmel_sam/sam4s/ @fallrisk
@@ -287,6 +287,7 @@
/tests/drivers/spi/ @tbursztyka
/tests/drivers/uart/uart_async_api/ @Mierunski
/tests/kernel/ @andrewboie @andyross @nashif
/tests/lib/ @nashif
/tests/net/ @jukkar @tbursztyka @pfalcon
/tests/net/buf/ @jukkar @jhedberg @tbursztyka @pfalcon
/tests/net/lib/ @jukkar @tbursztyka @pfalcon

View File

@@ -1,5 +1,5 @@
VERSION_MAJOR = 1
VERSION_MINOR = 14
PATCHLEVEL = 0
PATCHLEVEL = 1
VERSION_TWEAK = 0
EXTRAVERSION =
EXTRAVERSION = rc2

View File

@@ -267,7 +267,15 @@ _firq_reschedule:
pop_s r2
#endif
ld_s r3, [r2, _thread_offset_to_relinquish_cause]
#if defined(CONFIG_USERSPACE)
/*
* see comments in regular_irq.S
*/
lr r0, [_ARC_V2_AUX_IRQ_ACT]
bclr r0, r0, 31
sr r0, [_ARC_V2_AUX_IRQ_ACT]
#endif
ld r3, [r2, _thread_offset_to_relinquish_cause]
breq r3, _CAUSE_RIRQ, _firq_return_from_rirq
nop
@@ -279,7 +287,7 @@ _firq_reschedule:
.balign 4
_firq_return_from_coop:
ld_s r3, [r2, _thread_offset_to_intlock_key]
ld r3, [r2, _thread_offset_to_intlock_key]
st 0, [r2, _thread_offset_to_intlock_key]
/* pc into ilink */
@@ -298,7 +306,7 @@ _firq_return_from_coop:
or.nz r0, r0, _ARC_V2_STATUS32_IE
sr r0, [_ARC_V2_STATUS32_P0]
ld_s r0, [r2, _thread_offset_to_return_value]
ld r0, [r2, _thread_offset_to_return_value]
rtie
.balign 4

View File

@@ -181,7 +181,23 @@ _rirq_common_interrupt_swap:
pop_s r2
#endif
ld_s r3, [r2, _thread_offset_to_relinquish_cause]
#if defined(CONFIG_USERSPACE)
/*
* when USERSPACE is enabled, according to ARCv2 ISA, SP will be switched
* if interrupt comes out in user mode, and will be recorded in bit 31
* (U bit) of IRQ_ACT. when interrupt exits, SP will be switched back
* according to U bit.
*
* For the case that context switches in interrupt, the target sp must be
* thread's kernel stack, no need to do hardware sp switch. so, U bit should
* be cleared.
*/
lr r0, [_ARC_V2_AUX_IRQ_ACT]
bclr r0, r0, 31
sr r0, [_ARC_V2_AUX_IRQ_ACT]
#endif
ld r3, [r2, _thread_offset_to_relinquish_cause]
breq r3, _CAUSE_RIRQ, _rirq_return_from_rirq
nop
@@ -201,7 +217,7 @@ _rirq_return_from_coop:
/* update status32.ie (explanation in firq_exit:_firq_return_from_coop) */
ld_s r3, [r2, _thread_offset_to_intlock_key]
ld r3, [r2, _thread_offset_to_intlock_key]
st 0, [r2, _thread_offset_to_intlock_key]
cmp r3, 0
or.ne r0, r0, _ARC_V2_STATUS32_IE
@@ -212,7 +228,7 @@ _rirq_return_from_coop:
sub sp, sp, ___isf_t_pc_OFFSET
/* update return value on stack */
ld_s r0, [r2, _thread_offset_to_return_value]
ld r0, [r2, _thread_offset_to_return_value]
st_s r0, [sp, ___isf_t_r0_OFFSET]
/* reset zero-overhead loops */

View File

@@ -82,7 +82,7 @@ SECTION_FUNC(TEXT, __swap)
ld_s r2, [r1, _kernel_offset_to_current]
/* save intlock key */
st_s r0, [r2, _thread_offset_to_intlock_key]
st r0, [r2, _thread_offset_to_intlock_key]
st _CAUSE_COOP, [r2, _thread_offset_to_relinquish_cause]
/*
@@ -92,7 +92,7 @@ SECTION_FUNC(TEXT, __swap)
* z_set_thread_return_value().
*/
ld r3, [_k_neg_eagain]
st_s r3, [r2, _thread_offset_to_return_value]
st r3, [r2, _thread_offset_to_return_value]
/*
* Save status32 and blink on the stack before the callee-saved registers.
@@ -142,7 +142,7 @@ SECTION_FUNC(TEXT, __swap)
pop_s r2
#endif
ld_s r3, [r2, _thread_offset_to_relinquish_cause]
ld r3, [r2, _thread_offset_to_relinquish_cause]
breq r3, _CAUSE_RIRQ, _swap_return_from_rirq
nop
@@ -154,9 +154,9 @@ SECTION_FUNC(TEXT, __swap)
.balign 4
_swap_return_from_coop:
ld_s r1, [r2, _thread_offset_to_intlock_key]
ld r1, [r2, _thread_offset_to_intlock_key]
st 0, [r2, _thread_offset_to_intlock_key]
ld_s r0, [r2, _thread_offset_to_return_value]
ld r0, [r2, _thread_offset_to_return_value]
lr ilink, [_ARC_V2_STATUS32]
bbit1 ilink, _ARC_V2_STATUS32_AE_BIT, _return_from_exc

View File

@@ -22,7 +22,6 @@
#include <linker/linker-defs.h>
#include <kernel_internal.h>
#include <arch/arm/cortex_m/cmsis.h>
#include <cortex_m/stack.h>
#if defined(__GNUC__)
/*
@@ -37,44 +36,6 @@
#include <string.h>
static inline void switch_sp_to_psp(void)
{
__set_CONTROL(__get_CONTROL() | CONTROL_SPSEL_Msk);
/*
* When changing the stack pointer, software must use an ISB instruction
* immediately after the MSR instruction. This ensures that instructions
* after the ISB instruction execute using the new stack pointer.
*/
__ISB();
}
static inline void set_and_switch_to_psp(void)
{
u32_t process_sp;
process_sp = (u32_t)&_interrupt_stack + CONFIG_ISR_STACK_SIZE;
__set_PSP(process_sp);
switch_sp_to_psp();
}
void lock_interrupts(void)
{
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
__disable_irq();
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
__set_BASEPRI(_EXC_IRQ_DEFAULT_PRIO);
#else
#error Unknown ARM architecture
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
}
#ifdef CONFIG_INIT_STACKS
static inline void init_stacks(void)
{
memset(&_interrupt_stack, 0xAA, CONFIG_ISR_STACK_SIZE);
}
#endif
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
#ifdef CONFIG_XIP
@@ -168,14 +129,6 @@ extern void z_IntLibInit(void);
#endif
void _PrepC(void)
{
#ifdef CONFIG_INIT_STACKS
init_stacks();
#endif
/*
* Set PSP and use it to boot without using MSP, so that it
* gets set to _interrupt_stack during initialization.
*/
set_and_switch_to_psp();
relocate_vector_table();
enable_floating_point();
z_bss_zero();

View File

@@ -19,6 +19,8 @@
_ASM_FILE_PROLOGUE
GTEXT(__reset)
GTEXT(memset)
GDATA(_interrupt_stack)
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
GTEXT(_PlatformInit)
#endif
@@ -61,12 +63,46 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
#endif
/* lock interrupts: will get unlocked when switch to main task */
bl lock_interrupts
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
cpsid i
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
movs.n r0, #_EXC_IRQ_DEFAULT_PRIO
msr BASEPRI, r0
#else
#error Unknown ARM architecture
#endif
#ifdef CONFIG_WDOG_INIT
/* board-specific watchdog initialization is necessary */
bl _WdogInit
#endif
#ifdef CONFIG_INIT_STACKS
ldr r0, =_interrupt_stack
ldr r1, =0xaa
ldr r2, =CONFIG_ISR_STACK_SIZE
bl memset
#endif
/*
* Set PSP and use it to boot without using MSP, so that it
* gets set to _interrupt_stack during initialization.
*/
ldr r0, =_interrupt_stack
ldr r1, =CONFIG_ISR_STACK_SIZE
adds r0, r0, r1
msr PSP, r0
mrs r0, CONTROL
movs r1, #2
orrs r0, r1 /* CONTROL_SPSEL_Msk */
msr CONTROL, r0
/*
* When changing the stack pointer, software must use an ISB instruction
* immediately after the MSR instruction. This ensures that instructions
* after the ISB instruction execute using the new stack pointer.
*/
isb
/*
* 'bl' jumps the furthest of the branch instructions that are
* supported on all platforms. So it is used when jumping to _PrepC

View File

@@ -383,7 +383,7 @@ _oops:
#if CONFIG_USERSPACE
/*
* System call will setup a jump to the _do_arm_syscall function
* System call will setup a jump to the z_arm_do_syscall() function
* when the SVC returns via the bx lr.
*
* There is some trickery involved here because we have to preserve
@@ -408,15 +408,17 @@ _do_syscall:
ldr r1, =z_arm_do_syscall
str r1, [r0, #24] /* overwrite the PC to point to z_arm_do_syscall */
/* validate syscall limit, only set priv mode if valid */
/* validate syscall limit */
ldr ip, =K_SYSCALL_LIMIT
cmp r6, ip
blt valid_syscall_id
/* bad syscall id. Set arg0 to bad id and set call_id to SYSCALL_BAD */
/* bad syscall id. Set arg1 to bad id and set call_id to SYSCALL_BAD */
str r6, [r0, #0]
ldr r6, =K_SYSCALL_BAD
/* Bad syscalls treated as valid syscalls with ID K_SYSCALL_BAD. */
valid_syscall_id:
push {r0, r1}
ldr r0, =_kernel

View File

@@ -282,11 +282,11 @@ u32_t z_check_thread_stack_fail(const u32_t fault_addr, const u32_t psp)
}
}
#else /* CONFIG_USERSPACE */
if (IS_MPU_GUARD_VIOLATION(thread->stack_info.start,
if (IS_MPU_GUARD_VIOLATION(thread->stack_info.start -
MPU_GUARD_ALIGN_AND_SIZE,
fault_addr, psp)) {
/* Thread stack corruption */
return thread->stack_info.start +
MPU_GUARD_ALIGN_AND_SIZE;
return thread->stack_info.start;
}
#endif /* CONFIG_USERSPACE */

View File

@@ -178,6 +178,44 @@ SECTION_FUNC(TEXT,z_arm_userspace_enter)
*
*/
SECTION_FUNC(TEXT, z_arm_do_syscall)
/* The function is executing in privileged mode. This implies that we
* shall not be allowed to use the thread's default unprivileged stack,
* (i.e push to or pop from it), to avoid a possible stack corruption.
*
* Rationale: since we execute in PRIV mode and no MPU guard or PSPLIM
* register is guarding the end of the default stack, we won't be able
* to detect any stack overflows.
*/
#if defined(CONFIG_BUILTIN_STACK_GUARD)
/* clear stack pointer limit before setting the PSP */
mov ip, #0
msr PSPLIM, ip
#endif
/* setup privileged stack */
ldr ip, =_kernel
ldr ip, [ip, #_kernel_offset_to_current]
ldr ip, [ip, #_thread_offset_to_priv_stack_start] /* priv stack ptr */
add ip, #CONFIG_PRIVILEGED_STACK_SIZE
/* Store current SP and LR at the beginning of the priv stack */
subs ip, #8
str sp, [ip, #0]
str lr, [ip, #4]
/* switch to privileged stack */
msr PSP, ip
#if defined(CONFIG_BUILTIN_STACK_GUARD)
/* Set stack pointer limit (needed in privileged mode) */
ldr ip, =_kernel
ldr ip, [ip, #_kernel_offset_to_current]
ldr ip, [ip, #_thread_offset_to_priv_stack_start] /* priv stack ptr */
msr PSPLIM, ip
#endif
/*
* r0-r5 contain arguments
* r6 contains call_id
@@ -188,45 +226,12 @@ SECTION_FUNC(TEXT, z_arm_do_syscall)
bne valid_syscall
/* BAD SYSCALL path */
/* fixup stack frame on unprivileged stack, adding ssf */
/* fixup stack frame on the privileged stack, adding ssf */
mov ip, sp
push {r4,r5,ip,lr}
b dispatch_syscall
valid_syscall:
/* setup privileged stack */
push {r6}
ldr r6, =_kernel
ldr r6, [r6, #_kernel_offset_to_current]
ldr ip, [r6, #_thread_offset_to_priv_stack_start] /* priv stack ptr */
ldr r6, =CONFIG_PRIVILEGED_STACK_SIZE
add ip, r6
pop {r6}
subs ip, #8
str sp, [ip, #0]
str lr, [ip, #4]
#if defined(CONFIG_BUILTIN_STACK_GUARD)
/* clear stack pointer limit before setting the PSP */
push {r3}
mov r3, #0
msr PSPLIM, r3
pop {r3}
#endif
/* switch to privileged stack */
msr PSP, ip
#if defined(CONFIG_BUILTIN_STACK_GUARD)
/* Set stack pointer limit (needed in privileged mode) */
push {r6}
ldr r6, =_kernel
ldr r6, [r6, #_kernel_offset_to_current]
ldr r6, [r6, #_thread_offset_to_priv_stack_start] /* priv stack ptr */
msr PSPLIM, r6
pop {r6}
#endif
/* push args to complete stack frame */
push {r4,r5}

View File

@@ -69,7 +69,7 @@ z_arch_switch_to_main_thread(struct k_thread *main_thread,
start_of_main_stack =
Z_THREAD_STACK_BUFFER(main_stack) + main_stack_size;
#endif
start_of_main_stack = (void *)STACK_ROUND_DOWN(start_of_main_stack);
start_of_main_stack = (char *)STACK_ROUND_DOWN(start_of_main_stack);
#ifdef CONFIG_TRACING
z_sys_trace_thread_switched_out();

View File

@@ -72,6 +72,8 @@ struct threads_table_el {
bool running; /* Is this the currently running thread */
pthread_t thread; /* Actual pthread_t as returned by native kernel */
int thead_cnt; /* For debugging: Unique, consecutive, thread number */
/* Pointer to the status kept in the Zephyr thread stack */
posix_thread_status_t *t_status;
};
static struct threads_table_el *threads_table;
@@ -260,11 +262,11 @@ static void posix_cleanup_handler(void *arg)
*/
static void *posix_thread_starter(void *arg)
{
posix_thread_status_t *ptr = (posix_thread_status_t *) arg;
int thread_idx = (intptr_t)arg;
PC_DEBUG("Thread [%i] %i: %s: Starting\n",
threads_table[ptr->thread_idx].thead_cnt,
ptr->thread_idx,
threads_table[thread_idx].thead_cnt,
thread_idx,
__func__);
/*
@@ -286,18 +288,20 @@ static void *posix_thread_starter(void *arg)
pthread_cleanup_push(posix_cleanup_handler, arg);
PC_DEBUG("Thread [%i] %i: %s: After start mutex (hav mut)\n",
threads_table[ptr->thread_idx].thead_cnt,
ptr->thread_idx,
threads_table[thread_idx].thead_cnt,
thread_idx,
__func__);
/*
* The thread would try to execute immediately, so we block it
* until allowed
*/
posix_wait_until_allowed(ptr->thread_idx);
posix_wait_until_allowed(thread_idx);
posix_new_thread_pre_start();
posix_thread_status_t *ptr = threads_table[thread_idx].t_status;
z_thread_entry(ptr->entry_point, ptr->arg1, ptr->arg2, ptr->arg3);
/*
@@ -306,13 +310,13 @@ static void *posix_thread_starter(void *arg)
*/
/* LCOV_EXCL_START */
posix_print_trace(PREFIX"Thread [%i] %i [%lu] ended!?!\n",
threads_table[ptr->thread_idx].thead_cnt,
ptr->thread_idx,
threads_table[thread_idx].thead_cnt,
thread_idx,
pthread_self());
threads_table[ptr->thread_idx].running = false;
threads_table[ptr->thread_idx].state = FAILED;
threads_table[thread_idx].running = false;
threads_table[thread_idx].state = FAILED;
pthread_cleanup_pop(1);
@@ -370,16 +374,18 @@ void posix_new_thread(posix_thread_status_t *ptr)
threads_table[t_slot].state = USED;
threads_table[t_slot].running = false;
threads_table[t_slot].thead_cnt = thread_create_count++;
threads_table[t_slot].t_status = ptr;
ptr->thread_idx = t_slot;
PC_SAFE_CALL(pthread_create(&threads_table[t_slot].thread,
NULL,
posix_thread_starter,
(void *)ptr));
(void *)(intptr_t)t_slot));
PC_DEBUG("created thread [%i] %i [%lu]\n",
PC_DEBUG("%s created thread [%i] %i [%lu]\n",
__func__,
threads_table[t_slot].thead_cnt,
ptr->thread_idx,
t_slot,
threads_table[t_slot].thread);
}

View File

@@ -12,4 +12,5 @@ CONFIG_ARCV2_TIMER=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_ARC_MPU_ENABLE=y

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 90 KiB

View File

@@ -13,9 +13,9 @@ This board acts as a sensor hub platform for all 96Boards compliant
family products. It can also be used as a standalone board.
.. figure:: img/96b_argonkey.jpg
:width: 557px
:width: 540px
:align: center
:height: 480px
:height: 558px
:alt: 96Boards Argonkey
96Boards Argonkey
@@ -76,6 +76,9 @@ features:
| I2C | on-chip | i2c |
+-----------+------------+-------------------------------------+
More information about the board can be found at the
`ARGONKEY website`_.
The default board configuration can be found in the defconfig file:
``boards/arm/96b_argonkey/96b_argonkey_defconfig``
@@ -223,6 +226,9 @@ References
.. target-notes::
.. _ARGONKEY website:
https://www.st.com/en/evaluation-tools/steval-mki187v1.html
.. _AN2606:
https://www.st.com/resource/en/application_note/cd00167594.pdf

View File

@@ -6,7 +6,7 @@
/dts-v1/;
#include <nxp/nxp_rt.dtsi>
#include <nxp/nxp_rt1020.dtsi>
/ {
model = "NXP MIMXRT1020-EVK board";

View File

@@ -22,3 +22,4 @@ CONFIG_CONSOLE=y
# additional board options
CONFIG_GPIO_AS_PINRESET=y
CONFIG_NFCT_PINS_AS_GPIOS=y

View File

@@ -37,6 +37,11 @@ static int board_reel_board_init(struct device *dev)
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
gpio->PIN_CNF[DT_NORDIC_NRF_UART_0_TX_PIN] =
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
return 0;
}

View File

@@ -6,7 +6,7 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 320
ram: 128
flash: 1024
supported:
- pwm

View File

@@ -291,6 +291,7 @@ foreach(root ${BOARD_ROOT})
if(DEFINED SHIELD)
foreach(s ${SHIELD_AS_LIST})
list(REMOVE_ITEM SHIELD ${s})
list(FIND SHIELD_LIST ${s} _idx)
if (NOT _idx EQUAL -1)
list(GET shields_refs_list ${_idx} s_path)

View File

@@ -12,12 +12,20 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated)
# CMake configure-time.
#
# See ~/zephyr/doc/dts
set(GENERATED_DTS_BOARD_UNFIXED_H ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board_unfixed.h)
set(GENERATED_DTS_BOARD_CONF ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board.conf)
set(GENERATED_DTS_BOARD_UNFIXED_H ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board_unfixed.h)
set(GENERATED_DTS_BOARD_CONF ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board.conf)
set_ifndef(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)
set_ifndef(DTS_COMMON_OVERLAYS ${ZEPHYR_BASE}/dts/common/common.dts)
set_ifndef(DTS_APP_BINDINGS ${APPLICATION_SOURCE_DIR}/dts/bindings)
set_ifndef(DTS_APP_INCLUDE ${APPLICATION_SOURCE_DIR}/dts)
# 'DTS_ROOT' is a list of directories where a directory tree with DT
# files may be found. It always includes the application directory and
# ${ZEPHYR_BASE}.
list(APPEND
DTS_ROOT
${APPLICATION_SOURCE_DIR}
${ZEPHYR_BASE}
)
set(dts_files
${DTS_SOURCE}
@@ -64,6 +72,33 @@ if(SUPPORTS_DTS)
math(EXPR i "${i}+1")
endforeach()
foreach(dts_root ${DTS_ROOT})
foreach(dts_root_path
include
dts/common
dts/${ARCH}
dts
)
set(full_path ${dts_root}/${dts_root_path})
if(EXISTS ${full_path})
list(APPEND
DTS_ROOT_SYSTEM_INCLUDE_DIRS
-isystem ${full_path}
)
endif()
endforeach()
endforeach()
foreach(dts_root ${DTS_ROOT})
set(full_path ${dts_root}/dts/bindings)
if(EXISTS ${full_path})
list(APPEND
DTS_ROOT_BINDINGS
${full_path}
)
endif()
endforeach()
# TODO: Cut down on CMake configuration time by avoiding
# regeneration of generated_dts_board_unfixed.h on every configure. How
# challenging is this? What are the dts dependencies? We run the
@@ -77,12 +112,8 @@ if(SUPPORTS_DTS)
COMMAND ${CMAKE_C_COMPILER}
-x assembler-with-cpp
-nostdinc
-isystem ${DTS_APP_INCLUDE}
-isystem ${ZEPHYR_BASE}/include
-isystem ${ZEPHYR_BASE}/dts/${ARCH}
-isystem ${ZEPHYR_BASE}/dts
${DTS_ROOT_SYSTEM_INCLUDE_DIRS}
${DTC_INCLUDE_FLAG_FOR_DTS} # include the DTS source and overlays
-I${ZEPHYR_BASE}/dts/common
${NOSYSDEF_CFLAG}
-D__DTS__
-P
@@ -124,13 +155,9 @@ if(SUPPORTS_DTS)
message(FATAL_ERROR "command failed with return code: ${ret}")
endif()
if(NOT EXISTS ${DTS_APP_BINDINGS})
set(DTS_APP_BINDINGS)
endif()
set(CMD_EXTRACT_DTS_INCLUDES ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/dts/extract_dts_includes.py
--dts ${BOARD}.dts_compiled
--yaml ${ZEPHYR_BASE}/dts/bindings ${DTS_APP_BINDINGS}
--yaml ${DTS_ROOT_BINDINGS}
--keyvalue ${GENERATED_DTS_BOARD_CONF}
--include ${GENERATED_DTS_BOARD_UNFIXED_H}
--old-alias-names

View File

@@ -25,7 +25,7 @@ else()
# via pypi, which will result in a single line of output.
string(REGEX REPLACE "\n" ";" west_version_output "${west_version_output}")
foreach(item ${west_version_output})
if("${item}" MATCHES ".*v([0-9]+[.][0-9]+[.][0-9]+)")
if("${item}" MATCHES "^[^\/\\]*v([0-9]+[.][0-9]+[.][0-9]+)")
set(west_version "${CMAKE_MATCH_1}")
if(${west_version} VERSION_LESS ${MIN_WEST_VERSION})
message(FATAL_ERROR "The detected west version is unsupported.\n\

View File

@@ -22,6 +22,7 @@ function(gen_kobj gen_dir_out)
--kobj-otype-output ${KOBJ_OTYPE}
--kobj-size-output ${KOBJ_SIZE}
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS $ENV{ZEPHYR_BASE}/scripts/gen_kobject_list.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(${KOBJ_TYPES_H_TARGET} DEPENDS ${KOBJ_TYPES} ${KOBJ_OTYPE})

View File

@@ -1,3 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/generic.cmake)
if (NOT ZEPHYR_SDK_INSTALL_DIR)
message(FATAL_ERROR "ZEPHYR_SDK_INSTALL_DIR must be set")
endif()
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/generic.cmake)

View File

@@ -34,6 +34,7 @@ file(READ ${sdk_version_path} SDK_VERSION_PRE1)
string(REGEX REPLACE "-.*" "" SDK_VERSION_PRE2 ${SDK_VERSION_PRE1})
# Strip any trailing spaces/newlines from the version string
string(STRIP ${SDK_VERSION_PRE2} SDK_VERSION)
string(REGEX MATCH "([0-9]*).([0-9]*)" SDK_MAJOR_MINOR ${SDK_VERSION})
if(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION})
message(FATAL_ERROR "The SDK version you are using is too old, please update your SDK.
You need at least SDK version ${REQUIRED_SDK_VER}.
@@ -43,4 +44,4 @@ https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${REQUIRED_SDK_V
")
endif()
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/host-tools.cmake)
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/host-tools.cmake)

View File

@@ -1,3 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/target.cmake)
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/target.cmake)

View File

@@ -510,12 +510,12 @@ again.
.. _application_debugging:
.. _custom_board_definition:
Custom Board and SOC Definitions
********************************
Custom Board, DeviceTree and SOC Definitions
********************************************
In cases where the board or platform you are developing for is not yet supported
by Zephyr, you can add the board and SOC definition to your application and
build for this board or SOC without having to add them to the Zephyr tree.
In cases where the board or platform you are developing for is not yet
supported by Zephyr, you can add board, DeviceTree and SOC definitions
to your application without having to add them to the Zephyr tree.
The structure needed to support out-of-tree board and SOC development
is similar to how boards and SOCs are maintained in the Zephyr tree. By using
@@ -644,6 +644,29 @@ Zephyr binary into your application directory.
You can also define the ``SOC_ROOT`` variable in the application
:file:`CMakeLists.txt` file.
DeviceTree Definitions
======================
Additional DeviceTree directory trees, or DTS_ROOTs, can be added by
creating this directory tree:
dts/bindings/
dts/common/
dts/arm/
include/
Where 'arm' is changed to the appropriate architecture. Each directory
is optional. The binding directory contains bindings and the other
directories contain files that can be included from DT sources.
Once the directory structure is in place, you can use it by specifying
its location through the ``DTS_ROOT`` CMake Cache variable::
cmake -DDTS_ROOT=<path to dts root>
You can also define the variable in the application
:file:`CMakeLists.txt` file.
.. _ext-projs:
Modules (External projects)

View File

@@ -42,11 +42,14 @@ First, install the ``west`` binary and bootstrapper:
.. code-block:: console
# Linux
pip3 install --user west
pip3 install --user west~=0.5.8
# macOS and Windows
pip3 install west
(Later versions of west than v0.5.x may also work with Zephyr v1.14, but that
was the version in use at the time of release.)
.. note::
See :ref:`gs_python_deps` for additional clarfication on using the
``--user`` switch.
@@ -71,7 +74,7 @@ Next, clone the Zephyr source code repositories from GitHub using the
.. code-block:: console
west init zephyrproject
west init zephyrproject --mr v1.14.1
cd zephyrproject
west update

View File

@@ -40,10 +40,10 @@ Controller qualifications
- Nordic
- nRF52x
PICS Features
ICS Features
*************
The PICS features for each supported protocol & profile can be found in
The ICS features for each supported protocol & profile can be found in
the following documents:
.. toctree::
@@ -54,5 +54,5 @@ the following documents:
l2cap-pics.rst
sm-pics.rst
rfcomm-pics.rst
mesh-pics.rst

View File

@@ -1,7 +1,7 @@
GAP PICS
********
GAP ICS
*******
PTS version: 7.2.0
PTS version: 7.4.1
\* - different than PTS defaults
@@ -30,11 +30,9 @@ Version Configuration
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_GAP_0A_1 False (*) Core Specification Addendum 3 (CSA3) (C.1)
TSPC_GAP_0A_2 False (*) Core Specification Addendum 4 (CSA4) (C.2)
TSPC_GAP_0A_3 False (*) Core Spec version 4.1 (Core v4.1) (C.3)
TSPC_GAP_0A_4 True Core Spec version 4.2 (Core v4.2) (C.4)
TSPC_GAP_0A_5 False (*) Core Spec version 5.0 (Core v5.0) (C.4)
TSPC_GAP_0A_4 False (*) Core Spec version 4.2 (Core v4.2) (C.4)
TSPC_GAP_0A_5 False (*) Core Spec version 5.0 (Core v5.0) (C.5)
TSPC_GAP_0A_6 True Core Spec version 5.1 (Core v5.1) (C.6)
============== ============== =======================================
@@ -157,7 +155,6 @@ TSPC_GAP_8_2 True Scannable Undirected Event (O)
TSPC_GAP_8_3 False (*) Non-Connectable and Non-Scannable
Directed Event (C.1)
TSPC_GAP_8_4 False (*) Scannable Directed Event (C.1)
============== ============== =======================================
@@ -171,20 +168,20 @@ TSPC_GAP_8A_1 True AD Type-Service UUID (O)
TSPC_GAP_8A_2 True AD Type-Local Name (O)
TSPC_GAP_8A_3 True AD Type-Flags (O)
TSPC_GAP_8A_4 True AD Type-Manufacturer Specific Data (O)
TSPC_GAP_8A_5 False (*) AD Type-TX Power Level (O)
TSPC_GAP_8A_5 True AD Type-TX Power Level (O)
TSPC_GAP_8A_6 False (*) AD Type-Security Manager Out of Band
(OOB) (C.1)
TSPC_GAP_8A_7 False (*) AD Type-Security manager TK Value (O)
TSPC_GAP_8A_8 False (*) AD Type-Slave Connection Interval Range (O)
TSPC_GAP_8A_9 False (*) AD Type-Service Solicitation (O)
TSPC_GAP_8A_7 True AD Type-Security manager TK Value (O)
TSPC_GAP_8A_8 True AD Type-Slave Connection Interval Range (O)
TSPC_GAP_8A_9 True AD Type-Service Solicitation (O)
TSPC_GAP_8A_10 True AD Type-Service Data (O)
TSPC_GAP_8A_11 True AD Type-Appearance (O)
TSPC_GAP_8A_12 False (*) AD Type-Public Target Address (O)
TSPC_GAP_8A_13 False (*) AD Type-Random Target Address (O)
TSPC_GAP_8A_14 False (*) AD Type-Advertising Interval (O)
TSPC_GAP_8A_15 False (*) AD Type-LE Bluetooth Device Address (O)
TSPC_GAP_8A_16 False (*) AD Type-LE Role (O)
TSPC_GAP_8A_17 False (*) AD Type-URI (C.3)
TSPC_GAP_8A_12 True AD Type-Public Target Address (O)
TSPC_GAP_8A_13 True AD Type-Random Target Address (O)
TSPC_GAP_8A_14 True AD Type-Advertising Interval (O)
TSPC_GAP_8A_15 True AD Type-LE Bluetooth Device Address (O)
TSPC_GAP_8A_16 True AD Type-LE Role (O)
TSPC_GAP_8A_17 True AD Type-URI (C.3)
============== ============== =======================================
@@ -217,7 +214,7 @@ Parameter Name Selected Description
TSPC_GAP_11_1 True Privacy Feature v1.0 (O)
TSPC_GAP_11_2 True Resolvable Private Address Generation
Procedure (C.1)
TSPC_GAP_11_3 False (*) Non-Resolvable Private Address Generation
TSPC_GAP_11_3 True Non-Resolvable Private Address Generation
Procedure (C.2)
============== ============== =======================================
@@ -294,7 +291,7 @@ Observer Privacy Feature
Parameter Name Selected Description
============== ============== =======================================
TSPC_GAP_17_1 True Privacy Feature v1.0 (O)
TSPC_GAP_17_2 False (*) Non-Resolvable Private Address Generation
TSPC_GAP_17_2 True Non-Resolvable Private Address Generation
Procedure (C.1)
TSPC_GAP_17_3 True Resolvable Private Address Resolution
Procedure (C.2)
@@ -367,20 +364,20 @@ TSPC_GAP_20A_1 True AD Type-Service UUID (C.1)
TSPC_GAP_20A_2 True AD Type-Local Name (C.1)
TSPC_GAP_20A_3 True AD Type-Flags (C.2)
TSPC_GAP_20A_4 True AD Type-Manufacturer Specific Data (C.1)
TSPC_GAP_20A_5 False (*) AD Type-TX Power Level (C.1)
TSPC_GAP_20A_5 True AD Type-TX Power Level (C.1)
TSPC_GAP_20A_6 False (*) AD Type-Security Manager Out of Band (OOB)
(C.3)
TSPC_GAP_20A_7 False (*) AD Type-Security manager TK Value (C.1)
TSPC_GAP_20A_8 False (*) AD Type-Slave Connection Interval Range (C.1)
TSPC_GAP_20A_9 False (*) AD Type-Service Solicitation (C.1)
TSPC_GAP_20A_7 True AD Type-Security manager TK Value (C.1)
TSPC_GAP_20A_8 True AD Type-Slave Connection Interval Range (C.1)
TSPC_GAP_20A_9 True AD Type-Service Solicitation (C.1)
TSPC_GAP_20A_10 True AD Type-Service Data (C.1)
TSPC_GAP_20A_11 True AD Type-Appearance (C.1)
TSPC_GAP_20A_12 False (*) AD Type-Public Target Address (C.1)
TSPC_GAP_20A_13 False (*) AD Type-Random Target Address (C.1)
TSPC_GAP_20A_14 False (*) AD Type-Advertising Interval (C.1)
TSPC_GAP_20A_15 False (*) AD Type-LE Bluetooth Device Address (C.1)
TSPC_GAP_20A_16 False (*) AD Type-LE Role (C.1)
TSPC_GAP_20A_17 False (*) AD Type-URI (C.4)
TSPC_GAP_20A_12 True AD Type-Public Target Address (C.1)
TSPC_GAP_20A_13 True AD Type-Random Target Address (C.1)
TSPC_GAP_20A_14 True AD Type-Advertising Interval (C.1)
TSPC_GAP_20A_15 True AD Type-LE Bluetooth Device Address (C.1)
TSPC_GAP_20A_16 True AD Type-LE Role (C.1)
TSPC_GAP_20A_17 True AD Type-URI (C.4)
=============== ============= =======================================
@@ -463,7 +460,7 @@ TSPC_GAP_25_7 True Authenticated Pairing
TSPC_GAP_25_8 True Unauthenticated Pairing
(LE security mode 1 level 2) (C.1)
TSPC_GAP_25_9 True LE Security Mode 1 Level 4 (C.3)
TSPC_GAP_25_10 False (*) Secure Connections Only Mode (C.4)
TSPC_GAP_25_10 True Secure Connections Only Mode (C.4)
============== ============== =======================================
@@ -493,12 +490,31 @@ TSPC_GAP_27_1 True Device Name (M)
TSPC_GAP_27_2 True Appearance (M)
TSPC_GAP_27_3 False (*) Peripheral Privacy Flag (C.1)
TSPC_GAP_27_4 False (*) Reconnection Address (C.2)
TSPC_GAP_27_5 False (*) Peripheral Preferred Connection Parameters
TSPC_GAP_27_5 True Peripheral Preferred Connection Parameters
(C.3)
TSPC_GAP_27_6 False (*) Writable Device Name (C.3)
TSPC_GAP_27_6 True Writable Device Name (C.3)
TSPC_GAP_27_7 False (*) Writable Appearance (C.3)
TSPC_GAP_27_8 False (*) Writable Peripheral Privacy Flag (C.4)
TSPC_GAP_27_9 False (*) Central Address Resolution (C.5)
TSPC_GAP_27_9 True Central Address Resolution (C.5)
============== ============== =======================================
Periodic Advertising Modes and Procedures
=========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_GAP_27A_1 False (*) Periodic Advertising Synchronization
Transfer procedure (C.1)
TSPC_GAP_27A_2 False (*) Periodic Advertising Synchronization
Establishment procedure over an LE
connection without listening for periodic
advertising (C.2)
TSPC_GAP_27A_3 False (*) Periodic Advertising Synchronization
Establishment procedure over an LE
connection with listening for periodic
advertising (C.3)
============== ============== =======================================
@@ -552,7 +568,7 @@ TSPC_GAP_31_6 True Termination Procedure (M)
TSPC_GAP_31_7 False (*) LE Ping Procedure (C.1)
TSPC_GAP_31_8 True Slave Initiated Feature Exchange Procedure
(C.2)
TSPC_GAP_31_9 False (*) Connection Parameter Request Procedure (C.3)
TSPC_GAP_31_9 True Connection Parameter Request Procedure (C.3)
TSPC_GAP_31_10 True Data Length Update Procedure (C.4)
TSPC_GAP_31_11 True PHY Update Procedure (C.5)
TSPC_GAP_31_12 False (*) Minimum Number Of Used Channels Procedure (C.5)
@@ -627,7 +643,7 @@ Central Privacy Feature
Parameter Name Selected Description
============== ============== =======================================
TSPC_GAP_36_1 True Privacy Feature v1.0 (O)
TSPC_GAP_36_2 False (*) Non-Resolvable Private Address Generation
TSPC_GAP_36_2 True Non-Resolvable Private Address Generation
Procedure (C.1)
TSPC_GAP_36_3 True Resolvable Private Address Resolution
Procedure (C.2)
@@ -650,6 +666,25 @@ TSPC_GAP_37_3 True Central Address Resolution (C.1)
============== ============== =======================================
Periodic Advertising Modes and Procedures
=========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_GAP_37A_1 False (*) Periodic Advertising Synchronization
Transfer procedure (C.1)
TSPC_GAP_37A_2 False (*) Periodic Advertising Synchronization
Establishment procedure over an LE
connection without listening for
periodic advertising
TSPC_GAP_37A_3 False (*) Periodic Advertising Synchronization
Establishment procedure over an LE
connection with listening for periodic
advertising
============== ============== =======================================
BR/EDR/LE Roles
===============
@@ -756,13 +791,3 @@ TSPC_GAP_45_2 False (*) Simultaneous BR/EDR and LE Transports - BR/EDR
Master to the same device (C.1)
============== ============== =======================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_GATT_1_1 True GATT Client Role (O)
TSPC_GATT_1_2 True GATT Server Role (O)
TSPC_SM_1_1 True Master Role (Initiator)
TSPC_SM_1_2 True Slave Role (Responder)
TSPC_SM_2_4 False (*) OOB supported (O)
============== ============== =======================================

View File

@@ -1,7 +1,7 @@
GATT PICS
=========
GATT ICS
********
PTS version: 7.2.0
PTS version: 7.4.1
\* - different than PTS defaults
@@ -35,7 +35,7 @@ TSPC_GATT_1a_3 True GATT Server over LE (C.3)
TSPC_GATT_1a_4 False GATT Server over BR/EDR (C.4)
TSPC_GATT_1a_5 False Complete GATT Client layer over LE (C.5)
TSPC_GATT_1a_6 False Complete GATT Client layer over BR/EDR (C.6)
TSPC_GATT_1a_7 False Complete GATT Server layer over LE (C.7)
TSPC_GATT_1a_7 True Complete GATT Server layer over LE (C.7)
TSPC_GATT_1a_8 False Complete GATT Server layer over BR/EDR (C.8)
============== =========== ============================================
@@ -59,7 +59,7 @@ Generic Attribute Profile Support
Parameter Name Selected Description
============== =========== ============================================
TSPC_GATT_3_1 True Client: Exchange MTU (C.1)
TSPC_GATT_3_2 False (*) Client: Discover All Primary Services (C.1)
TSPC_GATT_3_2 True Client: Discover All Primary Services (C.1)
TSPC_GATT_3_3 True Client: Discover Primary Services Service
UUID (C.1)
TSPC_GATT_3_4 True Client: Find Included Services (C.1)
@@ -69,7 +69,7 @@ TSPC_GATT_3_6 True Client: Discover Characteristics by UUID (C.1)
TSPC_GATT_3_7 True Client: Discover All Characteristic Descriptors
(C.1)
TSPC_GATT_3_8 True Client: Read Characteristic Value (C.1)
TSPC_GATT_3_9 False (*) Client: Read using Characteristic UUID (C.1)
TSPC_GATT_3_9 True Client: Read using Characteristic UUID (C.1)
TSPC_GATT_3_10 True Client: Read Long Characteristic Values (C.1)
TSPC_GATT_3_11 True Client: Read Multiple Characteristic
Values (C.1)
@@ -89,6 +89,9 @@ TSPC_GATT_3_22 True Client: Write Long Characteristic Descriptors
(C.1)
TSPC_GATT_3_23 True Client: Service Changed Characteristic (M)
TSPC_GATT_3_24 False (*) Client: Configured Broadcast (C.3)
TSPC_GATT_3_25 False (*) Client: Client Supported Features Characteristic
(C.4)
TSPC_GATT_3_26 False (*) Client: Database Hash Characteristic (C.4)
============== =========== ============================================
@@ -181,6 +184,9 @@ TSPC_GATT_4_22 True Server: Write Long Characteristic
TSPC_GATT_4_23 True Server: Service Changed Characteristic (C.1)
TSPC_GATT_4_24 False (*) Server: Configured Broadcast (C.5)
TSPC_GATT_4_25 False (*) Server: Execute Write Request with empty queue (C.7)
TSPC_GATT_4_26 True Server: Client Supported Features Characteristic
(C.9)
TSPC_GATT_4_27 True Server: Database Hash Characteristic (C.8)
============== =========== ============================================
@@ -235,8 +241,8 @@ TSPC_GATT_4B_38 True Server: Characteristic Format: struct (M)
=============== =========== ============================================
Generic Attribute Profile Service - SDP Interoperability
========================================================
SDP Interoperability
====================
============== =========== ============================================
Parameter Name Selected Description
@@ -274,12 +280,3 @@ TSPC_GATT_8_1 False (*) Support for Multiple ATT bearers from same
device (C.1)
============== =========== ============================================
Device Configuration
====================
============== =========== ============================================
Parameter Name Selected Description
============== =========== ============================================
TSPC_GAP_0_2 True LE (C.2)
============== =========== ============================================

View File

@@ -1,12 +1,12 @@
L2CAP PICS
==========
L2CAP ICS
*********
PTS version: 7.2.0
PTS version: 7.4.1
* - different than PTS defaults
Device Configuration
====================
L2CAP Transport Configuration
=============================
================ =========== =======================================
Parameter Name Selected Description
@@ -97,7 +97,7 @@ TSPC_L2CAP_2_42 True Send Connection Parameter Update Request
TSPC_L2CAP_2_43 True Send Connection Parameter Update
Response
TSPC_L2CAP_2_44 False (*) Extended Flow Specification for AMP
TSPC_L2CAP_2_45 True Send disconnect request command
TSPC_L2CAP_2_45 False (*) Send disconnect request command
TSPC_L2CAP_2_45a True Send disconnect request command - LE
TSCP_L2CAP_2_46 True Support LE Credit Based Flow Control
Mode
@@ -141,3 +141,4 @@ TSPC_L2CAP_3_15 False (*) Negotiate and support service type
TSPC_L2CAP_3_16 True Support Multiple Simultaneous LE Data
Channels
================ =========== =======================================

View File

@@ -0,0 +1,312 @@
.. _mesh-pics:
MESH ICS
********
PTS version: 7.4.1
\* - different than PTS defaults
\^ - field not available on PTS
M - mandatory
O - optional
Major Profile Version (X.Y)
===========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_0_1 True Mesh v1.0 (M)
============== ============== =======================================
Minor Profile Version (X.Y.Z)
=============================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_0A_1 True Erratum 10395 (C.1)
TSPC_MESH_0A_2 True Mesh v1.0.1 (C.2)
============== ============== =======================================
Bluetooth Core Specification v4.0 and Later
===========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_1_1 True Core Specification 4.0 or later version (M)
============== ============== =======================================
Roles
=====
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_2_1 True Node (C.1)
TSPC_MESH_2_2 False (*) Provisioner (C.1)
============== ============== =======================================
Node Capabilities - Bearers
===========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_3_1 True Advertising Bearer (C.1)
TSPC_MESH_3_2 True GATT Bearer (C.1)
============== ============== =======================================
Provisioning
============
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_4_1 True PB-ADV (C.1)
TSPC_MESH_4_2 True PB-GATT (C.2)
TSPC_MESH_4_3 True Device UUID (C.3)
TSPC_MESH_4_4 True Sending Unprovisioned Device Beacon (C.4)
TSPC_MESH_4_5 True Generic Provisioning Layer (C.3)
TSPC_MESH_4_6 True Provisioning Protocol (C.3)
TSPC_MESH_4_7 False (*) Provisioning: Public Key OOB (C.5)
TSPC_MESH_4_8 True Provisioning: Public Key No OOB (C.5)
TSPC_MESH_4_9 True Provisioning: Authentication Output OOB (C.6)
TSPC_MESH_4_10 False (*) Provisioning: Authentication Input OOB (C.6)
TSPC_MESH_4_11 False (*) Provisioning: Authentication Static OOB (C.6)
TSPC_MESH_4_12 True Provisioning: Authentication No OOB (C.3)
============== ============== =======================================
Node Capabilities - Network Layer
=================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_5_1 True Transmitting and Receiving Secured Network
Layer Messages (M)
TSPC_MESH_5_2 True Relay Feature (C.1)
TSPC_MESH_5_3 True Network Message Cache (C.2)
============== ============== =======================================
Node Capabilities - Lower Transport Layer
=========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_6_1 True Transmitting and Receiving a Lower Transport
PDU (M)
TSPC_MESH_6_2 True Segmentation and Reassembly Behavior (M)
TSPC_MESH_6_3 True Friend Cache (C.1)
============== ============== =======================================
Node Capabilities - Upper Transport Layer
=========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_7_1 True Transmitting a Secured Access Payload (M)
TSPC_MESH_7_2 True Receiving a Secured Upper Transport PDU (M)
TSPC_MESH_7_3 True Friend Feature (C.1)
TSPC_MESH_7_4 True Low Power Feature (C.1)
TSPC_MESH_7_5 True Heartbeat (M)
============== ============== =======================================
Node Capabilities - Access Layer
================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_8_1 True Transmitting and Receiving an Access Layer
Message (M)
============== ============== =======================================
Node Capabilities - Security
============================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_9_1 True Message Replay Protection (M)
============== ============== =======================================
Node Capabilities - Mesh Management
===================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_10_1 True Secure Network Beacon (M)
TSPC_MESH_10_2 True Key Refresh Procedure (M)
TSPC_MESH_10_3 True IV Update Procedure (M)
TSPC_MESH_10_4 True IV Index Recovery Procedure (M)
============== ============== =======================================
Node Capabilities - Foundation Mesh Models
==========================================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_11_1 True Configuration Server Model (M)
TSPC_MESH_11_2 True Health Server Model (M)
TSPC_MESH_11_3 False (*) Configuration Client Model (O)
TSPC_MESH_11_4 False (*) Health Client Model (O)
============== ============== =======================================
Node Capabilities - Proxy
=========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_12_1 True Proxy Server (C.1)
TSPC_MESH_12_2 True GATT Server (C.2)
TSPC_MESH_12_3 True Advertising with Network ID (C.2)
TSPC_MESH_12_4 True Advertising with Node Identity (C.2)
TSPC_MESH_12_5 False (*) Proxy Client (C.3)
TSPC_MESH_12_6 False (*) GATT Client (C.4)
============== ============== =======================================
Mesh GATT Services
==================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_13_1 True Mesh Provisioning Service (C.1)
TSPC_MESH_13_2 True Mesh Proxy Service (C.2)
============== ============== =======================================
GATT Server Requirements
========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_14_1 True Discover All Primary Services (M)
TSPC_MESH_14_2 True Discover Primary Services by Service UUID (M)
TSPC_MESH_14_3 True Write without Response (M)
TSPC_MESH_14_4 True Notification (M)
TSPC_MESH_14_5 True Write Characteristic Descriptors (M)
============== ============== =======================================
GATT Client Requirements
========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_15_1 False (*) Discover All Primary Services (C.1)
TSPC_MESH_15_2 False (*) Discover Primary Services by Service UUID (C.1)
TSPC_MESH_15_3 False (*) Write without Response (M)
TSPC_MESH_15_4 False (*) Notification (M)
TSPC_MESH_15_5 False (*) Write Characteristic Descriptors (M)
============== ============== =======================================
GAP Requirements
================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_16_1 True Broadcaster (C.1)
TSPC_MESH_16_2 True Observer (C.1)
TSPC_MESH_16_3 True Peripheral (C.2)
TSPC_MESH_16_4 True Peripheral - Security Mode 1 (C.2)
TSPC_MESH_16_5 False (*) Central (C.3)
TSPC_MESH_16_6 False (*) Central - Security Mode 1 (C.3)
============== ============== =======================================
Provisioner - Bearers
=====================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_17_1 False (*) Advertising Bearer (C.1)
TSPC_MESH_17_2 False (*) GATT Bearer (C.1)
============== ============== =======================================
Provisioner - Provisioning
==========================
=============== ============== =======================================
Parameter Name Selected Description
=============== ============== =======================================
TSPC_MESH_18_1 False (*) Receiving Unprovisioned Device Beacon (C.1)
TSPC_MESH_18_2 False (*) PB-ADV (C.1)
TSPC_MESH_18_3 False (*) Generic Provisioning Layer (M)
TSPC_MESH_18_4 False (*) Provisioning Protocol (M)
TSPC_MESH_18_5 False (*) PB-GATT (C.2)
TSPC_MESH_18_6 False (*) GATT Client (C.2)
TSPC_MESH_18_7 False (*) Provisioning: Public Key OOB (M)
TSPC_MESH_18_8 False (*) Provisioning: Public Key No OOB (M)
TSPC_MESH_18_9 False (*) Provisioning: Authentication Output OOB (M)
TSPC_MESH_18_10 False (*) Provisioning: Authentication Input OOB (M)
TSPC_MESH_18_11 False (*) Provisioning: Authentication Static or No OOB (M)
=============== ============== =======================================
Provisioner - Mesh Management
=============================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_19_1 False (*) Receiving Secure Network Beacon (M)
============== ============== =======================================
GATT Client Requirements
========================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_20_1 False (*) Discover All Primary Services (C.1)
TSPC_MESH_20_2 False (*) Discover Primary Services by Service UUID (C.1)
TSPC_MESH_20_3 False (*) Write without Response (M)
TSPC_MESH_20_4 False (*) Notification (M)
TSPC_MESH_20_5 False (*) Write Characteristic Descriptors (M)
============== ============== =======================================
GAP Requirements
================
============== ============== =======================================
Parameter Name Selected Description
============== ============== =======================================
TSPC_MESH_21_1 False (*) Broadcaster (C.1)
TSPC_MESH_21_2 False (*) Observer (C.1)
TSPC_MESH_21_3 False (*) Central (C.2)
TSPC_MESH_21_4 False (*) Central - Security Mode 1 (C.2)
============== ============== =======================================

View File

@@ -1,7 +1,7 @@
SM PICS
*******
SM ICS
******
PTS version: 7.2.0
PTS version: 7.4.1
\* - different than PTS defaults
@@ -33,7 +33,7 @@ TSPC_SM_2_1 True Authenticated MITM protection (O)
TSPC_SM_2_2 True Unauthenticated no MITM protection (C.1)
TSPC_SM_2_3 True No security requirements (M)
TSPC_SM_2_4 False OOB supported (O)
TSPC_SM_2_5 True LE Secure Connections (C.2)
TSPC_SM_2_5 True Slave Role (Responder) (C.2)
=============== =========== =======================================
@@ -69,7 +69,7 @@ TSPC_SM_5_1 True Encryption Setup using STK (C.3)
TSPC_SM_5_2 True Encryption Setup using LTK (O)
TSPC_SM_5_3 True Slave Initiated Security (C.1)
TSPC_SM_5_4 True Slave Initiated Security - Master response(C.2)
TSPC_SM_5_5 True Link Key Conversion Function h7 (C.4)
TSPC_SM_5_5 False (*) Link Key Conversion Function h7 (C.4)
=============== =========== =======================================

View File

@@ -73,6 +73,18 @@ Additionally you can specify the build system target using the ``--target``
You can list all targets with ``ninja help`` (or ``west build -t help``) inside
the build folder.
A clean build can be triggered by using the ``--pristine`` (or ``-p``) option.
This is particularly handy if you want to switch source dirs or boards without
using a different build dir::
west build -b qemu_x86 samples/philosophers
west build -p -b reel_board samples/hello_world
If you are unsure about whether the command-line parameters you supply to
``west build`` require a clean build you can let west decide for you by using
the ``auto`` setting in the ``--pristine`` option::
west build -p auto -b reel_board samples/hello_world
Finally, you can add additional arguments to the CMake invocation performed by
``west build`` by supplying additional parameters (after a ``--``) to the
@@ -93,6 +105,33 @@ a CMake re-run using the ``-c`` (or ``--cmake``) option::
west build -c
Configuration Options
=====================
You can :ref:`configure <west-config-cmd>` ``west build`` using these options.
.. NOTE: docs authors: keep this table sorted alphabetically
.. list-table::
:widths: 10 30
:header-rows: 1
* - Option
- Description
* - ``build.pristine``
- String. Controls the way in which ``west build`` may clean the build
folder before building. Can take the following values:
- ``never`` (default): Never automatically make the build folder
pristine.
- ``auto``: ``west build`` will automatically make the build folder
pristine before building, if a build system is present and the build
would fail otherwise (e.g. the user has specified a different board
or application from the one previously used to make the build
directory).
- ``always``: Always make the build folder pristine before building, if
a build system is present.
.. _west-flashing:
Flashing: ``west flash``

View File

@@ -0,0 +1,74 @@
.. _fcb-manual:
Flash Circular Buffer (FCB)
###########################
Flash circular buffer provides an abstraction through which you can treat
flash like a FIFO. You append entries to the end, and read data from the
beginning.
Description
***********
Entries in the flash contain the length of the entry, the data within
the entry, and checksum over the entry contents.
Storage of entries in flash is done in a FIFO fashion. When you
request space for the next entry, space is located at the end of the
used area. When you start reading, the first entry served is the
oldest entry in flash.
Entries can be appended to the end of the area until storage space is
exhausted. You have control over what happens next; either erase oldest
block of data, thereby freeing up some space, or stop writing new data
until existing data has been collected. FCB treats underlying storage as
an array of flash sectors; when it erases old data, it does this a
sector at a time.
Entries in the flash are checksummed. That is how FCB detects whether
writing entry to flash completed ok. It will skip over entries which
don't have a valid checksum.
Usage
*****
To add an entry to circular buffer:
- Call `fcb_append` to get the location where data can be written. If
this fails due to lack of space, you can call `fcb_rotate` to erase
the oldest sector which will make the space. And then call `fcb_append`
again.
- Use `flash_area_write` to write entry contents.
- Call `fcb_append_finish` when done. This completes the writing of the
entry by calculating the checksum.
To read contents of the circular buffer:
- Call `fcb_walk` with a pointer to your callback function.
- Within callback function copy in data from the entry using
`flash_area_read`. You can tell when all data from within a sector
has been read by monitoring the returned entry's area pointer. Then you
can call `fcb_rotate`, if you're done with that data.
Alternatively:
- Call `fcb_getnext` with 0 in entry offset to get the pointer to
the oldest entry.
- Use `flash_area_read` to read entry contents.
- Call `fcb_getnext` with pointer to current entry to get the next one.
And so on.
API Reference
*************
The FCB subsystem APIs are provided by ``fcb.h``:
Data structures
===============
.. doxygengroup:: fcb_data_structures
:project: Zephyr
API functions
=============
.. doxygengroup:: fcb_api
:project: Zephyr

View File

@@ -10,3 +10,4 @@ Storage
nvs/nvs.rst
disk/sdhc.rst
flash_map/flash_map.rst
fcb/fcb.rst

View File

@@ -165,16 +165,11 @@ static struct net_buf *get_rx(int timeout)
{
BT_DBG("type 0x%02x, evt 0x%02x", rx.type, rx.evt.evt);
if (rx.type == H4_EVT && (rx.evt.evt == BT_HCI_EVT_CMD_COMPLETE ||
rx.evt.evt == BT_HCI_EVT_CMD_STATUS)) {
return bt_buf_get_cmd_complete(timeout);
if (rx.type == H4_EVT) {
return bt_buf_get_evt(rx.evt.evt, rx.discardable, timeout);
}
if (rx.type == H4_ACL) {
return bt_buf_get_rx(BT_BUF_ACL_IN, timeout);
} else {
return bt_buf_get_rx(BT_BUF_EVT, timeout);
}
return bt_buf_get_rx(BT_BUF_ACL_IN, timeout);
}
static void rx_thread(void *p1, void *p2, void *p3)

View File

@@ -408,16 +408,7 @@ static inline struct net_buf *get_evt_buf(u8_t evt)
{
struct net_buf *buf;
switch (evt) {
case BT_HCI_EVT_CMD_COMPLETE:
case BT_HCI_EVT_CMD_STATUS:
buf = bt_buf_get_cmd_complete(K_NO_WAIT);
break;
default:
buf = bt_buf_get_rx(BT_BUF_EVT, K_NO_WAIT);
break;
}
buf = bt_buf_get_evt(evt, false, K_NO_WAIT);
if (buf) {
net_buf_add_u8(h5.rx_buf, evt);
}

View File

@@ -353,12 +353,9 @@ static void bt_spi_rx_thread(void)
/* Vendor events are currently unsupported */
bt_spi_handle_vendor_evt(rxmsg);
continue;
case BT_HCI_EVT_CMD_COMPLETE:
case BT_HCI_EVT_CMD_STATUS:
buf = bt_buf_get_cmd_complete(K_FOREVER);
break;
default:
buf = bt_buf_get_rx(BT_BUF_EVT, K_FOREVER);
buf = bt_buf_get_evt(rxmsg[EVT_HEADER_EVENT],
false, K_FOREVER);
break;
}

View File

@@ -57,16 +57,11 @@ static int bt_dev_index = -1;
static struct net_buf *get_rx(const u8_t *buf)
{
if (buf[0] == H4_EVT && (buf[1] == BT_HCI_EVT_CMD_COMPLETE ||
buf[1] == BT_HCI_EVT_CMD_STATUS)) {
return bt_buf_get_cmd_complete(K_FOREVER);
if (buf[0] == H4_EVT) {
return bt_buf_get_evt(buf[1], false, K_FOREVER);
}
if (buf[0] == H4_ACL) {
return bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER);
} else {
return bt_buf_get_rx(BT_BUF_EVT, K_FOREVER);
}
return bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER);
}
static bool uc_ready(void)

View File

@@ -571,15 +571,15 @@ static void can_stm32_set_filter_bank(int filter_nr,
static inline void can_stm32_set_mode_scale(enum can_filter_type filter_type,
u32_t *mode_reg, u32_t *scale_reg,
int filter_nr)
int bank_nr)
{
u32_t mode_reg_bit = (filter_type & 0x01) << filter_nr;
u32_t scale_reg_bit = (filter_type >> 1) << filter_nr;
u32_t mode_reg_bit = (filter_type & 0x01) << bank_nr;
u32_t scale_reg_bit = (filter_type >> 1) << bank_nr;
*mode_reg &= ~(1 << filter_nr);
*mode_reg &= ~(1 << bank_nr);
*mode_reg |= mode_reg_bit;
*scale_reg &= ~(1 << filter_nr);
*scale_reg &= ~(1 << bank_nr);
*scale_reg |= scale_reg_bit;
}
@@ -699,7 +699,7 @@ static inline int can_stm32_set_filter(const struct zcan_filter *filter,
u32_t scale_reg = can->FS1R;
can_stm32_set_mode_scale(filter_type, &mode_reg, &scale_reg,
filter_nr);
bank_nr);
shift_width = filter_in_bank[filter_type] - filter_in_bank[bank_mode];

View File

@@ -36,7 +36,7 @@ if !SOC_SERIES_STM32F4X
choice COUNTER_RTC_STM32_LSE_DRIVE
prompt "LSE oscillator drive capability"
depends on RTC_STM32_CLOCK_LSE
depends on COUNTER_RTC_STM32_CLOCK_LSE
config COUNTER_RTC_STM32_LSE_DRIVE_LOW
bool "Low"

View File

@@ -275,10 +275,14 @@ static int rtc_stm32_init(struct device *dev)
#else /* CONFIG_COUNTER_RTC_STM32_CLOCK_LSE */
#ifndef(CONFIG_SOC_SERIES_STM32F4X)
#if !defined(CONFIG_SOC_SERIES_STM32F4X) && \
!defined(CONFIG_SOC_SERIES_STM32F2X)
LL_RCC_LSE_SetDriveCapability(
CONFIG_COUNTER_RTC_STM32_LSE_DRIVE_STRENGTH);
#endif /* !CONFIG_SOC_SERIES_STM32F4X */
#endif /* !CONFIG_SOC_SERIES_STM32F4X && !CONFIG_SOC_SERIES_STM32F2X */
LL_RCC_LSE_Enable();
/* Wait until LSE is ready */

View File

@@ -99,6 +99,15 @@ static int counter_nrfx_set_alarm(struct device *dev, u8_t chan_id,
nrfx_config->ch_data[chan_id].callback = alarm_cfg->callback;
nrfx_config->ch_data[chan_id].user_data = alarm_cfg->user_data;
if ((cc_val == 0) &&
(get_dev_data(dev)->top != counter_get_max_top_value(dev))) {
/* From Product Specification: If a CC register value is 0 when
* a CLEAR task is set, this will not trigger a COMPARE event.
*/
LOG_INST_INF(nrfx_config->log,
"Attempt to set CC to 0, delayed to 1.");
cc_val++;
}
nrfx_rtc_cc_set(rtc, ID_TO_CC(chan_id), cc_val, true);
return 0;

View File

@@ -1,6 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_link_interface_ifdef(CONFIG_MBEDTLS mbedTLS)
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_CRYPTO_TINYCRYPT_SHIM crypto_tc_shim.c)
zephyr_library_sources_ifdef(CONFIG_CRYPTO_ATAES132A crypto_ataes132a.c)

View File

@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017 Linaro Limited
* Copyright (c) 2017 BayLibre, SAS.
* Copyright (c) 2019 Centaur Analytics, Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,21 +17,26 @@
/* STM32F0: maximum erase time of 40ms for a 2K sector */
#if defined(CONFIG_SOC_SERIES_STM32F0X)
#define STM32_FLASH_TIMEOUT (K_MSEC(40))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40))
/* STM32F3: maximum erase time of 40ms for a 2K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F3X)
#define STM32_FLASH_TIMEOUT (K_MSEC(40))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40))
/* STM32F4: maximum erase time of 4s for a 128K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F4X)
#define STM32_FLASH_TIMEOUT (K_MSEC(4000))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000))
/* STM32F7: maximum erase time of 4s for a 256K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F7X)
#define STM32_FLASH_TIMEOUT (K_MSEC(4000))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000))
/* STM32L4: maximum erase time of 24.47ms for a 2K sector */
#elif defined(CONFIG_SOC_SERIES_STM32L4X)
#define STM32_FLASH_TIMEOUT (K_MSEC(25))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25))
#endif
/* Let's wait for double the max erase time to be sure that the operation is
* completed.
*/
#define STM32_FLASH_TIMEOUT (2 * STM32_FLASH_MAX_ERASE_TIME)
/*
* This is named flash_stm32_sem_take instead of flash_stm32_lock (and
* similarly for flash_stm32_sem_give) to avoid confusion with locking

View File

@@ -342,17 +342,19 @@ static int spi_flash_wb_erase(struct device *dev, off_t offset, size_t size)
break;
}
if (size_remaining >= W25QXXDV_BLOCK_SIZE) {
if ((size_remaining >= W25QXXDV_BLOCK_SIZE) &&
((new_offset & (W25QXXDV_BLOCK_SIZE - 1)) == 0)) {
ret = spi_flash_wb_erase_internal(dev, new_offset,
W25QXXDV_BLOCK_SIZE);
W25QXXDV_BLOCK_SIZE);
new_offset += W25QXXDV_BLOCK_SIZE;
size_remaining -= W25QXXDV_BLOCK_SIZE;
continue;
}
if (size_remaining >= W25QXXDV_BLOCK32K_SIZE) {
if ((size_remaining >= W25QXXDV_BLOCK32K_SIZE) &&
((new_offset & (W25QXXDV_BLOCK32K_SIZE - 1)) == 0)) {
ret = spi_flash_wb_erase_internal(dev, new_offset,
W25QXXDV_BLOCK32K_SIZE);
W25QXXDV_BLOCK32K_SIZE);
new_offset += W25QXXDV_BLOCK32K_SIZE;
size_remaining -= W25QXXDV_BLOCK32K_SIZE;
continue;
@@ -360,7 +362,7 @@ static int spi_flash_wb_erase(struct device *dev, off_t offset, size_t size)
if (size_remaining >= W25QXXDV_SECTOR_SIZE) {
ret = spi_flash_wb_erase_internal(dev, new_offset,
W25QXXDV_SECTOR_SIZE);
W25QXXDV_SECTOR_SIZE);
new_offset += W25QXXDV_SECTOR_SIZE;
size_remaining -= W25QXXDV_SECTOR_SIZE;
continue;

View File

@@ -12,6 +12,7 @@
#include <soc.h>
#include <fsl_common.h>
#include <fsl_port.h>
#include <clock_control.h>
#include "gpio_utils.h"
@@ -19,6 +20,9 @@ struct gpio_rv32m1_config {
GPIO_Type *gpio_base;
PORT_Type *port_base;
unsigned int flags;
char *clock_controller;
clock_control_subsys_t clock_subsys;
int (*irq_config_func)(struct device *dev);
};
struct gpio_rv32m1_data {
@@ -228,6 +232,27 @@ static void gpio_rv32m1_port_isr(void *arg)
config->port_base->ISFR = 0xFFFFFFFF;
}
static int gpio_rv32m1_init(struct device *dev)
{
const struct gpio_rv32m1_config *config = dev->config->config_info;
struct device *clk;
int ret;
if (config->clock_controller) {
clk = device_get_binding(config->clock_controller);
if (!clk) {
return -ENODEV;
}
ret = clock_control_on(clk, config->clock_subsys);
if (ret < 0) {
return ret;
}
}
return config->irq_config_func(dev);
}
static const struct gpio_driver_api gpio_rv32m1_driver_api = {
.config = gpio_rv32m1_configure,
@@ -248,13 +273,21 @@ static const struct gpio_rv32m1_config gpio_rv32m1_porta_config = {
.flags = GPIO_INT,
#else
.flags = 0,
#endif
.irq_config_func = gpio_rv32m1_porta_init,
#ifdef DT_OPENISA_RV32M1_GPIO_GPIO_A_CLOCK_CONTROLLER
.clock_controller = DT_OPENISA_RV32M1_GPIO_GPIO_A_CLOCK_CONTROLLER,
.clock_subsys = (clock_control_subsys_t)
DT_OPENISA_RV32M1_GPIO_GPIO_A_CLOCK_NAME,
#else
.clock_controller = NULL,
#endif
};
static struct gpio_rv32m1_data gpio_rv32m1_porta_data;
DEVICE_AND_API_INIT(gpio_rv32m1_porta, DT_OPENISA_RV32M1_GPIO_GPIO_A_LABEL,
gpio_rv32m1_porta_init,
gpio_rv32m1_init,
&gpio_rv32m1_porta_data, &gpio_rv32m1_porta_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&gpio_rv32m1_driver_api);
@@ -285,13 +318,21 @@ static const struct gpio_rv32m1_config gpio_rv32m1_portb_config = {
.flags = GPIO_INT,
#else
.flags = 0,
#endif
.irq_config_func = gpio_rv32m1_portb_init,
#ifdef DT_OPENISA_RV32M1_GPIO_GPIO_B_CLOCK_CONTROLLER
.clock_controller = DT_OPENISA_RV32M1_GPIO_GPIO_B_CLOCK_CONTROLLER,
.clock_subsys = (clock_control_subsys_t)
DT_OPENISA_RV32M1_GPIO_GPIO_B_CLOCK_NAME,
#else
.clock_controller = NULL,
#endif
};
static struct gpio_rv32m1_data gpio_rv32m1_portb_data;
DEVICE_AND_API_INIT(gpio_rv32m1_portb, DT_OPENISA_RV32M1_GPIO_GPIO_B_LABEL,
gpio_rv32m1_portb_init,
gpio_rv32m1_init,
&gpio_rv32m1_portb_data, &gpio_rv32m1_portb_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&gpio_rv32m1_driver_api);
@@ -323,12 +364,21 @@ static const struct gpio_rv32m1_config gpio_rv32m1_portc_config = {
#else
.flags = 0,
#endif
.irq_config_func = gpio_rv32m1_portc_init,
#ifdef DT_OPENISA_RV32M1_GPIO_GPIO_C_CLOCK_CONTROLLER
.clock_controller = DT_OPENISA_RV32M1_GPIO_GPIO_C_CLOCK_CONTROLLER,
.clock_subsys = (clock_control_subsys_t)
DT_OPENISA_RV32M1_GPIO_GPIO_C_CLOCK_NAME,
#else
.clock_controller = NULL,
#endif
};
static struct gpio_rv32m1_data gpio_rv32m1_portc_data;
DEVICE_AND_API_INIT(gpio_rv32m1_portc, DT_OPENISA_RV32M1_GPIO_GPIO_C_LABEL,
gpio_rv32m1_portc_init,
gpio_rv32m1_init,
&gpio_rv32m1_portc_data, &gpio_rv32m1_portc_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&gpio_rv32m1_driver_api);
@@ -359,13 +409,21 @@ static const struct gpio_rv32m1_config gpio_rv32m1_portd_config = {
.flags = GPIO_INT,
#else
.flags = 0,
#endif
.irq_config_func = gpio_rv32m1_portd_init,
#ifdef DT_OPENISA_RV32M1_GPIO_GPIO_D_CLOCK_CONTROLLER
.clock_controller = DT_OPENISA_RV32M1_GPIO_GPIO_D_CLOCK_CONTROLLER,
.clock_subsys = (clock_control_subsys_t)
DT_OPENISA_RV32M1_GPIO_GPIO_D_CLOCK_NAME,
#else
.clock_controller = NULL,
#endif
};
static struct gpio_rv32m1_data gpio_rv32m1_portd_data;
DEVICE_AND_API_INIT(gpio_rv32m1_portd, DT_OPENISA_RV32M1_GPIO_GPIO_D_LABEL,
gpio_rv32m1_portd_init,
gpio_rv32m1_init,
&gpio_rv32m1_portd_data, &gpio_rv32m1_portd_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&gpio_rv32m1_driver_api);
@@ -396,13 +454,21 @@ static const struct gpio_rv32m1_config gpio_rv32m1_porte_config = {
.flags = GPIO_INT,
#else
.flags = 0,
#endif
.irq_config_func = gpio_rv32m1_porte_init,
#ifdef DT_OPENISA_RV32M1_GPIO_GPIO_E_CLOCK_CONTROLLER
.clock_controller = DT_OPENISA_RV32M1_GPIO_GPIO_E_CLOCK_CONTROLLER,
.clock_subsys = (clock_control_subsys_t)
DT_OPENISA_RV32M1_GPIO_GPIO_E_CLOCK_NAME,
#else
.clock_controller = NULL,
#endif
};
static struct gpio_rv32m1_data gpio_rv32m1_porte_data;
DEVICE_AND_API_INIT(gpio_rv32m1_porte, DT_OPENISA_RV32M1_GPIO_GPIO_E_LABEL,
gpio_rv32m1_porte_init,
gpio_rv32m1_init,
&gpio_rv32m1_porte_data, &gpio_rv32m1_porte_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&gpio_rv32m1_driver_api);

View File

@@ -609,7 +609,7 @@ static void i2s_stm32_isr(void *arg)
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
struct stream *stream = &dev_data->rx;
LOG_ERR("%s: err=%d", __func__, LL_I2S_ReadReg(cfg->i2s, SR));
LOG_ERR("%s: err=%d", __func__, (int)LL_I2S_ReadReg(cfg->i2s, SR));
stream->state = I2S_STATE_ERROR;
/* OVR error must be explicitly cleared */

View File

@@ -87,8 +87,8 @@ int kw41_dbg_idx;
#define RADIO_0_IRQ_PRIO 0x0
#define KW41Z_FCS_LENGTH 2
#define KW41Z_PSDU_LENGTH 125
#define KW41Z_OUTPUT_POWER_MAX 2
#define KW41Z_OUTPUT_POWER_MIN (-19)
#define KW41Z_OUTPUT_POWER_MAX 4
#define KW41Z_OUTPUT_POWER_MIN (-31)
#define IEEE802154_ACK_LENGTH 5
@@ -122,16 +122,28 @@ enum {
};
/* Lookup table for PA_PWR register */
static const u8_t pa_pwr_lt[22] = {
2, 2, 2, 2, 2, 2, /* -19:-14 dBm */
4, 4, 4, /* -13:-11 dBm */
6, 6, 6, /* -10:-8 dBm */
8, 8, /* -7:-6 dBm */
10, 10, /* -5:-4 dBm */
12, /* -3 dBm */
14, 14, /* -2:-1 dBm */
18, 18, /* 0:1 dBm */
24 /* 2 dBm */
static const u8_t pa_pwr_lt[] = {
1, /* -31.1 dBm: -31 */
2, 2, 2, 2, 2, 2, 2, /* -25.0 dBm: -30, -29, -28, -27, -26, -25 */
4, 4, 4, 4, 4, /* -19.0 dBm: -24, -23, -22, -21, -20, -19 */
6, 6, 6, /* -15.6 dBm: -18, -17, -16 */
8, 8, /* -13.1 dBm: -15, -14 */
10, 10, /* -11.2 dBm: -13, -12 */
12, 12, /* - 9.6 dBm: -11, -10 */
14, /* - 8.3 dBm: -9 */
16, /* - 7.2 dBm: -8 */
18, /* - 6.2 dBm: -7 */
20, /* - 5.3 dBm: -6 */
22, /* - 4.5 dBm: -5 */
24, /* - 3.8 dBm: -4 */
28, /* - 2.5 dBm: -3 */
30, /* - 1.9 dBm: -2 */
34, /* - 1.0 dBm: -1 */
40, /* + 0.3 dBm: 0 */
44, /* + 1.1 dBm: +1 */
50, /* + 2.1 dBm: +2 */
58, /* + 3.1 dBm: +3 */
62 /* + 3.5 dBm: +4 */
};
struct kw41z_context {
@@ -433,13 +445,21 @@ static int kw41z_filter(struct device *dev,
static int kw41z_set_txpower(struct device *dev, s16_t dbm)
{
if (dbm < KW41Z_OUTPUT_POWER_MIN) {
ZLL->PA_PWR = 0;
LOG_INF("TX-power %d dBm below min of %d dBm, using %d dBm",
dbm,
KW41Z_OUTPUT_POWER_MIN,
KW41Z_OUTPUT_POWER_MIN);
dbm = KW41Z_OUTPUT_POWER_MIN;
} else if (dbm > KW41Z_OUTPUT_POWER_MAX) {
ZLL->PA_PWR = 30;
} else {
ZLL->PA_PWR = pa_pwr_lt[dbm - KW41Z_OUTPUT_POWER_MIN];
LOG_INF("TX-power %d dBm above max of %d dBm, using %d dBm",
dbm,
KW41Z_OUTPUT_POWER_MAX,
KW41Z_OUTPUT_POWER_MAX);
dbm = KW41Z_OUTPUT_POWER_MAX;
}
ZLL->PA_PWR = pa_pwr_lt[dbm - KW41Z_OUTPUT_POWER_MIN];
return 0;
}

View File

@@ -30,9 +30,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <net/net_pkt.h>
#include <net/net_if.h>
#include <net/net_core.h>
#include <net/dummy.h>
#include <console/uart_pipe.h>
#include <net/ethernet.h>
#include <net/lldp.h>
#define SLIP_END 0300
#define SLIP_ESC 0333
@@ -395,9 +394,13 @@ static void slip_iface_init(struct net_if *iface)
struct slip_context *slip = net_if_get_device(iface)->driver_data;
struct net_linkaddr *ll_addr;
#if defined(CONFIG_NET_L2_ETHERNET)
ethernet_init(iface);
#endif
#if defined(CONFIG_NET_LLDP)
net_lldp_set_lldpdu(iface);
#endif
if (slip->init_done) {
return;
@@ -429,6 +432,7 @@ use_random_mac:
static struct slip_context slip_context_data;
#if defined(CONFIG_SLIP_TAP)
static enum ethernet_hw_caps eth_capabilities(struct device *dev)
{
ARG_UNUSED(dev);
@@ -440,7 +444,6 @@ static enum ethernet_hw_caps eth_capabilities(struct device *dev)
;
}
#if defined(CONFIG_SLIP_TAP) && defined(CONFIG_NET_L2_ETHERNET)
static const struct ethernet_api slip_if_api = {
.iface_api.init = slip_iface_init,
@@ -458,7 +461,7 @@ ETH_NET_DEVICE_INIT(slip, CONFIG_SLIP_DRV_NAME, slip_init, &slip_context_data,
#else
static const struct dummy_api slip_if_api = {
.iface_init.init = slip_iface_init,
.iface_api.init = slip_iface_init,
.send = slip_send,
};

View File

@@ -57,10 +57,11 @@ static u32_t pwm_period_check_and_set(const struct pwm_nrfx_config *config,
/* See if there is a prescaler that will make it work: */
bool matching_prescaler_found = false;
/* Go through all available prescaler values on device.
/* Go through all available prescaler values on device (skip 0
* here as it is used in the 'else' block).
* nRF52832 has 0-7 (Div1 - Div128)
*/
for (u8_t prescaler = 0;
for (u8_t prescaler = 1;
prescaler <= PWM_PRESCALER_PRESCALER_Msk;
prescaler++) {
u32_t new_countertop = period_cycles >> prescaler;
@@ -82,10 +83,10 @@ static u32_t pwm_period_check_and_set(const struct pwm_nrfx_config *config,
return -EINVAL;
}
} else {
/* If period_cycles fit with standard prescaler,
* set it directly
/* If period_cycles fit the PWM counter without dividing
* the PWM clock, use the zero prescaler.
*/
data->prescaler = 1U;
data->prescaler = 0U;
data->countertop = period_cycles;
data->period_cycles = period_cycles;
}

View File

@@ -69,7 +69,8 @@ static u32_t rtc_stm32_read(struct device *dev)
/* Convert calendar datetime to UNIX timestamp */
now.tm_year = 100 + __LL_RTC_CONVERT_BCD2BIN(
__LL_RTC_GET_YEAR(rtc_date));
now.tm_mon = __LL_RTC_CONVERT_BCD2BIN(__LL_RTC_GET_MONTH(rtc_date));
/* tm_mon starts from 0 */
now.tm_mon = __LL_RTC_CONVERT_BCD2BIN(__LL_RTC_GET_MONTH(rtc_date)) - 1;
now.tm_mday = __LL_RTC_CONVERT_BCD2BIN(__LL_RTC_GET_DAY(rtc_date));
now.tm_hour = __LL_RTC_CONVERT_BCD2BIN(__LL_RTC_GET_HOUR(rtc_time));
@@ -147,7 +148,8 @@ static int rtc_stm32_set_config(struct device *dev, struct rtc_config *cfg)
gmtime_r(&init_ts, &init_tm);
rtc_date.Year = init_tm.tm_year % 100;
rtc_date.Month = init_tm.tm_mon;
/* tm_mon starts from 0 */
rtc_date.Month = init_tm.tm_mon + 1;
rtc_date.Day = init_tm.tm_mday;
rtc_date.WeekDay = init_tm.tm_wday + 1;

View File

@@ -399,12 +399,12 @@ DEVICE_AND_API_INIT(uart_sifive_0, DT_SIFIVE_UART_0_LABEL,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void uart_sifive_irq_cfg_func_0(void)
{
IRQ_CONNECT(DT_SIFIVE_UART_0_IRQ_0,
IRQ_CONNECT(RISCV_MAX_GENERIC_IRQ + DT_SIFIVE_UART_0_IRQ_0,
CONFIG_UART_SIFIVE_PORT_0_IRQ_PRIORITY,
uart_sifive_irq_handler, DEVICE_GET(uart_sifive_0),
0);
irq_enable(DT_SIFIVE_UART_0_IRQ_0);
irq_enable(RISCV_MAX_GENERIC_IRQ + DT_SIFIVE_UART_0_IRQ_0);
}
#endif
@@ -438,12 +438,12 @@ DEVICE_AND_API_INIT(uart_sifive_1, DT_SIFIVE_UART_1_LABEL,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void uart_sifive_irq_cfg_func_1(void)
{
IRQ_CONNECT(DT_SIFIVE_UART_1_IRQ_0,
IRQ_CONNECT(RISCV_MAX_GENERIC_IRQ + DT_SIFIVE_UART_1_IRQ_0,
CONFIG_UART_SIFIVE_PORT_1_IRQ_PRIORITY,
uart_sifive_irq_handler, DEVICE_GET(uart_sifive_1),
0);
irq_enable(DT_SIFIVE_UART_1_IRQ_0);
irq_enable(RISCV_MAX_GENERIC_IRQ + DT_SIFIVE_UART_1_IRQ_0);
}
#endif

View File

@@ -227,7 +227,7 @@ void spi_context_buffers_setup(struct spi_context *ctx,
if (tx_bufs) {
ctx->current_tx = tx_bufs->buffers;
ctx->tx_count = tx_bufs->count;
ctx->tx_buf = ctx->current_tx->buf;
ctx->tx_buf = (const u8_t *)ctx->current_tx->buf;
ctx->tx_len = ctx->current_tx->len / dfs;
} else {
ctx->current_tx = NULL;
@@ -239,7 +239,7 @@ void spi_context_buffers_setup(struct spi_context *ctx,
if (rx_bufs) {
ctx->current_rx = rx_bufs->buffers;
ctx->rx_count = rx_bufs->count;
ctx->rx_buf = ctx->current_rx->buf;
ctx->rx_buf = (u8_t *)ctx->current_rx->buf;
ctx->rx_len = ctx->current_rx->len / dfs;
} else {
ctx->current_rx = NULL;
@@ -278,7 +278,7 @@ void spi_context_update_tx(struct spi_context *ctx, u8_t dfs, u32_t len)
ctx->tx_count--;
if (ctx->tx_count) {
ctx->current_tx++;
ctx->tx_buf = ctx->current_tx->buf;
ctx->tx_buf = (const u8_t *)ctx->current_tx->buf;
ctx->tx_len = ctx->current_tx->len / dfs;
} else {
ctx->tx_buf = NULL;
@@ -326,7 +326,7 @@ void spi_context_update_rx(struct spi_context *ctx, u8_t dfs, u32_t len)
ctx->rx_count--;
if (ctx->rx_count) {
ctx->current_rx++;
ctx->rx_buf = ctx->current_rx->buf;
ctx->rx_buf = (u8_t *)ctx->current_rx->buf;
ctx->rx_len = ctx->current_rx->len / dfs;
} else {
ctx->rx_buf = NULL;

View File

@@ -752,7 +752,7 @@ int z_clock_device_ctrl(struct device *port, u32_t ctrl_command,
}
if (cb) {
cb(dev, ret, context, arg);
cb(port, ret, context, arg);
}
return ret;

View File

@@ -362,6 +362,11 @@ int usb_dc_ep_set_stall(const u8_t ep)
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (for_in) {
endpoint->EPSTATUSSET.bit.STALLRQ1 = 1;
} else {
@@ -378,6 +383,11 @@ int usb_dc_ep_clear_stall(const u8_t ep)
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (for_in) {
endpoint->EPSTATUSCLR.bit.STALLRQ1 = 1;
} else {
@@ -394,6 +404,16 @@ int usb_dc_ep_is_stalled(const u8_t ep, u8_t *stalled)
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (stalled == NULL) {
LOG_ERR("parameter must not be NULL");
return -1;
}
if (for_in) {
*stalled = endpoint->EPSTATUS.bit.STALLRQ1;
} else {
@@ -403,6 +423,28 @@ int usb_dc_ep_is_stalled(const u8_t ep, u8_t *stalled)
return 0;
}
/* Halt the selected endpoint */
int usb_dc_ep_halt(u8_t ep)
{
return usb_dc_ep_set_stall(ep);
}
/* Flush the selected endpoint */
int usb_dc_ep_flush(u8_t ep)
{
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
/* TODO */
LOG_WRN("flush not implemented");
return 0;
}
/* Enable an endpoint and the endpoint interrupts */
int usb_dc_ep_enable(const u8_t ep)
{
@@ -411,6 +453,11 @@ int usb_dc_ep_enable(const u8_t ep)
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (for_in) {
endpoint->EPSTATUSCLR.bit.BK1RDY = 1;
} else {
@@ -424,6 +471,25 @@ int usb_dc_ep_enable(const u8_t ep)
return 0;
}
/* Disable the selected endpoint */
int usb_dc_ep_disable(u8_t ep)
{
UsbDevice *regs = &REGS->DEVICE;
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
endpoint->EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0
| USB_DEVICE_EPINTENCLR_TRCPT1
| USB_DEVICE_EPINTENCLR_RXSTP;
return 0;
}
/* Write a single payload to the IN buffer on the endpoint */
int usb_dc_ep_write(u8_t ep, const u8_t *buf, u32_t len, u32_t *ret_bytes)
{
@@ -434,6 +500,11 @@ int usb_dc_ep_write(u8_t ep, const u8_t *buf, u32_t len, u32_t *ret_bytes)
UsbDeviceDescriptor *desc = &data->descriptors[ep_num];
u32_t addr = desc->DeviceDescBank[1].ADDR.reg;
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (endpoint->EPSTATUS.bit.BK1RDY) {
/* Write in progress, drop */
return -EAGAIN;
@@ -469,6 +540,11 @@ int usb_dc_ep_read_ex(u8_t ep, u8_t *buf, u32_t max_data_len,
u32_t take;
int remain;
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (!endpoint->EPSTATUS.bit.BK0RDY) {
return -EAGAIN;
}
@@ -527,6 +603,11 @@ int usb_dc_ep_read_continue(u8_t ep)
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
endpoint->EPSTATUSCLR.bit.BK0RDY = 1;
data->out_at = 0U;
@@ -539,6 +620,11 @@ int usb_dc_ep_set_callback(const u8_t ep, const usb_dc_ep_callback cb)
u8_t for_in = ep & USB_EP_DIR_MASK;
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
data->ep_cb[for_in ? 1 : 0][ep_num] = cb;
return 0;
@@ -547,14 +633,33 @@ int usb_dc_ep_set_callback(const u8_t ep, const usb_dc_ep_callback cb)
int usb_dc_ep_mps(const u8_t ep)
{
struct usb_sam0_data *data = usb_sam0_get_data();
UsbDevice *regs = &REGS->DEVICE;
u8_t for_in = ep & USB_EP_DIR_MASK;
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceDescriptor *desc = &data->descriptors[ep_num];
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep];
int size;
if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}
if (for_in) {
/* if endpoint is not configured, this should return 0 */
if (endpoint->EPCFG.bit.EPTYPE1 == 0) {
return 0;
}
size = desc->DeviceDescBank[1].PCKSIZE.bit.SIZE;
} else {
/* if endpoint is not configured, this should return 0 */
if (endpoint->EPCFG.bit.EPTYPE0 == 0) {
return 0;
}
size = desc->DeviceDescBank[0].PCKSIZE.bit.SIZE;
}

View File

@@ -427,7 +427,7 @@ int usb_dc_attach(void)
* For STM32F0 series SoCs on QFN28 and TSSOP20 packages enable PIN
* pair PA11/12 mapped instead of PA9/10 (e.g. stm32f070x6)
*/
#if defined(CONFIG_SOC_SERIES_STM32F0X) && defined(SYSCFG_CFGR1_PA11_PA12_RMP)
#if defined(DT_USB_ENABLE_PIN_REMAP)
if (LL_APB1_GRP2_IsEnabledClock(LL_APB1_GRP2_PERIPH_SYSCFG)) {
LL_SYSCFG_EnablePinRemap();
} else {
@@ -880,12 +880,21 @@ int usb_dc_reset(void)
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
{
int i;
LOG_DBG("");
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_IN, EP0_MPS, EP_TYPE_CTRL);
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_OUT, EP0_MPS,
EP_TYPE_CTRL);
/* The DataInCallback will never be called at this point for any pending
* transactions. Reset the IN semaphores to prevent perpetual locked state.
* */
for (i = 0; i < DT_USB_NUM_BIDIR_ENDPOINTS; i++) {
k_sem_give(&usb_dc_stm32_state.in_ep_state[i].write_sem);
}
if (usb_dc_stm32_state.status_cb) {
usb_dc_stm32_state.status_cb(USB_DC_RESET, NULL);
}

View File

@@ -117,6 +117,11 @@ static int wdt_sam0_install_timeout(struct device *dev,
return -ENOTSUP;
}
if (cfg->window.max == 0) {
LOG_ERR("Upper limit timeout out of range");
return -EINVAL;
}
per = wdt_sam0_timeout_to_wdt_period(cfg->window.max);
if (per > WDT_CONFIG_PER_16K_Val) {
LOG_ERR("Upper limit timeout out of range");

View File

@@ -245,7 +245,7 @@
compatible = "snps,designware-spi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x80010100 0x100>;
reg = <0x80010200 0x100>;
interrupts = <78 2>, <79 2>, <80 2>;
interrupt-names = "err-int", "rx-avail", "tx-req";
interrupt-parent = <&intc>;

View File

@@ -65,7 +65,6 @@
sercom0: sercom@42000800 {
compatible = "atmel,sam0-sercom";
reg = <0x42000800 0x40>;
interrupts = <9 0>;
status = "disabled";
label = "SERCOM0";
};
@@ -73,7 +72,6 @@
sercom1: sercom@42000c00 {
compatible = "atmel,sam0-sercom";
reg = <0x42000c00 0x40>;
interrupts = <10 0>;
status = "disabled";
label = "SERCOM1";
};
@@ -81,7 +79,6 @@
sercom2: sercom@42001000 {
compatible = "atmel,sam0-sercom";
reg = <0x42001000 0x40>;
interrupts = <11 0>;
status = "disabled";
label = "SERCOM2";
};
@@ -89,7 +86,6 @@
sercom3: sercom@42001400 {
compatible = "atmel,sam0-sercom";
reg = <0x42001400 0x40>;
interrupts = <12 0>;
status = "disabled";
label = "SERCOM3";
};
@@ -97,7 +93,6 @@
sercom4: sercom@42001800 {
compatible = "atmel,sam0-sercom";
reg = <0x42001800 0x40>;
interrupts = <13 0>;
status = "disabled";
label = "SERCOM4";
};
@@ -105,7 +100,6 @@
sercom5: sercom@42001c00 {
compatible = "atmel,sam0-sercom";
reg = <0x42001c00 0x40>;
interrupts = <14 0>;
status = "disabled";
label = "SERCOM5";
};
@@ -126,15 +120,6 @@
#gpio-cells = <2>;
};
usb0: usb@41005000 {
compatible = "atmel,sam0-usb";
status = "disabled";
reg = <0x41005000 0x1000>;
interrupts = <7 0>;
num-bidir-endpoints = <8>;
label = "USB0";
};
rtc: rtc@40001400 {
compatible = "atmel,sam0-rtc";
reg = <0x40001400 0x1C>;

View File

@@ -5,3 +5,27 @@
*/
#include <atmel/samd.dtsi>
&sercom0 {
interrupts = <7 0>;
};
&sercom1 {
interrupts = <8 0>;
};
&sercom2 {
interrupts = <9 0>;
};
&sercom3 {
interrupts = <10 0>;
};
&sercom4 {
interrupts = <11 0>;
};
&sercom5 {
interrupts = <12 0>;
};

View File

@@ -5,3 +5,40 @@
*/
#include <atmel/samd.dtsi>
/ {
soc {
usb0: usb@41005000 {
compatible = "atmel,sam0-usb";
status = "disabled";
reg = <0x41005000 0x1000>;
interrupts = <7 0>;
num-bidir-endpoints = <8>;
label = "USB0";
};
};
};
&sercom0 {
interrupts = <9 0>;
};
&sercom1 {
interrupts = <10 0>;
};
&sercom2 {
interrupts = <11 0>;
};
&sercom3 {
interrupts = <12 0>;
};
&sercom4 {
interrupts = <13 0>;
};
&sercom5 {
interrupts = <14 0>;
};

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019, Linaro
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <nxp/nxp_rt.dtsi>
/* i.MX rt1020 default FlexRAM partition:
* ITCM: 64KB
* DTCM: 64KB
* OCRAM: 128KB
*/
&itcm0 {
reg = <0x00000000 0x10000>;
};
&dtcm0 {
reg = <0x20000000 0x10000>;
};
&ocram0 {
reg = <0x20200000 0x20000>;
};

View File

@@ -31,6 +31,12 @@ properties:
description: Human readable string describing the device (used by Zephyr for API name)
generation: define
clocks:
type: array
category: optional
description: Clock gate control information
generation: define
"#cells":
- pin
- flags

View File

@@ -53,4 +53,11 @@ properties:
category: optional
generation: define
description: PHY provider specifier
enable-pin-remap:
type: boolean
category: optional
description: For STM32F0 series SoCs on QFN28 and TSSOP20 packages
enable PIN pair PA11/12 mapped instead of PA9/10 (e.g. stm32f070x6)
generation: define, use-prop-name
...

View File

@@ -171,6 +171,7 @@
interrupts = <4>;
reg = <0x10023000 0x1000>;
reg-names = "control";
label = "uart_1";
status = "disabled";
};
spi0: spi@10014000 {

View File

@@ -146,7 +146,7 @@ static uint32_t CSI_TransferGetQueueDelta(uint32_t startIdx, uint32_t endIdx)
}
else
{
return startIdx + CSI_DRIVER_ACTUAL_QUEUE_SIZE - endIdx;
return endIdx + CSI_DRIVER_ACTUAL_QUEUE_SIZE - startIdx;
}
}

View File

@@ -51,6 +51,7 @@
#endif
#else
#define MPU_MIN_SIZE_ALIGN
#define MPU_ALIGN(region_size) . = ALIGN(4)
#endif
#if defined(CONFIG_XIP)
@@ -128,7 +129,7 @@ SECTIONS {
} GROUP_LINK_IN(ROMABLE_REGION)
_image_rodata_end = .;
MPU_MIN_SIZE_ALIGN
MPU_ALIGN(_image_rodata_end - _image_rom_start);
_image_rom_end = .;
_image_rom_size = _image_rom_end - _image_rom_start;

View File

@@ -118,6 +118,12 @@
#define REGION_USER_RO_ATTR {(MPU_REGION_READ | \
MPU_REGION_SU)}
/* ENET device (Master 3) will not be able to access RAM when
ram region is dynamically disabled in NXP MPU.
DEBUGGER (Master 1) can't be disabled in Region 0. */
#define REGION_DEBUGGER_AND_DEVICE_ATTR {((MPU_REGION_SU) | \
((UM_READ | UM_WRITE) << BM3_UM_SHIFT))}
#define REGION_DEBUG_ATTR {MPU_REGION_SU}
#define REGION_BACKGROUND_ATTR {MPU_REGION_SU_RW}

View File

@@ -40,7 +40,12 @@
#define SKIP_TO_KINETIS_FLASH_CONFIG
#endif
#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0)
#define ROM_ADDR RAM_ADDR
#else
#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
#endif
#ifdef CONFIG_TI_CCFG_PRESENT
#define CCFG_SIZE 88
#define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET - \
@@ -183,6 +188,10 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME_2,,)
{
_image_text_start = .;
#include <linker/priv_stacks-text.ld>
#include <linker/kobject-text.ld>
*(.text)
*(".text.*")
*(.gnu.linkonce.t.*)
@@ -193,9 +202,6 @@ SECTIONS
*/
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
#include <linker/priv_stacks-text.ld>
#include <linker/kobject-text.ld>
} GROUP_LINK_IN(ROMABLE_REGION)
_image_text_end = .;
@@ -277,6 +283,7 @@ SECTIONS
#endif /* CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS */
_image_rodata_end = .;
MPU_ALIGN(_image_rodata_end -_image_rom_start);
_image_rom_end = .;
GROUP_END(ROMABLE_REGION)
@@ -409,6 +416,10 @@ SECTIONS
*(COMMON)
*(".kernel_bss.*")
#ifdef CONFIG_CODE_DATA_RELOCATION
#include <linker_sram_bss_relocate.ld>
#endif
/*
* As memory is cleared in words only, it is simpler to ensure the BSS
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
@@ -446,6 +457,10 @@ SECTIONS
#ifdef CONFIG_CUSTOM_RWDATA_LD
/* Located in project source directory */
#include <custom-rwdata.ld>
#endif
#ifdef CONFIG_CODE_DATA_RELOCATION
#include <linker_sram_data_relocate.ld>
#endif
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

View File

@@ -64,6 +64,19 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout);
*/
struct net_buf *bt_buf_get_cmd_complete(s32_t timeout);
/** Allocate a buffer for an HCI Event
*
* This will set the buffer type so bt_buf_set_type() does not need to
* be explicitly called before bt_recv_prio() or bt_recv().
*
* @param evt HCI event code
* @param discardable Whether the driver considers the event discardable.
* @param timeout Timeout in milliseconds, or one of the special values
* K_NO_WAIT and K_FOREVER.
* @return A new buffer.
*/
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, s32_t timeout);
/** Set the buffer type
*
* @param buf Bluetooth buffer

View File

@@ -971,9 +971,14 @@ typedef u8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, u8_t err,
* @param handle_count If equals to 1 single.handle and single.offset
* are used. If >1 Read Multiple Characteristic
* Values is performed and handles are used.
* If equals to 0 by_uuid is used for Read Using
* Characteristic UUID.
* @param handle Attribute handle
* @param offset Attribute data offset
* @param handles Handles to read in Read Multiple Characteristic Values
* @param start_handle First requested handle number
* @param end_handle Last requested handle number
* @param uuid 2 or 16 octet UUID
*/
struct bt_gatt_read_params {
struct bt_att_req _req;
@@ -985,6 +990,11 @@ struct bt_gatt_read_params {
u16_t offset;
} single;
u16_t *handles;
struct {
u16_t start_handle;
u16_t end_handle;
struct bt_uuid *uuid;
} by_uuid;
};
};
@@ -992,6 +1002,14 @@ struct bt_gatt_read_params {
*
* This procedure read the attribute value and return it to the callback.
*
* When reading attributes by UUID the callback can be called multiple times
* depending on how many instances of given the UUID exists with the
* start_handle being updated for each instance.
*
* If an instance does contain a long value which cannot be read entirely the
* caller will need to read the remaining data separately using the handle and
* offset.
*
* Note: This procedure is asynchronous therefore the parameters need to
* remains valid while it is active.
*
@@ -1114,7 +1132,16 @@ enum {
* when the client reconnects, it will have to
* issue a new subscription.
*/
BT_GATT_SUBSCRIBE_FLAG_VOLATILE = BIT(0),
BT_GATT_SUBSCRIBE_FLAG_VOLATILE,
/** Write pending flag
*
* If set, indicates write operation is pending waiting remote end to
* respond.
*/
BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING,
BT_GATT_SUBSCRIBE_NUM_FLAGS
};
/** @brief GATT Subscribe parameters */
@@ -1130,7 +1157,8 @@ struct bt_gatt_subscribe_params {
/** Subscribe value */
u16_t value;
/** Subscription flags */
u8_t flags;
ATOMIC_DEFINE(flags, BT_GATT_SUBSCRIBE_NUM_FLAGS);
sys_snode_t node;
};

View File

@@ -1355,6 +1355,7 @@ struct bt_hci_cp_le_set_privacy_mode {
/* Event definitions */
#define BT_HCI_EVT_UNKNOWN 0x00
#define BT_HCI_EVT_VENDOR 0xff
#define BT_HCI_EVT_INQUIRY_COMPLETE 0x01

View File

@@ -66,6 +66,7 @@ typedef enum bt_l2cap_chan_state {
BT_L2CAP_CONNECTED,
/** Channel in disconnecting state */
BT_L2CAP_DISCONNECT,
} __packed bt_l2cap_chan_state_t;
/** @brief L2CAP Channel structure. */

View File

@@ -269,7 +269,8 @@ static inline int z_impl_can_send(struct device *dev,
const struct zcan_frame *msg,
s32_t timeout, can_tx_callback_t callback_isr)
{
const struct can_driver_api *api = dev->driver_api;
const struct can_driver_api *api =
(const struct can_driver_api *)dev->driver_api;
return api->send(dev, msg, timeout, callback_isr);
}
@@ -344,7 +345,8 @@ static inline int z_impl_can_attach_msgq(struct device *dev,
struct k_msgq *msg_q,
const struct zcan_filter *filter)
{
const struct can_driver_api *api = dev->driver_api;
const struct can_driver_api *api =
(const struct can_driver_api *)dev->driver_api;
return api->attach_msgq(dev, msg_q, filter);
}
@@ -371,7 +373,8 @@ static inline int can_attach_isr(struct device *dev,
can_rx_callback_t isr,
const struct zcan_filter *filter)
{
const struct can_driver_api *api = dev->driver_api;
const struct can_driver_api *api =
(const struct can_driver_api *)dev->driver_api;
return api->attach_isr(dev, isr, filter);
}
@@ -391,7 +394,8 @@ __syscall void can_detach(struct device *dev, int filter_id);
static inline void z_impl_can_detach(struct device *dev, int filter_id)
{
const struct can_driver_api *api = dev->driver_api;
const struct can_driver_api *api =
(const struct can_driver_api *)dev->driver_api;
return api->detach(dev, filter_id);
}
@@ -412,7 +416,8 @@ __syscall int can_configure(struct device *dev, enum can_mode mode,
static inline int z_impl_can_configure(struct device *dev, enum can_mode mode,
u32_t bitrate)
{
const struct can_driver_api *api = dev->driver_api;
const struct can_driver_api *api =
(const struct can_driver_api *)dev->driver_api;
return api->configure(dev, mode, bitrate);
}

View File

@@ -51,7 +51,8 @@ struct clock_control_driver_api {
static inline int clock_control_on(struct device *dev,
clock_control_subsys_t sys)
{
const struct clock_control_driver_api *api = dev->driver_api;
const struct clock_control_driver_api *api =
(const struct clock_control_driver_api *)dev->driver_api;
return api->on(dev, sys);
}
@@ -65,7 +66,8 @@ static inline int clock_control_on(struct device *dev,
static inline int clock_control_off(struct device *dev,
clock_control_subsys_t sys)
{
const struct clock_control_driver_api *api = dev->driver_api;
const struct clock_control_driver_api *api =
(const struct clock_control_driver_api *)dev->driver_api;
return api->off(dev, sys);
}
@@ -81,7 +83,8 @@ static inline int clock_control_get_rate(struct device *dev,
clock_control_subsys_t sys,
u32_t *rate)
{
const struct clock_control_driver_api *api = dev->driver_api;
const struct clock_control_driver_api *api =
(const struct clock_control_driver_api *)dev->driver_api;
__ASSERT(api->get_rate != NULL, "%s not implemented for device %s",
__func__, dev->config->name);

View File

@@ -10,15 +10,16 @@
#if defined(CONFIG_USB) && defined(CONFIG_SOC_NRF52840)
#include <device.h>
#endif
#include <nrf_clock.h>
/* TODO: move all these to clock_control.h ? */
/* Define 32KHz clock source */
#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC
#define CLOCK_CONTROL_NRF_K32SRC 0
#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_RC
#endif
#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL
#define CLOCK_CONTROL_NRF_K32SRC 1
#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_Xtal
#endif
/* Define 32KHz clock accuracy */

View File

@@ -20,13 +20,13 @@
* @{
*/
#include <zephyr/types.h>
#include <device.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
#include <device.h>
/**
* @typedef entropy_get_entropy_t
* @brief Callback API to get entropy.
@@ -69,7 +69,8 @@ static inline int z_impl_entropy_get_entropy(struct device *dev,
u8_t *buffer,
u16_t length)
{
const struct entropy_driver_api *api = dev->driver_api;
const struct entropy_driver_api *api =
(const struct entropy_driver_api *)dev->driver_api;
__ASSERT(api->get_entropy != NULL,
"Callback pointer should not be NULL");
@@ -94,7 +95,8 @@ static inline int entropy_get_entropy_isr(struct device *dev,
u16_t length,
u32_t flags)
{
const struct entropy_driver_api *api = dev->driver_api;
const struct entropy_driver_api *api =
(const struct entropy_driver_api *)dev->driver_api;
if (unlikely(!api->get_entropy_isr)) {
return -ENOTSUP;

View File

@@ -21,50 +21,106 @@ extern "C" {
#include <kernel.h>
#define FCB_MAX_LEN (CHAR_MAX | CHAR_MAX << 7) /* Max length of element */
/**
* @defgroup fcb Flash Circular Buffer (FCB)
* @ingroup file_system_storage
* @{
* @}
*/
/*
/**
* @defgroup fcb_data_structures Flash Circular Buffer Data Structures
* @ingroup fcb
* @{
*/
#define FCB_MAX_LEN (CHAR_MAX | CHAR_MAX << 7) /**< Max length of element */
/**
* @brief FCB entry info structure. This data structure describes the element
* location in the flash.
*
* You would use it to figure out what parameters to pass to flash_area_read()
* to read element contents. Or to flash_area_write() when adding a new element.
* Entry location is pointer to area (within fcb->f_sectors), and offset
* within that area.
*/
struct fcb_entry {
struct flash_sector *fe_sector; /* ptr to sector */
/* within fcb->f_sectors */
u32_t fe_elem_off; /* start of entry */
u32_t fe_data_off; /* start of data */
u16_t fe_data_len; /* size of data area */
struct flash_sector *fe_sector;
/**< Pointer to info about sector where data are placed */
u32_t fe_elem_off;
/**< Offset from the start of the sector to beginning of element. */
u32_t fe_data_off;
/**< Offset from the start of the sector to the start of element. */
u16_t fe_data_len; /**< Size of data area in fcb entry*/
};
/*
* Helper macro for calculate the data offset related to
/**
* @brief Helper macro for calculating the data offset related to
* the fcb flash_area start offset.
*
* @param entry fcb entry structure
*/
#define FCB_ENTRY_FA_DATA_OFF(entry) (entry.fe_sector->fs_off +\
entry.fe_data_off)
/**
* @brief Structure for transferring complete information about FCB entry
* location within flash memory.
*/
struct fcb_entry_ctx {
struct fcb_entry loc;
struct fcb_entry loc; /**< FCB entry info */
const struct flash_area *fap;
/**< Flash area where the entry is placed */
};
/**
* @brief FCB instance structure
*
* The following data structure describes the FCB itself. First part should
* be filled in by the user before calling @ref fcb_init. The second part is
* used by FCB for its internal bookkeeping.
*/
struct fcb {
/* Caller of fcb_init fills this in */
u32_t f_magic; /* As placed on the disk */
u8_t f_version; /* Current version number of the data */
u8_t f_sector_cnt; /* Number of elements in sector array */
u8_t f_scratch_cnt; /* How many sectors should be kept empty */
struct flash_sector *f_sectors; /* Array of sectors, */
/* must be contiguous */
u32_t f_magic;
/**< Magic value. It is placed in the beginning of FCB flash sector.
* FCB uses this when determining whether sector contains valid data
* or not.
*/
u8_t f_version; /**< Current version number of the data */
u8_t f_sector_cnt; /**< Number of elements in sector array */
u8_t f_scratch_cnt;
/**< Number of sectors to keep empty. This can be used if you need
* to have scratch space for garbage collecting when FCB fills up.
*/
struct flash_sector *f_sectors;
/**< Array of sectors, must be contiguous */
/* Flash circular buffer internal state */
struct k_mutex f_mtx; /* Locking for accessing the FCB data */
struct flash_sector *f_oldest;
struct fcb_entry f_active;
u16_t f_active_id;
u8_t f_align; /* writes to flash have to aligned to this */
struct k_mutex f_mtx;
/**< Locking for accessing the FCB data, internal state */
const struct flash_area *fap; /* Flash area used by the fcb instance */
/* This can be transfer to FCB user */
struct flash_sector *f_oldest;
/**< Pointer to flash sector containing the oldest data,
* internal state
*/
struct fcb_entry f_active; /**< internal state */
u16_t f_active_id;
/**< Flash location where the newest data is, internal state */
u8_t f_align;
/**< writes to flash have to aligned to this, internal state */
const struct flash_area *fap;
/**< Flash area used by the fcb instance, , internal state.
* This can be transfer to FCB user
*/
};
/*
@@ -79,66 +135,211 @@ struct fcb {
#define FCB_ERR_CRC -6
#define FCB_ERR_MAGIC -7
/**
* @}
*/
/**
* @brief Flash Circular Buffer APIs
* @defgroup fcb_api fcb API
* @ingroup fcb
* @{
*/
/**
* Initialize FCB instance.
*
* @param[in] f_area_id ID of flash area where fcb storage resides.
* @param[in,out] fcb FCB instance structure.
*
* @return 0 on success, non-zero on failure.
*/
int fcb_init(int f_area_id, struct fcb *fcb);
/*
* fcb_append() appends an entry to circular buffer. When writing the
* contents for the entry, use loc->fl_area and loc->fl_data_off with
* flash_area_write(). When you're finished, call fcb_append_finish() with
* loc as argument.
/**
* Appends an entry to circular buffer.
*
* When writing the
* contents for the entry, use loc->fl_sector and loc->fl_data_off with
* flash_area_write() to fcb flash_area.
* When you're finished, call fcb_append_finish() with loc as argument.
*
* @param[in] fcb FCB instance structure.
* @param[in] len Length of data which are expected to be written as the entry
* payload.
* @param[out] loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *loc);
/**
* Finishes entry append operation.
*
* @param[in] fcb FCB instance structure.
* @param[in] append_loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append_finish(struct fcb *fcb, struct fcb_entry *append_loc);
/*
* Walk over all log entries in FCB, or entries in a given flash_area.
* cb gets called for every entry. If cb wants to stop the walk, it should
* return non-zero value.
/**
* FCB Walk callback function type.
*
* Type of function which is expected to be called while walking over fcb
* entries thanks to a @ref fcb_walk call.
*
* Entry data can be read using flash_area_read(), using
* loc->fe_area, loc->fe_data_off, and loc->fe_data_len as arguments.
* loc_ctx fields as arguments.
* If cb wants to stop the walk, it should return non-zero value.
*
* @param[in] loc_ctx entry location information (full context)
* @param[in,out] arg callback context, transferred from @ref fcb_walk.
*
* @return 0 continue walking, non-zero stop walking.
*/
typedef int (*fcb_walk_cb)(struct fcb_entry_ctx *loc_ctx, void *arg);
/**
* Walk over all entries in the FCB sector
*
* @param[in] sector fcb sector to be wallked. If null, traverse entire
* storage.
* @param[in] fcb FCB instance structure.
* @param[in] cb pointer to the function which gets called for every
* entry. If cb wants to stop the walk, it should return
* non-zero value.
* @param[in,out] cb_arg callback context, transferred to the callback
* implementation.
*
* @return 0 on success, negative on failure (or transferred form callback
* return-value), positive transferred form callback return-value
*/
int fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb,
void *cb_arg);
/**
* Get next fcb entry location.
*
* Function to obtain fcb entry location in relation to entry pointed by
* <p> loc.
* If loc->fe_sector is set and loc->fe_elem_off is not 0 function fetches next
* fcb entry location.
* If loc->fe_sector is NULL function fetches the oldest entry location within
* FCB storage. loc->fe_sector is set and loc->fe_elem_off is 0 function fetches
* the first entry location in the fcb sector.
*
* @param[in] fcb FCB instance structure.
* @param[in,out] loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_getnext(struct fcb *fcb, struct fcb_entry *loc);
/*
* Erases the data from oldest sector.
* Rotate fcb sectors
*
* Function erases the data from oldest sector. Upon that the next sector
* becomes the oldest. Active sector is also switched if needed.
*
* @param[in] fcb FCB instance structure.
*/
int fcb_rotate(struct fcb *fcb);
/*
* Start using the scratch block.
*
* Take one of the scratch blocks into use. So a scratch sector becomes
* active sector to which entries can be appended.
*
* @param[in] fcb FCB instance structure.
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append_to_scratch(struct fcb *fcb);
/*
* How many sectors are unused.
/**
* Get free sector count.
*
* @param[in] fcb FCB instance structure.
*
* @return Number of free sectors.
*/
int fcb_free_sector_cnt(struct fcb *fcb);
/*
* Whether FCB has any data.
/**
* Check whether FCB has any data.
*
* @param[in] fcb FCB instance structure.
*
* @return Positive value if fcb is empty, otherwise 0.
*/
int fcb_is_empty(struct fcb *fcb);
/*
* Element at offset *entries* from last position (backwards).
/**
* Finds the fcb entry that gives back up to n entries at the end.
*
* @param[in] fcb FCB instance structure.
* @param[in] entries number of fcb entries the user wants to get
* @param[out] last_n_entry last_n_entry the fcb_entry to be returned
*
* @return 0 on there are any fcbs available; -ENOENT otherwise
*/
int fcb_offset_last_n(struct fcb *fcb, u8_t entries,
struct fcb_entry *last_n_entry);
/*
* Clears FCB passed to it
/**
* Clear fcb instance storage.
*
* @param[in] fcb FCB instance structure.
*
* @return 0 on success; non-zero on failure
*/
int fcb_clear(struct fcb *fcb);
/**
* @}
*/
/**
* @brief Flash Circular internall
* @defgroup fcb_internall fcb non-API prototypes
* @ingroup fcb
* @{
*/
/**
* Read raw data from the fcb flash sector.
*
* @param[in] fcb FCB instance structure.
* @param[in] sector FCB sector.
* @param[in] off Read offset form sector begin.
* @param[out] dst Destination buffer.
* @param[in] len Read-out size.
*
* @return 0 on success, negative errno code on fail.
*/
int fcb_flash_read(const struct fcb *fcb, const struct flash_sector *sector,
off_t off, void *dst, size_t len);
/**
* Write raw data to the fcb flash sector.
*
* @param[in] fcb FCB instance structure.
* @param[in] sector FCB sector.
* @param[in] off Write offset form sector begin.
* @param[out] src Source buffer.
* @param[in] len Read-out size.
*
* @return 0 on success, negative errno code on fail.
*/
int fcb_flash_write(const struct fcb *fcb, const struct flash_sector *sector,
off_t off, const void *src, size_t len);
/**
* @}
*/
#ifdef __cplusplus
}
#endif

View File

@@ -207,7 +207,7 @@ struct _k_object_assignment {
*/
void z_object_init(void *obj);
#else
/* LCOV_EXCL_START */
#define K_THREAD_ACCESS_GRANT(thread, ...)
/**
@@ -250,6 +250,7 @@ static inline void k_object_access_all_grant(void *object)
{
ARG_UNUSED(object);
}
/* LCOV_EXCL_STOP */
#endif /* !CONFIG_USERSPACE */
/**
@@ -326,6 +327,7 @@ __syscall void *k_object_alloc(enum k_objects otype);
*/
void k_object_free(void *obj);
#else
/* LCOV_EXCL_START */
static inline void *z_impl_k_object_alloc(enum k_objects otype)
{
ARG_UNUSED(otype);
@@ -337,6 +339,7 @@ static inline void k_obj_free(void *obj)
{
ARG_UNUSED(obj);
}
/* LCOV_EXCL_STOP */
#endif /* CONFIG_DYNAMIC_OBJECTS */
/** @} */
@@ -537,7 +540,7 @@ struct k_thread {
#if defined(CONFIG_THREAD_NAME)
/* Thread name */
const char *name;
char name[CONFIG_THREAD_MAX_NAME_LEN];
#endif
#ifdef CONFIG_THREAD_CUSTOM_DATA
@@ -1260,8 +1263,14 @@ __syscall void *k_thread_custom_data_get(void);
* Set the name of the thread to be used when THREAD_MONITOR is enabled for
* tracing and debugging.
*
* @param thread_id Thread to set name, or NULL to set the current thread
* @param value Name string
* @retval 0 on success
* @retval -EFAULT Memory access error with supplied string
* @retval -ENOSYS Thread name configuration option not enabled
* @retval -EINVAL Thread name too long
*/
__syscall void k_thread_name_set(k_tid_t thread_id, const char *value);
__syscall int k_thread_name_set(k_tid_t thread_id, const char *value);
/**
* @brief Get thread name
@@ -1269,9 +1278,23 @@ __syscall void k_thread_name_set(k_tid_t thread_id, const char *value);
* Get the name of a thread
*
* @param thread_id Thread ID
*
* @retval Thread name, or NULL if configuration not enabled
*/
__syscall const char *k_thread_name_get(k_tid_t thread_id);
const char *k_thread_name_get(k_tid_t thread_id);
/**
* @brief Copy the thread name into a supplied buffer
*
* @param thread_id Thread to obtain name information
* @param buf Destination buffer
* @param size Destinatiomn buffer size
* @retval -ENOSPC Destination buffer too small
* @retval -EFAULT Memory access error
* @retval -ENOSYS Thread name feature not enabled
* @retval 0 Success
*/
__syscall int k_thread_name_copy(k_tid_t thread_id, char *buf,
size_t size);
/**
* @}
@@ -4010,13 +4033,13 @@ struct k_mem_pool {
* @req K-MPOOL-001
*/
#define K_MEM_POOL_DEFINE(name, minsz, maxsz, nmax, align) \
char __aligned(align) _mpool_buf_##name[_ALIGN4(maxsz * nmax) \
char __aligned(align) _mpool_buf_##name[_ALIGN4(maxsz) * nmax \
+ _MPOOL_BITS_SIZE(maxsz, minsz, nmax)]; \
struct sys_mem_pool_lvl _mpool_lvls_##name[Z_MPOOL_LVLS(maxsz, minsz)]; \
struct k_mem_pool name __in_section(_k_mem_pool, static, name) = { \
.base = { \
.buf = _mpool_buf_##name, \
.max_sz = maxsz, \
.max_sz = _ALIGN4(maxsz), \
.n_max = nmax, \
.n_levels = Z_MPOOL_LVLS(maxsz, minsz), \
.levels = _mpool_lvls_##name, \

View File

@@ -276,6 +276,10 @@ int log_printk(const char *fmt, va_list ap);
*/
char *log_strdup(const char *str);
#ifdef __cplusplus
}
#define LOG_IN_CPLUSPLUS 1
#endif
/* Macro expects that optionally on second argument local log level is provided.
* If provided it is returned, otherwise default log level is returned or
* LOG_LEVEL, if it was locally defined.
@@ -292,8 +296,8 @@ char *log_strdup(const char *str);
/* Return first argument */
#define _LOG_ARG1(arg1, ...) arg1
#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
COND_CODE_1(LOG_IN_CPLUSPLUS, (extern), ()) \
const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
__attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
__attribute__((used)) = { \
@@ -309,8 +313,8 @@ char *log_strdup(const char *str);
__attribute__((used))
#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
Z_LOG_EVAL( \
IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING), \
COND_CODE_1( \
CONFIG_LOG_RUNTIME_FILTERING, \
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);), \
() \
)
@@ -351,7 +355,6 @@ char *log_strdup(const char *str);
* @see LOG_MODULE_DECLARE
*/
#define LOG_MODULE_REGISTER(...) \
Z_LOG_EVAL( \
_LOG_LEVEL_RESOLVE(__VA_ARGS__), \
@@ -422,9 +425,4 @@ char *log_strdup(const char *str);
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_H_ */

View File

@@ -48,14 +48,14 @@ struct sys_mem_pool_block {
*/
#define SYS_MEM_POOL_DEFINE(name, ignored, minsz, maxsz, nmax, align, section) \
char __aligned(align) Z_GENERIC_SECTION(section) \
_mpool_buf_##name[_ALIGN4(maxsz * nmax) \
_mpool_buf_##name[_ALIGN4(maxsz) * nmax \
+ _MPOOL_BITS_SIZE(maxsz, minsz, nmax)]; \
struct sys_mem_pool_lvl Z_GENERIC_SECTION(section) \
_mpool_lvls_##name[Z_MPOOL_LVLS(maxsz, minsz)]; \
Z_GENERIC_SECTION(section) struct sys_mem_pool name = { \
.base = { \
.buf = _mpool_buf_##name, \
.max_sz = maxsz, \
.max_sz = _ALIGN4(maxsz), \
.n_max = nmax, \
.n_levels = Z_MPOOL_LVLS(maxsz, minsz), \
.levels = _mpool_lvls_##name, \

View File

@@ -159,8 +159,9 @@ struct _rb_foreach {
}
#else
#define _RB_FOREACH_INIT(tree, node) { \
.stack = alloca((tree)->max_depth * sizeof(struct rbnode *)), \
.is_left = alloca((tree)->max_depth * sizeof(char)), \
.stack = (struct rbnode **) \
alloca((tree)->max_depth * sizeof(struct rbnode *)), \
.is_left = (char *)alloca((tree)->max_depth * sizeof(char)), \
.top = -1 \
}
#endif

View File

@@ -481,10 +481,10 @@ static inline
enum ethernet_hw_caps net_eth_get_hw_capabilities(struct net_if *iface)
{
const struct ethernet_api *eth =
net_if_get_device(iface)->driver_api;
(struct ethernet_api *)net_if_get_device(iface)->driver_api;
if (!eth->get_capabilities) {
return 0;
return (enum ethernet_hw_caps)0;
}
return eth->get_capabilities(net_if_get_device(iface));

View File

@@ -1285,15 +1285,17 @@ void net_if_ipv6_dad_failed(struct net_if *iface, const struct in6_addr *addr);
/**
* @brief Return global IPv6 address from the first interface that has
* a global IPv6 address either in TENTATIVE or PREFERRED state.
* a global IPv6 address matching the given state.
*
* @param state IPv6 address state (ANY, TENTATIVE, PREFERRED, DEPRECATED)
* @param iface Caller can give an interface to check. If iface is set to NULL,
* then all the interfaces are checked. Pointer to interface where the IPv6
* address is defined is returned to the caller.
*
* @return Pointer to IPv6 address, NULL if not found.
*/
struct in6_addr *net_if_ipv6_get_global_addr(struct net_if **iface);
struct in6_addr *net_if_ipv6_get_global_addr(enum net_addr_state state,
struct net_if **iface);
/**
* @brief Allocate network interface IPv4 config.
@@ -1493,6 +1495,18 @@ const struct in_addr *net_if_ipv4_select_src_addr(struct net_if *iface,
struct in_addr *net_if_ipv4_get_ll(struct net_if *iface,
enum net_addr_state addr_state);
/**
* @brief Get a IPv4 global address in a given state.
*
* @param iface Interface to use. Must be a valid pointer to an interface.
* @param addr_state IPv4 address state (preferred, tentative, deprecated)
*
* @return Pointer to link local IPv4 address, NULL if no proper IPv4 address
* could be found.
*/
struct in_addr *net_if_ipv4_get_global_addr(struct net_if *iface,
enum net_addr_state addr_state);
/**
* @brief Set IPv4 netmask for an interface.
*

View File

@@ -140,6 +140,7 @@ struct net_mgmt_event_callback {
#ifdef CONFIG_NET_MGMT_EVENT_INFO
const void *info;
size_t info_length;
#endif
/** A mask of network events on which the above handler should be
@@ -242,6 +243,8 @@ static inline void net_mgmt_event_notify(u32_t mgmt_event, struct net_if *iface)
* the caller wants to listen to.
* @param info a valid pointer if user wants to get the information the
* event might bring along. NULL otherwise.
* @param info_length tells how long the info memory area is. Only valid if
* the info is not NULL.
* @param timeout a delay in milliseconds. K_FOREVER can be used to wait
* indefinitely.
*
@@ -254,12 +257,14 @@ int net_mgmt_event_wait(u32_t mgmt_event_mask,
u32_t *raised_event,
struct net_if **iface,
const void **info,
size_t *info_length,
int timeout);
#else
static inline int net_mgmt_event_wait(u32_t mgmt_event_mask,
u32_t *raised_event,
struct net_if **iface,
const void **info,
size_t *info_length,
int timeout)
{
return 0;
@@ -277,6 +282,8 @@ static inline int net_mgmt_event_wait(u32_t mgmt_event_mask,
* interested in that information.
* @param info a valid pointer if user wants to get the information the
* event might bring along. NULL otherwise.
* @param info_length tells how long the info memory area is. Only valid if
* the info is not NULL.
* @param timeout a delay in milliseconds. K_FOREVER can be used to wait
* indefinitely.
*
@@ -289,12 +296,14 @@ int net_mgmt_event_wait_on_iface(struct net_if *iface,
u32_t mgmt_event_mask,
u32_t *raised_event,
const void **info,
size_t *info_length,
int timeout);
#else
static inline int net_mgmt_event_wait_on_iface(struct net_if *iface,
u32_t mgmt_event_mask,
u32_t *raised_event,
const void **info,
size_t *info_length,
int timeout)
{
return 0;

View File

@@ -60,7 +60,7 @@ static inline int net_promisc_mode_on(struct net_if *iface)
{
ARG_UNUSED(iface);
return -ENOSUP;
return -ENOTSUP;
}
#endif /* CONFIG_NET_PROMISCUOUS_MODE */
@@ -78,7 +78,7 @@ static inline int net_promisc_mode_off(struct net_if *iface)
{
ARG_UNUSED(iface);
return -ENOSUP;
return -ENOTSUP;
}
#endif /* CONFIG_NET_PROMISCUOUS_MODE */

View File

@@ -75,21 +75,24 @@ struct pinmux_driver_api {
static inline int pinmux_pin_set(struct device *dev, u32_t pin, u32_t func)
{
const struct pinmux_driver_api *api = dev->driver_api;
const struct pinmux_driver_api *api =
(const struct pinmux_driver_api *)dev->driver_api;
return api->set(dev, pin, func);
}
static inline int pinmux_pin_get(struct device *dev, u32_t pin, u32_t *func)
{
const struct pinmux_driver_api *api = dev->driver_api;
const struct pinmux_driver_api *api =
(const struct pinmux_driver_api *)dev->driver_api;
return api->get(dev, pin, func);
}
static inline int pinmux_pin_pullup(struct device *dev, u32_t pin, u8_t func)
{
const struct pinmux_driver_api *api = dev->driver_api;
const struct pinmux_driver_api *api =
(const struct pinmux_driver_api *)dev->driver_api;
return api->pullup(dev, pin, func);
}
@@ -97,7 +100,8 @@ static inline int pinmux_pin_pullup(struct device *dev, u32_t pin, u8_t func)
static inline int pinmux_pin_input_enable(struct device *dev, u32_t pin,
u8_t func)
{
const struct pinmux_driver_api *api = dev->driver_api;
const struct pinmux_driver_api *api =
(const struct pinmux_driver_api *)dev->driver_api;
return api->input(dev, pin, func);
}

View File

@@ -160,8 +160,7 @@ static inline int pthread_condattr_destroy(pthread_condattr_t *att)
* @param name Symbol name of the mutex
*/
#define PTHREAD_MUTEX_DEFINE(name) \
struct pthread_mutex name \
__in_section(_k_mutex, static, name) = \
struct pthread_mutex name = \
{ \
.lock_count = 0, \
.wait_q = Z_WAIT_Q_INIT(&name.wait_q), \

View File

@@ -148,7 +148,7 @@ static inline void ring_buf_init(struct ring_buf *buf, u32_t size, void *data)
{
memset(buf, 0, sizeof(struct ring_buf));
buf->size = size;
buf->buf.buf32 = data;
buf->buf.buf32 = (u32_t *)data;
if (is_power_of_two(size)) {
buf->mask = size - 1;
} else {

View File

@@ -57,9 +57,6 @@ struct wdt_config {
u32_t timeout;
void (*interrupt_fn)(struct device *dev);
};
/**
* @}
*/
/**

View File

@@ -148,7 +148,7 @@ config SCHED_CPU_MASK
config MAIN_STACK_SIZE
int "Size of stack for initialization and main thread"
default 2048 if COVERAGE_GCOV
default 512 if ZTEST
default 512 if ZTEST && !RISCV32
default 1024
help
When the initialization is complete, the thread executing it then
@@ -361,11 +361,22 @@ config THREAD_NAME
bool "Thread name [EXPERIMENTAL]"
help
This option allows to set a name for a thread.
config THREAD_MAX_NAME_LEN
int "Max length of a thread name"
default 32
range 8 128
depends on THREAD_NAME
help
Thread names get stored in the k_thread struct. Indicate the max
name length, including the terminating NULL byte. Reduce this value
to conserve memory.
endmenu
menu "Work Queue Options"
config SYSTEM_WORKQUEUE_STACK_SIZE
int "System workqueue stack size"
default 4096 if COVERAGE
default 1024
config SYSTEM_WORKQUEUE_PRIORITY
@@ -380,6 +391,7 @@ config SYSTEM_WORKQUEUE_PRIORITY
config OFFLOAD_WORKQUEUE_STACK_SIZE
int "Workqueue stack size for thread offload requests"
default 4096 if COVERAGE
default 1024
config OFFLOAD_WORKQUEUE_PRIORITY

View File

@@ -26,6 +26,10 @@
*/
unsigned char sys_pm_idle_exit_notify;
/* LCOV_EXCL_START
* These are almost certainly overidden and in any event do nothing
*/
#if defined(CONFIG_SYS_POWER_SLEEP_STATES)
void __attribute__((weak)) _sys_resume(void)
{
@@ -37,6 +41,7 @@ void __attribute__((weak)) _sys_resume_from_deep_sleep(void)
{
}
#endif
/* LCOV_EXCL_STOP */
#endif /* CONFIG_SYS_POWER_MANAGEMENT */

Some files were not shown because too many files have changed in this diff Show More