Commit graph

41120 commits

Author SHA1 Message Date
David B. Kinder
b48c7fc9c1 doc: add note about force pushes to contrib guide
Let folks know that using amend and force pushes for adding review
changes is the recommend method for contributing to the project, but it
can cause some unexpected behavior from GitHub.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-03-13 16:08:08 -07:00
Jukka Rissanen
6346cc1a9e doc: net: Add SNTP API documentation
Documentation for Simple Network Time Protocol library was
missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 15:37:02 -07:00
Ioannis Glaropoulos
cac20e91d8 kernel: userspace: correct documentation for Z_SYSCALL_MEMORY_ macros
Corrections in the documentation of arguments in
Z_SYSCALL_MEMORY, Z_SYSCALL_MEMORY_READ, and
Z_SYSCALL_MEMORY_WRITE macros.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-03-13 15:36:15 -07:00
Ioannis Glaropoulos
c686dd5064 kernel: enhance documentation of z_arch_buffer_validate
This commit enhances the documentation of z_arch_buffer_validate
describing the cases where the validation is performed
successfully, as well as the cases where the result is
undefined.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-03-13 15:36:15 -07:00
Kumar Gala
5e26c27fb7 boards: rv32m1_vega: Enable building with Zephyr toolchain
Now that we have SDK 0.10.0 we can enable building this board with the
Zephyr toolchain.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Kumar Gala
1230ae1e63 scripts/sanitycheck: Add 'vectors' section to whitelist
Add 'vectors' to the whitelisted list of linker sections.  This is
needed by the openisa_rv32m1 SoC.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Kumar Gala
6ef55b0942 tests: kernel: context: Fix build issue with RV32M1_LPTMR_TIMER
We needed to add support for the RV32M1_LPTMR_TIMER to the test so its
knows what the IRQ of the timer is.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Kumar Gala
aa15ae94a9 soc: riscv32: openisa_rv32m1: Link .srodata section
Apply a similar fix to commit 0289a410ba
to the openisa_rv32m1 linker script for handling .srodata sections.

Otherwise we get oprhan read-only data section.  Fix this by adding
the .srodata section to the RISC-V linker script.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Wayne Ren
6704b82d5b arch: arc: implement stack pointer random
implement the stack pointer random for CONFIG
_STACK_POINTER_RANDOM

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-03-13 14:52:50 -07:00
Kumar Gala
0033448f10 net: lwm2m: Fix minor bug with setting flags
Looks like we are setting some bit flags so we should use '|' not '||'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 16:28:58 -05:00
Jukka Rissanen
e7107ba562 samples: net: can: Readme file was missing
The socket CAN application was missing a README.rst file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 15:57:48 -05:00
Daniel Leung
af10d16a08 linker: sort sections by alignment
This turns on the linker flag to sort sections by alignment
in decreasing size of symbols. This helps to minimize
padding between symbols.

