[meta-networking,2/4] ot-daemon: add recipe for OpenThread daemon

Message ID 20220404130354.2131131-2-stefan@datenfreihafen.org
State New
Headers show
Series [meta-networking,1/4] ot-br-posix: add recipe for an OpenThread Border Router | expand

Commit Message

Stefan Schmidt April 4, 2022, 1:03 p.m. UTC
From: Stefan Schmidt <stefan.schmidt@huawei.com>

The OpenThread daemon allows Linuxes devices to participate in a Thread
mesh network without acting as a full border router. The device
participates like any other child or router devices within the network.

This same repo is used for range of different modes to run the
OpenThread code. From bare metal over vendor SDKs to posix platforms.
For this recipe the focus is on the Linux posix implementation and we do
not pull in all the git submodules on purpose.

There are openthread enabled recipes in meta-zephyr for people who want
to also use OpenThread on MCU based platforms on top of Zephyr.

Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
---
 .../openthread/ot-daemon_git.bb               | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb

Comments

Khem Raj April 5, 2022, 3:16 a.m. UTC | #1
fails on x86_64/glibc see
https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610

On Mon, Apr 4, 2022 at 9:04 AM Stefan Schmidt <stefan@datenfreihafen.org> wrote:
>
> From: Stefan Schmidt <stefan.schmidt@huawei.com>
>
> The OpenThread daemon allows Linuxes devices to participate in a Thread
> mesh network without acting as a full border router. The device
> participates like any other child or router devices within the network.
>
> This same repo is used for range of different modes to run the
> OpenThread code. From bare metal over vendor SDKs to posix platforms.
> For this recipe the focus is on the Linux posix implementation and we do
> not pull in all the git submodules on purpose.
>
> There are openthread enabled recipes in meta-zephyr for people who want
> to also use OpenThread on MCU based platforms on top of Zephyr.
>
> Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
> ---
>  .../openthread/ot-daemon_git.bb               | 27 +++++++++++++++++++
>  1 file changed, 27 insertions(+)
>  create mode 100644 meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb
>
> diff --git a/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb b/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb
> new file mode 100644
> index 000000000..7bce46e22
> --- /dev/null
> +++ b/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb
> @@ -0,0 +1,27 @@
> +# SPDX-FileCopyrightText: Huawei Inc.
> +#
> +# SPDX-License-Identifier: Apache-2.0
> +SUMMARY = "OpenThread Daemon is an OpenThread POSIX build mode that runs OpenThread as a service."
> +SECTION = "net"
> +LICENSE = "BSD-3-Clause"
> +LIC_FILES_CHKSUM = "file://LICENSE;md5=543b6fe90ec5901a683320a36390c65f"
> +DEPENDS = "readline"
> +SRCREV = "7dfde1f12923f03c9680be4d838b94b7a2320324"
> +PV = "0.1+git${SRCPV}"
> +
> +# We are not using the git submodules fetch on purpose. None the third_party
> +# components are needed for the plain posix build and we can avoid all the
> +# differently licensed code.
> +SRC_URI = "git://github.com/openthread/openthread.git;protocol=https;branch=main \
> +           "
> +
> +S = "${WORKDIR}/git"
> +
> +inherit cmake
> +
> +EXTRA_OECMAKE = "-DOT_DAEMON=ON \
> +                 -DOT_SPINEL_RESET_CONNECTION=ON \
> +                 -DOT_THREAD_VERSION=1.2 \
> +                 -DOT_COVERAGE=OFF \
> +                 -DOT_PLATFORM=posix \
> +                 "
> --
> 2.35.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#96379): https://lists.openembedded.org/g/openembedded-devel/message/96379
> Mute This Topic: https://lists.openembedded.org/mt/90240938/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Stefan Schmidt April 5, 2022, 8:39 a.m. UTC | #2
Hello Khem.

On 05.04.22 05:16, Khem Raj wrote:
> fails on x86_64/glibc see
> https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610

Ah, its not x86_64/glibc (I tested this) but the fact that the 
autobuilder uses poky and I tested here without DISTRO in openembedded core.

