Commit graph

19400 commits

Author SHA1 Message Date
Johan Hedberg 27e1c4fbb2 Bluetooth: Mesh: Fix handling of failed transmissions
When sending a segmented message, the state could get stuck if the
advertising bearer fails in transmitting and we don't detect that it
happened. Add a send_start callback for all packets so we can always
know if sending fails.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-14 11:43:34 +02:00
Johan Hedberg 6379da2a09 Bluetooth: Mesh: Fix NULL pointer access with PB-ADV
When both PB-ADV and PB-GATT are enabled, the PB-ADV code (prov.c)
uses the bt_mesh_proxy_get_buf() API to get a net_buf_simple buffer.
Unfortunately this function also suffers from the same issue that was
fixed by commit 2b273444c1.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-14 11:43:34 +02:00
Michael Scott 086893fc55 net: app: client: set remote port after DNS lookup
In net_app_init_client(), the remote port is set after an initial
set of checks based on the remote_addr's assigned family.

However, if the peer_addr_str is a host name which needs to be
resolved via DNS, the family won't be set yet, and the port is
left as 0.

To fix this behavior let's move the port assignment after the
DNS lookup section to be sure that the remote sa_family is set.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-02-14 09:40:01 +02:00
Andy Ross 03c1d28e6e work_q: Correctly clear pending flag in delayed work queue, update docs
As discovered in https://github.com/zephyrproject-rtos/zephyr/issues/5952

...a duplicate call to k_delayed_work_submit_to_queue() on a work item
whose timeout had expired but which had not yet executed (i.e. it was
pending in the queue for the active work queue thread) would fail,
because the cancellation step wouldn't clear the PENDING bit, causing
the resubmission to see the object in an invalid state.  Trivially
fixed by adding a bit clear.

It also turns out that the behavior of the code doesn't match the
docs, which state that a PENDING work item is not supposed to be
cancelled at all.  Fix the docs to remove that.

And on yet further review, it turns out that there's no way to make a
test like the one in the linked bug threadsafe.  The work queue does
no synchronization by design, so if the user code does no external
synchronization it might very well clobber the running handler.  Added
a sentence to the docs to reflect this gotcha.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-02-13 18:08:57 -05:00
Carles Cufi 771dfb0d13 doc: nordic_segger: Add link to Python viewer
Courtesy of thomsten on IRC, add a link to a handy RTT viewer written in
Python and cross-platform.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-13 17:27:48 -05:00
Carles Cufi 3f623c2160 doc: nordic_segger: Document conflicting console
Describe how to disable the UART console to avoid unexpected
redirections that will prevent the console output to go through RTT.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-13 17:27:48 -05:00
Ramakrishna Pallala 3f2f1223ac kernel: thread: Remove unused _k_thread_single_start()
Remove unused _k_thread_single_start() as this logic is
now moved to _impl_k_thread_start().

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-13 17:26:21 -05:00
Andy Gross 4c47d7f7e2 arch: arm: Enable stack guard before starting main
This patch fixes a hole in the stack guard configuration.  The initial
branch to main is missing the stack guard configuration.

Fixes: Issue #3718

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 13:06:41 -08:00
Andy Gross 0eb6275fa5 doc: kernel: usermode: Add MPU stack and userspace documentation
This patch adds documentation on the design and implementation of stack
objects for architectures which utilize MPU backed stack and memory
protection.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Andy Gross 465e04cae7 arch: arm: Fixup stack end calculations
This patch fixes calculations for the top of the interrupt and main
stacks.  Due to power of two alignment requirements for certain MPUs,
the guard size must be taken into account due to the guard being
counted against the initial stack size.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Andy Gross f35c0318a1 tests: mem_protect: userspace: Adjust kernel stack tests
This patch adjusts the calculation of the overflow size for the kernel
stack tests which read/write to areas below the current user stack.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Andy Gross f7ec62eb85 arm: mpu: Enable userspace support for NXP and ARM
This patch set implements the APIs and changed required to support
the user mode thread support.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Andy Gross 1c047c9bef arm: userspace: Add ARM userspace infrastructure
This patch adds support for userspace on ARM architectures.  Arch
specific calls for transitioning threads to user mode, system calls,
and associated handlers.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Andy Gross 9ccdcb9be6 arm: mpu: Add user context API placeholder
This patch adds a configure_mpu_user_context API and implements
the required function placeholders in the NXP and ARM MPU files.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-13 12:42:37 -08:00
Carles Cufi 29af3e0396 scripts: nrfjprog: Use built-in pin reset enable
Use nrfjprog's built-in pin reset enabling functionality instead of
doing it manually.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-13 20:14:09 +01:00
Erwin Rol cb3d127981 sanitycheck: add ccm_bss, ccm_noinit and ccm_data sections
Add the STM32 ccm_bss, ccm_noinit, abd ccm_data sections
to the list of allowed sections so the sanity check passes.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol 6c0e69e7fd samples: olimex_stm32_e407: CCM usage example
Add an example program showing the use of the STM32 CCM.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol 3f3466af8d dts: add ccm config to olimex stm32 boards
Add ccm config to the Olimex STM32 boards DTS files.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol eaf74f71ed dts: arm: stm32: Add ccm address and size configurations
Configure ccm size and address via dts. According to the DT
specification, the unit-address of a node must match the
first address specified in the reg property of the node.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol 1dc41d19b3 kernel: init: initialize stm32 ccm sections
Initialize the ccm_bss section to zero.
Copy the ccm_data section from the rom section.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol e4890181b4 scripts/dts/extract_dts_includes.py: add ccm support
Add support for generating CONFIG_CCM_BASE_ADDRESS and CONFIG_CCM_SIZE
from the dts files.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Erwin Rol 581446d8cd linker: arm: add stm32 ccm sections
The STM32 has special Core Coupled Memory, ccm for short, that can
only be accessed through the CPU and can not be use for DMA.

