Commit Graph

48007 Commits

Author SHA1 Message Date
Hubert Miś 0475cd0eae net: coap: Allow encoding packets using data from constant buffers
Token and payload are appended from data buffers to a CoAP packet
being encoded. Keyword const was missing for parameters in functions
appending these parts to a packet.

Now token and paylod can be copied to CoAP packet from constant
buffers, that can be stored in ROM.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-26 06:17:41 -05:00
Hubert Miś 759f7454d8 net: coap: define max token length
This patch introduces COAP_TOKEN_MAX_LEN definition in coap.h file.
This definition replaces magic number across CoAP protocol
implementation and CoAP samples.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-26 06:17:41 -05:00
Stephanos Ioannidis f769a03081 arch: arm: aarch32: Fix interrupt nesting
In the current interrupt nesting implementation, if an ISR is
interrupted while executing inside a branch, the lr_svc register will
be corrupted, and the branch of the interrupted ISR will exit to the
return address of the final branch of the interrupting ISR, which may
or may not correspond to the intended return address.

This commit fixes the aforementioned bug by storing the lr_svc register
in the stack at the ISR entry, and restoring its value before exiting
the ISR.

For more details, refer to the issue #30517.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-01-26 06:17:15 -05:00
Stephanos Ioannidis c00169daba arch: arm: aarch32: Fix exception exit failures
This commit fixes the following bugs in the AArch32 z_arm_exc_exit
routine:

1. Invalid return address when calling `z_arm_pendsv` from the
   exception-specific mode

2. Caller-saved register is referenced after a call to `z_arm_pendsv`

For more details, refer to the issue #31511.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-01-26 06:17:15 -05:00
Stephanos Ioannidis d86fdb2154 arch: arm: aarch32: Update stale references to `_IntExit`
This commit updates the stale references to the `_IntExit` function in
the in-line documentation.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-01-26 06:17:15 -05:00
Krzysztof Chruscinski 7f08061f0c logging: Revamp menuconfig
Clean up logging menuconfig by grouping configuration into
sections like: mode, processing configuration, backends.

Additionlly, removed LOG_ENABLE_FANCY_OUTPUT_FORMATTING which is no
longer in use.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-01-26 06:15:42 -05:00
Wentong Wu 27a43808a2 boards: nios2: enable icount for qemu_nios2 platform
Enable icount for qemu_nios2 platform.

Fixes: #25918.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2021-01-26 06:13:35 -05:00
Emil Gydesen 085d2eda8d Bluetooth: Audio: Add missing unref for ISO recv
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.

Also adds a few additional debug messages.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Emil Gydesen aed1db5782 Bluetooth: shell: Fix number of optional args for iso send
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Piotr Pryga a8c18ff5f4 tests: Bluetooth: df: Fix build error, missing antenna config in DTS
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.

To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.

Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.

Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-25 21:46:34 -05:00
Joakim Andersson dbe4a5f0d2 Bluetooth: host: Remove ATT modification of L2CAP conn pointer
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00
Joakim Andersson 28bddf9380 Bluetooth: host: Handle ATT timeout on disconnected ATT channel
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
 called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.

Fixes: #29098

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00
Peter Bigot f91e9fba51 device: fix potential truncation of DT-derived device names
While using the encoded path to a device tree node guarantees a unique
identifier for the corresponding device there is a limit on the number
of characters of that name that can be captured when looking up a
device by name from user mode, and the path can exceed that limit.

Synthesize a unique name from the node dependency ordinal instead, and
update the gen_defines script to record the name associated with the
full path in the extern declaration.

Add a build-time check that no device is created with a name that
violates the user mode requirement.

Also update the network device DTS helper functions to use the same
inference for dev_name and label that the real one does, since they
bypass the real one.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-25 16:26:12 -05:00
Marcin Niestroj 0782f9c4a6 power: device: provide device_pm_state_str() with CONFIG_PM=n
So far device_pm_state_str() was built only when CONFIG_PM=y (former
CONFIG_SYSTEM_POWER_MANAGEMENT=y). 'device list' shell
command (CONFIG_DEVICE_SHELL=y) is using that function when
CONFIG_PM_DEVICE=y. This resulted in build failures when CONFIG_PM=n, as
linker could not find its implementation.

Build device_pm_state_str() function regardless of CONFIG_PM value, so
device shell module builds successfully in every case.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-01-25 14:21:00 -05:00
Kumar Gala ae4e4b78d6 x86: Fix zefi.py generation to use SDK toolchain
With SDK 0.12.2 we have support to generation EFI binaries in binutils
which is needed by the zefi.py script.  Now that is there we can utilize
the SDK objcopy instead of assuming the host objcopy can do this (which
would only be the case on x86 linux host systems).

