Commit graph

41120 commits

Author SHA1 Message Date
Michael Scott
74bb1a9be9 drivers: modem: cmd_handler: remove extra comment
Remove extra comment left over from prototype driver.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
44e977c467 drivers: modem: cmd_handler: save 1 char for NUL in match_buf
For parsing purposes we need to add a NUL to the end of match_buf.

When there is no CR/LF in the incoming rx bufs then we fill match_buf
to its max size.  This ended up with an off by one error which was
overflowing match_buf into the following data.

To account for this, let's fill the buffer to size - 1 so that we
leave room for the NUL at the end and stop corrupting data.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
f4b49fbb90 drivers: modem: cmd_handler: cleanup parse_params()
- rename buf_len to match_len for clarity
- pass in modem_cmd_handler_data instead of buffer pointer directly
- buffer adjustments for the command length are kept inside
  parse_params()

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
889fc85f67 drivers: modem: socket: add is_connected field to modem_socket
Let's add a field which the drivers can use to keep track of whether
they are connected or not.  This will normally be enabled / disabled
in the socket connect and URC for socket close notify.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
25ce3bf3eb drivers: modem: socket: add modem_socket_next_packet_size
Let's hide the internals of sock->packet_sizes[] by adding a function
which returns the size of the next waiting packet.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
e23ada9d4a drivers: modem: socket: reset is_polled in modem_socket_put()
Let's make sure is_polled gets reset when we reset the socket.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
8908c61bcc drivers: modem: socket: add wait_data and data_ready functions
Let's hide the internals of the modem_socket's sem_data_ready and
poll handling with 2 new functions:
- modem_socket_wait_data: take a semaphore and wait for data
- modem_socket_data_ready: give back the data ready semaphore and
  unblock poll() users

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
987837ecd8 drivers: modem: socket: introduce locking
Add lock behavior for functions in modem_socket, to prevent race
conditions when performing socket data maintenance.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Michael Scott
d4b8b5fcf2 drivers: modem: socket: allow partial packet reads
Let's allow protocols to request portions of the current packet.

This is seen in the MQTT library when parsing headers for the type
and variable length of the packet.

This fixes basic parsing done in the MQTT library and probably others.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-02-10 12:29:41 +02:00
Vinayak Kariappa Chettimada
8a3a4bb589 Bluetooth: controller: split: Fix PHY update tx pause
Data transmission was paused when PHY update request control
PDU was enqueued in ULL. If there was pending data PDU in
ULL that was not enqueued towards LLL, this caused
transmission to stall.

Move the tx pause due to PHY update request/response being
enqueued to pre_tx_ack callback, this way all pending PDUs
in ULL is enqueued to LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-10 10:22:42 +01:00
Anas Nashif
ad9883a15b CODEOWNERS: add owner for .github/
Owner for various github related files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-09 11:55:56 -05:00
Anas Nashif
3b625aaaa9 ci: add license check using github actions
Use Github for license checks.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-09 11:55:56 -05:00
Johan Hedberg
e089906b33 release: Zephyr 2.2.0-rc1
Bumped to v2.2.0-rc1

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-02-08 20:29:29 +02:00
Kumar Gala
28da5fdde7 sam0: flash: Fix build issue reported by flash_shell sample
The DT_FLASH_DEV_NAME define used by the sample was set to a define
symbol that was never generated.  Change it to use
DT_INST_0_ATMEL_SAM0_NVMCTRL_LABEL on the sam0 family of SoCs that
had this issue.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-08 10:29:28 -06:00
Kumar Gala
b1de748948 github: Rename GitHub workflow action
GitHub checks need to be uniquely named, and 'Documentation' conflicts
with the ci-tool name.  Rename this while we are running both so the
names don't conflict.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-08 09:05:50 -06:00
Sebastian Bøe
f17428a009 cmake: Have gperf be opt-out instead of mandatory
gperf is only used when CONFIG_USERSPACE is enabled. Users that use
arch's that don't support CONFIG_USERSPACE, or happen to not never
enable CONFIG_USERSPACE should not be artificially required to install
gperf.

This change makes gperf optional by moving it's presence-check to it's
usage.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-02-08 09:13:45 -05:00
Andrew Boie
768a30c14f x86: organize 64-bit ESF
The callee-saved registers have been separated out and will not
be saved/restored if exception debugging is shut off.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-08 08:51:43 -05:00
Andy Ross
7353c7f95d kernel/userspace: Move syscall_frame field to thread struct
The syscall exception frame was stored on the CPU struct during
syscall execution, but that's not right.  System calls might "feel
like" exceptions, but they're actually perfectly normal kernel mode
code and can be preempted and migrated between CPUs at any time.

