Commit graph

41120 commits

Author SHA1 Message Date
David B. Kinder
b4d67dcc46 doc: update doc generation instructions
Incorrectly stated Sphinx 1.7.0 was supported (it's not); newest working
version is 1.6.7.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-04-25 05:55:03 +05:30
Erwan Gouriou
986f249f03 dts/st: dtc v1.4.6 warnings: pin-c... node has a reg ... no unit name
To prepare to upcoming dtc v1.4.6, fix warnings in dts files.

This commit addresses the following warning:
Warning (unit_address_vs_reg): Node /soc/pin-controller has a reg
or ranges property, but no unit name

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-24 14:46:48 -05:00
Erwan Gouriou
acc20e24d6 dts/st: dtc v1.4.6 warnings: Missing property '#clock-cells' in node
To prepare to upcoming dtc v1.4.6, fix warnings in dts files.

This commit addresses the following warning:
Warning (clocks_property): Missing property '#clock-cells' in node
/soc/rcc@40021000 or bad phandle (referred from
/soc/pin-controller/gpio@40011800:clocks[0])

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-24 14:46:48 -05:00
Erwan Gouriou
a27c0ede12 dts/st: dtc v1.4.6 warnings: #address-cells/#size-cells without "ranges"
To prepare to upcoming dtc v1.4.6, fix warnings in dts files.

This commit addresses the following warning:
"unnecessary #address-cells/#size-cells without "ranges" or child
"reg" property in /gpio_keys".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-24 14:46:48 -05:00
Andrew Boie
31bdfc014e userspace: add support for dynamic kernel objects
A red-black tree is maintained containing the metadata for all
dynamically created kernel objects, which are allocated out of the
system heap.

Currently, k_object_alloc() and k_object_free() are supervisor-only.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-04-24 12:27:54 -07:00
Erwan Gouriou
513488c937 boards: disco_l475_iot1: define 2 default clock configurations
In some BLE use cases, using MSI driven SYSCLK is required.
Rework board Kconfig.defconfig in order to enable use of 2
alternate default clock configurations.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-24 08:55:02 -05:00
Erwan Gouriou
d8ba007a8b drivers: clock_control: Add MSI as possible clock source for stm32
Add MSI as potential SYSCLK direct source for L0 and L4.
It could be needed in some cases when an accurate clock
is required and no external clock is available.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-24 08:55:02 -05:00
Håkon Øye Amundsen
c26fdc1b55 drivers/spi: Fixed incorrect prompt.
The prompt for SPI1 IRQ priority stated SPI0 incorrectly.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-04-24 08:23:30 -05:00
Maureen Helm
4624f13290 ext: mcux: Remove clock_config.c/h
We have never used the mcux clock_config.c/h files, so remove them. We
configure clocks in soc.c instead to allow more options with Kconfigs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-04-24 07:55:48 -05:00
Maureen Helm
adf5b36a78 lpc54114: Remove unused include in soc.c
The lpc54114 soc.c file included clock_config.h unnecessarily.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-04-24 07:55:48 -05:00
Maureen Helm
57e80e5345 ext: mcux: Reorganize imported drivers into soc family subfolders
We have been combining imported mcux drivers into a flattened directory
structure to maximize driver reuse, but the introduction of additional
nxp soc families (lpc and imx) to zephyr has introduced driver naming
conflicts. This caused us to rename and modify imported files, such as
fsl_gpio.c/h, to make them unique across all three nxp soc families.
This makes updating the the mcux drivers complicated, especially for the
lpc family.

Reoganize the mcux drivers into soc family subfolders, so we can just
copy all the drivers from an mcux distribution (which is done on an
soc-basis) into the appropriate soc family folder. Undo all of the
naming changes that occurred when lpc and imx drivers were originally
imported. Undo the accidental squashing of the kinetis watchdog and dcdc
drivers that occurred when the imx drivers were introduced.

The drawback to this approach is that we have duplicate files when the
same hw ip modules exist in multiple soc families, however there are
only few cases where this occurs, such as fsl_lpuart and fsl_trng.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-04-24 07:55:48 -05:00
Maureen Helm
9791597ef9 ext: mcux: Update README to follow template format
A template for documenting non-apache licensed components was introduced
after mcux was originally imported. Update the README to follow the
template in doc/contribute/code_component_README.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-04-24 07:55:48 -05:00
Leandro Pereira
f5f95ee3a9 kernel: sem: Ensure that initial count is lesser or equal than limit
Ensure this value during static initialization (with build assertions),
and dynamic initializations through system calls.

If initial count is larger than the limit, it's possible for the count
to wraparound, causing locking issues.

Expanding the BUILD_ASSERT() macros after declaring a k_sem struct in
K_SEM_DEFINE() is necessary to support cases where a semaphore is
defined statically.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:04:36 +05:30
Leandro Pereira
05169a02ce toolchain: common: Allow multiple uses of BUILD_ASSERT() in same scope
BUILD_ASSERT() was always defining a type with the name
__build_assert_failure, causing issues if more than one assertion were
used in the same scope.

Also, use an enum instead of a typedef to avoid (possibly spurious)
warnings such as these:

  variably modified ‘__build_assert_failure1’ at file scope [-Werror]

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:04:36 +05:30
Leandro Pereira
666274fa60 toolchain: gcc: Only use _Static_assert if building with C11
Zephyr currently builds as C99, whereas _Static_assert is a C11
feature.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:04:36 +05:30
Leandro Pereira
d9ac1d4b4a warnings: Disable "unused-local-typedefs" compiler warning
This is required to have BUILD_ASSERT() from toolchain/common.h to
work without issuing a warning.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:04:36 +05:30
Leandro Pereira
ae7911cce0 arch: x86: segmentation: Remove unused _far_call() and _far_jump()
These functions were not used throughout the Zephyr code base, and
as such has been removed.  They can be reinstated if there's a need,
but will need to be adapted to use retpolines when CONFIG_RETPOLINE
is set.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:00:01 +05:30
Leandro Pereira
16472cafcf arch: x86: Use retpolines in core assembly routines
In order to mitigate Spectre variant 2 (branch target injection), use
retpolines for indirect jumps and calls.

The newly-added hidden CONFIG_X86_NO_SPECTRE flag, which is disabled
by default, must be set by a x86 SoC if its CPU performs speculative
execution.  Most targets supported by Zephyr do not, so this is
set to "y" by default.

A new setting, CONFIG_RETPOLINE, has been added to the "Security
Options" sections, and that will be enabled by default if
CONFIG_X86_NO_SPECTRE is disabled.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:00:01 +05:30
Andy Ross
8a4b2e8cf2 kernel, posix: Move ready_one_thread() to scheduler
The POSIX layer had a simple ready_one_thread() utility.  Move this to
the scheduler API (with a prepended underscore -- it's an internal
API) so that it can be synchronized along with the rest of the
scheduler.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
22642cf309 kernel: Clean up _unpend_thread() API
Almost everywhere this was called, it was immediately followed by
_abort_thread_timeout(), for obvious reasons.  The only exceptions
were in timeout and k_timer expiration (unifying these two would be
another good cleanup), which are peripheral parts of the scheduler and
can plausibly use a more "internal" API.

So make the common case the default, and expose the old behavior as
_unpend_thread_no_timeout().  (Along with identical changes for
_unpend_first_thread) Saves code bytes and simplifies scheduler
surface area for future synchronization work.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
5792ee6da2 kernel/mutex: Clean up k_mutex_unlock()
Recent changes to the scheduler API means we can simplify this
further: move the assignment to mutex->owner outside the if(), which
removes the need to have an else clause (which just set that field to
NULL when the new_owner was already NULL); and we can likewise move
the irq_unlock() outside the block.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
d89249dbc5 pthread: Respect cooperative thread schedulign in condition variable
Originally, pthread_cond_signal() was written to yield even in
circumstances where the current thread is at a cooperative priority
and would not expect to be context-switched out until it blocks.  This
makes sense, as in most cases you want the newly signaled thread to
get a chance to run as soon as possible.

On further reflection (and also because it complicates the scheduler),
I think that's wrong.  The point to cooperative scheduling is that it
allows the cooperative code to make synchronization assumptions about
exactly when it might yield to other threads, and having arbitrary
APIs be "preemption points" like this complicates that analysis
significantly.

Use _reschedule() like other code does.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
3f55dafebc kernel: Deprecate k_thread_cancel() API
The only difference between this call and k_thread_abort() (beyond
some minor performance deltas) is that "cancel" will act as a noop in
cases where the thread has begun execution and will return an error.
"Abort" always succeeds, of course.  That is inherently racy when used
as a "stop the thread" API: there's no way in general (or at all in
SMP situations) to know that you're calling this function "early
enough" to catch the thread before it starts.