The following 3 sections have been added.
- ccm_bss for zero initialized data
- ccm_data for initialized data
- ccm_noinit for uninitialized data

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Anas Nashif 1aa1edaafa sanitycheck: make schema for toolchains more flexible
Allow for any toolchain variants to be useable with sanitycheck without
the need for them to be registered.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Anas Nashif 622ab2f6fd toolchain: organise toolchain/compiler files
Move toolchain definitions into toolchain/ and move compilers to
compilers/
Usage of toolchain- for everything was confusing, there are the actual
compiler related definitions and there is the toolchain/SDK related
configs, so keeping them separate helps understand the different and
prevents confusion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Anas Nashif 7ee8bb9677 build: deprecate ZEPHYR_GCC_VARIANT
We want to support other toolchain not based on GCC, so the variable is
confusing, use ZEPHYR_TOOLCHAIN_VARIANT instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Kumar Gala 5478d57911 dma: Fix building when system calls are disabled
When we added system call support to dma_start/dma_stop we forgot to
include <syscalls/dma.h> to get the full proper magic implemented.
Adding the header in fixes builds when system call support is not
enabled and using dma support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-13 10:32:41 -05:00
Tomasz Bursztyka 47e45c52a1 net: buf: Support allocation of a net_buf pointing to external buffer
Difference being that the data is not, then, allocated from the pool.
Only the net_buf is.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-02-13 16:46:32 +02:00
Luiz Augusto von Dentz 5c464b1bcc Bluetooth: central_hr: Fix assigning temporary UUID to discovery
bt_gatt_discover_params parameter shall remain valid as long as the
procedure is in place.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-02-13 16:24:04 +02:00
Ruslan Mstoi b743f98896 net: icmpv4: Drop ICMPv4 packet if ICMP header is NULL
This commit fixes the crash of echo_server from malformed
ICMPv4 packet.

Fixes #6081

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-02-13 16:05:25 +02:00
Johan Hedberg 2b273444c1 Bluetooth: Mesh: Fix NULL pointer access with GATT Proxy
The conversion to the new net_buf_simple API was done incorrectly
here. The buffer initialization should use net_buf_simple_init()
instead of net_buf_simple_reset(), so that buf->__buf gets properly
initialized (and not left pointing at NULL).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-13 15:03:34 +02:00
Johan Hedberg abc20e7eae Bluetooth: Introduce dedicated TX fragment pool
There's a risk of a deadlock if we use the same pool for ACL fragments
as we use for general ACL TX buffers: all TX buffers are queued up,
and we try to segment one of them, a segment buffer will never become
available. To work around this risk, introduce a dedicated fragment
pool.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-13 14:49:52 +02:00
Vinayak Kariappa Chettimada 4c123a5162 Bluetooth: controller: Refactor ticker integration into hal
Refactor ticker execution context dependency out into HAL
folder. This decouples ticker from mayfly, enabling porting
towards a more tasklet (if and when kernel gets the support)
style execution contexts type implementation support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-13 13:26:37 +01:00
Johan Hedberg ac1360f0a7 Bluetooth: Mesh: Convert to new net_buf_simple APIs
Convert the mesh code to use the new net_buf_siple APIs. This has the
benefit of saving 4 bytes off the stack due to the not needed pointer.
Also update the publication context helpers to map to the new
net_buf_simple API in an intuitive way.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-13 14:00:08 +02:00
Ravi kumar Veeramally 18422de8da net: tcp: Provide local address in TCP reset message preparation
If context is bound to IPv6 unspecified addresss and some port
number, then unspecified address is passed in TCP reset packet
message preparation. Eventually packet dropped at the peer.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-13 13:37:20 +02:00
Ravi kumar Veeramally 1f20111ef3 net: tcp: Do not handle packet re-transmission in TCP ACK
Zephyr doesn't have luxury to create re-transmit timer per packet. So
it has different methods to handle packets in queue. But re-sending
packets on valid ack messages causing issues.

E.g. A TCP node sent two packets (packet-1, packet-2). Peer replied
two ACKs (ACK-1 and ACK-2), and these two ACK's are at rx_thread
queue. Now ACK-1 is handled and reference of packet-1 is freed
from sent list. Then if condiftion (valid ACK and connection
state is ESTABLISHED) notices that, sent list is not empty.
Restart the timer, modify sent flag and resend packets in a
list. Here packet-2 is sent again, even though ACK-2 is already
received. Situation is worse if there are more packets in the
list.