Fixes #27047

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-25 13:17:02 -05:00
Henrik Brix Andersen 8cf62f119e dts: bindings: mtd: rename SPI/I2C EEPROM base binding
Rename the SPI/I2C EEPROM devicetree binding to reflect that it only
covers AT24 and AT25 EEPROMs).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-25 12:32:54 -05:00
Kumar Gala 536be8f005 sdk: Move to SDK 0.12.2
Update ci and docs to reference SDK 0.12.2

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-25 12:30:49 -05:00
Ioannis Glaropoulos 6182d832bd trusted-firmware-m: update manifest pointer for TF-M module
Update the manifest pointer for the tf-m module
to pull in latest master.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-01-25 11:43:21 -05:00
Anas Nashif ec47912292 twister: generate json report on demand
Do not generate json report by default. Use --json-report to generate
the file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-25 09:56:53 -05:00
Andrzej Puzdrowski b9d492e4d2 drivers/flash: select to allow flash write by MPU on ARM SoCs
Added selection of MPU_ALLOW_FLASH_WRITE.
Using a flash driver while MPU is enable without
this option on doesn't make sense at all.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-25 08:59:01 -05:00
Jedrzej Ciupis 91e0895e9a west.yml: Update hal_nordic revision
Update hal_nordic to bring build warning fix for 802.15.4 serialization.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2021-01-25 14:26:53 +01:00
Vinayak Kariappa Chettimada c2513eb993 Bluetooth: controller: Fix PHY update procedure cachability
Fix missing PHY update procedure cachability omitted in
commit 16dbb9a4fe ("Bluetooth: controller: split: Fix cmd
disallowed and collision disconnects").

Relates to #31473.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-25 11:49:28 +01:00
Henrik Brix Andersen 7b9b3cfe5a samples: canbus: canopen: mass-erase flash prior to running sample
Mass-erase the flash prior to running the sample to ensure the storage
partition can be initialized correctly.

Fixes: #30477

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-24 21:22:25 -05:00
Anas Nashif ef1b4d45b0 release: Zephyr 2.5.0-rc1
Set version to 2.5.0-rc1

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-24 17:15:54 -05:00
Matija Tudan 1463596205 drivers: dac: added driver for TI DACx3608
The DAC53608 and DAC43608 (DACx3608) are lowpower, eight-channel,
voltage-output, 10-bit or 8-bit digital-to-analog converters (DACs)
respectively. They support I2C with a wide power supply range
from 1.8 V to 5.5 V, and a full scale output voltage range of
1.8 V to 5.5 V. The DACx3608 also includes per channel, user
programmable, power down registers.

Signed-off-by: Matija Tudan <mtudan@mobilisis.hr>
2021-01-24 14:28:05 -05:00
Klaus H. Sorensen 4e7b5769bd lib: crc32_sw: 4 bit at a time implementation
Calculate crc32 4 bits at a time. The return value of the calculation is
identical to the previous 1 bit at a time implementation.

Results in a speed up of a factor 3 at the cost of using 64 bytes of
flash for a crc table.

Calculating crc32 of 128kB of flash on a 120MHz Kinetis MKE16F512
Cortex-M4 takes 99ms using the 1 bit at a time implementation, and 30ms
using the 4 bits at a time implementation.

The crc32 routine is used by subsys/canbus/canopen/canopen_program.c to
calculate crc of flash images.

Signed-off-by: Klaus H. Sorensen <khso@vestas.com>
2021-01-24 14:24:48 -05:00
Enjia Mai e89fe33a5a tests: thread: refine the thread abort test case
Refine the thread abort test case and add one extra condition.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-24 14:18:00 -05:00
Jian Kang 30bf585e10 tests: kernel: Add some testcases for thread
Add some error condition of testcases to verify whether the
robustness of API. Such as give a NULL to some API and check
the response if get result that we were expacted.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
2021-01-24 14:13:29 -05:00
Volodymyr Babchuk b07065d3f3 arm: aarch64: add Xen virtual machine support
This commit adds minimal support for running zephyr as Xen guest. It
does not use xen PV console, which is somewhat hard to implement, as it
depends on xenbus infrastructure. Instead SBSA-compatible PL011 uart is
used.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
2021-01-24 13:59:55 -05:00
Volodymyr Babchuk 4fb1ee771a drivers: pl011: add SBSA mode
ARM Server Base System Architecture defines Generic UART interface,
which is subset of PL011 UART.

Minimal SBSA UART implementation does not define UART hardware
configuration registers. Basically, only FIFOs and interrupt management
operation are defined.

Add SBSA mode to PL011 UART driver, so it can be used at SBSA-compatible
platforms, like Xen guest.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
2021-01-24 13:59:55 -05:00
Volodymyr Babchuk 490408fa8e aarch64: introduce explicit instructions to access MMIO
With classic volatile pointer access gcc something generates
access instructions with immediate offset value, like

str     w4, [x1], #4

Such instructions produce invalid syndrome in HSR register when are
trapped by hypervisor. This leads to inability to emulate device access
in hypervisor.

So we need to make sure that any access to device memory is done
with plain str/ldr instructions without offset.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
2021-01-24 13:59:55 -05:00
Volodymyr Babchuk cd86ec2655 aarch64: add ability to generate image header
Image header is compatible with Linux aarch64 boot protocol,
so zephyr can be booted with U-boot or Xen loader.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
2021-01-24 13:59:55 -05:00
Yonatan Schachter 7191b64c6f gen_isr_tables: Added check of the IRQ num before accessing the vt
At its current state, the script tries to access the vector table
list without checking first that the index is valid. This can
cause the script to crash without a descriptive message.
The index can be invalid if an IRQ number that is larger than
the maximum number allowed by the SOC is used.
This PR adds a check of that index, that exits with an error
message if the index is invalid.

Fixes #29809

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2021-01-24 10:12:54 -05:00
Martin Åberg b6b6d39bb6 lib/os/heap: introduce option to force big heap mode
This option allows forcing big heap mode. Useful on for getting 8-byte
aligned blocks on 32-bit machines.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-24 10:11:11 -05:00
Martin Åberg 80b9080f9d tests/mem_alloc: check that malloc() objects can be accessed
Adds tests checking that we can use memory allocated by malloc(),
calloc() and realloc() to access objects of some common types,
including uint64_t and double.

It works by doing a number of allocations of various sizes and
dereferencing the returned pointer. The purpose is to catch cases where
the application would trap if accessing the allocated memory. (The
test does not check alignment against the ABI or alignof().)

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-24 10:11:11 -05:00
Martin Åberg 180ce491ad libc/minimal: reallocarray() in terms of realloc()
reallocarray() is defined in terms of realloc(). From OpenBSD manual
pages:
    "Designed for safe allocation of arrays, the reallocarray()
    function is similar to realloc() except it operates on nmemb
    members of size size and checks for integer overflow in the
    calculation nmemb * size."

The return value of sys_heap_realloc() is not compatible with that
of realloc().

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-24 10:11:11 -05:00
Kari Hulkko 22c0d0155a usb: fix for parallel transfer deadlock with usb_transfer_sync()
Parallel transfer to same endpoint is not supported and
may cause a deadlock. Adding a check to prevent starting
the transfer if tranfer is already ongoing on same endpoint.

Transfer status was not checked when accessing to transfer
from endpoint callback. Adding status check, to prevent
a double completion.

Fixes #30736

Signed-off-by: Kari Hulkko <kari.m.hulkko@gmail.com>
2021-01-24 10:08:27 -05:00
Andrew Boie 77861037d9 x86: map all RAM if ACPI
ACPI tables can lurk anywhere. Map all memory so they can be
read.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie c56b41f9b3 boards: x86: increase VM size on PC-like
These are all PC systems which have large amounts of memory
which needs to be mapped at runtime (most are 2GB).

Increase the address space size accordingly, adding an extra
8MB for mappings.

The ACRN target has 8MB, give it 16MB of VM.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 14c5d1f1f7 kernel: add CONFIG_ARCH_MAPS_ALL_RAM
Some arches like x86 need all memory mapped so that they can
fetch information placed arbitrarily by firmware, like ACPI
tables.

Ensure that if this is the case, the kernel won't accidentally
clobber it by thinking the relevant virtual memory is unused.
Otherwise this has no effect on page frame management.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 6c97ab3167 mmu: promote public APIs
These are application facing and are prefixed with k_.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 79d73063af tests: context: disable if DEMAND_PAGING
Until #31333 is resolved, the periodic timer in the eviction
algorithm interacts with this test in such a way that the system
deadlocks.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie c7be5dddda mmu: backing stores reserve page fault room
If we evict enough pages to completely fill the backing store,
through APIs like k_mem_map(), z_page_frame_evict(), or
z_mem_page_out(), this will produce a crash the next time we
try to handle a page fault.

The backing store now always reserves a free storage location
for actual page faults.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie cad944e259 tests: demand_paging: add more API tests
Add remaining APIs in mem_manage.h even though not all have
been promoted to public (yet).

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 60d306642e kernel: add z_num_pagefaults_get()
Simple counter of number of successfully handled page faults by
the core kernel.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 9a12d6028b CODEOWNERS: add demand paging subdir
Adding myself as original author.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie ef65597b73 tests: add intial demand paging testcase
More to be added, but for now show that we can map more
anonymous memory than we physically have, and that reading/
writing to it works as expected.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 146eaf4335 tests: add basic k_mem_map() test
Show we can measure free memory properly and map a page of
anonymous memory, which has been zeroed and is writable.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 611b626b39 mmu: pin the whole kernel
This will enable testing of the implementation until the
critical set of pages is identified and known to the
kernel.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Andrew Boie 4d6c20b9d7 qemu_x86_tiny: enable demand paging
This target is specifically for simulating x86 micro-
controllers with limited memory.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00