Effectively, all k_thread_cancel() gives you that k_thread_abort()
doesn't is an indication about whether or not a thread has started.
There are many other ways to get that information that don't require
dangerous kernel APIs.

Deprecate this function.  Zephyr's own code never used it except for
its own unit test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
15cb5d7293 kernel: Further unify _reschedule APIs
Now that other work has eliminated the two cases where we had to do a
reschedule "but yield even if we are cooperative", we can squash both
down to a single _reschedule() function which does almost exactly what
legacy _Swap() did, but wrapped as a proper scheduler API.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
0447a73f6c kernel: include cleanup
Recent changes have eliminated most use of _Swap() in favor of higher
level scheduler abstractions.  We can remove the header too.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
e0a572beeb kernel: Refactor, unifying _pend_current_thread() + _Swap() idiom
Everywhere the current thread is pended, the code is going to have to
do a _Swap() soon afterward, yet the scheduler API exposed these as
separate steps.  Unify this pattern everywhere it appears, which saves
some code bytes and gets _Swap() out of the general scheduler API at
zero cost.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
8606fabf74 kernel: Scheduler refactoring: use _reschedule_*() always
There was a somewhat promiscuous pattern in the kernel where IPC
mechanisms would do something that might effect the current thread
choice, then check _must_switch_threads() (or occasionally
__must_switch_threads -- don't ask, the distinction is being replaced
by real English words), sometimes _is_in_isr() (but not always, even
in contexts where that looks like it would be a mistake), and then
call _Swap() if everything is OK, otherwise releasing the irq_lock().
Sometimes this was done directly, sometimes via the inverted test,
sometimes (poll, heh) by doing the test when the thread state was
modified and then needlessly passing the result up the call stack to
the point of the _Swap().

