Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swvanbuuren/debos-rpi4
Raspberry Pi 4 Model B Debos recipe
https://github.com/swvanbuuren/debos-rpi4
debian debos qemu raspberry-pi raspberry-pi-4
Last synced: 1 day ago
JSON representation
Raspberry Pi 4 Model B Debos recipe
- Host: GitHub
- URL: https://github.com/swvanbuuren/debos-rpi4
- Owner: swvanbuuren
- License: apache-2.0
- Created: 2023-10-27T14:03:13.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-08T16:11:52.000Z (3 months ago)
- Last Synced: 2024-12-10T01:12:50.308Z (about 2 months ago)
- Topics: debian, debos, qemu, raspberry-pi, raspberry-pi-4
- Language: Shell
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Debos recipe for Raspberry Pi 4B
This repository contains a [debos](https://github.com/go-debos/debos) recipe for
the [Raspberry Pi 4 Model
B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/).## How to build
Follow these instructions to build the image.
### First build
In order to save build time, the `base-pack.yaml` recipe is prebuilt and stored
in a compressed archive. By default, the standard build is configured to extract and use build results from this archive. This is controlled using the variable `unpack`.You also might want to overrid the `firmware-version` variable, since it's
likely that a new firmware was released since the last time this repository was
updated.To build the image the first time, using the recipe `base-pack.yaml` instead of
the prebuilt archive, and to fetch the latest firmware version, run the
following command:```bash
FIRMWARE_VERSION=$(curl -s https://api.github.com/repos/raspberrypi/firmware/tags | grep name | head -n 1 | cut -d '"' -f 4)
debos -m 8192MB -b kvm -t unpack:false -t firmware_version:$FIRMWARE_VERSION debian-rpi4.yaml
```This will also store the results from the recipe `base-pack.yaml` and replace
any previously generated archive. If the `base-pack.yaml` recipe has been
changed, you also want build the image using this command.### Normal build
If you already have generated the `base-pack` archive and the `base-pack.yaml`
recipe hasn't been changed, you can build the image using:```bash
debos -m 8192MB -b kvm debian-rpi4.yaml
```## Test with Qemu
The following instructions show, how to test the image in a Qemu environment.
### Prerequisite
The instruction are valid for a recent Debian system (it was tested on Bullseye).
A series of package is required to be installed, using the following command:
```bash
sudo apt install libguestfs-tools qemu-system-arm qemu-utils
```### Instructions
To test the image in a Qemu environment, it is recommended to use the following
bash script `image_run`:```bash
#!/bin/bash
# Find boot artifacts
for basename in "vmlinuz" "initrd.img"; do
if [ -f "$basename" ]; then continue; fi
fpath=$(virt-ls -a "$1" /boot | grep -E "^$basename-[[:digit:]]" | sort -r | head -n 1)
echo "Found $fpath!"
virt-copy-out -a $1 "/boot/$fpath" .
mv $fpath $basename
done
# Launch Qemu
qemu-system-aarch64 \
-m 2048 \
-cpu cortex-a57 \
-smp 2 \
-M virt \
-kernel vmlinuz \
-initrd initrd.img \
-append 'root=/dev/vda2' \
-drive if=none,file=$1,format=qcow2,id=hd \
-device virtio-blk-pci,drive=hd \
-device virtio-net-pci,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-nographic
```Make the script executable (`chmod +x image_run`) and use it with the following
command```bash
./image_run debian-rpi4.qcow2
```You can terminate the Qemu environment by pressing Ctrl +
a followed by x.Please refer to [this
website](https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/)
for more background information.## Deploy to Raspberry Pi
First, the image needs to be flashed to sd-card.
### Flash to sd-card
By default, the recipe outputs a compressed image along with a `*.bmap` file.
Using the command `bmaptool` the image can be flashed efficiently to an sd-card.
This command is provided by the package `bmap-tools`, which is installed using```bash
sudo apt install bmap-tools
```
Finally, the image can be flashed to the sd-card, using the following command:```bash
sudo bmaptool copy debian-rpi4.img.gz
```
where `` is to be replaced with the device path the represents the
sd-card (e.g. `/dev/sdc`). This can be identified using the command `ls -l
/dev/disks/by-id`.Insert the sd-card into the Raspberry Pi after it has been flashed successfully.
### Serial Console
The image is configured to allow a serial console connection. This is useful to
interact with the Raspberry Pi in headless mode. It is recommended to use a
[3.3V FTDI cable](https://ftdichip.com/products/ttl-232r-rpi/) for this. With
this cable, connect Black to pin 6 (Ground), Yellow to pin 8 (GPIO 14 TXD) and
Orange to pin 10 (GPIO 15 RXD) on the 40-Pin GPIO Header as indicated in the
[Raspberry Pi
Documentation](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-and-the-40-pin-header).
After the FTDI cable has been plugged into the host computer, start the serial
console e.g. using `screen` with:```bash
screen /dev/serial/by-id/ 115200
```where `` is to replaced with the correct id of the FTDI cable, which can be
identified using the command `ls -l /dev/serial/by-id`. Note that you can detach
from the screen session by pressing Ctrl+a followed by
d.Finally, connect the Raspberry Pi's power source and enjoy!
## Notice
This debos recipe is based on the [rpi64
recipe](https://github.com/go-debos/debos-recipes/tree/main/rpi64) of
[debos-recipes](https://github.com/go-debos/debos-recipes). It contains a
modified, updated [recipe file](debian-rpi4.yaml) and adopts some of the
[overlays](overlays) and [scripts](scripts) from the
[original](https://github.com/go-debos/debos-recipes).## License
To remain inline with the [original
recipe](https://github.com/go-debos/debos-recipes) on which this recipe is
based, the same Apache style license applies to this recipe. See the
[LICENSE](LICENSE) file for more details.