Commit graph

71 commits

Author SHA1 Message Date
Kamil Kasperczyk 06bf2ca707 net: openthread: Added config options for NCP vendor hooks.
New config option that can be used to enable vendor hooks
for NCP component.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-07-23 10:44:19 +02:00
Marek Porwisz 740e0ccc9e net: openthread: Allow use of custom mbedtls
To allow hardware crypto acceleration custom mbedtls library needs to be
prepared. However current implementation forces the default library to
be used.
This patch allows not using the default library and passing custom
mbedtls target to use with openthread.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-07-22 15:32:30 -05:00
Marek Porwisz a6c6e7793f net: openthread: Use different kconfig switch for shim and src
Different switch was used for build to allow including all shim body
in zephyr without the need for building openthread from this repo. This
allows developer to include custom OpenThread sources as part of the
application.
This change is needed as Thread is a subject of certification and
sources provided by zephyr may not necesairly pass certification or be
precertified. User is allowed to use certified OpenThread version
this way.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-07-20 14:42:30 +03:00
Martí Bolívar dfbabb1201 openthread: avoid warning when CONFIG_NET_MGMT_EVENT=n
When this happens, ip6_addr_cb and ipv6_addr_event_handler() both look
unused, since they are passed to macros which discard them.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-20 14:28:30 +03:00
Lukasz Maciejonczyk ddb9f290e1 net: l2: openthread: Implement enable API function
It fixes #issues/26220.

openthread_start function is called when L2 enable(iface, true) is
called. openthread_stop is called when L2 enable(iface, false) is
called. openthread_stop makes the device to leave the OpenThread
network.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-07-02 08:43:45 -04:00
Markus Becker 350bab6d8c net: openthread: handle non mesh-local IPv6 addresses as DHCPv6
OpenThread BR can assign addresses via DHCPv6 or when acting as an
NCP, addresses can be added manually. Currently, those addresses are
handled in the same way as auto-configured addresses.

This patch maps the newly introduced mAddressOrigin of otNetifAddress to
Zephyr's net_addr_type.

This way an application can register a handler and differentiate by type
of assignment:

```
static void handler(struct net_mgmt_event_callback *cb,
                    u32_t mgmt_event,
                    struct net_if *iface)
{
  if (iface->config.ip.ipv6->unicast[i].addr_type == NET_ADDR_DHCP) {
  }
}
```

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-07-02 08:36:27 -04:00
Marek Porwisz 83f7f81d8d net: openthread: New build options for OpenThread
Some options were available in the options.cmake but were not reflected
in Kconfig.
Added possibility to enable additional configuration options for OT.
Some of the options were left commented out as those options are not
yet supported e.g. require Thread 1.2 or require shim changes.
As openthread has gazillion configuration options that are passed as
define value, created generic option for passing any number of those
values separated with space.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-30 07:48:08 -04:00
Marek Porwisz 81e0a05285 net: openthread: Simplify openthread enabling
Currently user needs to specify quite much additional options to enable
OpenThread support. He also needs to set ip address count,
heap size, etc depending on features enabled.
Nade changes to automatically select/set some of the options on
enabling OpenThread

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-30 07:48:08 -04:00
Lukasz Maciejonczyk 74b1c617af net: openthread: Add possibility to register ot state changed app cb
It may be useful for the application to register its own callback for
ot state changed event which does not override the current one.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-22 11:34:18 +03:00
Lukasz Maciejonczyk 4ad78d9249 net: openthread: Make function openthread_start be public
It may be useful to start openthread manually but with default
network settings. For instance when the application wants to register
ot state changed callback which should be done before openthread
starts.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-22 11:34:18 +03:00
Marek Porwisz 1130f8484e net: lib: openthread: Handle OT transmission in Thread task
OpenThread API is not thread-safe.
Moved creation of otMessage to the Thread task and created api
for passing it properly.
This way it should be less possible for an issue to occure eg.
during message buffer allocation.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-18 19:37:06 +02:00
Robert Lubos 7f9b85e8c3 net: openthread: Fix u16_t usage
PR #25936 introduced u16_t type usage and was merged after the type
transition in Zephyr.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-10 19:24:20 -04:00
Lukasz Maciejonczyk ff8b864f48 net: openthread: Make OT thread priority class be configurable
It add an option to configure openthread thread priority class
by the application if there is a such need.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 11:00:17 +03:00
Lukasz Maciejonczyk 3fa2fa9a50 net: openthread: Fix the order of adding net pkt in ot_receive_handler
Net pkt is added into the ot net list after queued net pkt into
the net_rx which bases on it. It affects in losting net pkt when for
instance ot thread is preemptive.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 10:57:00 +03:00
Eduardo Montoya fc1d0635df net: l2: openthread: Add config option to enable OpenThread ref. device
This option enables specific features used by Thread Certification
reference devices.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-06-08 21:41:40 +03:00
Markus Becker 2115b575a4 net: ieee802154: Allow to disable auto-start of 802.15.4 interfaces
Some radio drivers need configuration before start-up. Up to now only
the RF2XX drivers allowed this, but other radio drivers need this as
well. In particular for setting EUI64 addresses.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-08 19:55:19 +03:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Robert Lubos bc5b05f223 modules: mbedtls: Add Kconfig entry for MBEDTLS_MD and MBEDTLS_CIPHER
Due to new checks in mbedTLS config sanitizer, TLS option can no longer
be left enabled, when TLS is not used. OpenThread needs MBEDTLS_MD_C
and MBEDTLS_CIPHER_C even without TLS being used, so we need an option
to enable them manually.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-02 15:24:36 +02:00
Eduardo Montoya dd1a71f0c4 net: config: align Kconfig debug levels with OpenThread ones
OpenThread moved from 4 to 5 debug levels and it was not possible
to configure all of them with Kconfig.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-05-25 20:41:42 +02:00
Robert Lubos 139da50e3c net: openthread: Allow to disable automatic network attachment
Add OpenThread configuration option, which allows to configure and start
OpenThread stack operation manually. This mode should be used in NCP
devices, as well as is needed for certification purposes, where
OpenTread stack have to be configured by the test framework and not
initialize and join the network on its own.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-08 10:44:27 +03:00
Robert Lubos 3fa97df43c net: openthread: Update mbedTLS configuration
After the update, CMAC is also required when DTLS is not used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-07 23:27:49 -05:00
Lukasz Maciejonczyk ae68354428 net: l2: openthread: Add function for getting openthread default instance
The new function simplifies use of OpenThread API in Zephyr.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-05-05 16:30:20 +03:00
Lukasz Maciejonczyk 3ba7a3c82a net: l2: openthread: Add config option to enable OpenThread CoAP api
There was no way to use Openthread CoAP api in zephyr application so
far. These changes enable the feature. Now you can fully use CoAP
communication in an application working in Thread network.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-04-17 09:21:41 +03:00
Marek Porwisz ccd74755d5 net: openthread: Pass received frame to the proper thread.
Received frames shall be handled in the OpenThread thread, not in
the receiver thread.
Passed received frame to the function that will handle it in a proper
thread instead of calling otPlatRadioReceiveDone directly.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-04-09 16:19:20 +03:00
Markus Becker 0651141d84 net: openthread: Add NCP start-up and required platform changes
When NCP starts-up some of the initialisation functions of a regular
OpenThread device do not need to be called, because they get triggered
by wpantund via UART. Instead NCP initialisation needs to be called.

