Commit Graph

44607 Commits

Author SHA1 Message Date
Simon Glass 4d77edd6ba emul: Add messages in emul_init_for_bus_from_list
Add a log message to indicate that a new emulator is attached. Also add
a message in the assert to make it clearer what has gone wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass a1d8e55cad emul: spi: Add support for SPI emulators
Add an emulation controller which routes SPI traffic to an attached
emulator. Only one emulator is supported per bus at present, since
chip-selction functionality is not present.

This allows drivers for SPI peripherals to be tested on systems that
don't have that peripheral attached, with the emulator handling the SPI
traffic.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass 5a9f389159 drivers: sensor: bmi160: Use more constants for reg access
At present register access is a mix of constants and open-coded values
in the driver. Add a few more constants to clean this up.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass 2c73f3ed4c drivers: sensor: bmi160: Add a constant for number of axes
Define a constant instead of using an open-coded value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass e944855bbc drivers: sensor: bmi160: Move the ready bit into the header
This should be accessible to all files that need register access. Move
it into the header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass 2e14082334 tests: drivers: sensor: Move current test into generic/
The existing tests is for generic sensor drivers. To make room for a
driver-specific one, move it into a subdirectory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Martin Jäger 48684518fa dts: arm: stm32g474: add Xb and Xc variants
Only difference compared to existing Xe variant is less flash memory.

Existing nodes for DAC were moved up one level to stm32g474.dtsi

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-10-05 14:29:10 -05:00
Robert Lubos 5707678a51 CODEOWNERS: Update CoAP codeowner
Set myself as the codeowner of the CoAP library.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-10-05 14:27:37 -05:00
Anas Nashif dac6937cda actions: install needed modules for docs
add scripts/requirements-base.txt to install needed modules for docs to
build.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-05 13:04:22 -04:00
Arnaud Mouiche 7673baed84 libc: newlib: Avoid all files to be opened in line buffer mode
Default buffer mode is setup by fopen depending on isatty value.
Expect only 0, 1 & 2 to be tty for CONFIG_POSIX_API cases.

This way regular files are opened in block buffering mode (instead
of line buffering mode) which really speed up fread/fwrite
operations on FS.

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
2020-10-05 09:59:38 -07:00
Arnaud Mouiche fd9766c961 posix: fix missing _open for fopen support
Using fopen() in application failed to build when configured with
	CONFIG_NEWLIB_LIBC=y
	CONFIG_POSIX_API=y

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
2020-10-05 09:59:38 -07:00
Erwan Gouriou c3eef7744a include/devicetree.h: Add DT_ENUM_IDX_OR macro
In case a "required: False" enum binding doesn't mention a
default value, but a default value makes sense to be set in the code,
DT_ENUM_IDX_OR could be used to provide the default idx to be used.

New macro comes with appropriate tests.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-05 10:15:32 -05:00
Marcin Niestroj ad0dc48067 drivers: modem: ublox-sara-r4: inform modem_context about HW flow control
If HW flow control is enabled, then modem_context framework won't drain
UART FIFO blindly, but will stop when there is no more space in RX
ring_buf. This prevents data loss by "pausing" incoming data on hardware
level.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Marcin Niestroj f27de1f1bb drivers: wifi: esp: inform modem_context about HW flow control
If HW flow control is enabled, then modem_context framework won't drain
UART FIFO blindly, but will stop when there is no more space in RX
ring_buf. This prevents data loss by "pausing" incoming data on hardware
level.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Marcin Niestroj 05eb9644dc modem: iface_uart: improve RX flow with HW flow control
So far all received bytes over UART where blindly drained and pushed to
ring_buf. This approach is okay for UART devices without configured HW
flow control, as it basically decouples data processing from ISR handler
and gives more time before data overrun. However when HW flow control
is enabled, such behavior somehow suppresses UART flow control
advantage, because data can overrun when pushing to ring_buf.

