mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
tools: Add mkimage-rpi3 to build images for raspberry Pi 3
The package contains u-boot and the RPi firmware blobs. It expects a tar ball of the root filesystem (including kernel and dtbs) on stdin and produces a compressed tar ball on stdout with the files to copy to a FAT32 formatted SD card. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
847ae9d220
commit
c15f320ff6
56
tools/mkimage-rpi3/Dockerfile
Normal file
56
tools/mkimage-rpi3/Dockerfile
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
FROM linuxkit/alpine:b3f8da6c6f02440ee9c4c72bbf4dabdf500b1d8c as build
|
||||||
|
RUN apk add \
|
||||||
|
bc \
|
||||||
|
dtc \
|
||||||
|
curl \
|
||||||
|
make \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
musl-dev \
|
||||||
|
patch
|
||||||
|
|
||||||
|
# Create small rootfs
|
||||||
|
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
|
||||||
|
RUN apk add --no-cache --initdb -p /out \
|
||||||
|
alpine-baselayout \
|
||||||
|
busybox \
|
||||||
|
libarchive-tools \
|
||||||
|
musl \
|
||||||
|
tar
|
||||||
|
RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache
|
||||||
|
|
||||||
|
# u-boot compile. The patch is needed to handle larger kernels
|
||||||
|
ENV UBOOT_COMMIT=v2017.09
|
||||||
|
COPY u-boot.patch .
|
||||||
|
RUN git clone https://github.com/u-boot/u-boot.git && \
|
||||||
|
cd /u-boot && \
|
||||||
|
git checkout $UBOOT_COMMIT
|
||||||
|
WORKDIR /u-boot
|
||||||
|
RUN patch -p 1 < /u-boot.patch && \
|
||||||
|
make rpi_3_defconfig all && \
|
||||||
|
mkdir -p /out/boot && \
|
||||||
|
cp u-boot.bin /out/boot && \
|
||||||
|
mkdir -p /out/bin && \
|
||||||
|
cp tools/mkimage /out/bin
|
||||||
|
|
||||||
|
# fetch the Raspberry Pi 3 firmware (latest master)
|
||||||
|
ENV RPI_COMMIT=478d637c476e838ffcfa8535232ff0b86daf5918
|
||||||
|
RUN mkdir -p /out/boot && \
|
||||||
|
cd /out/boot && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/bootcode.bin && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/bootcode.bin && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/fixup_cd.dat && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/fixup.dat && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/fixup_x.dat && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/start_cd.elf && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/start.elf && \
|
||||||
|
curl -fsSLO https://github.com/raspberrypi/firmware/raw/$RPI_COMMIT/boot/start_x.elf
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
ENTRYPOINT []
|
||||||
|
CMD []
|
||||||
|
WORKDIR /
|
||||||
|
COPY --from=build /out/ /
|
||||||
|
COPY config.txt boot.script /boot/
|
||||||
|
COPY make-rpi3 /
|
||||||
|
ENTRYPOINT [ "/make-rpi3" ]
|
9
tools/mkimage-rpi3/boot.script
Normal file
9
tools/mkimage-rpi3/boot.script
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
setenv bootargs "dwc_otg.lpm_enable=0 earlyprintk console=tty1 console=ttyS0,115200 root=/dev/ram0 rw"
|
||||||
|
setenv dtbfile bcm2837-rpi-3-b.dtb
|
||||||
|
setenv machid 0x00000c42
|
||||||
|
saveenv
|
||||||
|
|
||||||
|
fatload mmc 0:1 ${kernel_addr_r} kernel.uimg
|
||||||
|
fatload mmc 0:1 ${fdt_addr_r} ${dtbfile}
|
||||||
|
fatload mmc 0:1 ${ramdisk_addr_r} initrd.uimg
|
||||||
|
bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
|
4
tools/mkimage-rpi3/build.yml
Normal file
4
tools/mkimage-rpi3/build.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
image: mkimage-rpi3
|
||||||
|
network: true
|
||||||
|
arches:
|
||||||
|
- arm64
|
5
tools/mkimage-rpi3/config.txt
Normal file
5
tools/mkimage-rpi3/config.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
avoid_warnings=2
|
||||||
|
# 64bit mode, serial and kernel
|
||||||
|
arm_control=0x200
|
||||||
|
enable_uart=1
|
||||||
|
kernel=u-boot.bin
|
29
tools/mkimage-rpi3/make-rpi3
Executable file
29
tools/mkimage-rpi3/make-rpi3
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# input is a tarball on stdin with kernel, dtbs and cmdline in /boot
|
||||||
|
# output is an tar to be extracted onto a SD card
|
||||||
|
|
||||||
|
mkdir -p /files
|
||||||
|
cd /files
|
||||||
|
|
||||||
|
# extract. BSD tar auto recognises compression
|
||||||
|
[ -t 0 ] || bsdtar xzf -
|
||||||
|
|
||||||
|
cd /
|
||||||
|
|
||||||
|
# copy/convert files
|
||||||
|
cp /files/boot/dtb/broadcom/bcm2837-rpi-3-b.dtb /boot
|
||||||
|
/bin/mkimage -A arm64 -O linux -T kernel -C gzip -a 0x80000 -e 0x80000 \
|
||||||
|
-d /files/boot/kernel /boot/kernel.uimg >> /boot/uboot.log
|
||||||
|
/bin/mkimage -A arm64 -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi3 \
|
||||||
|
-d /boot/boot.script /boot/boot.scr >> /boot/uboot.log
|
||||||
|
|
||||||
|
# build an initrd and convert it
|
||||||
|
rm -rf /files/boot
|
||||||
|
cd /files && find . | cpio -o -H newc | gzip > /initrd.img
|
||||||
|
/bin/mkimage -A arm64 -O linux -T ramdisk -d /initrd.img /boot/initrd.uimg >> /boot/uboot.log
|
||||||
|
|
||||||
|
# now everything is setup in /boot just need to tar it
|
||||||
|
cd /boot && tar cf - .
|
11
tools/mkimage-rpi3/u-boot.patch
Normal file
11
tools/mkimage-rpi3/u-boot.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
|
||||||
|
index c499b45..1faae3c 100644
|
||||||
|
--- a/include/configs/rpi.h
|
||||||
|
+++ b/include/configs/rpi.h
|
||||||
|
@@ -161,4 +161,6 @@
|
||||||
|
BOOTENV
|
||||||
|
|
||||||
|
|
||||||
|
+#define CONFIG_SYS_BOOTM_LEN (64 * 1024 * 1024)
|
||||||
|
+
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user