A small typo has been fixed as well.

Also initialisation for raw link packet interface has been added. Can be
used for picking up 802.15.4 frames and interpreting them in the
application.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-03-25 08:37:16 +02:00
Markus Becker 71ce94e0ed net: openthread: Add UART platform backend for NCP
Currently based on CDC-ACM. Can possibly be used with plain UART as
well.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-03-25 08:37:16 +02:00
Robert Lubos 24b6afaec2 net: openthread: Unify IS_ENABLED macro usage
Older OT code used preprocessor #if conditionals, while newer code
used IS_ENABLED macro. Unify the approach by switching to the latter
option.

Additinally, fix inclusion issue that came out after switching to
IS_ENABLED.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-10 14:36:24 +02: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
Robert Lubos b3a1ede830 net: openthread: Use settings subsystem
OpenThread settings implementation built on top of Zepyhr settings
submodule.

With this solution, OpenThread settings are identified with keys of
the following format: `ot/id/instance`, where `id` is assigned by
OpenThread stack, and `instance` is a 32-bit random number, both in
hex. The implementation makes use of `settings_load_subtree_direct`
function to iterate over settings instances. This allows the
OpenThread settings layer to be a fully transparent shim layer between
OpenThread/Zephyr APIs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-16 17:12:47 -06:00
Robert Lubos 649ec80c9e net: openthread: Update OpenThread version and better CMake integration
OpenThread recently introduced CMake build system into its repostiory
so we no longer need autotools to build OpenThread libraries and can
integrate them natively.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-16 11:08:09 +02:00
Robert Lubos e871ae9407 net: openthread: Allow to configure SED
Allow to select Sleepy End Device, and configure it during OpenThread
initialization.

According to Thread Specification, Sleepy End Devices should always
attach to the network as SED, to indicate increased buffer requirement
to a parent. Therefore, we reconfigure the Link Mode on each boot.

Note, that Poll Period value is not stored in the persistent storage,
hence we also need to initialize it on each boot.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-09 12:47:45 -05:00
Robert Lubos 4fe1da9f58 net: openthread: Process real ACK frame instead of fake one
OpenThread radio layer did not implement `ieee802154_radio_handle_ack`
API and provided fake ACK frame to the OpenThread.