Put the field on the thread struct.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Andy Ross
8153144de0 kernel/fatal: Fatal errors must not be preempted
The code underneath z_fatal_error() (which is usually run in an
exception context, but is not required to be) was running with
interrupts enabled, which is a little surprising.

The only bug present currently is that the CPU ID extracted for
logging is subject to a race (i.e. it's possible but very unlikely
that such a handler might migrate to another CPU after the error is
flagged and log the wrong CPU ID), but in general users with custom
error handlers are likely to be surprised when their dying threads
gets preempted by other code before they can abort.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Andy Ross
4b670bd4f5 tests/kernel/smp: current CPU is not atomic
This test was whiteboxing the _current_cpu pointer to extract the CPU
ID.  That's actually racy: the thread can be preempted and migrated to
another CPU between the _current_cpu expression and the read of the ID
field.  Do it right.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Andy Ross
0e32f4dab0 arch/x86_64: Save RFLAGS during arch_switch()
The context switch implementation forgot to save the current flag
state of the old thread, so on resume the flags would be restored to
whatever value they had at the last interrupt preemption or thread
initialization.  In practice this guaranteed that the interrupt enable
bit would always be wrong, becuase obviously new threads and preempted
ones have interrupts enabled, while arch_switch() is always called
with them masked.  This opened up a race between exit from
arch_switch() and the final exit path in z_swap().

The other state bits weren't relevant -- the oddball ones aren't used
by Zephyr, and as arch_switch() on this architecture is a function
call the compiler would have spilled the (caller-save) comparison
result flags anyway.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Andy Ross
eefd3daa81 kernel/smp: arch/x86_64: Address race with CPU migration
Use of the _current_cpu pointer cannot be done safely in a preemptible
context.  If a thread is preempted and migrates to another CPU, the
old CPU record will be wrong.

Add a validation assert to the expression that catches incorrect
usages, and fix up the spots where it was wrong (most important being
a few uses of _current outside of locks, and the arch_is_in_isr()
implementation).

Note that the resulting _current expression now requires locking and
is going to be somewhat slower.  Longer term it's going to be better
to augment the arch API to allow SMP architectures to implement a
faster "get current thread pointer" action than this default.

Note also that this change means that "_current" is no longer
expressible as an lvalue (long ago, it was just a static variable), so
the places where it gets assigned now assign to _current_cpu->current
instead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Peter Bigot
e11262c13e tests: lib: os: onoff: address Coverity complaint
Coverity believes that a field is null when it isn't.  Duplicate the
assert from 20 lines up in hopes it learns better.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-08 08:40:28 -05:00
Ulf Magnusson
eddd98f811 kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.

There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.

The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).

Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.

Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.

Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.

The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.

(Everything above is true for choices, menus, and comments as well.)

Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 08:32:42 -05:00
Kumar Gala
1f0089ff45 boards: qemu_cortex_r5: Reduce memory footprint when running
When running in qemu we utilize fdt-single_arch-zcu102-arm.dtb to
configure qemu.  The current dtb requests just under 2G of memory in the
simulation, but we don't really need this and it impacts running on low
memory VMs.

So remove DDR ddr_bank2 and reduce ddr_bank1_3 from 1G - 256K to
128M - 256K in size.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-08 08:31:48 -05:00
Markus Fuchs
29630cc7fc samples: crypto: Add AES-GCM sample
Add sample for AES Galois/Counter Mode (GCM) of operation with a MACsec
GCM-AES test vector.
Also improve existing code by declaring expected ciphertext arrays as
constant.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2020-02-08 13:40:33 +02:00
Markus Fuchs
ad8f011dcf drivers: crypto: crypto_mtls_shim: Add AES-GCM support
Add support for AES Galois/Counter Mode (GCM) of operation to the
mbed TLS shim driver.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2020-02-08 13:40:33 +02:00
Markus Fuchs
e1948ae3a1 include: crypto: Add Galois/Counter Mode (GCM) support
Add support for AES Galois/Counter Mode of Operation to the Crypto API.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2020-02-08 13:40:33 +02:00
Mikkel Jakobsen
4adc40889d drivers: spi: spi_mcux_dspi: fix missing context unlock on busy bus
Error codes from DSPI_MasterTransferNonBlocking are now handled in
tranceive to ensure that the context is unlocked when an busy bus
is detected.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2020-02-08 11:41:21 +02:00
Alex Porosanu
55eb4a11cd samples: bluetooth: add missing VEGABoard overlays
The default DTS of VEGABoard does not enable the necessary nodes
for the SW LL to function; as such an overlay is needed for
each sample that is intended to be run on the VEGABoard. Some
of the samples miss this overlay so this patch adds them.

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-02-08 10:23:49 +02:00
Nicholas Lowell
b096fcc476 pthread: wrap header with extern C
Other posix headers were already wrapped, this one seems
to have been missed so it can be compiled with C++

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-02-08 10:21:01 +02:00
Dominik Ermel
dab67c35f1 settings: settings_register static table does not need mutex
It is not needed to protect static table of handlers, with mutex,
as there is no possibility that there will be anything added to the
table at runtime.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-02-08 10:07:38 +02:00
Andrew Boie
efc5fe07a2 kernel: overhaul unused stack measurement
The existing stack_analyze APIs had some problems:

