Compare commits

...

169 Commits

Author SHA1 Message Date
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
220 changed files with 4400 additions and 1057 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

View File

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

View File

@@ -267,7 +267,7 @@ _firq_reschedule:
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, _firq_return_from_rirq
nop
@@ -279,7 +279,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 +298,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,7 @@ _rirq_common_interrupt_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, _rirq_return_from_rirq
nop
@@ -201,7 +201,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 +212,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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -0,0 +1,395 @@
/* ipm_stm32wb.c - HCI driver for stm32wb shared ram */
/*
* Copyright (c) 2019 Linaro Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <sys/util.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_driver.h>
#include "app_conf.h"
#include "stm32_wpan_common.h"
#include "shci.h"
#include "shci_tl.h"
#define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH * 4 * \
DIVC((sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE), 4))
/* Private variables ---------------------------------------------------------*/
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t BleCmdBuffer;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static u8_t EvtPool[POOL_SIZE];
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static TL_CmdPacket_t SystemCmdBuffer;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static u8_t
SystemSpareEvtBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + 255];
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static u8_t
BleSpareEvtBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + 255];
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static u8_t
HciAclDataBuffer[sizeof(TL_PacketHeader_t) + 5 + 251];
static void syscmd_status_not(SHCI_TL_CmdStatus_t status);
static void sysevt_received(void *pdata);
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
#define LOG_MODULE_NAME hci_ipm
#include "common/log.h"
#define HCI_CMD 0x01
#define HCI_ACL 0x02
#define HCI_SCO 0x03
#define HCI_EVT 0x04
static K_SEM_DEFINE(c2_started, 0, 1);
static K_SEM_DEFINE(ble_sys_wait_cmd_rsp, 0, 1);
static K_SEM_DEFINE(acl_data_ack, 1, 1);
static K_SEM_DEFINE(ipm_busy, 1, 1);
struct aci_set_tx_power {
u8_t cmd;
u8_t value[2];
};
#define ACI_WRITE_SET_TX_POWER_LEVEL BT_OP(BT_OGF_VS, 0xFC0F)
static void stm32wb_start_ble(void)
{
SHCI_C2_Ble_Init_Cmd_Packet_t ble_init_cmd_packet = {
{ { 0, 0, 0 } }, /**< Header unused */
{ 0, /** pBleBufferAddress not used */
0, /** BleBufferSize not used */
CFG_BLE_NUM_GATT_ATTRIBUTES,
CFG_BLE_NUM_GATT_SERVICES,
CFG_BLE_ATT_VALUE_ARRAY_SIZE,
CFG_BLE_NUM_LINK,
CFG_BLE_DATA_LENGTH_EXTENSION,
CFG_BLE_PREPARE_WRITE_LIST_SIZE,
CFG_BLE_MBLOCK_COUNT,
CFG_BLE_MAX_ATT_MTU,
CFG_BLE_SLAVE_SCA,
CFG_BLE_MASTER_SCA,
CFG_BLE_LSE_SOURCE,
CFG_BLE_MAX_CONN_EVENT_LENGTH,
CFG_BLE_HSE_STARTUP_TIME,
CFG_BLE_VITERBI_MODE,
CFG_BLE_LL_ONLY,
0 }
};
/**
* Starts the BLE Stack on CPU2
*/
SHCI_C2_BLE_Init(&ble_init_cmd_packet);
}
static void sysevt_received(void *pdata)
{
k_sem_give(&c2_started);
}
static void syscmd_status_not(SHCI_TL_CmdStatus_t status)
{
BT_DBG("status:%d", status);
}
void TM_EvtReceivedCb(TL_EvtPacket_t *hcievt)
{
struct net_buf *buf;
struct bt_hci_acl_hdr acl_hdr;
TL_AclDataSerial_t *acl;
k_sem_take(&ipm_busy, K_NO_WAIT);
switch (hcievt->evtserial.type) {
case HCI_EVT:
BT_DBG("EVT: hcievt->evtserial.evt.evtcode: 0x%02x",
hcievt->evtserial.evt.evtcode);
switch (hcievt->evtserial.evt.evtcode) {
case BT_HCI_EVT_VENDOR:
/* Vendor events are currently unsupported */
BT_ERR("Unknown evtcode type 0x%02x",
hcievt->evtserial.evt.evtcode);
goto out;
default:
buf = bt_buf_get_evt(evtserial.evt.evtcode, false,
K_FOREVER);
break;
}
net_buf_add_mem(buf, &hcievt->evtserial.evt,
hcievt->evtserial.evt.plen + 2);
break;
case HCI_ACL:
acl = &(((TL_AclDataPacket_t *)hcievt)->AclDataSerial);
buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER);
acl_hdr.handle = acl->handle;
acl_hdr.len = acl->length;
BT_DBG("ACL: handle %x, len %x", acl_hdr.handle, acl_hdr.len);
net_buf_add_mem(buf, &acl_hdr, sizeof(acl_hdr));
net_buf_add_mem(buf, (u8_t *)&acl->acl_data, acl_hdr.len);
break;
default:
BT_ERR("Unknown BT buf type %d", hcievt->evtserial.type);
TL_MM_EvtDone(hcievt);
goto out;
}
TL_MM_EvtDone(hcievt);
if (hcievt->evtserial.type == HCI_EVT &&
bt_hci_evt_is_prio(hcievt->evtserial.evt.evtcode)) {
bt_recv_prio(buf);
} else {
bt_recv(buf);
}
out:
k_sem_give(&ipm_busy);
}
static void TM_AclDataAck(void)
{
k_sem_give(&acl_data_ack);
}
void shci_notify_asynch_evt(void *pdata)
{
shci_user_evt_proc();
}
void shci_cmd_resp_release(uint32_t flag)
{
k_sem_give(&ble_sys_wait_cmd_rsp);
}
void shci_cmd_resp_wait(uint32_t timeout)
{
k_sem_take(&ble_sys_wait_cmd_rsp, timeout);
}
void ipcc_reset(void)
{
/* Reset IPCC */
LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_IPCC);
LL_C1_IPCC_ClearFlag_CHx(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
LL_C2_IPCC_ClearFlag_CHx(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
LL_C1_IPCC_DisableTransmitChannel(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
LL_C2_IPCC_DisableTransmitChannel(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
LL_C1_IPCC_DisableReceiveChannel(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
LL_C2_IPCC_DisableReceiveChannel(
IPCC,
LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 |
LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
/* Set IPCC default IRQ handlers */
IRQ_CONNECT(IPCC_C1_RX_IRQn, 0, HW_IPCC_Rx_Handler, NULL, 0);
IRQ_CONNECT(IPCC_C1_TX_IRQn, 0, HW_IPCC_Tx_Handler, NULL, 0);
}
void transport_init(void)
{
TL_MM_Config_t tl_mm_config;
TL_BLE_InitConf_t tl_ble_config;
SHCI_TL_HciInitConf_t shci_init_config;
BT_DBG("BleCmdBuffer: %p", (void *)&BleCmdBuffer);
BT_DBG("HciAclDataBuffer: %p", (void *)&HciAclDataBuffer);
BT_DBG("SystemCmdBuffer: %p", (void *)&SystemCmdBuffer);
BT_DBG("EvtPool: %p", (void *)&EvtPool);
BT_DBG("SystemSpareEvtBuffer: %p", (void *)&SystemSpareEvtBuffer);
BT_DBG("BleSpareEvtBuffer: %p", (void *)&BleSpareEvtBuffer);
/**< Reference table initialization */
TL_Init();
/**< System channel initialization */
shci_init_config.p_cmdbuffer = (u8_t *)&SystemCmdBuffer;
shci_init_config.StatusNotCallBack = syscmd_status_not;
shci_init(sysevt_received, (void *) &shci_init_config);
/**< Memory Manager channel initialization */
tl_mm_config.p_BleSpareEvtBuffer = BleSpareEvtBuffer;
tl_mm_config.p_SystemSpareEvtBuffer = SystemSpareEvtBuffer;
tl_mm_config.p_AsynchEvtPool = EvtPool;
tl_mm_config.AsynchEvtPoolSize = POOL_SIZE;
TL_MM_Init(&tl_mm_config);
/**< BLE channel initialization */
tl_ble_config.p_cmdbuffer = (u8_t *)&BleCmdBuffer;
tl_ble_config.p_AclDataBuffer = HciAclDataBuffer;
tl_ble_config.IoBusEvtCallBack = TM_EvtReceivedCb;
tl_ble_config.IoBusAclDataTxAck = TM_AclDataAck;
TL_BLE_Init((void *)&tl_ble_config);
TL_Enable();
}
static int bt_ipm_send(struct net_buf *buf)
{
TL_CmdPacket_t *ble_cmd_buff = &BleCmdBuffer;
k_sem_take(&ipm_busy, K_FOREVER);
switch (bt_buf_get_type(buf)) {
case BT_BUF_ACL_OUT:
BT_DBG("ACL: buf %p type %u len %u", buf, bt_buf_get_type(buf),
buf->len);
k_sem_take(&acl_data_ack, K_FOREVER);
net_buf_push_u8(buf, HCI_ACL);
memcpy((void *)
&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial,
buf->data, buf->len);
TL_BLE_SendAclData(NULL, 0);
break;
case BT_BUF_CMD:
BT_DBG("CMD: buf %p type %u len %u", buf, bt_buf_get_type(buf),
buf->len);
ble_cmd_buff->cmdserial.type = HCI_CMD;
ble_cmd_buff->cmdserial.cmd.plen = buf->len;
memcpy((void *)&ble_cmd_buff->cmdserial.cmd, buf->data,
buf->len);
TL_BLE_SendCmd(NULL, 0);
break;
default:
k_sem_give(&ipm_busy);
BT_ERR("Unsupported type");
return -EINVAL;
}
k_sem_give(&ipm_busy);
net_buf_unref(buf);
return 0;
}
static void start_ble_rf(void)
{
if ((LL_RCC_IsActiveFlag_PINRST()) && (!LL_RCC_IsActiveFlag_SFTRST())) {
/* Simulate power off reset */
LL_PWR_EnableBkUpAccess();
LL_PWR_EnableBkUpAccess();
LL_RCC_ForceBackupDomainReset();
LL_RCC_ReleaseBackupDomainReset();
}
/* Select LSE clock */
LL_RCC_LSE_Enable();
while (!LL_RCC_LSE_IsReady()) {
}
/* Select wakeup source of BLE RF */
LL_RCC_SetRFWKPClockSource(LL_RCC_RFWKP_CLKSOURCE_LSE);
LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSE);
/* Switch OFF LSI */
LL_RCC_LSI1_Disable();
/* Set RNG on HSI48 */
LL_RCC_HSI48_Enable();
while (!LL_RCC_HSI48_IsReady()) {
}
LL_RCC_SetCLK48ClockSource(LL_RCC_CLK48_CLKSOURCE_HSI48);
}
static int bt_ipm_ble_init(void)
{
struct aci_set_tx_power *param;
struct net_buf *buf, *rsp;
int err;
/* Send HCI_RESET */
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, &rsp);
if (err) {
return err;
}
/* TDB: Something to do on reset complete? */
net_buf_unref(rsp);
/* Send ACI_WRITE_SET_TX_POWER_LEVEL */
buf = bt_hci_cmd_create(ACI_WRITE_SET_TX_POWER_LEVEL, 3);
if (!buf) {
return -ENOBUFS;
}
param = net_buf_add(buf, sizeof(*param));
param->cmd = 0x0F;
param->value[0] = 0x18;
param->value[1] = 0x01;
err = bt_hci_cmd_send_sync(ACI_WRITE_SET_TX_POWER_LEVEL, buf, &rsp);
if (err) {
return err;
}
net_buf_unref(rsp);
return 0;
}
static int bt_ipm_open(void)
{
int err;
/* Take BLE out of reset */
ipcc_reset();
transport_init();
/* Device will let us know when it's ready */
k_sem_take(&c2_started, K_FOREVER);
BT_DBG("C2 unlocked");
stm32wb_start_ble();
BT_DBG("IPM Channel Open Completed");
err = bt_ipm_ble_init();
if (err) {
return err;
}
return 0;
}
static const struct bt_hci_driver drv = {
.name = "BT IPM",
.bus = BT_HCI_DRIVER_BUS_IPM,
.quirks = BT_QUIRK_NO_RESET,
.open = bt_ipm_open,
.send = bt_ipm_send,
};
static int _bt_ipm_init(struct device *unused)
{
ARG_UNUSED(unused);
bt_hci_driver_register(&drv);
start_ble_rf();
return 0;
}
SYS_INIT(_bt_ipm_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

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

@@ -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

@@ -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

@@ -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 - \
@@ -277,6 +282,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 +415,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 +456,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.
*

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

@@ -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

@@ -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);
/**
* @}

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

@@ -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 */

View File

@@ -10,6 +10,12 @@
#include <syscall_list.h>
/* All of this is build time magic, but LCOV gets confused. Disable coverage
* for this whole file.
*
* LCOV_EXCL_START
*/
/*
* The final link step uses the symbol _OffsetAbsSyms to force the linkage of
* offsets.o into the ELF image.
@@ -80,4 +86,5 @@ GEN_ABSOLUTE_SYM(K_THREAD_SIZEOF, sizeof(struct k_thread));
/* size of the device structure. Used by linker scripts */
GEN_ABSOLUTE_SYM(_DEVICE_STRUCT_SIZEOF, sizeof(struct device));
/* LCOV_EXCL_STOP */
#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_OFFSETS_H_ */

View File

@@ -244,7 +244,7 @@ static ALWAYS_INLINE void z_new_thread_init(struct k_thread *thread,
#endif
#ifdef CONFIG_THREAD_NAME
thread->name = NULL;
thread->name[0] = '\0';
#endif
#if defined(CONFIG_USERSPACE)

View File

@@ -36,7 +36,7 @@ static inline void z_waitq_init(_wait_q_t *w)
static inline struct k_thread *z_waitq_head(_wait_q_t *w)
{
return (void *)rb_get_min(&w->waitq.tree);
return (struct k_thread *)rb_get_min(&w->waitq.tree);
}
#else /* !CONFIG_WAITQ_SCALABLE: */
@@ -52,7 +52,7 @@ static inline void z_waitq_init(_wait_q_t *w)
static inline struct k_thread *z_waitq_head(_wait_q_t *w)
{
return (void *)sys_dlist_peek_head(&w->waitq);
return (struct k_thread *)sys_dlist_peek_head(&w->waitq);
}
#endif /* !CONFIG_WAITQ_SCALABLE */

View File

@@ -133,6 +133,13 @@ K_THREAD_STACK_DEFINE(_interrupt_stack3, CONFIG_ISR_STACK_SIZE);
extern void idle(void *unused1, void *unused2, void *unused3);
/* LCOV_EXCL_START
*
* This code is called so early in the boot process that code coverage
* doesn't work properly. In addition, not all arches call this code,
* some like x86 do this with optimized assembly
*/
/**
*
* @brief Clear BSS
@@ -216,7 +223,9 @@ void z_data_copy(void)
#endif /* CONFIG_STACK_CANARIES */
#endif /* CONFIG_USERSPACE */
}
#endif
#endif /* CONFIG_XIP */
/* LCOV_EXCL_STOP */
/**
*
@@ -278,12 +287,14 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
main();
/* Mark nonessenrial since main() has no more work to do */
_main_thread->base.user_options &= ~K_ESSENTIAL;
/* Dump coverage data once the main() has exited. */
gcov_coverage_dump();
} /* LCOV_EXCL_LINE ... because we just dumped final coverage data */
/* Terminate thread normally since it has no more work to do */
_main_thread->base.user_options &= ~K_ESSENTIAL;
}
/* LCOV_EXCL_START */
void __weak main(void)
{
@@ -291,6 +302,8 @@ void __weak main(void)
arch_nop();
}
/* LCOV_EXCL_STOP */
#if defined(CONFIG_MULTITHREADING)
static void init_idle_thread(struct k_thread *thr, k_thread_stack_t *stack)
{
@@ -408,7 +421,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
}
static void switch_to_main_thread(void)
static FUNC_NORETURN void switch_to_main_thread(void)
{
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
z_arch_switch_to_main_thread(_main_thread, _main_stack, MAIN_STACK_SIZE,
@@ -421,6 +434,7 @@ static void switch_to_main_thread(void)
*/
z_swap_unlocked();
#endif
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}
#endif /* CONFIG_MULTITHREADING */
@@ -515,9 +529,13 @@ FUNC_NORETURN void z_cstart(void)
#else
bg_thread_main(NULL, NULL, NULL);
/* LCOV_EXCL_START
* We've already dumped coverage data at this point.
*/
irq_lock();
while (true) {
}
/* LCOV_EXCL_STOP */
#endif
/*
@@ -526,5 +544,5 @@ FUNC_NORETURN void z_cstart(void)
* far.
*/
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}

View File

@@ -919,7 +919,6 @@ s32_t z_impl_k_sleep(s32_t duration)
s32_t ticks;
__ASSERT(!z_is_in_isr(), "");
__ASSERT(duration != K_FOREVER, "");
K_DEBUG("thread %p for %d ns\n", _current, duration);
@@ -962,12 +961,6 @@ s32_t z_impl_k_sleep(s32_t duration)
#ifdef CONFIG_USERSPACE
Z_SYSCALL_HANDLER(k_sleep, duration)
{
/* FIXME there were some discussions recently on whether we should
* relax this, thread would be unscheduled until k_wakeup issued
*/
Z_OOPS(Z_SYSCALL_VERIFY_MSG(duration != K_FOREVER,
"sleeping forever not allowed"));
return z_impl_k_sleep(duration);
}
#endif

View File

@@ -63,7 +63,7 @@ s32_t z_impl_k_stack_alloc_init(struct k_stack *stack, u32_t num_entries)
void *buffer;
s32_t ret;
buffer = z_thread_malloc(num_entries);
buffer = z_thread_malloc(num_entries * sizeof(u32_t));
if (buffer != NULL) {
k_stack_init(stack, buffer, num_entries);
stack->flags = K_STACK_FLAG_ALLOC;

View File

@@ -138,11 +138,22 @@ void z_impl_k_thread_custom_data_set(void *value)
_current->custom_data = value;
}
#ifdef CONFIG_USERSPACE
Z_SYSCALL_HANDLER(k_thread_custom_data_set, data)
{
z_impl_k_thread_custom_data_set((void *)data);
return 0;
}
#endif
void *z_impl_k_thread_custom_data_get(void)
{
return _current->custom_data;
}
#ifdef CONFIG_USERSPACE
Z_SYSCALL_HANDLER0_SIMPLE(k_thread_custom_data_get);
#endif /* CONFIG_USERSPACE */
#endif /* CONFIG_THREAD_CUSTOM_DATA */
#if defined(CONFIG_THREAD_MONITOR)
@@ -172,61 +183,109 @@ void z_thread_monitor_exit(struct k_thread *thread)
}
#endif
int z_impl_k_thread_name_set(struct k_thread *thread, const char *value)
{
#ifdef CONFIG_THREAD_NAME
void z_impl_k_thread_name_set(struct k_thread *thread, const char *value)
{
if (thread == NULL) {
_current->name = value;
} else {
thread->name = value;
thread = _current;
}
}
const char *z_impl_k_thread_name_get(struct k_thread *thread)
{
return (const char *)thread->name;
}
strncpy(thread->name, value, CONFIG_THREAD_MAX_NAME_LEN);
thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0';
return 0;
#else
void z_impl_k_thread_name_set(k_tid_t thread_id, const char *value)
{
ARG_UNUSED(thread_id);
ARG_UNUSED(thread);
ARG_UNUSED(value);
}
const char *z_impl_k_thread_name_get(k_tid_t thread_id)
{
ARG_UNUSED(thread_id);
return NULL;
}
return -ENOSYS;
#endif /* CONFIG_THREAD_NAME */
}
#ifdef CONFIG_USERSPACE
#if defined(CONFIG_THREAD_NAME)
Z_SYSCALL_HANDLER(k_thread_name_set, thread, data)
Z_SYSCALL_HANDLER(k_thread_name_set, thread, str_param)
{
char *name_copy = NULL;
#ifdef CONFIG_THREAD_NAME
struct k_thread *t = (struct k_thread *)thread;
size_t len;
int err;
const char *str = (const char *)str_param;
name_copy = z_user_string_alloc_copy((char *)data, 64);
z_impl_k_thread_name_set((struct k_thread *)thread, name_copy);
return 0;
if (t != NULL) {
if (Z_SYSCALL_OBJ(t, K_OBJ_THREAD) != 0) {
return -EINVAL;
}
}
len = z_user_string_nlen(str, CONFIG_THREAD_MAX_NAME_LEN, &err);
if (err != 0) {
return -EFAULT;
}
if (Z_SYSCALL_MEMORY_READ(str, len) != 0) {
return -EFAULT;
}
return z_impl_k_thread_name_set(t, str);
#else
return -ENOSYS;
#endif /* CONFIG_THREAD_NAME */
}
#endif /* CONFIG_USERSPACE */
const char *k_thread_name_get(struct k_thread *thread)
{
#ifdef CONFIG_THREAD_NAME
return (const char *)thread->name;
#else
ARG_UNUSED(thread);
return NULL;
#endif /* CONFIG_THREAD_NAME */
}
Z_SYSCALL_HANDLER1_SIMPLE(k_thread_name_get, K_OBJ_THREAD, k_tid_t);
#endif
#ifdef CONFIG_THREAD_CUSTOM_DATA
Z_SYSCALL_HANDLER(k_thread_custom_data_set, data)
int z_impl_k_thread_name_copy(k_tid_t thread_id, char *buf, size_t size)
{
z_impl_k_thread_custom_data_set((void *)data);
#ifdef CONFIG_THREAD_NAME
strncpy(buf, thread_id->name, size);
return 0;
#else
ARG_UNUSED(thread_id);
ARG_UNUSED(buf);
ARG_UNUSED(size);
return -ENOSYS;
#endif /* CONFIG_THREAD_NAME */
}
Z_SYSCALL_HANDLER0_SIMPLE(k_thread_custom_data_get);
#endif /* CONFIG_THREAD_CUSTOM_DATA */
#ifdef CONFIG_USERSPACE
Z_SYSCALL_HANDLER(k_thread_name_copy, thread_id, buf, size)
{
#ifdef CONFIG_THREAD_NAME
size_t len;
struct k_thread *t = (struct k_thread *)thread_id;
struct _k_object *ko = z_object_find(t);
/* Special case: we allow reading the names of initialized threads
* even if we don't have permission on them
*/
if (t == NULL || ko->type != K_OBJ_THREAD ||
(ko->flags & K_OBJ_FLAG_INITIALIZED) == 0) {
return -EINVAL;
}
if (Z_SYSCALL_MEMORY_WRITE(buf, size) != 0) {
return -EFAULT;
}
len = strlen(t->name);
if (len + 1 > size) {
return -ENOSPC;
}
return z_user_to_copy((void *)buf, t->name, len + 1);
#else
ARG_UNUSED(thread_id);
ARG_UNUSED(buf);
ARG_UNUSED(size);
return -ENOSYS;
#endif /* CONFIG_THREAD_NAME */
}
#endif /* CONFIG_USERSPACE */
#endif
#ifdef CONFIG_STACK_SENTINEL
/* Check that the stack sentinel is still present
@@ -386,7 +445,12 @@ void z_setup_new_thread(struct k_thread *new_thread,
k_spin_unlock(&lock, key);
#endif
#ifdef CONFIG_THREAD_NAME
new_thread->name = name;
if (name != NULL) {
strncpy(new_thread->name, name,
CONFIG_THREAD_MAX_NAME_LEN - 1);
/* Ensure NULL termination, truncate if longer */
new_thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0';
}
#endif
#ifdef CONFIG_USERSPACE
z_object_init(new_thread);

