# Unifying Legato and Yocto Build Environments in a Docker container

**URL:** <https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716>\
**Category:** Legato Linux distribution (Yocto project)\
**Created:** [March 13, 2024, 6:38pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716 "2024-03-13T18:38:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)\
**Post date:** [March 13, 2024, 6:38pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/1 "2024-03-13T18:38:33Z")

</div>

I am trying to deploy one docker container to support a team of developers targeting the WP7702. We need to implement secure boot so per your App Notes, we need to build the base images and sign them and therefor need the full Yocto environment.

1. Using the `travis.yml` file in the `legato-af` repo as a template, create a base `ubuntu:xenial` dockerfile
2. Download the Yocto Distro from Sierra’s Firmware Components 15.1 Page
3. Run the container and mount the uncompressed Yocto Environment, navigate to it and run `make dev`
4. At this point I can run `bitbake mdm9x28-image-minimal` and can build the `yocto_wp77xx.4k.cwe` and `appsboot_wp77xx.cwe` images. I can also modify these (kernel mods, signing, etc.) by modifying the bb recipes.

This leaves the following outstanding:

1. building the base legato cwe image
2. building and installing custom applications and kernel modules
3. building and installing FOSS tools that yocto already has recipes for (will ask about in another thread)

regarding #1, I notice that `make dev` outputs the following:

```auto
meta-swi-wp/common.mk:75: "Legato: build disabled since '/tmp/yocto/legato/' does not exist"

```

checking out `legato-af` at the Firmware 15.1 tag `21.05.0` and placing it into the directory removes the error, but does not build legato. Both trying to build legato host tools natively and via `bitbake legato-af` result in the error:

```auto
Makefile:131: build/localhost/.config.mk: No such file or directory
  KSET build/localhost/.config - TARGET_LOCALHOST
python3: can't open file '/tmp/yocto/legato/3rdParty/Kconfiglib/setconfig.py': [Errno 2] No such file or directory
Makefile:392: recipe for target 'build/localhost/.config' failed

```

This leave the following questions:

- How can I build legato’s host tools (`mksys`,`mkapp`,etc) leveraging the hooks in the yocto distro?
- How do i build the base legato cwe in the yocto environment?
- Where do I point `WP77XX_TOOLCHAIN_DIR` and `WP77XX_TOOLCHAIN_PREFIX` in the yocto environment for the host tools to work?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 14, 2024, 1:59am UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/2 "2024-03-14T01:59:12Z")

</div>

why don’t you build the legato image in leaf directory?

---

<div class="post-metadata">

**Author:** ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)\
**Post date:** [March 14, 2024, 12:53pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/3 "2024-03-14T12:53:55Z")

</div>

@jyijyi the core reason is I am trying to reduce the number of tools needed to be learned by my team. As we already require yocto to build the signed images for Secure Boot, I am trying to build around it. Yocto is far too complicated, but it is the defacto BSP framework, has excellent documentation, and most the team has some experience with it.

I also imagine that leaf is leveraging the toolchain generated by yocto to setup the environment so it seems like a more clean dev environment to just use the toolchain that has already been built rather than using another tool to re-download it.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 14, 2024, 1:07pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/4 "2024-03-14T13:07:50Z")

</div>

If you need to build legato app, you still need leaf+vscode

---

<div class="post-metadata">

**Author:** ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)\
**Post date:** [April 4, 2024, 3:53pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/5 "2024-04-04T15:53:41Z")

</div>

I have gotten this mostly working with the following:

```auto
tar xf Legato-Dist-Source-mdm9x06-SWI9X06Y_03.00.13.00.tar.bz2
cd ./yocto
repo init -u git://github.com/legatoproject/manifest -m legato/releases/21.05.0.xml
repo sync
make dev
cd ../legato
make wp77xx

```

---

<div class="post-metadata">

**Author:** ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)\
**Post date:** [April 10, 2024, 3:04pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/6 "2024-04-10T15:04:39Z")

</div>

This is mainly to answer my own questions and the Dockerfile to build the development container

- While the repo manifest to build the yocto environment is public (`git://github.com/legatoproject/manifest`) it references private repositories and cannot be used unless given access to them
  - Downloading the SDK and Yocto Env from the firmware components page is a stopgap to this

- The legato framework is easiest built by using the `Makefile` in the Yocto Env. The legato source must be placed in `yocto/legato`
- `repo` must be used to download legato, but the legato manifest will not work because of a change to github in 2022. To fix this you must have `git config --global url."git@github.com:".insteadOf git://github.com/ `
- a legato yocto recipe also fails without `git config --global --add safe.directory '*'` (it uses got to git commit hashes)

Once you run the container you can go into `yocto/legato` and run `make wp77xx` to build the legato ufi and after that `bitbake mdm9x28-image-minimal` to build all layers that are in the FW 15.1 Component page.

[wp77xx.dockerfile](https://forum.legato.io/uploads/short-url/b1oSE8VXEurIXYN03dQyY5E5qcW.dockerfile) (3.5 KB)

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [April 22, 2024, 7:16am UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/7 "2024-04-22T07:16:28Z")

</div>

@upsampled Why do you want to merge yocto and legato build? A single container is anyway much needed, but building legato outside yocto using VSCode is much faster vs building it inside the yocto .

---

<div class="post-metadata">

**Author:** ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)\
**Post date:** [June 2, 2025, 12:15pm UTC](https://forum.legato.io/t/unifying-legato-and-yocto-build-environments-in-a-docker-container/6716/8 "2025-06-02T12:15:02Z")

</div>

@Pankaj this is mainly because there are hacks in that look for the legato code and then build both development and production code. You could probably get away with using pre-compiled code, but I’d rather see and log/audit the code I am using.

Also comparatively does not increase the compile time because Yocto is so slow.