Allow drivers utilizing modem_context framework to pass information
about whether HW flow control is enabled or not. If it is enabled, then
read data from UART FIFO to the point when RX ring_buf is totally filled
and follow such situation by disabling RX interrupt. Incoming data will
be paused on HW level, so there is lots of time for RX thread to process
ring_buf content. Reenable RX interrupts after all data in ring_buf is
processed, so that number of context switches is kept at minimum level.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Marcin Niestroj 763bd27c75 modem: iface_uart: use ring_buf_{claim,finish} API
This API allows to drop use of preallocated isr_buf. Most importantly as
a result RAM usage is reduced for each driver utilizing modem_context
framework. Additionally there is less copying done in ISR context, as
data is direcly read from UART FIFO to ring_buf.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Jedrzej Ciupis 53007a8559 west.yml: Update hal_nordic revision
This patch fixes bugs in the ieee802154 radio driver

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2020-10-05 12:22:01 +02:00
Robert Lubos 12e1fd653d net: lwm2m: Fix FOTA block transfer with opaque content-format
This commit fixes PUSH FOTA when opaque content-format is used.

This consists of the following fixes:
 * Moved `struct block_context` to a private header, so that it can be a
   part of `struct lwm2m_input_context`. This allows content decoders to
   make use of the block context data.
 * Removed faulty `get_length_left` function from the plain text
   decoder, and replace it with coap_packet_get_payload() to obtain the
   actual payload size.
 * Introduce `struct lwm2m_opaque_context` as a part of block context,
   which allows to keep track of opaque data download progress.
 * Simplify `lwm2m_write_handler_opaque()` function. It will now only
   make calls to `engine_get_opaque` - it's the decoder responsibility
   to update the opaque context according to it's content format (for
   instance TLV decoder should only update it with the actual opaque
   data size, not the whole TLV).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-10-05 12:16:57 +02:00
Jordan Montgomery ec9080a036 Bluetooth: controller: Fix Null deref during adv data update
Added a check for adv->lll.aux before starting extended advertising to
fix observed NULL pointer dereference when updating AD data of legacy
advertising.

Fixes #28544.

Signed-off-by: Jordan Montgomery <montytyper@msn.com>
2020-10-05 11:47:30 +02:00
Andries Kruithof af7fc360ad CODEOWNERS: add Andries to bluetooth/controller
Added myself as codeowner to the bluetooth/controller project

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-10-05 09:42:44 +02:00
Torstein Grindvik 84cdc6fd92 logging: Refactoring macro to avoid Coverity issue
Change a runtime log check such that Coverity does not report a
needless issue on every use of any log macro.

Before the change, this was used in log macros:

    else if(is_user_context || (_level <= LOG_RUNTIME_FILTER(_filter)))

If runtime filtering is not enabled, this expands to:

    else if(is_user_context || 1)

Because the level is compared to log level debug (4) and will always be,
equal or lower.
Coverity always reports this as a potential issue, since the
variable part (is_user_context) makes no difference.

After the change, a macro is used which expands into the original code
when runtime filtering is used, else it simply expands to:

    else if(true)

Which has equal semantics as the previous code but isn't flagged by
Coverity.

Signed-off-by: Torstein Grindvik <torstein.grindvik@nordicsemi.no>
2020-10-04 14:45:45 -07:00
Enjia Mai 39696e3c1b tests: smp: improving the description for SMP test cases
Add more detail description for test case of arch_curr_cpu() and
arch_sched_ipi(). This is in order to make the purpose and process of
the test cases more clear.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-10-04 14:26:31 -07:00
Kumar Gala c8b94f468a kernel: Remove deprecated APIs and MACROs from 2.3
Remove old K_ prefixed macros defined in kernel.h as well as the
following APIs:

k_uptime_delta_32
k_enable_sys_clock_always_on
k_disable_sys_clock_always_on

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-04 14:13:09 -07:00
Kumar Gala d28f04110d kernel/sys_clock.h: Remove deprecated macros
Removed the following macros as they have been marked deprecated for at
least 2 releases:

__ticks_to_ms()
__ticks_to_us()
z_us_to_ticks()
sys_clock_hw_cycles_per_tick()
SYS_CLOCK_HW_CYCLES_TO_NS64()
SYS_CLOCK_HW_CYCLES_TO_NS()

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-04 14:12:27 -07:00
Jukka Rissanen d4347b4015 net: dhcpv4: Generate start/bound/stop mgmt events
The L4 connected/disconnected events are usually used to detect
when the application is connected to the network. Unfortunately
if the device has also a static address, then the connected event
might be created (for the static address) even if DHCPv4 is not
ready yet and application would not be able to connect (yet) to the
network. In order to allow the application to fine tune the network
connection creation, generate start, bound and stop events for DHCPv4.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-03 17:15:15 +03:00
Jukka Rissanen 088589837e net: event: Add start/bound/stop events for DHCPv4
Application would need this information in order to know when
it is able to create sockets with proper IPv4 address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-03 17:15:15 +03:00
Torstein Grindvik c02eb30bbf gen_isr_tables: Function ptr instead of (void *)
gen_isr_tables.py generates C-code which initializes a table with
values, and these values are structs with members cast to
(const void *) and (void *), respectively.

