Skip to content
Martin Olejar edited this page Sep 23, 2017 · 41 revisions

Embedded Linux VM is a Virtual Machine for local embedded Linux development, build with Vagrant tool

This project aims to make spinning up a simple local development environment incredibly quick and easy for i.MX platforms. It should take 5-10 minutes to build or rebuild the VM from scratch with minimal interaction from user side.

Dependencies

You must have installed the following software in your host OS:

  • VirtualBox - General-purpose full virtualizer for x86 hardware, targeted at server, desktop and embedded use.
  • Vagrant - Create and configure lightweight, reproducible, and portable development environments.

The Vagrant 1.9.7 and upper version doesn't work correctly in Windows 7, please use Vagrant 1.9.6 !

Useful commands

  • vagrant up - bring the VM up and provision it
  • vagrant ssh - enter SSH session for provisioned VM
  • vagrant halt - shutdown actually running VM
  • vagrant reload - reload the VM with actual config, e.g. if you change the memory size or some else in local.conf
  • vagrant destroy - completely remove the VM with all user data (when you run vagrant up again your VM will be completely fresh)
  • vagrant status – get environment status to see whether machines are running or not.
  • vagrant box update - update the box for the current Vagrant environment if there are updates available.
  • vagrant plugin install <plugin name> - install Vagrant plugin

The commands above effects the states of the virtual machines and the general flow can be described in the following diagram:

Vagrant states

commands for saving and restoring a snapshot from VM.

  • vagrant snapshot save <snapshot name> - save a new named snapshot
  • vagrant snapshot restore <snapshot name> - restore the named snapshot
  • vagrant snapshot list - will list all the snapshots taken.

The description of all Vagrant commands are located here: https://www.vagrantup.com/docs/cli

How to Start

Open shell terminal and navigate into root directory with Vagrantfile script.

Install vagrant plugin for adding VirtualBox guest support in Windows OS. Run it only first time after installing Vagrant application

  $ vagrant plugin install vagrant-vbguest

Run vagrant up to bring the VM up and provision it. If your PC has more than one network adapter, then select the right for internet access. After the VM is brought up and provisioned use vagrant ssh command to enter an SSH session on it.

  $ vagrant up
  $ ...
  $ vagrant ssh

For exiting from SSH session just push Ctrl + D keys or run logout. The command vagrant halt shutdown actually running VM

  $ logout
  $ ...
  $ vagrant halt

How to Customize VM

The default configuration for VM is stored in default.conf file and is using the YAML syntax. You can edit it directly, but better is to use a local.conf file for local modifications.

Features of running VM

  • TFTP Server - Usable for loading kernel and DTB into target by U-Boot. Data must be copied into /srv/tftp directory.
  • NAS Server - Usable for network boot. RootFS data must be extracted into /srv/nfs directory.
  • SAMBA Share - Easy access to home directory in VM from Windows OS.
  • Installed packages - build-essential, gcc-arm-linux-gnueabi, ncurses-dev, qemu-user-static, u-boot-tools, debootstrap and other

FAQ

Machine does't start if run vagrant up:
Sometime it takes longer time to start up the machine and vagrant finish with error. Just rerun the vagrant up command.

SSH session is broken if run vagrant ssh in Windows OS:
Git BASH could have problem with Vagrant SSH client. Use CMD or external ssh client like "putty"

In Windows I'm not able connect to SAMBA share:
The hostname must be unique on the same network, else can collide with other machines.