Seems the code base it not happy about the gcc changes to warn on the 
combination of _FORTIFY_SOURCE and non-optimized code:

error: #warning _FORTIFY_SOURCE requires compiling with optimization 
(-O) [-Werror=cpp]

Will fix and resend.

regards
Stefan Schmidt
Khem Raj April 5, 2022, 6:08 p.m. UTC | #3
On Tue, Apr 5, 2022 at 4:39 AM Stefan Schmidt <stefan@datenfreihafen.org>
wrote:

>
> Hello Khem.
>
> On 05.04.22 05:16, Khem Raj wrote:
> > fails on x86_64/glibc see
> > https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610
>
> Ah, its not x86_64/glibc (I tested this) but the fact that the
> autobuilder uses poky and I tested here without DISTRO in openembedded
> core.
>
> Seems the code base it not happy about the gcc changes to warn on the
> combination of _FORTIFY_SOURCE and non-optimized code:
>
> error: #warning _FORTIFY_SOURCE requires compiling with optimization
> (-O) [-Werror=cpp]


Hmm so you are not using security flags ?
That’s not good :) you should inherit good defaults


>
> Will fix and resend.
>
> regards
> Stefan Schmidt
>
Stefan Schmidt April 7, 2022, 7:28 p.m. UTC | #4
Hello Khem.

On 05.04.22 20:08, Khem Raj wrote:
> 
> 
> On Tue, Apr 5, 2022 at 4:39 AM Stefan Schmidt <stefan@datenfreihafen.org 
> <mailto:stefan@datenfreihafen.org>> wrote:
> 
> 
>     Hello Khem.
> 
>     On 05.04.22 05:16, Khem Raj wrote:
>      > fails on x86_64/glibc see
>      >
>     https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610
>     <https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610>
> 
>     Ah, its not x86_64/glibc (I tested this) but the fact that the
>     autobuilder uses poky and I tested here without DISTRO in
>     openembedded core.
> 
>     Seems the code base it not happy about the gcc changes to warn on the
>     combination of _FORTIFY_SOURCE and non-optimized code:
> 
>     error: #warning _FORTIFY_SOURCE requires compiling with optimization
>     (-O) [-Werror=cpp]
> 
> 
> Hmm so you are not using security flags ?

You mean Oniro is not using them? Not sure I can follow you train of 
thoughts here. :-)

> That’s not good :) you should inherit good defaults

The problem above was from the autobuilder error you pointed me to, 
building with Poky not Oniro.

-O2 -D_FORTIFY_SOURCE=2 itself works on the upstream code base, but it 
needs optimization enabled (as the error message states). No idea why 
that went wrong on the autobuilder.

regards
Stefan Schmidt
Khem Raj April 7, 2022, 7:36 p.m. UTC | #5
On Thu, Apr 7, 2022 at 3:28 PM Stefan Schmidt <stefan@datenfreihafen.org> wrote:
>
>
> Hello Khem.
>
> On 05.04.22 20:08, Khem Raj wrote:
> >
> >
> > On Tue, Apr 5, 2022 at 4:39 AM Stefan Schmidt <stefan@datenfreihafen.org
> > <mailto:stefan@datenfreihafen.org>> wrote:
> >
> >
> >     Hello Khem.
> >
> >     On 05.04.22 05:16, Khem Raj wrote:
> >      > fails on x86_64/glibc see
> >      >
> >     https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610
> >     <https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610>
> >
> >     Ah, its not x86_64/glibc (I tested this) but the fact that the
> >     autobuilder uses poky and I tested here without DISTRO in
> >     openembedded core.
> >
> >     Seems the code base it not happy about the gcc changes to warn on the
> >     combination of _FORTIFY_SOURCE and non-optimized code:
> >
> >     error: #warning _FORTIFY_SOURCE requires compiling with optimization
> >     (-O) [-Werror=cpp]
> >
> >
> > Hmm so you are not using security flags ?
>
> You mean Oniro is not using them? Not sure I can follow you train of
> thoughts here. :-)