The actual struct definition has a member of type (const void *)
and another of type void (*)(const void *).

In order to avoid a large amount of reported issues in Coverity,
cast this to the exact type.

Signed-off-by: Torstein Grindvik <torstein.grindvik@nordicsemi.no>
2020-10-02 18:48:46 +02:00
Håkon Øye Amundsen 780fa73b83 settings_fcb: initialize rc variable
Avoid warning about uninitialized variable.
The for loop should do at least two iterations
in a valid execution, hence initialize to an
error value.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-10-02 12:07:06 -04:00
Ievgenii Meshcheriakov 5cb09fe0fb drivers: flash: Restore write protection in flash_shell
Restore the flash write proectction after disabling it for
flash write and erase shell commands.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Ievgenii Meshcheriakov 4fc093ee58 drivers: flash_shell: Fix write protection in the test command
Flash drivers are free to re-enable write protection after a write or
erase operation is complete. Therefore write protection has to be
disabled before any such operation.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Ievgenii Meshcheriakov cf523e449e drivers: flash: Pass bool to flash_write_protection_set()
The second argument of this foonction is a bool, so passing 0 and 1
is incorrect.

Coccinelle script:

    @@
    expression e;
    @@
    flash_write_protection_set(e,
    (
    - 0
    + false
    |
    - 1
    + true
    )
     )

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Jakub Rzeszutko f43985e334 shell: enhance help command
To get a list of all supported shell commands user must hit the TAB
button. It may be awkward on some terminal emulators. This change
enhances the help command in a way it will in addition print all
supported commands.

Fixes: #28785

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jakub Rzeszutko 137b7ec5bd shell: help functions update
Functions shell_help_subcmd_print and shell_help_cmd_print
are more generic. Now they can operate on command passed as an
argument not hard coded active_cmd.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jakub Rzeszutko 0cf6670b70 shell: improve function shell_cmd_get
The function can return existing root command even if dloc argument
is a NULL pointer.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jeremy LOCHE ee2c66a627 boards: nucleo_h743zi: Configure serial console pins using dt
usart3 pin configuration is now done through device tree.

Signed-off-by: Jeremy LOCHE <lochejeremy@gmail.com>
2020-10-02 08:36:57 -05:00
Erwan Gouriou c82bd74237 dts/bindings/pinctrl: Remove usage of c comments within bindings
Reused Linux bindings were using /*  */ in some property description
fields.
This is not compatible with legacy device tree api which expands
these fields in commented sections of generated file
devicetree_legacy_unfixed.h resulting in compilation issue.
Seen when running tests/lib/devicetree/legacy_api.

Remove /* */ for now, waiting legacy api to be removed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-02 08:36:26 -05:00
Maciej Perkowski 2ec5ec2153 sanitycheck: Fix ZeroDivisionError during reporting
This patch fixes the ZeroDivisionError which can
occur during percantage of test execution reporting.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2020-10-02 07:56:17 -04:00
Jukka Rissanen db889774c2 net: tc: Remove not used field from net_traffic_class struct
The "tc" field which was holding the traffic class thread
priority is not used nor needed so remove it from the struct
to save some space.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-02 13:20:17 +03:00
Martí Bolívar a6856811a3 scripts: dts: pass tests on windows
Doing this just requires a bit of os.fspath()-ery.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-10-02 11:51:15 +02:00
Martí Bolívar a8612f75c5 scripts: dts: convert test suites to pytest
Use the pytest test framework in the dtlib.py and edtlib.py test
suites (testdtlib.py and testedtlib.py respectively).

The goal here is not to change what is being tested. The existing test
suite is excellent and very thorough.

However, it is made up of executable scripts where all of the tests
are run using a hand-rolled framework in a single function per file.
This is a bit all-or-nothing and prevents various nice features
available in the de-facto standard pytest test framework from being
used.

In particular, pytest can:

