This repository contains AodCore Yocto layers for building virtual machines for AosEdge units.
-
Ubuntu 18.0+ or any other Linux distribution which is supported by Poky/OE
-
Development packages for Yocto. Refer to [Yocto manual] (https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html#build-host-packages).
-
You need
Moulinof version 0.20 or newer installed in your PC. Recommended way is to install it for your user only:pip3 install --user git+https://github.com/xen-troops/moulin. Make sure that yourPATHenvironment variable includes${HOME}/.local/bin. -
Ninja build system:
sudo apt install ninja-buildon Ubuntu
You can fetch/clone this whole repository, but you actually only need one file from it: aos-vm.yaml.
During the build moulin will fetch this repository again into yocto/ directory. So, to reduce possible confuse,
we recommend to download only aos-vm.yaml:
curl -O https://raw.githubusercontent.com/aosedge/meta-aos-vm/main/aos-vm.yamlMoulin is used to generate Ninja build file: mouling aos-vm.yaml. This project provides number of additional
parameters. You can check them with--help-config command line option:
moulin aos-vm.yaml --help-config
usage: moulin aos-vm.yaml [--MACHINE {genericx86-64,qemux86-64,genericarm64,qemuarm64}] [--NODE_TYPE {main,secondary}] [--WITH_MESSAGE_PROXY {yes,no}]
Config file description: Aos virtual development machine
options:
--MACHINE {genericx86-64,qemux86-64,genericarm64,qemuarm64}
Aos VM machine type (default: genericx86-64)
--NODE_TYPE {main,secondary}
Node type to build (default: main)
--WITH_MESSAGE_PROXY {yes,no}
Enable Aos message proxy (default: no)
--CACHE_LOCATION {outside,inside}
Indicated where cache and downloads are stored: inside build dir or outside. (default: outside)-
MACHINEspecifies target machine. Currently,genericx86-64,qemux86-64,genericarm64,qemuarm64are supported. -
NODE_TYPEspecifies the node to build:main- main node in multi-node VM,secondary- secondary node in multi-node VM. By default, main node is built. -
WITH_MESSAGE_PROXY- specifies to include message proxy into the build. -
CACHE_LOCATION- by default Yocto build cache are located outside build directory. It is convenient to have common cache for different yocto build but can't be used when building with docker. If docker is used to build Aos VM image, this parameter should be set toinsidevalue.
After performing moulin command with desired configuration, it will generate build.ninja with all necessary build
targets. Issue command ninja ${NODE_TYPE}-${MACHINE}.img to build the default target (${NODE_TYPE} is main for main
node and secondary for secondary node). This will take some time and disk space.
Build main node for default genericx86-64 machine:
moulin aos-vm.yaml --NODE_TYPE=main
ninja main-genericx86-64.imgBuild secondary node:
moulin aos-vm.yaml --NODE_TYPE=secondary
ninja secondary-genericx86-64.imgYou should have main-genericx86-64.img and secondary-genericx86-64.img files in the build folder.
To create an archive of the VM images, use the following command:
yocto/meta-aos-vm/scripts/aos_vm.sh archive -m -s <number_of_secondary_nodes> -o <output_path>/aos-vm.tar.gzOptions:
--machine machine- machine to run (default genericx86-64);-d, --disk format- image disk format supported by qemu-img convert (default qcow2);-b, --bios <path/to/bios>- path to bios file required for arm machines (default yocto/build-$node/tmp/deploy/images/$machine/QEMU_EFI.fd);-o, --output <path/to/output>- output path;-m, --main- create main node;-s, --secondary <number>- create specified number of secondary nodes.
Example:
yocto/meta-aos-vm/scripts/aos_vm.sh archive -m -s 2 -o output/image/aos-vm-v5.0.1.tar.gzThis command will create a tar.gz archive containing one main node and two secondary nodes in the specified output path.
To generate VMDK disks for the VM images, use the following command:
yocto/meta-aos-vm/scripts/aos_vm.sh create -m -s <number_of_secondary_nodes> -o <output_path>
Options:
--machine machine- machine to run (default genericx86-64);-d, --disk format- image disk format supported by qemu-img convert (default qcow2);-b, --bios <path/to/bios>- path to bios file required for arm machines (default yocto/build-$node/tmp/deploy/images/$machine/QEMU_EFI.fd);-o, --output <path/to/output>- output path;-m, --main- create main node;-s, --secondary <number>- create specified number of secondary nodes.
Example:
yocto/meta-aos-vm/scripts/aos_vm.sh create -m -s 2 -o output/imageThis command will create qcow2 files for one main node and two secondary nodes in the specified output path.
To run the VM images, use the following command:
yocto/meta-aos-vm/scripts/aos_vm.sh run -f <file_or_folder>
Options:
-f file_or_folder- file or folder to run.
Example:
Run all images in a specific folder:
yocto/meta-aos-vm/scripts/aos_vm.sh run -f output/imageRun a specific image:
yocto/meta-aos-vm/scripts/aos_vm.sh run -f output/image/main.vmdkFollow the script output instructions to attach to the nodes' consoles.
# build docker image
docker/build_docker.sh -f docker/Dockerfile
# create directory for building VM
cd ..
# launch container
docker/run_docker.shTo build SDK, switch to desired node and issue ninja aos-sdk command:
moulin aos-vm.yaml --NODE_TYPE=main
ninja aos-sdkAfter successful build, SDK will be located in output/sdk folder.