📜 ⬆️ ⬇️

We start Yocto Linux on the virtual machine

In the development process, for example, for Intel Edison or Galileo, it may happen that the device needed for the experiments was not at hand. A similar thing happens when there is hardware, but the OS installed on it does not support all the capabilities required for the project. What to do?


One solution to this problem is to launch the target operating system on the virtual machine. You can compile, deploy and test programs on it. Today we will talk about how to create Yocto Linux images that are suitable for running in virtual environments, for example, in a simple software emulator QEMU. In addition, these images can be used in systems with hypervisors, for example, in Microsoft Hyper-V on Windows.

Prerequisites


In order to successfully master this guide, you will need the following:


Computer preparation


As the root user (or using “sudo”), execute the following command on the computer:
')
# apt-get install wget git-core unzip make gcc g++ build-essential subversion sed autoconf automake texi2html texinfo coreutils diffstat python-pysqlite2 docbook-utils libsdl1.2-dev libxml-parser-perl libgl1-mesa-dev libglu1-mesa-dev xsltproc desktop-file-utils chrpath groff libtool xterm gawk fop 

Note number 1 . The success of this command depends on the version of Ubuntu / Debian that you are using. However, you can easily, in order to resolve package dependencies, use “aptitude” and forcefully install the appropriate versions of the necessary packages (for example, with the following command: “aptitude install libsdl1.2-dev”).

Note number 2 . For other Linux distributions, such as RedHat, CentOS, Fedora, SuSe, Gentoo, and so on, we would advise you to look for suitable versions of the above packages using the appropriate package manager (for example, zypper or yum).

Step one. Setting up a working directory


These commands must be executed as a normal user, root privileges are not needed.

 # cd # mkdir yocto-2.0 # cd yocto-2.0 # wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2 # tar xvjf poky-jethro-14.0.0.tar.bz2 # cd poky-jethro-14.0.0/ 

Note number 3 . Here you can select another release thread for Yocto. In this tutorial, we use Yocto Poky 2.0.14.0.0 (Jethro).

Note number 4 . If you want to download the latest release of the Yocto source code, you can refer to the master branch. You will need to change a couple of commands from the above listing to the following:

 # git clone git://git.yoctoproject.org/poky.git # cd poky 

Note number 5 . You can select the desired branch using its code name. For example:

 # git clone -b jethro git://git.yoctoproject.org/poky.git 

Step two. Setting Environment Variables


This setting is very simple, it is performed using a script from the developers of Yocto.

 # . ./oe-init-build-env 

After you run the script and it successfully runs, the build folder will become a new workspace. For example, the path to this folder might look like this:

 /home/<your user>/yocto-2.0/poky-jethro-14.0.0/build/. 

Step three. BitBake setup


After executing the script from the previous step, the conf/local.conf file was created.

This configuration file is needed to configure BitBake, the Yocto build system (this is the central component of the Yocto Project).

Edit the BitBake configuration file in any text editor you use. We edited it in the nano editor. This is a simple console text editor for Unix environments. It starts like this:

 # cd conf/ # nano local.conf 

Uncomment the following lines in the configuration file:

 DL_DIR ?= "${TOPDIR}/downloads" SSTATE_DIR ?= "${TOPDIR}/sstate-cache" TMPDIR ?= "${TOPDIR}/tmp" SDKMACHINE ?= "i686" 

We advise you to collect images, including in them all the available additional features. Although the resulting image files are rather big (about 8 GB each), they include everything that is possible and, as a result, are suitable for any development tasks.

 EXTRA_IMAGE_FEATURES = "dbg-pkgs dev-pkgs ptest-pkgs tools-sdk tools-debug eclipse-debug tools-profile tools-testapps debug-tweaks" 

Save the changes to the local.conf file. In our case, this is done using the Ctrl + X key combination. Now run the following commands:

 # cd .. # hob 

In response, Hob should start (a graphical user interface for BitBake based on GTK-2). He will proceed to verify that the assembly system is configured correctly.


Check build system setup

After verification, select from the dropdown menu, as the target system, qemux86.


Target system selection

Wait for Hob to finish parsing the BitBake recipes and generate a dependency tree. Then select a recipe for the target image from the corresponding drop-down list. In our case, a full image without a graphical interface is selected: core-image-full-cmdline .


Choosing a recipe for image assembly

After that click on the “Advanced configuration” button.


Go to advanced settings

On the “Image types” tab, in the “Distro” menu, select “poky” if you want to build the latest stable release. Then, in the “Image types” list, select the desired image format. It usually makes sense to choose here “.iso”, “.vdi” and “.vmdk”. Images in such formats are most convenient for practical use.


Select image format

On the Output tab, configure the settings to suit your needs. We recommend adding at least 4 GB of free space to the image to enable the SDK for the i686 architecture (if you experiment with the Edison board). In addition, it was discovered that it is very useful to set “deb” as the format of the root file system. As a result, we have come to the following settings.


Image customization

Now you can save the settings you made by clicking on the “Save” button and, in the main window, click on the “Build Image” button to start the image building process.


Running the build

Hob will launch a bitbake core-image-full-cmdline instance with the specified settings.


Assembly

Note number 6 . The assembly process can take a very long time. But, depending on the capabilities of your computer, you can change the number of threads used in the build by configuring the “BitBake parallel threads” and “Make parallel threads” parameters in the Hob settings window.


Setting the number of threads used in the build

Note number 7 . And finally, when using Hob, you have the opportunity to choose which packages you want to include in the image you plan to build. In order to do this, before starting the image assembly, click on the “Edit image recipe” button.


Transition to setting the composition of packages included in the image

In the window that appears, select the packages you want to add to the image.


Package selection

When the process of assembling images is complete, you can immediately test them! To do this, click on the button "Run image". Hob will launch QEMU with the qemux86 image just assembled.


The image is assembled and ready to run.

At the very beginning of the launch, the system will ask you to set a superuser password.


Password entry

This will launch another UNIX command window. You can watch the download indicator in the background of the Yocto Project logo.


Loading

After downloading, you can log in to the root account of the newly created Yocto image. Remember that by adding a debugging parameter (debug-tweak) to the EXTRA_IMAGE_FEATURES variable in the conf / local.conf file, you can log in as root-user without a password. Otherwise, you will need to set a password for the root user in the BitBake recipe before building the image.


Login

Now everything is ready to start experimenting with the QEMU virtual machine, which runs Yocto Linux.

Note number 8 . After assembling the Yocto image according to the method presented above, 89.8 GB will be used on the disk.


The size of the data generated during the assembly of images

Results


Yocto Linux images generated during the build can be found at "~ / yocto-2.0 / poky-jethro-14.0.0 / build / tmp / deploy / images / qemux86 / *". Here, depending on the settings, there may be files in various formats. For example, .iso, .vmdk, .vdi files.

Now you can run the resulting images using the emulator or hypervisor that you usually use. Among them - Microsoft Hyper-V, VMware Fusion, VirtualBox and others. Successful experiments!

Source: https://habr.com/ru/post/303960/


All Articles