- drop into a debugger (pdb) when there is a problem
- accept a pattern which specifies a subset of tests to run
- print very detailed error messages about the actual and expected
  results in various traceback formats from brief to very verbose
- gather coverage data for the python scripts being tested (via plugin)
- run tests in parallel (via plugin)
- It's easy in pytest to run tests with temporary directories
  using the tmp_path and other fixtures. This us avoid
  temporarily dirtying the working tree as is done now.

Moving to pytest lets us leverage all of these things without any loss
in ease of use (in fact, some things are nicer in pytest):

- Any function that starts with "test_" is automatically picked up and
  run. No need for rolling up lists of functions into a test suite.
- Tests are written using ordinary Python 'assert'
  statements.
- Pytest magic unpacks the AST of failed asserts to print details on
  what went wrong in really nice ways. For example, it will show you
  exactly what parts of two strings that are expected to be equal
  differ.

For the most part, this is a pretty mechanical conversion:

- extract helpers and test cases into separate functions
- insert temporary paths and adjust tests accordingly to not match
  file names exactly
- use 'assert CONDITION' instead of 'if not CONDITION: fail()'

There are a few cases where making this happen required slightly
larger changes than that, but they are limited.

Move the checks from check_compliance.py to a new GitHub workflow,
removing hacks that are no longer needed.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-10-02 11:51:15 +02:00
Henrik Brix Andersen 0e7a76e462 dts: bindings: move io-channels and io-channel-names to base.yaml
Generalize io-channels and io-channel-names devicetree node properties
and move their definitions to base.yaml. Keep binding specific
description where relevant.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-10-02 11:50:30 +02:00
Emil Gydesen 8cc051ccac Bluetooth: host: Change PA sync callbacks to global callbacks
Changes the callbacks for periodic sync callbacks such that multiple
applications can register callbacks, similar to the connection and
scan callbacks.

This change will make it easier to support the PAST feature, as
PA syncs make be created by the controller which then notifies
the host, and thus the application (if callback registered).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-02 11:49:13 +02:00
Alexandre Bourdiol 2a6b52e9c2 boards: arm: stm32h747i_disco: wakeup pin is active high
Wakeup pin is active HIGH for stm32h747i_disco.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-10-02 11:48:32 +02:00
Alexandre Bourdiol cde8f37833 boards: arm: stm32 review Joystick polarity and pul up/down
Similarly to #28676 Joystick polarity and pull up/down
need to be review for all STM32 boards.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-10-02 11:48:32 +02:00
Mahesh Mahadevan 133705f497 drivers: spi: Set the spi_config before calling Chip select configure
This was accidentally moved to after calling chip select configure

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-02 11:47:23 +02:00
Kumar Gala 8ddd7f0f23 drivers: sensors: itds: Remove dts defaults
We should not be using defaults for enum properties, this should be
required: true instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-02 11:46:57 +02:00
Giancarlo Stasi ba7ef854d8 drivers: stm32: fix MSI PLL mode enabling
1. clock: move the call for MSI hardware auto calibration enabling
    before the control of MSI enable to ensure its execution in all
    cases.
 2. counter: add call for MSI hardware auto calibration enabling after
    the LSE enabling and after possible backup domain reset that may
    clear MSIPLLEN.

Signed-off-by: Giancarlo Stasi <giancarlo.stasi.co@gmail.com>
2020-10-02 11:46:22 +02:00
Peter A. Bigot 776e0db03d bluetooth: att: provide named constant for successful result
BT_HCI_ERR and BT_SECURITY_ERR both define success constants which can
be used to check the results and make the intended value domain clear.
Add the same for ATT error values.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-10-02 11:45:03 +02:00
Jett Rink c0f2720890 include: remove enum build assert
Since the size of an enum can be undefined in certain compilations
environments, remove the BUILD_ASSERT that verifies that the enum is
16 bits.

Signed-off-by: Jett Rink <jettrink@google.com>
2020-10-02 11:44:39 +02:00
Yiyu Zhu 741d8eee7a i2c: power on reset for certain stm32 devices
Described in ES096 2.14.7,
F101X8/B, F102X8/B, and F103X8/B
might not be able to enter i2c master mode on power-up.
Force reset help to mitigate this issue.

Signed-off-by: Yiyu Zhu <smallzzy@outlook.com>
2020-10-02 11:44:17 +02:00