Book Image

Embedded Linux Development Using Yocto Project Cookbook - Second Edition

By : Alex Gonzalez
Book Image

Embedded Linux Development Using Yocto Project Cookbook - Second Edition

By: Alex Gonzalez

Overview of this book

The Yocto Project has become the de facto distribution build framework for reliable and robust embedded systems with a reduced time to market.You'll get started by working on a build system where you set up Yocto, create a build directory, and learn how to debug it. Then, you'll explore everything about the BSP layer, from creating a custom layer to debugging device tree issues. In addition to this, you’ll learn how to add a new software layer, packages, data, scripts, and configuration files to your system. You will then cover topics based on application development, such as using the Software Development Kit and how to use the Yocto project in various development environments. Toward the end, you will learn how to debug, trace, and profile a running system. This second edition has been updated to include new content based on the latest Yocto release.
Table of Contents (13 chapters)
Title Page
Dedication
Packt Upsell
Foreword
Contributors
Preface
Index

Running a Toaster Docker container


Docker is a software technology that provides operating system level virtualization. Functionality-wise it can be compared with a virtual machine, except that it suffers less of a performance penalty. On Linux it uses the resource isolation features of the Linux kernel to provide abstraction and process isolation. It allows you to create containers that run on Docker and are independent of the operating system underneath.

There are Docker instances of the Toaster user interface available, which will be introduced in this recipe.

How to do it...

  1. To install Docker on your Ubuntu 16.04 machine, add the GPG key for the official Docker repository to the system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. Then add the Docker repository to APT sources:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  1. Next, update the package database with the Docker packages from the newly added repository:
$ sudo apt-get update$ sudo apt-get install docker-ce
  1. Add your user to the docker group:
$ sudo usermod -aG docker ${USER}$ su - ${USER}
  1. Finally, test run Docker by running the hello-world container:
$ docker run hello-world
  1. To run a docker-toaster instance, we will first create a directory in our host machine for the docker container to store the builds:
$ mkdir /opt/yocto/docker-toaster
  1. We can then instruct Docker to run the crops/toaster container and point its /workdir directory to the local directory we just created:
$ docker run -it --rm -p 127.0.0.1:18000:8000 -v /opt/yocto/docker-toaster:/workdir crops/toaster

Note

If you see the following error:Refusing to use a gid of 0Traceback (most recent call last):  File "/usr/bin/usersetup.py", line 62, in <module>    subprocess.check_call(cmd.split(), stdout=sys.stdout, stderr=sys.stderr)  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call    raise CalledProcessError(retcode, cmd)subprocess.CalledProcessError: Command '['sudo', 'restrict_groupadd.sh', '0', 'toasteruser']' returned non-zero exit status 1 Make sure the /opt/yocto/docker-toaster directory was created before running Docker and is not owned by root. If you don't create it beforehand, Docker will do it with the root user and the setup will fail as above. See https://github.com/crops/poky-container/issues/20.

Note

Note that you can replace the 127.0.0.1 above with an IP address that is externally accessible if you are running Docker on a different machine.

  1. You can now detach from the docker container with Ctrl + P Ctrl + Q. Check the container is still running with:
$ docker ps
  1. You can now access the Toaster web interface at http://127.0.0.1:18000.
  2. The docker container can be stopped with the following command:
$ docker stop <container-id>

See also