Initial commit
This commit is contained in:
commit
d264e8467c
|
@ -0,0 +1,5 @@
|
|||
root.tar.gz
|
||||
boot.tar.gz
|
||||
*.img
|
||||
build/*.tar
|
||||
build/*.img
|
|
@ -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}"
|
|
@ -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)
|
||||
```
|
||||
|
|
@ -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}" <<EOF
|
||||
8192,256M,c
|
||||
,3.5G,83
|
||||
EOF
|
||||
mkfs.vfat "${DEVICE}p1"
|
||||
mkfs.ext4 "${DEVICE}p2"
|
||||
TMP=$(mktemp -d)
|
||||
mount "${DEVICE}p1" "$TMP"
|
||||
tar -C "$TMP" -xf build/all.tar --strip=1 boot/
|
||||
umount "$TMP"
|
||||
mount "${DEVICE}p2" "$TMP"
|
||||
tar -C "$TMP" -xf build/all.tar --exclude='boot/*'
|
||||
umount "$TMP"
|
||||
losetup -D "${DEVICE}"
|
||||
rm -rf "$TMP"
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
losetup -Pf rpi.img
|
||||
LODEVICE=$(losetup -j rpi.img | cut -d ':' -f 1)
|
||||
mount "${LODEVICE}p2" "${TMPDIR}"
|
||||
tar -C "${TMPDIR}" -czf root.tar.gz .
|
||||
mount "${LODEVICE}p1" "${TMPDIR}/boot"
|
||||
tar -C "${TMPDIR}/boot" -czf boot.tar.gz .
|
||||
umount "${TMPDIR}/boot"
|
||||
umount "${TMPDIR}"
|
||||
rm -rf "${TMPDIR}"
|
||||
losetup -D "${LODEVICE}"
|
Loading…
Reference in New Issue