Debian tool chain and image generation for the Raspberry Pi 2, 3 and 4.
The edi configuration contained in this repository can be used to generate the following artifacts:
- A Debian buster arm64 (64bit) image suitable for the Raspberry Pi 3 or 4.
- A Debian buster armhf (32bit) image suitable for the Raspberry Pi 2 or 3.
- Matching Mender update artifacts for the above configurations.
- An amd64/arm64 or amd64/armhf based LXD container with a pre-installed cross development toolchain for C and C++.
- An emulated arm64 or armhf LXD container.
Please note that image generation operations require superuser privileges and therefore you can easily break your host operating system. Therefore make sure that you have a backup copy of your data.
edi-pi would not be possible without the fantastic Raspberry Pi community. Special thanks go to the people behind those two projects:
- Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3.
- Raspberry Pi 3 Debian Image Specification.
Prior to using edi-pi you have to install edi according to this instructions. Please take a careful look at the "Setting up ssh Keys" section since you will need a proper ssh key setup in order to access the container or the Rasperry Pi using ssh.
The image post processing commands require some additional tools. On Ubuntu 18.04 those tools can be installed as follows:
sudo apt install e2fsprogs dosfstools bmap-tools mtools parted zerofree python3-sphinx
To generate the Mender update artifact, the mender-artifact tool is required. Please download the standalone binary and make it visible and executable:
sudo cp ~/Downloads/mender-artifact /usr/local/bin/
sudo chmod +x /usr/local/bin/mender-artifact
A Raspberry Pi image can be created using the following command:
For Raspberry Pi 4, arm64:
sudo edi -v image create pi4-buster-arm64.yml
For Raspberry Pi 3, arm64:
sudo edi -v image create pi3-buster-arm64.yml
For Raspberry Pi 2, armhf:
sudo edi -v image create pi2-buster-armhf.yml
For Raspberry Pi 3, armhf:
sudo edi -v image create pi3-buster-armhf.yml
The resulting image can be copied to a SD card (here /dev/mmcblk0) using the following command (Please note that everything on the SD card will be erased!):
For Raspberry Pi 4, arm64:
sudo bmaptool copy artifacts/pi4-buster-arm64.img /dev/mmcblk0
For Raspberry Pi 3, arm64:
sudo bmaptool copy artifacts/pi3-buster-arm64.img /dev/mmcblk0
For Raspberry Pi 2, armhf:
sudo bmaptool copy artifacts/pi2-buster-armhf.img /dev/mmcblk0
For Raspberry Pi 3, armhf:
sudo bmaptool copy artifacts/pi3-buster-armhf.img /dev/mmcblk0
If the command fails, unmount the flash card and repeat the above command.
Once you have booted the Raspberry Pi using this SD card you can access it using ssh (the access should be granted thanks to to your ssh keys):
ssh pi@IP_ADDRESS
The password for the user pi is raspberry (just in case you want to
execute a command using sudo
or login via a local terminal).
A cross development container can be created using the following command:
For the Raspberry Pi 3 or 4, amd64/arm64:
sudo edi -v lxc configure edi-pi-cross-dev-buster pi-buster-arm64-cross-dev.yml
For the Raspberry Pi 2, 3 or 4, amd64/armhf:
sudo edi -v lxc configure edi-pi-cross-dev-buster pi-buster-armhf-cross-dev.yml
The container can be accessed as follows (the password is ChangeMe!):
lxc exec edi-pi-cross-dev-buster -- login ${USER}
Or with ssh (Hint: retrieve IP_OF_CONTAINER with lxc list
):
ssh IP_OF_CONTAINER
You can directly start to cross compile applications:
For the Raspberry Pi 3 or 4, arm64:
aarch64-linux-gnu-g++ ...
For the Raspberry Pi 2, 3 or 4, armhf:
arm-linux-gnueabihf-g++
For your convenience, the LXD container shares the folder edi-workspace with the host operating system.
The following command generates an emulated container:
For the Raspberry Pi 3, arm64:
sudo edi -v lxc configure edi-pi-arm64-dev-buster pi3-buster-arm64-dev.yml
For the Raspberry Pi 3, armhf:
sudo edi -v lxc configure edi-pi-armhf-dev-buster pi3-buster-armhf-dev.yml
As above, you can access the container as follows (the password is ChangeMe!):
For the Raspberry Pi 3, arm64:
lxc exec edi-pi-arm64-dev-buster -- login ${USER}
For the Raspberry Pi 3, armhf:
lxc exec edi-pi-armhf-dev-buster -- login ${USER}
Please note that no services get started in the emulated container and thus no ssh access will be possible.
To enable networking within the emulated container use the following command to bring up the default network interface:
sudo ip link set eth0 up && sudo dhclient eth0
During the image build the documentation gets rendered to artifacts/CONFIGNAME_documentation as reStructuredText. The text files can be transformed into a nice pdf file with some additional tools that need to be installed first:
sudo apt install texlive-latex-recommended texlive-pictures texlive-latex-extra latexmk
Then the pdf can be generated using the following commands:
cd artifacts/CONFIGNAME_documentation
make latexpdf
For more information please read the edi documentation and this blog post.
For details about the Mender based robust update integration please refer to this blog post.
If you are curious about the U-Boot bootloader setup please take a look at this blog post.