This prevented proper Sleepy End Device operation, as it expects to
receive information in the ACK whether it should wait for more data to
come or should it put the radio to sleep.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-09 12:47:45 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Robert Lubos 83bb911a21 net: openthread: Update OpenThread version
Use the newest version of the OpenThread project, as updated in
https://github.com/zephyrproject-rtos/openthread/pull/2.

Introduce the following fixes along with the update (they're squashed to
retain bisectability of OT samples):

* Update configs and flags used
	Some OT configs were renamed, some new were introduced that Zephyr port
	needs to set.

* Add entropy platform driver
	OpenThreads `random` platform subsystem was replaced with `entropy`
	subsystem which is supposed to serve as an entropy source for the
	generic OpenThread's random generator.

* Halt OT thread when OT command is processed
	OpenThread can currently be processed from two threads - a
	genuine OpenThread thread and shell thread, which processes CLI
	commands. This could cause trouble, when context was switched
	during OT command processing (i.e. switched to process an incomming OT
	message, while still in unfinished command handler).

	In result, it was not possible to turn the commissioner role on via
	CLI, as the commissioner petition response was handled before the
	Commissioner::Start function finished its execution (if the
	petitioner is also the network leader, all messages are passed
	internally within the stack).

	Fix this by suspending the OT thread for the time of an OT command
	processing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-10-28 13:00:56 +02:00
Robert Lubos 063fefd15d net: openthread: Use Zephyr's mbedTLS instead of compiling own
So far OpenThread compiled it's own, internal copy of mbedTLS library.
This commit changes this behavior by using Zephyr's mbedTLS instance
appropriately configured for OpenThread needs.

Generic mbedTLS config file was used in this case, so that application
can still configure remaining parts of mbedTLS for it's own needs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-09-17 20:07:58 +08:00
Markus Becker 3178555878 net: openthread: Allow DHCP configuration of OpenThread in Zephyr
Certain Thread implementations (notably ARMs) require a DHCPv6
implementation.
Allow the usage of the relevant OpenThread configuration parameters in
Zephyr.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2019-07-22 13:23:05 +03:00
Robert Lubos 1ee8e0b055 net: openthread: Verify iface in net_mgmt event handler
OpenThread did not verify if the interface provided in the net_mgmt
handler is actually an OpenThread interface. In result, when multiple
network interfaces were used, different interfaces were processed by the
OpenThread handler, ending up in a crash.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-07-03 19:51:34 +03:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Robert Lubos 51a9e6f534 net: openthread: Do not overwrite stored dataset with defaults
This commit prevents a situation when stored and possibly modified
commissioner dataset is overwritten with default configuration during
OpenThread initialization.

It introduces a new function, openthread_start, which verifies if the
dataset is already stored, and if not, depending on configuration,
preloads the default configuration or initiates the join procedure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-04-23 16:43:36 +03:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Ulf Magnusson 214ef00db3 kconfig: subsys: net: Remove redundant dependencies
subsys/net/lib/lwm2m/Kconfig.ipso is 'source'd within an 'if LWM2M', in
subsys/net/lib/lwm2m/Kconfig, so the 'depends on LWM2M' is redundant.

The 'depends on NET_IPV4' and 'depends on NET_L2_OPENTHREAD' are within
corresponding 'if's in the same file.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 09:49:59 -05:00
Takumi Ando 1981eef674 net/l2: openthread: Add support for automatic joiner start
We sometimes want to join a device to OpenThread mesh automatically.
This commit adds supports to do by Kconfig.

The default of CONFIG_OPENTHREAD_JOINER_PSKD is based on this page:
https://codelabs.developers.google.com/codelabs/openthread-hardware/

Signed-off-by: Takumi Ando <takumi.ando@atmark-techno.com>
2019-03-04 19:51:10 -05:00
Tomasz Bursztyka d086f50243 net/l2: Switch OpenThread L2 to new net_pkt allocator
Maybe there is an easier way to fill in the buffer in one call from an
otMessage.

Switch "frag" keyword to "buf", as "frag" is now reserved for actual
packet fragmentation and not buffer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:20 -05:00
Tomasz Bursztyka a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Robert Lubos 43a431e149 net: openthread: Set mesh_local flag in mesh-local OT addresses
Mark automatically and statically configured mesh-local addresses
with mesh_local flag, so that they are not used as a source for
off-mesh destinations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-28 21:24:26 -05:00
Robert Lubos c349bafab3 net: openthread: Do not register RLOC and ALOC addresses
In OpenThread RLOC address and ALOC address are used for internal mesh
routing and should not be used by applications as they can change
dynamically during runtime. Therefore prevent registering them on Zephyr
interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-25 10:09:27 +02:00
Robert Lubos 73ec83a9a5 net: openthread: Increase default stack size when commissioner is on
OpenThread commissioner feature has extra stack requirements, hence
increase it in this configuration.

Fixes #12455

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-18 15:24:16 +02:00