This also adds the linker options to sort common symbols by
alignment in descending to minimize the need for padding.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-13 15:54:29 -05:00
Daniel Leung
8328d6df76 linker: nios2: align rodata section
During testing with sorting section by alignment with qemu_nios2,
if rodata section is not aligned on 4-byte boundary and its size
not of multiple of 4, it would never boot correctly. So align
the rodata here. This is in preparation to enable the linker
option to sort sections by alignment.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-13 15:54:29 -05:00
Andy Ross
bbe6fa04b5 arch/x86_64: Flag xuk shared page volatile
The shared page is inherently used in multiprocessor contexts where
the compiler optimizer can trip us up (specifically, a spin on
num_active_pus was being hoisted out of the loop on some gcc's).  Put
the volatile declartion into the struct pointer itself instead of
relying on the code to get it right.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
1781ec9d2f soc/x86_64: board/x86_64/qemu_x86_64: Enable 2-processor SMP as default
We can turn this off in application code, but the default should be
SMP.

Oddball note: the SMP setting is in the soc layer and not arch, even
though I think it would be better there.  We don't actually have a
per-arch defconfig file included by kconfig.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
05c1263ebd tests/kernel/smp: Clean up "guess waiting" on SMP thread exit
The various tests would all do a "wait for threads to exit" step
before checking the results, but this was implemented with a simple
busy wait that turns out to need careful tuning (because there was
busy waiting in the threads).

Rather than try to synchronize this, white box the issue (it's a low
level SMP test, after all) by spinning on the thread states directly
watching for the kernel to flag them dead.  The downside here is that
if the process fails for some reason we'll get a hang and a timeout
reported from sanitycheck and not a synchronous ztest assertion.  But
in return, successful tests run much faster and I don't need to worry
about how to tune them for IPI latency on different platforms.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
829f6639da tests/kernel/smp: Remove test_wakeup_pending_threads case
This case was predicated on a mistake.  The behavior of k_wakeup() has
always been NOT to wake up threads that are "pending" on a wait queue,
only ones blocked on a timeout in k_sleep().  As written, this test
case could never pass.

(Really there's no good reason for that.  It seems reasonable to me to
expect wakeup to work symmetrically, and the docs are sort of
ambiguous on the subject.  But the code in k_wakeup() is clear:
threads flagged pending get an early exit and the call becomes a
noop.)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
ea1c99b11b kernel/sched: Fix k_yield() in SMP
This was always doing a remove/add of the _current thread to the run
queue, which is wrong because in SMP _current isn't in the queue to
remove.  But it went undetected until the recent dlist changes.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
8c1bdda33c kernel/sched: Fix spinlock validation glitch in SMP
In SMP, we are setting the _current pointer while holding the
scheduler spinlock locally, which means that when we try to release it
the validation layer (not the spinlock per se) will scream at us
because the thread that took the lock doesn't match the one releasing
it.

Special case this when validation is enabled.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
f37e0c6e4d kernel/spinlock: Fix race in spinlock validation
The k_spin_lock() validation was setting the new owner of the spinlock
BEFORE the actual lock was taken, so it could race against other
processors trying the same thing.  Split the modification step out
into a separate function that can be called after we affirmatively
have the lock.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
5697dd7980 tests/kernel/smp: Honor TEST_EXTRA_STACKSIZE
There was a test-created thread that wasn't including this.  It's a
huge stack and doesn't overflow (though I thought briefly that it
was), but it's a rule that we need to have that buffer and I'm trying
to fix these as I find them.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
b18685bcf1 kernel/sched: Clean up tracing hooks
The tracing fixes in commit e87193896a ("subsys: debug: tracing: Fix
thread tracing") were... not a readability win.  The point appears to
have been to put a tracing hook immediately before and after the
assignment to the _current pointer.  So do that in an abstracted
function and clean up _get_next_switch_handle() (which is a subtle and
important function already polluted with some unavoidable preprocessor
testing!)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
42ed12a387 kernel/sched: arch/x86_64: Support synchronous k_thread_abort() in SMP
Currently thread abort doesn't work if a thread is currently scheduled
on a different CPU, because we have no way of delivering an interrupt
to the other CPU to force the issue.  This patch adds a simple
framework for an architecture to provide such an IPI, implements it
for x86_64, and uses it to implement a spin loop in abort for the case
where a thread is currently scheduled elsewhere.

On SMP architectures (xtensa) where no such IPI is implemented, we
fall back to waiting on an arbitrary interrupt to occur.  This "works"
for typical code (and all current tests), but of course it cannot be
guaranteed on such an architecture that k_thread_abort() will return
in finite time (e.g. the other thread on the other CPU might have
taken a spinlock and entered an infinite loop, so it will never
receive an interrupt to terminate itself)!

On non-SMP architectures this patch changes no code paths at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
6ed59bc442 kernel/smp: Fix bitrot with the way the SMP "start flag" works
Tickless timers mean that k_busy_wait() won't work until after the
timer driver is initialized, which is very early but not as early as
SMP.  No need for it, just spin.

Also the original code used a stack variable for the start flag, which
racily presumed that _arch_start_cpu() would comes back synchronously
with the other CPU fired up and running right now.  The cleaned up smp
bringup API on x86_64 isn't so perky, so it exposed the bug.  The flag
just needs to be static.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
02a1e21c3d x86_64: Missing a volatile on a struct used for spinning
Before we're initialized and can use proper synchronization, the CPU
initialization path spins on the thread entry function to be non-null.
But the data wasn't tagged volatile, and with gcc 8.2.1 (but not
6.2.0) the optimizer was hoisting the reads to SMP init would spin
forever.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
aed8288196 kernel/sched: Handle aboring _current correctly in SMP
In SMP, _current is not "queued".  (The run queue only stores
unscheduled threads because we can't rely on the head of the list
being _current).  We weren't updating the cache choice, which would
flag swap_ok, so calling k_thread_abort(_current) (for example, when a
thread exits from its entry function) would try to switch back into
the thread and then run off the end of the function.

