Unifying Legato and Yocto Build Environments in a Docker container

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:

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:

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?

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

@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.

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

I have gotten this mostly working with the following:

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

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 (3.5 KB)

@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 .