So only start the re-transmit timer in-case queue is not empty. It
allows rx_thread to handle all incoming packets (in this e.g ACKs).
When the re-trasmit timer expires, it sends the packets which
are left in queue.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-13 13:37:20 +02:00
Ravi kumar Veeramally e059e8b379 net: context: Handle failure case of tcp backlog entry
In case of failed to get source address from the net packet,
release the assgined tcp backlog entry. Otherwise it will
never be freed.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-13 13:37:20 +02:00
Ravi kumar Veeramally 7dc72c3ca6 net: context: Remove duplicate call
k_delayed_work_cancel(&context->tcp->fin_timer) called twice
immediately one after other.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-13 13:37:20 +02:00
Luiz Augusto von Dentz 800bfaf9a7 Bluetooth: UUID: Remove macros defining 16 bit values
Application should normally declare a bt_uuid with proper type and then
use bt_uuid_cmp.

Fixes #5162

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-02-13 13:33:48 +02:00
Robert Chou 6f466cd7e5 net: coap: retransmission for four times
RFC 7252, sec 4.8 [https://tools.ietf.org/html/rfc7252#section-4.8]
The default MAX_RETRANSMIT is 4, current implementation only
retry 3 times. Update next_timeout() to return one more retry.

Also, add a TODO for random generated initial ACK timeout

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-02-13 13:06:15 +02:00
David B. Kinder 8cdd9bed6c doc: fix duplicate sample doc titles
Two docs listed in the Samples an Demos TOC had the same title displayed
in the board-specific samples section, "Power Management Demo".  Give
both sample docs a more specific title.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-02-12 21:59:54 -05:00
Paul Sokolovsky ede25c12a3 net: sockets: getaddrinfo() buffer overflow, etc. fixes
The existing implementation assumed DNS resolv callback will be
called just once, but that's not always the case (apparently,
for multi-homes hosts or something). So, apply array bounds
checking (and do pointer arithmetic only after it, as the C
standard otherwise warns of "undefined behavior"). In such a case,
the port number wasn't set in each entry too, so rework how it's
done.

The issues discovered while resolving archive.ubuntu.com.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-12 20:17:26 -05:00
Andrew Boie ce6c8f347b dma: add system calls for dma_start/dma_stop
As per current policy of requiring supervisor mode to register
callbacks, dma_config() is omitted.

A note added about checking the channel ID for start/stop, current
implementations already do this but best make it explicitly
documented.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-02-12 19:24:25 -05:00
Carles Cufi 980c0cf4ac build: win: Add a new zephyr-env.cmd file
Add a new zephyr-env.cmd that mirrors the functionality of zephyr-env.sh
but on Windows platforms. It sets ZEPHYR_BASE to the location of the
script.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-12 19:22:22 -05:00
Michael Scott 7a9b688526 x86: fix build warning
During compile of lwm2m_client using qemu_x86, the following build
warning was noticed:
zephyr/arch/x86/core/excstub.S:132:2: warning: "/*" within comment [-Wcomment]
  /*

In commit ff42bdd0a0 ("debug: remove option GDB_INFO"), the comment tag
was omitted.  Fix the comment end tag.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-02-12 19:21:06 -05:00
Anas Nashif 11a9625eaf debug: remove DEBUG_INFO option
This feature is X86 only and is not used or being tested. It is legacy
feature and no one can prove it actually works. Remove it until we have
proper documentation and samples and multi architecture support.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-12 13:58:28 -08:00
Anas Nashif ff42bdd0a0 debug: remove option GDB_INFO
This feature is X86 only and is not used or being tested. It is legacy
feature and no one can prove it actually works. Remove it until we have
proper documentation and samples and multi architecture support.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-12 13:58:28 -08:00
Carles Cufi d0c2be7c8a doc: getting_started: Windows build doc fixes
Correct 2 items in the Windows Getting Started doc:

 * dtc-msys2 is now an upstream Chocolatey package
 * Add instructions to clone and build Ninja for MSYS2

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-12 13:47:42 -05:00
Andy Gross ff22490d56 doc: Update security feature information
This patch updates information pertaining to userspace related security
features.  Some of these have been added to releases and this needs to
be shown in the document.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-12 13:47:19 -05:00
Yannis Damigos 6973d134bd dts/arm/st: fix dts inclusion for stm32f334
stm32f334 is not an expansion of stm32f303, since
stm32f303 has more I2C, SPI ports than stm32f303.

Fix this by including stm32f3.dtsi in stm32f334.dtsi.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-02-12 09:17:37 -06:00
Yannis Damigos 9dacb3a02d dts/arm: Move i2c2 node inside stm32fxxx dtsi file
SoC stm32f334x8 doesn't support I2C2 port. This
patch moves i2c2 node inside stm32f303 and
stm32f373 dtsi files.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-02-12 09:17:37 -06:00