Amusingly this was more benign than you'd think.  Stumbled on it by
accident.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
0f8bee9c07 kernel/smp: Warning cleanup
When CONFIG_SMP is enabled but CONFIG_MP_NUM_CPUS is 1 (which is a
legal configuration, though a weird one) this static function ends up
being defined but unused, producing a compiler warning.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
cf2879200b arch/x86_64: Add a per-CPU SMP bringup API
The previous scheme where the xuk layer would call out to the to
"fetch" the stack for a SMP CPU at startup was sorta weird, and an
impedance mismatch with Zephyr which has a "start this CPU" call
instead.  It also got broken when x86_64 started launching CPUs
(correctly) on their interrupt stacks instead of a temporary area;
they weren't ready yet when xuk initialization was happening and the
system would deadlock waiting for code that can't run yet to provide a
stack.

Note that this preserves the somewhat quirky behavior that Zephyr's
CPU numbering is just the order in which the SMP CPUs emerge from
initialization and not a hardware ID.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
154c20ce7a cmake/emu: Add qemu SMP flags automatically
No need to do this in arch code, all qemu variants speak the same
command line and the kconfig values we need are easily available.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
0a2d2413e0 drivers/timer/hpet: Add noop SMP initialization function
This is intended to initialize CPU-local timer devices, but HPET is
global so we have nothing to do.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross
c9cba3a032 arch/x86_64: Clean up stack initialization
When this code was written, there was no "stack frame" struct defined.
There is now, so use that for clarity and concision.  Also remove an
obvious comment (I mean, duh, we can put any segment selectors in
those fields we want).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Daniel Leung
212ec9a29a linker: sort app shared mem partition by alignment
If CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT is enabled,
the app shared memory partition may cause waste of memory
due to the need for padding.

For example, tests/subsys/jwt and board mps2_an385:

  z_test_mem_partition: addr 0x20000000, size 52
  z_libc_partition    : addr 0x20000040, size 4
  k_mbedtls_partition : addr 0x20008000, size 32736

    ending at 0x2000ffff, taking up 65536 bytes

With power-of-two size and alignment requirement,
k_mbedtls_partition takes up 32KB memory and needs to be
aligned on 32KB boundary. If the above partitions are
ordered as shown, there needs to be a lot of padding
after z_libc_partition before k_mbedtls_partition can
start. In order to minimize padding, these partitions
need to be sort by size in descending order.

After the changes here,	the partitions are:

  k_mbedtls_partition : addr 0x20000000, size 32736
  z_test_mem_partition: addr 0x20008000, size 52
  z_libc_partition    : addr 0x20008040, size 4

    ending at 0x2000805f, taking up 32864 bytes

With the above example, sorting results in a saving
of 32672 bytes of saving.

Fixes #14121

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-13 18:26:51 +01:00
Daniel Leung
e8a2348fac linker: move app_smem.ld into include/linker
The app_smem.ld is also being used by architectures other than ARM.
So move the linker script out of include/arch/arm and into
include/linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-13 18:26:51 +01:00
Vincent Wan
017446ba20 drivers: wifi: simplelink: Return success when TLS_PEER_VERIFY is set
mqtt_client_tls_connect() calls setsockopt() to set the TLS_PEER_VERIFY
option to require verfication. To enable mqtt, we need to return
success at a minimum when this option is set to 2.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-13 12:06:38 -05:00
Vincent Wan
7816827468 drivers: wifi: simplelink: Fix error handling
The driver is not returning correct error codes when error occurs.
The error handling function is expecting negative input values, but
that is not true for BSD error codes. So I am taking an approach
where I use a function to convert SimpleLink error codes to BSD
error codes, and call slcb_setErrno() to set the errno independently.