And some places were just calling _reschedule_threads(), which did all
this already.

Unify all this madness.  The old _reschedule_threads() function has
split into two variants: _reschedule_yield() and
_reschedule_noyield().  The latter is the "normal" one that respects
the cooperative priority of the current thread (i.e. it won't switch
out even if there is a higher priority thread ready -- the current
thread has to pend itself first), the former is used in the handful of
places where code was doing a swap unconditionally, just to preserve
precise behavior across the refactor.  I'm not at all convinced it
should exist...

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Andy Ross
b481d0a045 kernel: Allow pending w/o wait_q for scheduler API cleanup
The mailbox code was written to use the _remove_thread_from_ready_q()
API directly, which would be good to get out of the scheduler internal
API.  What it really wanted to do is to mark a thread "PENDING"
without actually adding it to a wait queue, which is sane enough (the
message stores the "thread to wake up on receipt" handle).

So allow that naturally in the _pend_thread() API by passing a NULL
wait_q.  Really a wait_q needn't be the only way a thread can block.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-24 03:57:20 +05:30
Ulf Magnusson
64eb789ff5 doc: Clarify format for CONF_FILE
The documentation doesn't give the format for listing multiple files in
CONF_FILE (space-separated list).

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 03:39:12 +05:30
Ulf Magnusson
303484aa2f doc: Clarify application configuration
The current application configuration documentation makes it a bit
unclear that configuration files are merged. Rewrite the documentation
to explicitly talk about merging, which I think is less confusing.

Remove the following section from the introduction as well, as I think
it might make people wonder how they can have an existing kernel
configuration when they haven't created one. The updated configuration
section (which the introduction now has a forward reference to)
clarifies the zephyr/.config bit anyway.

    If omitted, the application's existing kernel configuration option
    values are used; if no existing values are provided, the kernel's
    default configuration values are used.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 03:38:20 +05:30
Ulf Magnusson
1ae99f02f1 doc: Improve Kconfig interface description
Pressing Y/N to configure boolean configuration symbols probably won't
be supported in the upcoming Python menuconfig implementation, and Space
is much smoother anyway. '?' is smoother than tabbing to '< Help >' too.

Also remove this part, which I couldn't make sense of:

    When a non-default entry is selected for options that are
    non-numerical, an asterisk :kbd:`*` appears between the square
    brackets in the display. There is nothing added added the display
    when you select the option's default.

[*] just means the current symbol value is 'y'.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 03:36:12 +05:30
Leandro Pereira
81f4b11126 include: toolchain: common: Remove deprecated __stack macro
This macro has been deprecated in favor of K_DECLARE_STACK; should have
been removed by 1.11.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-23 10:11:08 -07:00
Håkon Øye Amundsen
597517c79f boards: dts: Add i2c to nrf5X_pcaX board dts.
Fixes #7137

Enables the i2c drivers for these boards.
Required to enable i2c with these boards.
Tested samples/bluetooth/beacon for nrf52_pca10040
with i2c enabled.

Parameters used for enabling i2c:
CONFIG_I2C=y
CONFIG_I2C_0=y
CONFIG_I2C_NRF5=y
CONFIG_I2C_NRF5_0_GPIO_SCL_PIN=6
CONFIG_I2C_NRF5_0_GPIO_SDA_PIN=7

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.com>
2018-04-23 09:07:07 -05:00
Ioannis Glaropoulos
0b7c964f5f arch: arm: clear BFSR sticky bits in ARMv8-M Mainline MCUs
Contrary to ARMv7-M, in ARMv8-M MCUs with the Main Extension,
BusFault Status Register bits are sticky and must be cleared.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-04-23 08:40:15 -05:00
Paul Sokolovsky
1d1db121d3 tests: socket: udp: Tighten up error checking
Add zassert's to check results of intermediate operations like
socket/bind/connect. Also, use symbolic expressions instead of
constants like 4 (for data length).

