Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Raspberry Pi OS App in QEMU | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-24.04-arm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install QEMU and dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y qemu-system qemu-user-static binfmt-support libfdt-dev | |
- name: Install dtmerge tool | |
run: | | |
git clone https://github.com/raspberrypi/utils.git | |
cd utils/dtmerge | |
cmake . | |
make | |
sudo make install | |
- name: Download and Prepare Raspberry Pi OS Image | |
run: | | |
wget -q https://downloads.raspberrypi.org/raspios_lite_arm64_latest -O rpi-os.img.xz | |
xz -d rpi-os.img.xz | |
fdisk -l rpi-os.img | |
sudo mkdir boot | |
sudo mount -o loop,offset=4194304 rpi-os.img boot | |
cp boot/kernel8.img kernel8.img | |
cp boot/bcm2710-rpi-3-b-plus.dtb custom.dtb | |
dtmerge custom.dtb merged.dtb - uart0=on | |
mv merged.dtb custom.dtb | |
dtmerge custom.dtb merged.dtb boot/overlays/disable-bt.dtbo | |
mv merged.dtb custom.dtb | |
sudo touch boot/ssh | |
echo 'pi:$6$uQd.Z0f45vuTlnIM$fH2KnG/2zM/c7oQNYKf/VOhqPlkR82IFNIjmDWftvrmw/K1XPLNJVMvWgmqq0iMjn9dd7gfJAl2tM5e8vgiu8/' | sudo tee boot/userconf.txt > /dev/null | |
echo -e "\ndtoverlay=disable-bt\ndtparam=uart0=on" | sudo tee -a boot/config.txt > /dev/null | |
sudo umount boot | |
qemu-img resize rpi-os.img 8g | |
- name: Run Raspberry Pi OS with QEMU | |
run: | | |
qemu-system-aarch64 \ | |
-machine raspi3b \ | |
-cpu cortex-a72 \ | |
-smp 4 -m 1G \ | |
-kernel kernel8.img \ | |
-dtb custom.dtb \ | |
-drive "file=rpi-os.img,format=raw,index=0,if=sd" \ | |
-append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" \ | |
-device usb-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:22 \ | |
-display none \ | |
-daemonize | |
until nc -z localhost 5555; do | |
echo "Waiting for QEMU to be ready..." | |
sleep 5 | |
done | |
echo "QEMU is ready!" | |
sshpass -p "raspberry" ssh -o StrictHostKeyChecking=no -p 5555 pi@localhost "ls /" | |
- name: Build project inside Raspberry Pi OS | |
run: | | |
sshpass -p "raspberry" ssh -o StrictHostKeyChecking=no -p 5555 pi@localhost "sudo apt update && sudo apt install -y cmake build-essential" | |
sshpass -p "raspberry" scp -r . pi@localhost:~/project | |
sshpass -p "raspberry" ssh -o StrictHostKeyChecking=no -p 5555 pi@localhost "ls ~/project" | |
sshpass -p "raspberry" ssh -o StrictHostKeyChecking=no -p 5555 pi@localhost "cd project && mkdir build && cd build && cmake .. && make -j$(nproc)" |