1. Not properly namespaced
2. Accepted the stack object as a parameter, yet the stack object
   does not contain the necessary information to get the associated
   buffer region, the thread object is needed for this
3. Caused a crash on certain platforms that do not allow inspection
   of unused stack space for the currently running thread
4. No user mode access
5. Separately passed in thread name

We deprecate these functions and add a new API
k_thread_stack_space_get() which addresses all of these issues.

A helper API log_stack_usage() also added which resembles
STACK_ANALYZE() in functionality.

Fixes: #17852

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-08 10:02:35 +02:00
Andrzej Puzdrowski
f02fdd2d7b manifest: mcuboot version with fixed USB recovery
Since zephyrproject-rtos/zephyr#20375
Need to enable USB by the mcuboot code explicitly.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-02-08 10:01:47 +02:00
Daniel Leung
52993afd62 Revert "arch: xtensa: Use reset-vector.S in booloader code"
This reverts commit 9987c2e2f9
which spills SoC configs into architecture files and is not
exactly desirable. So revert it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-02-08 10:01:24 +02:00
Daniel Leung
db2eb23bd2 boards: up_squared_adsp: provide start address for bootloader
Commit 9987c2e2f9 spills SoC configs
into architecture files which is less desirable. This provides
the jump address for bootloader, and modifies the bootloader to
jump to __start defined in reset-vector.S. This prepares for
that commit to be reverted.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-02-08 10:01:24 +02:00
Daniel Leung
d93fd37ef6 boards: up_squared_adsp: provide default memctl in linker script
Both memctl_default.S and memerror-vector.S (inside
arch/xtensa/core/startup) refer to XCHAL_CACHE_MEMCTL_DEFAULT which
is not defined anywhere. The linker script for intel_apl_adsp SoC
provides default values, but not the bootloader linker script. So
provide the same default value in the bootloader linker script as
in the SoC linker script.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-02-08 10:01:24 +02:00
Alexey Brodkin
2d79dc3bcd kconfig: Make BUILD_NO_GAP_FILL independent
Even though it looks logical to not expose BUILD_NO_GAP_FILL
when we don't expect to use objcopy for creation of .bin, .hex etc
in reality generation of at least zephyr.hex happens if one wants
to use openocd runner, see CMakeLists.txt:
---------------------------->8----------------------
if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
  set(out_hex_cmd    "")
  set(out_hex_byprod "")
  set(out_hex_sections_remove
    .comment
    COMMON
    .eh_frame
    )
  bintools_objcopy(
    RESULT_CMD_LIST    out_hex_cmd
    RESULT_BYPROD_LIST out_hex_byprod
    STRIP_ALL
    GAP_FILL           ${GAP_FILL}
    TARGET_OUTPUT      "ihex"
    SECTION_REMOVE     ${out_hex_sections_remove}
    FILE_INPUT         ${KERNEL_ELF_NAME}
    FILE_OUTPUT        ${KERNEL_HEX_NAME}
    )
  list(APPEND
    post_build_commands
    ${out_hex_cmd}
    )
  list(APPEND
    post_build_byproducts
    ${KERNEL_HEX_NAME}
    ${out_hex_byprod}
    )
endif()
---------------------------->8----------------------

So if there's a good reason to disable gap filling
(like funny memory map wit huuuuge holes) let's keep that opportunity
instead of relying on sanity of all the other code.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-08 09:59:20 +02:00
Ulf Magnusson
b9270c388d kconfig: Remove redundant SPI_DW dep on SPI_DW_ACCESS_WORD_ONLY
This symbol is already defined within an 'if SPI_DW'.

Flagged by https://github.com/zephyrproject-rtos/ci-tools/pull/128.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 09:58:33 +02:00
Ulf Magnusson
de42aea18f kconfig/cmake: Check that one of the CONFIG_<arch> symbols is set
All SoCs must now 'select' one of the CONFIG_<arch> symbols. Add an
ARCH_IS_SET helper symbol that's selected by the arch symbols and
checked in CMake, printing a warning otherwise.

Might save people some time until they're used to the new scheme.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 00:50:08 -06:00
Ulf Magnusson
c5839f834b kconfig: Remove assignments to CONFIG_<arch> syms and hide them
All board defconfig files currently set the architecture in addition to
the board and the SoC, by setting e.g. CONFIG_ARM=y. This spams up
defconfig files.

CONFIG_<arch> symbols currently being set in configuration files also
means that they are configurable (can be changed in menuconfig and in
configuration files), even though changing the architecture won't work,
since other things get set from -DBOARD=<board>. Many boards also allow
changing the architecture symbols independently from the SoC symbols,
which doesn't make sense.

Get rid of all assignments to CONFIG_<arch> symbols and clean up the
relationships between symbols and the configuration interface, like
this:

1. Remove the choice with the CONFIG_<arch> symbols in arch/Kconfig and
   turn the CONFIG_<arch> symbols into invisible
   (promptless/nonconfigurable) symbols instead.

   Getting rid of the choice allows the symbols to be 'select'ed (choice
   symbols don't support 'select').

2. Select the right CONFIG_<arch> symbol from the SOC_SERIES_* symbols.
   This makes sense since you know the architecture if you know the SoC.

   Put the select on the SOC_* symbol instead for boards that don't have
   a SOC_SERIES_*.

3. Remove all assignments to CONFIG_<arch> symbols. The assignments
   would generate errors now, since the symbols are promptless.

The change was done by grepping for assignments to CONFIG_<arch>
symbols, finding the SOC_SERIES_* (or SOC_*) symbol being set in the
same defconfig file, and putting a 'select' on it instead.

See
https://github.com/ulfalizer/zephyr/commits/hide-arch-syms-unsquashed
for a split-up version of this commit, which will make it easier to see
how stuff was done. This needs to go in as one commit though.

This change is safer than it might seem re. outstanding PRs, because any
assignment to CONFIG_<arch> symbols generates an error now, making
outdated stuff easy to catch.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 00:50:08 -06:00
Kumar Gala
b81eec951b sanitycheck: make pyserial optional
We only need pyserial python module if we are doing device testing.
Treat it similar to how we treat tabulate module.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 19:48:24 -06:00
Kumar Gala
d62dfe8d0e tracing: usb: Fix build issues.
1. Remove usb_descriptor.h as tracing_backend_usb.c doesn't have access
   to that include file.
2. Make TRACING_BACKEND_USB depend on USB being enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 20:06:17 -05:00
Kumar Gala
63fddba8d1 ci: github: doc: Add a GH workflow to test build the docs
This github workflow will build the html docs on a pull request or push.
This is similar to the current ci-tools 'Documentation' check.  One
difference is this version produces a GH artifact of the html docs
instead of posting it to S3.  The artifact is a tarball that is than
zip'd (not gzip).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 18:10:15 -06:00
Zide Chen
d0126a037d boards/x86/acrn: build it in x86_64 mode and switch to X2APIC
- added CONFIG_X86_64 since ACRN hypervisor supports x86_64 capable
  platforms only.
- removed CONFIG_SET_GDT: Zephyr doesn't support it in x86_64, and ACRN
  doesn't require the guests to setup GDT during boot time.
- added CONFIG_X2APIC, which is preferred by ACRN, which makes it
  possible to pass through local APIC to the guests.

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-07 14:14:53 -08:00
Zide Chen
c698669f4e arch/x86_64: make sysapic.h available for x86_64 as well
sysapic.h is needed for x86_64 if CONFIG_LOAPIC is defined.

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-07 14:14:53 -08:00
Alexander Wachter
f590d4fadb drivers: lora: build with newlib
The loramac-node library uses math functions from math.h that
are not included in the minimal lib.
This commit changes the samples project config to always build
with newlib and adds a dependency to newlib.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-07 16:00:47 -06:00
Alex Porosanu
03892c1571 Bluetooth: controller: split: openisa: fix missing include
If CONFIG_BT_CTLR_CONN_RSSI is enabled, then lll_conn.h should
be included as well. Otherwise, struct lll_conn is unknown
at the compile unit level. This has been reproduced by
compiling the hci_uart sample, where the following error occurs:

lll_adv.c: In function 'isr_rx_pdu':
lll_adv.c:722:13: error: dereferencing pointer to incomplete
                         type 'struct lll_conn'
    lll->conn->rssi_latest =  radio_rssi_get();
             ^~

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-02-07 15:52:26 -06:00
Ulf Magnusson
7b52475720 kconfig: Remove duplicated ARM_MPU dependency on CUSTOM_SECTION_ALIGN
CUSTOM_SECTION_ALIGN is already defined within an 'if ARM_MPU', so it
does not need a 'depends on ARM_MPU'.

Flagged by https://github.com/zephyrproject-rtos/ci-tools/pull/128.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-07 15:50:33 -06:00
Alex Porosanu
1a7a0dd494 samples: bluetooth: hci_uart: add VEGABoard configuration
VEGABoard BLE controller implementation supports HCI over UART;
as such enable this configuration when building the hci_uart
sample.

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-02-07 15:49:35 -06:00