Using Prebuilt Container Image for Development Print


This application note explains how to use a prebuilt container image for development.

Perform the following steps:

  1. Pull the docker image (11GB):
  2. $ docker pull ghcr.io/emcraftsystems/ubuntu14-6ull:latest
    ...

  3. Prepare a directory on the host to map to the docker:
  4. $ mkdir docker-work
    $ chmod 777 docker-work

  5. Run the docker:
  6. $ docker run -i -t --security-opt "label=disable" -v `pwd`/docker-work:/work ghcr.io/emcraftsystems/ubuntu14-6ull:latest
    dev@8a2a7bac0970:/home/dev$ ls -l
    total 8
    -rw-r--r-- 1 dev dev 521 Sep 8 16:28 README.txt
    drwxr-xr-x 14 dev dev 4096 Sep 8 15:22 yocto-1.8.1-emcraft
    dev@8a2a7bac0970:/home/dev$ ls -l /work
    total 0
    dev@8a2a7bac0970:/home/dev$

  7. Install the BSP: on the host, copy it to the shared directory and then unpack in the docker:
  8. dev@89639e42b08d:/home/dev$ ls /work/
    total 133328
    linux-imx6ull-2.4.4.tar.bz2
    dev@89639e42b08d:/home/dev$

  9. Build the bootable images:
  10. dev@89639e42b08d:/home/dev$ cd linux-imx6ull-2.4.4/
    dev@89639e42b08d:/home/dev/linux-imx6ull-2.4.4$ source ./ACTIVATE.sh
    dev@89639e42b08d:/home/dev/linux-imx6ull-2.4.4$ cd projects/rootfs/
    dev@89639e42b08d:/home/dev/linux-imx6ull-2.4.4/projects/rootfs$ make
    ...
    dev@89639e42b08d:/home/dev/linux-imx6ull-2.4.4/projects/root$ ls
    ...
    rootfs.dtb
    rootfs.uImage
    rootfs.ubi

  11. If you need to keep the project's changes in the container image, do not exit the image, commit the changes to the docker. Run on the host:
  12. $ docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    89639e42b08d ghcr.io/emcraftsystems/ubuntu14-6ull:latest "/bin/bash" 10 minutes ago Up 10 minutes affectionate_payne
    $ docker commit 89639e42b08d ghcr.io/emcraftsystems/ubuntu14-6ull:latest
    ...

  13. Exit the docker.

Perform the following steps tо add a new package to the Yocto's packages collection and to the project:

  1. Start the docker image:
  2. $ docker run -i -t --security-opt "label=disable" -v `pwd`/docker-work:/work ghcr.io/emcraftsystems/ubuntu14-6ull:latest
    dev@8e360c1341d7:/home/dev$

  3. Activate Yocto build environment:

    dev@8e360c1341d7:/home/dev$ cd yocto-1.8.1-emcraft
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft$
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft$ source oe-init-build-env build
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$

  4. As an example, add the vim package to the packages collection. Edit core-image-qte-sdk.bb and add vim to the IMAGE_INSTALL list:
  5. dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ emacs ../meta-emcraft/recipes-qt/images/core-image-qte-sdk.bb
    ...
    tcsh \
    vim \
    "

    export IMAGE_BASENAME = "core-image-qte-sdk"
    ...

  6. Download and install Yocto build cache (6GB):
  7. dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ wget https://emcraft.com/misc/sstate-cache-6ull-1.8.1.tar .
    ...
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ tar xf sstate-cache-6ull-1.8.1.tar
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ rm sstate-cache-6ull-1.8.1.tar
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ ls -l
    total 32
    -rw-r--r-- 1 dev dev 0 Sep 8 18:44 bitbake.lock
    drwxr-xr-x 1 dev dev 4096 Sep 8 18:44 cache
    drwxr-xr-x 1 dev dev 4096 Sep 8 15:24 conf
    drwxr-xr-x 259 dev dev 4096 Sep 7 13:38 sstate-cache
    drwxr-xr-x 1 dev dev 4096 Sep 8 16:05 tmp
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$

  8. Rebuild the package collection and check that the vim package now exists:
  9. dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ bitbake core-image-qte-sdk
    Loading cache:
    ...
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$ find tmp/deploy/ipk/ -name vim*
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-dbg_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-common_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-help_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-vimrc_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-doc_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-tutor_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-syntax_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    tmp/deploy/ipk/cortexa5hf-vfp-neon/vim-dev_7.4.481-r0_cortexa5hf-vfp-neon.ipk
    dev@8e360c1341d7:/home/dev/yocto-1.8.1-emcraft/build$

  10. On the host, start a new shell in the running docker:
  11. $ docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    8e360c1341d7 ghcr.io/emcraftsystems/ubuntu14-6ull:latest "/bin/bash" 29 minutes ago Up 29 minutes quirky_ritchie
    $ docker exec -it 8e360c1341d7 bash
    dev@8e360c1341d7:/home/dev$

  12. Check that vim is now available to add to the target image:
  13. dev@8e360c1341d7:/home/dev/linux-imx6ull-2.4.4$ source ./ACTIVATE.sh dev@8e360c1341d7:/home/dev/linux-imx6ull-2.4.4$ cd projects/rootfs/ dev@8e360c1341d7:/home/dev/linux-imx6ull-2.4.4/projects/rootfs$ emacs rootfs.initramfs
    ...
    opkg wt
    opkg vim

  14. Exit with save.
  15. dev@8e360c1341d7:/home/dev/linux-imx6ull-2.4.4/projects/rootfs$ make
    ...
    dev@8e360c1341d7:/home/dev/linux-imx6ull-2.4.4/projects/rootfs$