Coverity-Id: 182765, 182767
Fixes: #6104, #6106

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-23 15:26:43 +03:00
Leandro Pereira
541c3cb18b kernel: sched: Fix validation of priority levels
A priority value cannot be simultaneously higher than the maximum
possible value and smaller than the minimum value.  Rewrite the
_VALID_PRIO() macro as a function so that this if either of these
invariants are invalid, the priority is considered invalid.

Coverity-CID: 182584
Coverity-CID: 182585
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-21 08:39:42 -07:00
8f7e5bd0a5 uart_pipe: re-work the RX function to match the API and work with USB.
include/uart.h says that an interrupt may be an edge or a level.
Re-work the uart_pipe interrupt handler to support both.  This makes
uart_pipe work with the USB CDC ACM driver.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-21 08:37:54 -07:00
Iván Sánchez Ortega
e618608fca doc: Expand info about troubleshooting ModemManager
Expand information about the ModemManager issues (spurious AT commands)
and instructions on adding Segger USB devices to the ModemManager
blacklist.

Signed-off-by: Iván Sánchez Ortega <ivan@sanchezortega.es>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-21 07:05:38 -07:00
qianfan Zhao
b7862eb832 hid: core: truncated wLength if it doesn't match report descriptor size
Some buggy system may be pass a larger wLength when it try read
HID report descriptor, although we had already tell it the right
descriptor size.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-04-21 07:01:36 -07:00
Diego Sueiro
140daa2f27 sanitycheck: add min_flash option for 32K devices
Following tests were failing on a microcontroller with 32KB flash:
    test-mbedtls
    kernel.common

The min_flash option has been added in the test case yaml files.

Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
2018-04-21 06:57:38 -07:00
Leandro Pereira
3af88642d2 lib: posix: mqueue: Minor formatting cleanups
Remove double spaces before pointer asterisks in some places.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-21 06:56:27 -07:00
Leandro Pereira
2a5fb57e95 lib: posix: mqueue: Do not dereference mqd pointer before null check
The compiler can remove the NULL check since the dereference happens
before it (and assume that the pointer is always valid).

Coverity-Id: 185281

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-21 06:56:27 -07:00
David B. Kinder
a380dce018 doc: fix links to mailing lists
A recent LF change to the Zephyr mailing list hosting software changed
the mailing list names and links to the message archives.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-04-21 06:55:46 -07:00
David B. Kinder
b57ac8a2ff doc: improve Sphinx search results output
The search result from Sphinx displays raw ReST file snippets showing
the context of the search hit.  While we could generate text versions of
the ReST files just for the search results, it would potentially double
the time to generate docs (run once to generate txt files, run again to
generate HTML).

Instead, this patch does a poor man's cleanup of the ReST markup on the
fly when the search summary snippets are written out.  Not perfect, but
looks much better.

It does expose a problem that some of our ReST content is not actually
written out into a .rst file. Content that's dynamically generated by
extensions, such as the sample code from zephyr-app-commands, can
yield a search result hit, but there's no hits in the .rst file content
itself.

Line 552-558 are the modified lines from the Sphinx-provided
searchtools.js that does the pattern match/replace.

Addresses: #7032

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-04-21 06:54:35 -07:00
Leandro Pereira
2c58de5735 ext: lib: crypto: Update mbedTLS to 2.8.0
This updates mbedTLS to 2.8.0, which fixes CVEs 2018-0488 and
2048-0487, that affects 2.7.0.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-21 05:44:24 -07:00
Tomasz Bursztyka
a09a0b2c49 sensors/lsm5dsl: Fix SPI API usage
The driver was not moved to the recent SPI API changes.

Fixes #7009

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-21 05:42:59 -07:00
Sebastian Bøe
558406932b doc: win: Invoke pip3 instead of pip to be safe
It has been observed that users might "default" to Python2 and pip
will therefore install packages for the wrong Python. pip3 appears to
always be installed when Python3 is installed, so we invoke pip3
instead of pip2 to be safe.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-21 05:42:04 -07:00
Iván Sánchez Ortega
b35274a4e9 samples: usb: webusb: Prettify binary object store descriptor
This is a simple cosmetic change. Each field in the BOS (Binary
Object Store) descriptor has a comment, to understand it better.

Signed-off-by: Iván Sánchez Ortega <ivan@sanchezortega.es>
2018-04-20 21:06:11 -07:00
Andrei Emeltchenko
d665e12833 usb: hci_usb: Correct README
Correct README file

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko
fc5134b03f usb: hci_usb: Fix test name
Correct test name

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00