From b97f47b0aa77a5067c642ceb0aacd934d3265c8d Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Sun, 26 May 2019 09:59:46 +0100 Subject: [PATCH 1/3] Update rpi3 u-boot to detect newer hardware Update the u-boot image included in the mkimage-rpi3 image to support detecting newer hardware versions and setting the fdtfile variable accordingly Shallow clone the u-boot repository during docker build to improve build efficiency Signed-off-by: Richard Connon --- tools/mkimage-rpi3/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/mkimage-rpi3/Dockerfile b/tools/mkimage-rpi3/Dockerfile index 7451122fe..180157932 100644 --- a/tools/mkimage-rpi3/Dockerfile +++ b/tools/mkimage-rpi3/Dockerfile @@ -1,8 +1,10 @@ FROM linuxkit/alpine:86cd4f51b49fb9a078b50201d892a3c7973d48ec as build RUN apk add \ bc \ + bison \ dtc \ curl \ + flex \ make \ gcc \ git \ @@ -20,11 +22,10 @@ RUN apk add --no-cache --initdb -p /out \ 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 +ENV UBOOT_COMMIT=v2019.04 COPY u-boot.patch . -RUN git clone https://github.com/u-boot/u-boot.git && \ - cd /u-boot && \ - git checkout $UBOOT_COMMIT +RUN git clone -b $UBOOT_COMMIT --depth 1 https://github.com/u-boot/u-boot.git && \ + cd /u-boot WORKDIR /u-boot RUN patch -p 1 < /u-boot.patch && \ make rpi_3_defconfig all && \ From 5ffbfbbf679ffbb167505441a728352ca203fd0f Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Sun, 26 May 2019 10:05:10 +0100 Subject: [PATCH 2/3] Support loading correct DTB for RPi 3 model B+ U-Boot sets the variable fdtfile to the correct file name for the detected hardware revision. Use this in the boot script to load either the 3-b or 3-b-plus DTB Signed-off-by: Richard Connon --- tools/mkimage-rpi3/Dockerfile | 3 +-- tools/mkimage-rpi3/boot.script | 8 ++++---- tools/mkimage-rpi3/make-rpi3 | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/mkimage-rpi3/Dockerfile b/tools/mkimage-rpi3/Dockerfile index 180157932..fbee6f6e7 100644 --- a/tools/mkimage-rpi3/Dockerfile +++ b/tools/mkimage-rpi3/Dockerfile @@ -24,8 +24,7 @@ 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=v2019.04 COPY u-boot.patch . -RUN git clone -b $UBOOT_COMMIT --depth 1 https://github.com/u-boot/u-boot.git && \ - cd /u-boot +RUN git clone -b $UBOOT_COMMIT --depth 1 https://github.com/u-boot/u-boot.git WORKDIR /u-boot RUN patch -p 1 < /u-boot.patch && \ make rpi_3_defconfig all && \ diff --git a/tools/mkimage-rpi3/boot.script b/tools/mkimage-rpi3/boot.script index c717ccb8a..15d2f5587 100644 --- a/tools/mkimage-rpi3/boot.script +++ b/tools/mkimage-rpi3/boot.script @@ -1,9 +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 loadaddr 0x01000000 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 ${loadaddr} kernel.uimg +fatload mmc 0:1 ${fdt_addr_r} dtb/${fdtfile} fatload mmc 0:1 ${ramdisk_addr_r} initrd.uimg -bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} +bootm ${loadaddr} ${ramdisk_addr_r} ${fdt_addr_r} diff --git a/tools/mkimage-rpi3/make-rpi3 b/tools/mkimage-rpi3/make-rpi3 index d41818d9a..135a9f648 100755 --- a/tools/mkimage-rpi3/make-rpi3 +++ b/tools/mkimage-rpi3/make-rpi3 @@ -14,7 +14,8 @@ cd /files cd / # copy/convert files -cp /files/boot/dtb/broadcom/bcm2837-rpi-3-b.dtb /boot +mkdir -p /boot/dtb/broadcom +cp /files/boot/dtb/broadcom/bcm2837-rpi-3-b*.dtb /boot/dtb/broadcom /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 \ From 30b78d7e8238f313d653004500ac93bb531e7be2 Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Tue, 4 Jun 2019 08:04:10 +0000 Subject: [PATCH 3/3] Update mkimage-rpi3 tool reference in linuxkit CLI Update the image tag for the mkimage-rpi3 tool used by the CLI to adopt the dynamic DTB selection feature. Signed-off-by: Richard Connon --- src/cmd/linuxkit/moby/output.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/linuxkit/moby/output.go b/src/cmd/linuxkit/moby/output.go index 84300f518..bf249cceb 100644 --- a/src/cmd/linuxkit/moby/output.go +++ b/src/cmd/linuxkit/moby/output.go @@ -27,7 +27,7 @@ var ( "vhd": "linuxkit/mkimage-vhd:4cc60c4f46b07e11c64ba618e46b81fa0096c91f", "dynamic-vhd": "linuxkit/mkimage-dynamic-vhd:99b9009ed54a793020d3ce8322a42e0cc06da71a", "vmdk": "linuxkit/mkimage-vmdk:b55ea46297a16d8a4448ce7f5a2df987a9602b27", - "rpi3": "linuxkit/mkimage-rpi3:9f2d993daa83152c5d52af16ebb7fefa1e69f28e", + "rpi3": "linuxkit/mkimage-rpi3:9dd4f7735e19e495c2b0a856a52af15141816534", } )