Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Building Embedded System

There are two build systems that can be used to build images embedded systems using linux.

Tool to help the build

Raspberry pi

The official raspbian o/s is built with Buildroot, but there is also Yocto based builds available,

If you want to switch init system, you can check existing init system by using sudo stat /sbin/init.

Cross compile raspbian

Yocto with wsl2

wsl2 for cross compile

the default mounts for wsl2 ubuntu ext4 is C:\Users\<username>\AppData\Local\Packages\Canonical*\LocalState\ext4.vhdx. Often time we require multiple instances to work on separate ext4 mount on a different drive for disk space or other reasons.

First check the distro name.

C:\> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

The distro name is Ubuntu-20.04.

Now we need to set the default user via editing /etc/wsl.conf.

[user]
default=<username> 

Now we will create another image which is a copy of the Ubuntu-20.04.

PS C:\> wsl --shutdown
PS C:\> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2
PS C:\> cd d:\
PS D:\> mkdir my_wsl
PS D:\> cd my_wsl
PS D:\my_wsl> wsl --export Ubuntu-20.04 my_distro.tar
PS D:\my_wsl> wsl --import my_distro my_distro my_distro.tar
PS D:\my_wsl> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2
  my_distro       Stopped         2

Now we have distro on D drive.

We can create a VHDX file using windows 10 Computer Management tool. The we can detach it. We have to figure out a way to initialize the file as ext4 and mount to a wsl2 linux distro.

Manually download wsl2 distro

Use download page to get distro. It downloads a .appx file which can be opened by 7zip and extract install.tar.gz. now we can use wsl command to install it,

wsl --import my_distro my_distro install.tar.gz

yocto devtool

yocto tutorials