poky defaults now a days include security_flags.inc which enables
fortify and other
good security stuff from compiler's point of view. So it seems your
distro is not inheriting
all the default distro policies was what I was trying to point at.

>
> > That’s not good :) you should inherit good defaults
>
> The problem above was from the autobuilder error you pointed me to,
> building with Poky not Oniro.
>
> -O2 -D_FORTIFY_SOURCE=2 itself works on the upstream code base, but it
> needs optimization enabled (as the error message states). No idea why
> that went wrong on the autobuilder.

-O2 is also poky default via SELECTED_OPTIMIZATION. So unless recipe is doing
something exotic to ignore these flags then it might happen because
SECURITY_FLAGS
are passed via CC not CFLAGS unlike SELECTED_OPTIMIZATION which is passed via
CFLAGS.

>
> regards
> Stefan Schmidt
Stefan Schmidt April 7, 2022, 7:56 p.m. UTC | #6
Hello.

On 07.04.22 21:36, Khem Raj wrote:
> On Thu, Apr 7, 2022 at 3:28 PM Stefan Schmidt <stefan@datenfreihafen.org> wrote:
>>
>>
>> Hello Khem.
>>
>> On 05.04.22 20:08, Khem Raj wrote:
>>>
>>>
>>> On Tue, Apr 5, 2022 at 4:39 AM Stefan Schmidt <stefan@datenfreihafen.org
>>> <mailto:stefan@datenfreihafen.org>> wrote:
>>>
>>>
>>>      Hello Khem.
>>>
>>>      On 05.04.22 05:16, Khem Raj wrote:
>>>       > fails on x86_64/glibc see
>>>       >
>>>      https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610
>>>      <https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1610>
>>>
>>>      Ah, its not x86_64/glibc (I tested this) but the fact that the
>>>      autobuilder uses poky and I tested here without DISTRO in
>>>      openembedded core.
>>>
>>>      Seems the code base it not happy about the gcc changes to warn on the
>>>      combination of _FORTIFY_SOURCE and non-optimized code:
>>>
>>>      error: #warning _FORTIFY_SOURCE requires compiling with optimization
>>>      (-O) [-Werror=cpp]
>>>
>>>
>>> Hmm so you are not using security flags ?
>>
>> You mean Oniro is not using them? Not sure I can follow you train of
>> thoughts here. :-)
> 
> poky defaults now a days include security_flags.inc which enables
> fortify and other
> good security stuff from compiler's point of view. So it seems your
> distro is not inheriting
> all the default distro policies was what I was trying to point at.

We actually included security_flags.inc from the very beginning. :-)
First in oniro-linux only and since March also in oniro-zephyr.

regards
Stefan Schmidt

Patch

diff --git a/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb b/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb
new file mode 100644
index 000000000..7bce46e22
--- /dev/null
+++ b/meta-networking/recipes-connectivity/openthread/ot-daemon_git.bb
@@ -0,0 +1,27 @@ 
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+SUMMARY = "OpenThread Daemon is an OpenThread POSIX build mode that runs OpenThread as a service."
+SECTION = "net"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=543b6fe90ec5901a683320a36390c65f"
+DEPENDS = "readline"
+SRCREV = "7dfde1f12923f03c9680be4d838b94b7a2320324"
+PV = "0.1+git${SRCPV}"
+
+# We are not using the git submodules fetch on purpose. None the third_party
+# components are needed for the plain posix build and we can avoid all the
+# differently licensed code.
+SRC_URI = "git://github.com/openthread/openthread.git;protocol=https;branch=main \
+           "
+
+S = "${WORKDIR}/git"
+
+inherit cmake
+
+EXTRA_OECMAKE = "-DOT_DAEMON=ON \
+                 -DOT_SPINEL_RESET_CONNECTION=ON \
+                 -DOT_THREAD_VERSION=1.2 \
+                 -DOT_COVERAGE=OFF \
+                 -DOT_PLATFORM=posix \
+                 "