View File

@@ -760,7 +760,7 @@ static u32_t handler_bad_syscall(u32_t bad_id, u32_t arg2, u32_t arg3,
{
printk("Bad system call id %u invoked\n", bad_id);
z_arch_syscall_oops(ssf);
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}
static u32_t handler_no_syscall(u32_t arg1, u32_t arg2, u32_t arg3,
@@ -768,7 +768,7 @@ static u32_t handler_no_syscall(u32_t arg1, u32_t arg2, u32_t arg3,
{
printk("Unimplemented system call\n");
z_arch_syscall_oops(ssf);
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}
#include <syscall_dispatch.c>

View File

@@ -24,6 +24,7 @@ config CMSIS_MAX_THREAD_COUNT
config CMSIS_THREAD_MAX_STACK_SIZE
int "Max stack size threads can be allocated in CMSIS RTOS application"
default 4096 if COVERAGE
default 512
help
Mention max stack size threads can be allocated in CMSIS RTOS application.

View File

@@ -38,13 +38,15 @@ config CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT
config CMSIS_V2_THREAD_MAX_STACK_SIZE
int "Max stack size threads can be allocated in CMSIS RTOS V2 application"
default 4096 if COVERAGE
default 512
help
Mention max stack size threads can be allocated in CMSIS RTOS V2 application.
config CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE
int "Dynamic stack size threads are allocated in CMSIS RTOS V2 application"
default 0
default 4096 if COVERAGE
default 512
help
Mention dynamic stack size threads are allocated in CMSIS RTOS V2 application.

View File

@@ -102,6 +102,10 @@ void *realloc(void *ptr, size_t requested_size)
size_t block_size, total_requested_size;
void *new_ptr;
if (ptr == NULL) {
return malloc(requested_size);
}
if (requested_size == 0) {
return NULL;
}

View File

@@ -57,8 +57,6 @@ extern void *_heap_sentry;
#define MAX_HEAP_SIZE ((KB(CONFIG_SRAM_SIZE)) - USED_RAM_SIZE)
#endif
static unsigned char *heap_base = UINT_TO_POINTER(USED_RAM_END_ADDR);
#ifdef CONFIG_USERSPACE
struct k_mem_partition z_malloc_partition;
@@ -66,7 +64,11 @@ static int malloc_prepare(struct device *unused)
{
ARG_UNUSED(unused);
#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
z_malloc_partition.start = (u32_t)heap_base;
#else
z_malloc_partition.start = USED_RAM_END_ADDR;
#endif
z_malloc_partition.size = MAX_HEAP_SIZE;
z_malloc_partition.attr = K_MEM_PARTITION_P_RW_U_RW;
return 0;
@@ -222,7 +224,11 @@ void _exit(int status)
void *_sbrk(int count)
{
#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
void *ptr = heap_base + heap_sz;
#else
void *ptr = _end + heap_sz;
#endif
if ((heap_sz + count) < MAX_HEAP_SIZE) {
heap_sz += count;

View File

@@ -45,6 +45,7 @@ static void _printk_hex_ulong(out_func_t out, void *ctx,
*
* @return 0
*/
/* LCOV_EXCL_START */
__attribute__((weak)) int z_arch_printk_char_out(int c)
{
ARG_UNUSED(c);
@@ -52,6 +53,7 @@ static void _printk_hex_ulong(out_func_t out, void *ctx,
/* do nothing */
return 0;
}
/* LCOV_EXCL_STOP */
int (*_char_out)(int) = z_arch_printk_char_out;
@@ -506,18 +508,14 @@ static int str_out(int c, struct str_context *ctx)
int snprintk(char *str, size_t size, const char *fmt, ...)
{
struct str_context ctx = { str, size, 0 };
va_list ap;
int ret;
va_start(ap, fmt);
z_vprintk((out_func_t)str_out, &ctx, fmt, ap);
ret = vsnprintk(str, size, fmt, ap);
va_end(ap);
if (ctx.count < ctx.max) {
str[ctx.count] = '\0';
}
return ctx.count;
return ret;
}
int vsnprintk(char *str, size_t size, const char *fmt, va_list ap)

View File

@@ -28,18 +28,12 @@ FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry,
{
entry(p1, p2, p3);
#ifdef CONFIG_MULTITHREADING
k_thread_abort(k_current_get());
#else
for (;;) {
k_cpu_idle();
}
#endif
/*
* Compiler can't tell that k_thread_abort() won't return and issues a
* warning unless we tell it that control never gets this far.
*/
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}

View File

@@ -67,20 +67,15 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts)
int clock_settime(clockid_t clock_id, const struct timespec *tp)
{
struct timespec base;
int res;
if (clock_id != CLOCK_REALTIME) {
errno = EINVAL;
return -1;
}
res = clock_gettime(clock_id, &base);
if (res != 0) {
return res;
}
s64_t delta = (s64_t)NSEC_PER_SEC * (tp->tv_sec - base.tv_sec) +
(tp->tv_nsec - base.tv_nsec);
u64_t elapsed_msecs = k_uptime_get();
s64_t delta = (s64_t)NSEC_PER_SEC * tp->tv_sec + tp->tv_nsec
- elapsed_msecs * USEC_PER_MSEC * NSEC_PER_USEC;
base.tv_sec = delta / NSEC_PER_SEC;
base.tv_nsec = delta % NSEC_PER_SEC;

View File

@@ -29,6 +29,7 @@
#define _SRAM2_DATA_SECTION_NAME .sram2_data
#define _SRAM2_BSS_SECTION_NAME .sram2_bss
#define _SRAM2_TEXT_SECTION_NAME .sram2_text
#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2)
#endif
#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512)

View File

@@ -26,7 +26,6 @@ CONFIG_BT_PERIPHERAL=y
CONFIG_BT=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_RX_BUF_COUNT=30
CONFIG_BT_L2CAP_RX_MTU=69
CONFIG_BT_L2CAP_TX_MTU=69
CONFIG_BT_L2CAP_TX_BUF_COUNT=5

View File

@@ -17,6 +17,8 @@ CONFIG_SETTINGS_FCB=y
CONFIG_BT=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_RX_STACK_SIZE=1100
CONFIG_BT_RX_BUF_COUNT=3
CONFIG_BT_DISCARDABLE_BUF_COUNT=3
CONFIG_BT_CTLR_DUP_FILTER_LEN=0
CONFIG_BT_OBSERVER=y

View File

@@ -3,7 +3,6 @@ CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_BT=y
CONFIG_BT_RX_BUF_COUNT=30
CONFIG_BT_TINYCRYPT_ECC=y
#CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_OBSERVER=y

View File

@@ -7,7 +7,7 @@ CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_GATT_DIS=y
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Zephyr Peripheral Sample Long Name"
CONFIG_BT_DEVICE_APPEARANCE=833

View File

@@ -31,7 +31,6 @@ CONFIG_BT_PERIPHERAL=y
CONFIG_BT=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_RX_BUF_COUNT=30
CONFIG_BT_L2CAP_RX_MTU=69
CONFIG_BT_L2CAP_TX_MTU=69
CONFIG_BT_L2CAP_TX_BUF_COUNT=8

View File

@@ -26,7 +26,6 @@ CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_RX_BUF_COUNT=30
CONFIG_BT_RX_STACK_SIZE=4096
CONFIG_BT_L2CAP_RX_MTU=69
CONFIG_BT_L2CAP_TX_MTU=69

View File

@@ -19,7 +19,6 @@ CONFIG_BT_MESH_DEBUG=y
CONFIG_BT_OBSERVER=y
CONFIG_BT_BROADCASTER=y
CONFIG_BT_RX_BUF_COUNT=30
CONFIG_BT_L2CAP_RX_MTU=69
CONFIG_BT_L2CAP_TX_MTU=69
CONFIG_BT_L2CAP_TX_BUF_COUNT=8

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