mirror of
https://github.com/lukechilds/dockerpi.git
synced 2026-01-22 18:05:11 +00:00
Add network support to Pi2/3 (#21)
Co-authored-by: Luke Childs <lukechilds123@gmail.com>
This commit is contained in:
parent
f07a233eb3
commit
6c1ac8edab
3 changed files with 23 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Build stage for qemu-system-arm
|
||||
FROM debian:stable-slim AS qemu-builder
|
||||
ARG QEMU_VERSION=4.2.0
|
||||
ARG QEMU_VERSION=6.0.0
|
||||
ENV QEMU_TARBALL="qemu-${QEMU_VERSION}.tar.xz"
|
||||
WORKDIR /qemu
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ RUN tar xvf "${QEMU_TARBALL}"
|
|||
|
||||
RUN # Build source
|
||||
# These seem to be the only deps actually required for a successful build
|
||||
RUN apt-get -y install python build-essential libglib2.0-dev libpixman-1-dev
|
||||
RUN apt-get -y install python build-essential libglib2.0-dev libpixman-1-dev ninja-build
|
||||
# These don't seem to be required but are specified here: https://wiki.qemu.org/Hosts/Linux
|
||||
RUN apt-get -y install libfdt-dev zlib1g-dev
|
||||
# Not required or specified anywhere but supress build warnings
|
||||
|
|
@ -32,7 +32,7 @@ RUN "qemu-${QEMU_VERSION}/configure" --static --target-list=arm-softmmu,aarch64-
|
|||
RUN make -j$(nproc)
|
||||
|
||||
RUN # Strip the binary, this gives a substantial size reduction!
|
||||
RUN strip "arm-softmmu/qemu-system-arm" "aarch64-softmmu/qemu-system-aarch64"
|
||||
RUN strip "arm-softmmu/qemu-system-arm" "aarch64-softmmu/qemu-system-aarch64" "qemu-img"
|
||||
|
||||
|
||||
# Build stage for fatcat
|
||||
|
|
@ -67,6 +67,7 @@ ARG RPI_KERNEL_CHECKSUM="295a22f1cd49ab51b9e7192103ee7c917624b063cc5ca2e11434164
|
|||
|
||||
COPY --from=qemu-builder /qemu/arm-softmmu/qemu-system-arm /usr/local/bin/qemu-system-arm
|
||||
COPY --from=qemu-builder /qemu/aarch64-softmmu/qemu-system-aarch64 /usr/local/bin/qemu-system-aarch64
|
||||
COPY --from=qemu-builder /qemu/qemu-img /usr/local/bin/qemu-img
|
||||
COPY --from=fatcat-builder /fatcat/fatcat /usr/local/bin/fatcat
|
||||
|
||||
ADD $RPI_KERNEL_URL /tmp/qemu-rpi-kernel.zip
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ docker run -it lukechilds/dockerpi pi2
|
|||
docker run -it lukechilds/dockerpi pi3
|
||||
```
|
||||
|
||||
> **Note:** Pi 2 and Pi 3 support is currently experimental. Networking doesn't work and QEMU hangs once the machines are powered down requiring you to `docker kill` the container. See [#4](https://github.com/lukechilds/dockerpi/pull/4) for details.
|
||||
> **Note:** In the Pi 2 and Pi 3 machines, QEMU hangs once the machines are powered down requiring you to `docker kill` the container. See [#4](https://github.com/lukechilds/dockerpi/pull/4) for details.
|
||||
|
||||
|
||||
## Wait, what?
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
GIB_IN_BYTES="1073741824"
|
||||
|
||||
target="${1:-pi1}"
|
||||
image_path="/sdcard/filesystem.img"
|
||||
zip_path="/filesystem.zip"
|
||||
|
|
@ -15,6 +17,14 @@ if [ ! -e $image_path ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
qemu-img info $image_path
|
||||
image_size_in_bytes=$(qemu-img info --output json $image_path | grep "virtual-size" | awk '{print $2}' | sed 's/,//')
|
||||
if [[ "$(($image_size_in_bytes % ($GIB_IN_BYTES * 2)))" != "0" ]]; then
|
||||
new_size_in_gib=$((($image_size_in_bytes / ($GIB_IN_BYTES * 2) + 1) * 2))
|
||||
echo "Rounding image size up to ${new_size_in_gib}GiB so it's a multiple of 2GiB..."
|
||||
qemu-img resize $image_path "${new_size_in_gib}G"
|
||||
fi
|
||||
|
||||
if [ "${target}" = "pi1" ]; then
|
||||
emulator=qemu-system-arm
|
||||
kernel="/root/qemu-rpi-kernel/kernel-qemu-4.19.50-buster"
|
||||
|
|
@ -22,21 +32,23 @@ if [ "${target}" = "pi1" ]; then
|
|||
machine=versatilepb
|
||||
memory=256m
|
||||
root=/dev/sda2
|
||||
nic='--net nic --net user,hostfwd=tcp::5022-:22'
|
||||
nic="--net nic --net user,hostfwd=tcp::5022-:22"
|
||||
elif [ "${target}" = "pi2" ]; then
|
||||
emulator=qemu-system-arm
|
||||
machine=raspi2
|
||||
machine=raspi2b
|
||||
memory=1024m
|
||||
kernel_pattern=kernel7.img
|
||||
dtb_pattern=bcm2709-rpi-2-b.dtb
|
||||
nic=''
|
||||
append="dwc_otg.fiq_fsm_enable=0"
|
||||
nic="-netdev user,id=net0,hostfwd=tcp::5022-:22 -device usb-net,netdev=net0"
|
||||
elif [ "${target}" = "pi3" ]; then
|
||||
emulator=qemu-system-aarch64
|
||||
machine=raspi3
|
||||
machine=raspi3b
|
||||
memory=1024m
|
||||
kernel_pattern=kernel8.img
|
||||
dtb_pattern=bcm2710-rpi-3-b-plus.dtb
|
||||
nic=''
|
||||
append="dwc_otg.fiq_fsm_enable=0"
|
||||
nic="-netdev user,id=net0,hostfwd=tcp::5022-:22 -device usb-net,netdev=net0"
|
||||
else
|
||||
echo "Target ${target} not supported"
|
||||
echo "Supported targets: pi1 pi2 pi3"
|
||||
|
|
@ -78,7 +90,7 @@ exec ${emulator} \
|
|||
${nic} \
|
||||
--dtb "${dtb}" \
|
||||
--kernel "${kernel}" \
|
||||
--append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=${root} rootwait panic=1" \
|
||||
--append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=${root} rootwait panic=1 ${append}" \
|
||||
--no-reboot \
|
||||
--display none \
|
||||
--serial mon:stdio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue