Commit graph

41120 commits

Author SHA1 Message Date
Carles Cufi
7f5ae21a6d Bluetooth: tester: Add logging in core handlers
Add warnings when something goes unhandled.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-21 13:42:07 +02:00
Vinayak Kariappa Chettimada
cc468e89d0 Bluetooth: controller: Fix ticker resolve collision implementation
Fix ticker resolve collision implementation for incorrect
ticks accumulation and the calculation of next period.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-21 11:38:37 +01:00
Vinayak Kariappa Chettimada
ae9bf5e440 Bluetooth: controller: split: Fix radio in use during flash op
Fix a race condition in radio abort requested by flash
driver. It is possible that during abort function execution,
PPI setup to start radio fires. Hence, check explicitly in
cleanup function for radio being in use and disable it.

Fixes #22945.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-21 11:38:37 +01:00
Vinayak Kariappa Chettimada
459ff3f83e Bluetooth: controller: Fix BT_TICKER_EXT dependency
BT_TICKER_EXT depends on BT_TICKER_COMPATIBILITY_MODE not
being selected.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-21 10:55:51 +01:00
Vinayak Kariappa Chettimada
a749e28d98 Bluetooth: controller: split: nRF: Use ticker compat mode as default
Use the old ticker compatibility mode implementation as
default for nRF5x Series SoCs.

Fixes #22926.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-21 11:38:20 +02:00
Andrew Boie
8dec1beffe samples: pi: fix sample.yaml
Whitelists are bad; configuration filters scale much better.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-21 07:45:04 +02:00
Anas Nashif
82e0066601 ci: support license check with topic branch with v3
When determining added files, support branches other than master.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-20 18:22:58 -06:00
Carles Cufi
b01cd4c7bb Bluetooth: tests: tester: Add an init log message
Add a log message to let people running the test know that the tester
booted up correctly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-20 21:37:33 +02:00
Carles Cufi
5af621282e tests: bluetooth: tester: Add a config for the 52840 DK
Add a configuration file for the nRF52840 DK so that it uses RTT for
debugging and enables more protection measures.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-20 21:37:33 +02:00
Carles Cufi
6de5c4b7b3 tests: bluetooth: tester: Clean up configuration
- Use the built-in mechanism for configuration overlays
  (having a boards/ folder with <board>.conf fragments)
- Clean up variables that were giving warnings

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-20 21:37:33 +02:00
Joakim Andersson
9ab17a3eb4 Bluetooth: test: Delay SMP pairing distribution phase when testing
Avoid the HCI-USB race condition where HCI data and HCI events can be
re-ordered, and pairing information appears to be sent unencrypted.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-20 21:32:59 +02:00
Vinayak Kariappa Chettimada
62c1e1a52b Bluetooth: controller: split: Fix assert on invalid packet sequence
Fix to remove assertion failure check on detecting invalid
packet sequence used by peer central and that no non-empty
packet was transmitted.

Fixes #22967.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-20 19:34:17 +02:00
Oane Kingma
8f4c80f930 boards/arm/efm32gg_stk3701a: correct NVS example storage partition size
Set the size of the storage partition in flash used by the NVS example
to 3 times the erase-block-size for this SoC family. In this case a
total of 12KB (as 3 erase-block-sizes is the minimum).

Signed-off-by: Oane Kingma <o.kingma@interay.com>
2020-02-20 11:17:53 -06:00
Oane Kingma
8043d989a0 dts/arm/silabs: EFM32GG11B: correct flash erase block size
Corrected the erase-block-size to the actual value of 4096 bytes for
this SoC family.

Signed-off-by: Oane Kingma <o.kingma@interay.com>
2020-02-20 11:17:53 -06:00
Peter Bigot
d8146d6c6d kernel: work_q: fix return value in non-error case
A recent patch allowed an error code to be returned even though the
execution path treated it as a non-error condition.  Clear the code
before returning.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-20 17:50:05 +02:00
Abhishek Shah
f64cd1a5db soc: arm64: qemu-cortex-a53: Add MMU support
Add qemu-cortex-a53 memory regions with proper attributes
to translation tables. Minimal regions to execute "hello_world"
are added as of now, More granular memory regions should be
added later as per the requirement.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah
f587c5f019 arch: arm64: mmu: Add zephyr execution regions
Add zephyr execution regions(text, rodata, data, noinit, bss, etc.)
with proper attributes to translation tables.
Linker script has been modified a little to align these sections to
minimum translation granule(4 kB).

With this in place, code cannot be overwritten accidently as it is
marked read only. Similarly, execution is prohibited from data/RW
section as it is marked execute-never.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah
10a05a162f arch: arm64: Add MMU support
Add MMU support for ARMv8A. We support 4kB translation granule.
Regions to be mapped with specific attributes are required to be
at least 4kB aligned and can be provided through platform file(soc.c).

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah
6429dd81bf arch: arm: aarch64: linker.ld: move vector table to text segment
Following changes are done:
- The vector table should be placed in text segment.
- Removed Vector relay table related entries as it is
  only applicable to aarch32.
- irq_vector_table contains ISR pointers - should be placed
  in rodata segment.
- put openocd_dbg in rodata and skip adding <linker_relocate.ld>
  as CONFIG_CODE_DATA_RELOCATION is not defined for aarch64
  currently (add later if needed).

Fixes: #22673
Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah
1d59d3afed arch: arm: aarch64: linker: Discard plt and got sections
plt and got sections are used for dynamic linking which
is not supported in Zephyr.

Reference: #11953
commit 3ba7097e73 ("linker: add orphan sections to linker script")

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Martí Bolívar
93237fcdde doc: dts: pacify checkpatch in macros.rst
This is old text, but checkpatch is complaining since it was
introduced into itso wn file.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 12:15:27 +02:00
Martí Bolívar
3a2417443f doc: dts: add design goals defining the scope of DT
Add a page describing the high-level design goals for how Zephyr
should use DT, with examples and counter-examples from current
practice.

Add a TBD section for code generation. It's not clear (to me at least)
where the discussion on that has landed.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 12:15:27 +02:00
Martí Bolívar
a20241540b doc: dts: clean up introduction
Combine various bits of information that were formerly scattered about
into a logical order, and fix a few mistakes.

Make some policy changes, e.g. discouraging the use of fixup macros.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 12:15:27 +02:00
Martí Bolívar
51b885019e doc: split devicetree docs into multiple pages
The one page on devicetree is too long. Split it into multiple pages
to make it easier to digest and more squintable. This is basically
just moving content around; minimal changes have been made apart from
redoing some transitions and adding a couple of introductory paragraphs.

Rename the 'device-tree' Sphinx :ref: target while we are here.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 12:15:27 +02:00
Martí Bolívar
6dab163cad scripts: fix west sign when ZEPHYR_BASE is unset
Due to cleanups in west targeted at getting rid of zephyr-specific
code, extension commands can no longer rely on ZEPHYR_BASE being set
in the calling environment at import time (it's still set at run()
time for now, though, to keep west build working).

Add a new helper to make dealing with this easier from west sign.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Martí Bolívar
eb95bed552 scripts: west_commands: fix argument handling with runners.yaml
Refactor the code to support the new runners.yaml file created by the
build system.

Compared to fishing around in the CMake cache, this makes it trivial
to put all the command line arguments to a runner-based command on
equal footing, regardless of if they're defined in the runners package
proper or defined in run_common.py.

This allows board.cmake files to do things like this:

   board_set_runner_args(foo
     --bin-file=${PROJECT_BINARY_DIR}/my-signed.bin)

While at it, make some other cleanups:

- Stop using the obsolete and deprecated west.cmake module while we're
  here in favor of the zcmake.py module which was added to Zephyr a long
  time ago. Yikes. I had forgotten this was still here.

- Stop using west.util's wrap function in favor of raw use of
  textwrap. The west function splits on hyphens, which is breaking
  runner names like "em-starterkit".

- Clean up the --context output a bit

Fixes: #22563
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Martí Bolívar
5ba47f0728 cmake/flash: fix obsolete help text for missing west
This is only valid advice for west 0.5.x, which is obsolete.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Martí Bolívar
b85954787e cmake/flash: persist python runners state in YAML
The YAML contents mirror the values in the ZEPHYR_RUNNER_CONFIG
variables, but they are phrased in terms of command line arguments.

This makes it possible for Python to intermix them with
runner-specific arguments, which is a step towards being able to set
arguments like --bin-file via board_set_runner_args(). The next step
is to handle them in Python too.

Move the RUNNERS_VERBOSE setting closer to its use while at it, to
preserve readability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Andrew Boie
271621fb99 revert: "change IO APIC to logical destination..."
This reverts commit e91e7fc3d5.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-19 14:40:19 -08:00
Andrew Boie
9062a5ee91 revert: "program local APIC LDR register for..."
This reverts commit 87b65c5ac2.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-19 14:40:19 -08:00
Ioannis Glaropoulos
83b278ec01 tests: arch: arm: add test-suite to verify syscall internals
This commit contributes a simple test-suite which verifies the
internal (ARCH) implementation for user mode syscalls, as well
as the stack limit checking mechanism for ARMv8-M MCUS.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Andrew Boie
bd8a3bba54 tests: syscalls: add torture test
Hammer all CPUs with multiple threads all making system calls
that do memory allocations and buffer validation, in the hopes
that it will help smoke out concurrency issues.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
f8a5f0330d arch: arm: mpu: protect RNR when reading RBAR, RASR in ARMv7-M driver
We lock IRQs around writing to RNR and immediate reading of RBAR
RASR in ARMv7-M MPU driver. We do this for the functions invoked
directly or undirectly by arch_buffer_validate(). This locking
guarantees that
- arch_buffer_validate() calls by ISRs may safely preempt each
  other
- arch_buffer_validate() calls by threads may safely preempt
  each other (i.e via context switch -out and -in again).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
db0ca2e31a arch: arm: userspace: lock swap to set PSP, PSPLIM in userspace enter
When entering user mode, and before the privileged are dropped,
the thread switches back to using its default (user) stack. For
stack limit checking not to lead to a stack overflow, the PSPLIM
and PSP register updates need to be done with PendSV IRQ locked.
This is because context-switch (done in PendSV IRQ) reprograms
the stack pointer limit register based on the current PSP
of the thread. This commit enforces PendSV locking and
unlocking while reprogramming PSP and PSPLIM when switching to
user stack at z_arm_userspace_enter().

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
b09607dee5 arch: arm: aarch32: no PSLIM clearing in z_arm_userspace_enter()
Modifying the PSP via an MSR instruction is not subject to
stack limit checking so we can remove the relevant code
block in the begining of z_arm_userspace_enter(), which clears
PSPLIM. We add a comment when setting the PSP to the privilege
stack to stress that clearing the PSPLIM is not required and it
is always a safe operation.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
c4c595c56e arch: arm: userspace: lock swap to set PSP & PSPLIM in syscall return
When returning from a system call, the thread switches back
to using its default (user) stack. For stack limit checking
not to lead to a stack overflow, the updates of PSPLIM and
PSP registers need to be done with PendSV IRQ locked. This
is because context-switch (done in PendSV IRQ) reprograms
the stack pointer limit register based on the current PSP
of the thread. This commit enforces PendSV locking and
unlocking while reprogramming PSP and PSPLIM when returning
from a system call.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
6494658983 arch: arm: userspace: no PSPLIM clearing in z_arm_do_syscall() enter
In this commit we remove the PSPLIM clearing when entering
z_arm_do_syscall(), since we want PSPLIM to keep guarding
the user thread stack, until the thread has switched to its
privileged stack, for executing the system call.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
f00dfce891 arch: arm: userspace: set PSPLIM to guard default stack in SVCall
Thread will be in privileged mode after returning from SCVall. It
will use the default (user) stack before switching to the privileged
stack to execute the system call. We need to protect the user stack
against stack overflows until this stack transition. We update the
note in z_arm_do_syscall(), stating clearly that it executing with
stack protection when building with stack limit checking support
(ARMv8-M only).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
a5ecd71163 arch: arm: cortex-m: fix PSPLIM configuring in context-switch
When configuring the built-in stack guard, via setting the
PSPLIM register, during thread context-switch, we shall only
set PSPLIM to "guard" the thread's privileged stack area when
the thread is actually using it (PSP is on this stack).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
16ce4b6953 arch: arm: cortex-m: move PSPLIM clearing in the relevant function
We do not need to have the PSPLIM clearing directly inside
the PendSV handler and outside the function that configures
it, configure_builtin_stack_guard(), since the latter is also
invoked inside the PendSV handler. This commit moves the
PSPLIM clearing inside configure_builtin_stack_guard(). The
patch is not introducing any behavioral change on the
stack limit checking mechanism for Cortex-M.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
36e80673f9 arch: arm: aarch32: cortex-m: introduce offset for stack info start
We add the mechanism to generate offset #defines for
thread stack info start, to be used directly in ASM.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
4223b71b77 arch: aarch32: define macro for PendSV IRQ priority level
We introduce a macro to define the IRQ priority level for
PendsV, and use it in arch/arm/include/aarch32/exc.h
to set the PendSV IRQ level. The commit does not change
the behavior of PendSV interrupt.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
f9d9b7642e arch: aarch32: document exception priority scheme for 32-bit ARM
This commit adds some documentation for the exception
priority scheme for 32-bit ARM architecture variants.
In addition we document that SVCall priority level for
ARMv6-M is implicitly set to highest (by leaving it as
default).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
14237335e0 arch: arm: update file header info for arm/aarch32/exc.h
Public arm/aarch32/exc.h header file is used by both
Cortex-M and Cortex-R; we update the header information
accordingly.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos
446ac06458 arch: arm: core: aarch32: fix wrong indentation in thread.c
Some minor indentation fixes in thread.c.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Zide Chen
87b65c5ac2 interrupt_controller: program local APIC LDR register for xAPIC
If IO APIC is in logical destination mode, local APICs compare their
logical APIC ID defined in LDR (Logical Destination Register) with
the destination code sent with the interrupt to determine whether or not
to accept the incoming interrupt.

