From d264e8467c8c1dbe0d61aca28399dbb1ca8d98e4 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Sat, 18 Dec 2021 15:56:45 -0500 Subject: [PATCH] Initial commit --- .gitignore | 5 ++++ Containerfile | 60 ++++++++++++++++++++++++++++++++++++++++ README.md | 47 +++++++++++++++++++++++++++++++ build/.gitkeep | 0 scripts/extract_build.sh | 26 +++++++++++++++++ scripts/extract_root.sh | 13 +++++++++ 6 files changed, 151 insertions(+) create mode 100644 .gitignore create mode 100644 Containerfile create mode 100644 README.md create mode 100644 build/.gitkeep create mode 100755 scripts/extract_build.sh create mode 100755 scripts/extract_root.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fb2737 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +root.tar.gz +boot.tar.gz +*.img +build/*.tar +build/*.img diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..a840817 --- /dev/null +++ b/Containerfile @@ -0,0 +1,60 @@ +FROM scratch +ADD root.tar.gz / +Add boot.tar.gz /boot +USER root + +# # Import our image +# COPY rpi.img /root/rpi.img +# # Mount image +# # @see https://www.boulderes.com/resource-library/building-raspberry-pi-disk-images-with-docker-a-case-study-in-software-automation +# RUN losetup -Pf /root/rpi.img +# RUN export RPILOOP=$(losetup -j /root/rpi.img | cut -d ':' -f 1) +# RUN mount "/dev/${RPILOOP}p2" /mnt +# RUN mount "/dev/${RPILOOP}p1" /mnt/boot +# RUN mount -o bind /dev /mnt/dev +# RUN mount -o bind /proc /mnt/proc +# RUN mount -o bind /sys /mnt/sys +# RUN chroot /mnt +# Do stuff inside the chroot +RUN hostname -f +RUN cat /etc/shadow | grep pi +# Configure dwc2 +RUN echo 'dwc2' >> /etc/modules +RUN echo 'dtoverlay=dwc2' >> /boot/config.txt +RUN sed -i 's/rootwait/rootwait modules-load=dwc2/' /boot/cmdline.txt +RUN echo 'g_mass_storage' >> /etc/modules +RUN echo 'options g_mass_storage file=/piusb.bin stall=0 ro=1' > /etc/modprobe.d/piusb.conf +RUN dd if=/dev/zero of=/piusb.bin bs=1M count=2048 +RUN mkdosfs /piusb.bin -F 32 -I +RUN mkdir /mnt/usb_share +RUN echo '/piusb.bin /mnt/usb_share vfat users,gid=mariner,umask=002 0 2' >> /etc/fstab + +# Configure serial port comm to control the printer +RUN echo 'enable_uart=1' >> /boot/config.txt +# RUN systemctl stop serial-getty@ttyS0 +RUN systemctl disable serial-getty@ttyS0 +RUN sed -i 's/console=serial0,115200//' /boot/cmdline.txt + +# Install mariner +RUN curl -sL gpg.l9o.dev | sudo apt-key add - +RUN echo "deb https://ppa.l9o.dev/raspbian ./" | sudo tee /etc/apt/sources.list.d/l9o.list +RUN apt-get update +RUN apt-get install -y mariner3d + +# Clean-up +RUN apt-get clean + +# Create output files +#RUN tar -C / -czf /root/root.tar.gz --exclude='/boot/*' --exclude='/sys/*' \ +# --exclude='/proc/*' --exclude='/run/*' --exclude='/dev/*' \ +# --exclude=/root/root.tar.gz / +#RUN tar -C /boot -czf /root/boot.tar.gz +# # Leave the chroot and cleanup +# RUN exit +# RUN umount /mnt/dev +# RUN umount /mnt/proc +# RUN umount /mnt/sys +# RUN sync +# RUN umount /mnt/boot +# RUN unmount /mnt +# RUN losetup -d /dev/"${RPILOOP}" \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8071b69 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Pileagoo + +An image for having a Raspberry Pi control an Elegoo saturn. + +This is based off of https://l9o.dev/posts/controlling-an-elegoo-mars-pro-remotely/ + +This particular image is principally aimed at the Raspberry Pi (512M original Rev) with a wifi dongle. + +## Building + +1. Download the raspberry image and link rpi.img to that file +2. Run the following commands + +``` +# Creates root.tar.gz and boot.tar.gz +sudo ./scripts/extract_root.sh +# Run the build +podman build --rm=false --platform linux/armv/v7 -t localhost/pileogoo . +CONTAINERID=$(podman create localhost/pileogoo /bin/bash) +podman export -o build/root.tar.gz "${CONTAINERID}" +# Creates a new image from the exported copy +sudo ./scripts/extra_build.sh +rm ./build/all.tar +``` + +### Errors + +standard_init_linux.go:228: exec user process caused: exec format error + + * this is caused by the image not matching the architecture: make sure you + can run non-native archiectures by checking the Installation steps. + +## Installation + +Install `qemu-system-arm`, `qemu-user-static`, and `qemu-user-binfmt` to provide +arm architectures. + +Note that not all versions of the Raspberry Pi are supported in qemu. For eg. + +``` +$ qemu-system-arm -M help | grep rasp +raspi0 Raspberry Pi Zero (revision 1.2) +raspi1ap Raspberry Pi A+ (revision 1.1) +raspi2 Raspberry Pi 2B (revision 1.1) (alias of raspi2b) +raspi2b Raspberry Pi 2B (revision 1.1) +``` + diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/extract_build.sh b/scripts/extract_build.sh new file mode 100755 index 0000000..f3614bd --- /dev/null +++ b/scripts/extract_build.sh @@ -0,0 +1,26 @@ +#!/bin/bash +ex + +dd if=/dev/zero of=build/rpi.img bs=1M count=4096 +# Copy the first 8k from the original rpi.img, which seems to have +# non-zeroed content +#dd if=rpi.img of=build/rpi.img bs=8192 count=1 conv=notrunc +sudo losetup -Pf build/rpi.img +# Partition: +# start: 8192, size 256M typ W95 FAT32 +DEVICE=$(losetup -j build/rpi.img | cut -d ':' -f 1) +mkfs.msdos "${DEVICE}" +sfdisk "${DEVICE}" <