Fixes #12745

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-13 12:06:38 -05:00
Ulf Magnusson
9bf05a56e0 mbedtls: kconfig: Remove redundant 'depends on MBEDTLS'
Appears within an 'if MBEDTLS'.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-13 12:00:17 -05:00
Erwan Gouriou
7f84787c13 scripts: fix path issue in push-hook script
series-puh-hook.sh script was pushed with local path
instead of ${ZEPHYR_BASE}.
Fix this.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-13 11:59:38 -05:00
Anthony Kreft
075e130843 boards: nucleo_l053r8: add clock ticks
Add CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 to nucleo_l053r8_defconfig.
All STM32 boards seem to have this defined.
Makes samples with ksleep work properly.

Signed-off-by: Anthony Kreft <anthony.kreft@gmail.com>
2019-03-13 11:59:09 -05:00
Alberto Escolar Piedras
319caa25e0 uart: native_posix: Fix out of bounds access
Fix an out of bound access in the native_posix uart driver,
when generating the string to autoattach a terminal to the UART.
(The space for the null termination was missing)

Fixes: #14401
Coverity issue CID: 195855

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-03-13 11:58:50 -05:00
Alberto Escolar Piedras
448755e622 uart: native_posix: Check fcntl() return value
fcntl() may (very unlikely) fail when setting the new pseudoterminal
to non-blocking.
Let's check for this condition, handle it, and in the process
silence a coverity issue.

Fixes #14396
Coverity CID: 195872

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-03-13 11:58:26 -05:00
Paweł Zadrożniak
79dc1feeb3 drivers: usb: nordic: Fix for events when cable is detached
When user disconnects the USB cable, peripheral should be
immediately disabled, howewer a delay may occur when driver
events are processed from a workqueue or higher-priority
thread/ISR is active. This may lead to a fake resume/reset
event (peripheral-specific behavior). This fix drops such
events when cable is detached.

Fixes #13822

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-03-13 17:35:55 +01:00
Luiz Augusto von Dentz
bcf3d8e16b Bluetooth: GATT: Add BT_GATT_DISCOVER_ATTRIBUTE type
This adds BT_GATT_DISCOVER_ATTRIBUTE which can be used to discover any
type of attribute in a given range.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Luiz Augusto von Dentz
0aa10521f4 Bluetooth: GATT: Document discover types
This documents existing types that can be used with bt_gatt_discover.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Luiz Augusto von Dentz
af61102ae1 Bluetooth: GATT: Skip Characteristic Value when discovering Descriptors
Those are not considered Descriptors and shall be discovered with
use of BT_GATT_DISCOVER_CHARACTERISTIC.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Luiz Augusto von Dentz
76deb657d7 Bluetooth: GATT: Skip certain attributes when discovering descriptors
When discovering descriptor Find Information procedure is used which
does not allow any filtering by the server so it will return all
attributes in the given range including services and characteristics.

Fixes #14265

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Krzysztof Chruscinski
3b27779cf6 tests: drivers: counter: Fix coverity issues
Issues 190937, 190952, 190967, 190983

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-03-13 09:08:55 -05:00
Loic Poulain
df7de7c985 drivers: i2c: mcux_i2c: Fix unexpected I2C start condition
Ensure that no I2C start condition is inserted between messages of
a same transfer, except if explicitely requested (restart flag).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-03-13 09:08:21 -05:00
Loic Poulain
ba0d4d8e92 drivers: i2c: mcux_lpi2c: Fix unexpected I2C start condition
Ensure that no I2C start condition is inserted between messages of
a same transfer, except if explicitely requested (restart flag).

This fix issue with I2C register write functions.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-03-13 09:08:21 -05:00
Sebastian Bøe
755ffed242 cmake: kconfig: Allow user to add custom menuconfig impl.
Out-of-tree Kconfig frontends need to know which environment variables
are exported by Zephyr to Kconfig.

To support this we allow additional Kconfig python frontend targets to
be specified from out-of-tree.

This support was added on request by a third-party with a custom
Kconfig frontend.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-13 14:46:16 +01:00
Carles Cufi
55e12c4233 boards: 96b_carbon: Require BT for NET_L2_BT
Since NET_L2_BT no longer "select"s BT and the rest of required BT
features, enable them within the defconfig file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-03-13 14:26:11 +01:00