This patch programs LDR in xAPIC mode to support IO APIC logical mode.

The local APIC ID from local APIC ID register can't be used as the
'logical APIC ID' because LAPIC ID may not be consecutive numbers hence
it makes it impossible for LDR to encode 8 IDs within 8 bits.

This patch chooses 0 for BSP, and for APs, cpu_number which is the index
to x86_cpuboot[], which ultimately assigned in z_smp_init[].

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-19 10:25:10 -08:00
Zide Chen
e91e7fc3d5 interrupt_controller: change IO APIC to logical destination mode
Currently IO APIC is working in physical destination mode, which
doesn't support interrupt to be delivered to multiple local APICs.
By definition only 4 bits [59:63] in IO APIC IOREDTBL register are
available for destination addresses and it contains an APIC ID only.

This patch changes it to logical destination mode so that IOREDTBL
can potentially define a set of processors and it's posible to deliver
interrupts to multiple APICs.

Also it changes delivery mode from fixed to lowest priority. The reason
being in fixed mode, the interrupt could be delivered to all CPUs
which put burden in software to handle repeated interrupts. While in
lowest priority mode, interrupt is delivered to one local APIC only.

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-19 10:25:10 -08:00
Piotr Mienkowski
6baff1b3b9 doc: update BOOTLOADER_MCUBOOT description
mcuboot.overlay is not used any more when BOOTLOADER_MCUBOOT Kconfig
option is selected. Update the documentation accordingly.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-19 07:30:43 -06:00
Piotr Mienkowski
62fc80deea doc: Update "Linking Zephyr Within a Partition" section
The method used to link code partition, as defined by
zephyr,code-partition has been modified in Zephyr 1.14. Update the
"Linking Zephyr Within a Partition" section to reflect the change.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-19 07:30:43 -06:00
Piotr Mienkowski
a83f1fcd0a boards: remove outdated documentation about partition linking
The method used to link code partition, as defined by
zephyr,code-partition has been modified in Zephyr 1.14. Remove any
remaining, outdated documentation that was embedded in the board dts
files.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-19 07:30:43 -06:00