From a23515a3e27ee615fd6b12a7318244a57f9cc5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=B6hmke?= Date: Sat, 2 Nov 2019 23:51:56 +0100 Subject: [PATCH] added uboot --- Dockerfile | 49 ++++++++++++++++++++++++++++- Dockerfile.bak | 30 ++++++++++++++++++ resources/boot.cmd | 3 ++ resources/build.sh | 68 +++++++++++++++++++++++++++++++---------- resources/resizedata.sh | 9 ++---- 5 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 Dockerfile.bak create mode 100644 resources/boot.cmd diff --git a/Dockerfile b/Dockerfile index 16cb457..43a8272 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,54 @@ +FROM debian:buster AS uboot + +RUN apt-get update && \ + apt-get install -y build-essential git wget bison flex gcc-arm-linux-gnueabi device-tree-compiler bc + +RUN mkdir /uboot_build/ && \ + mkdir /uboot/ + +WORKDIR /uboot_build/ + +RUN wget ftp://ftp.denx.de/pub/u-boot/u-boot-2019.10.tar.bz2 && \ + tar -xjf u-boot-2019.10.tar.bz2 + +WORKDIR /uboot_build/u-boot-2019.10/ + +# model a/b/zero +RUN make CROSS_COMPILE=arm-linux-gnueabi- distclean && \ + make CROSS_COMPILE=arm-linux-gnueabi- rpi_defconfig && \ + make CROSS_COMPILE=arm-linux-gnueabi- -j8 u-boot.bin && \ + cp u-boot.bin /uboot/u-boot_rpi1.bin + +# model zero w +RUN make CROSS_COMPILE=arm-linux-gnueabi- distclean && \ + make CROSS_COMPILE=arm-linux-gnueabi- rpi_0_w_defconfig && \ + make CROSS_COMPILE=arm-linux-gnueabi- -j8 u-boot.bin && \ + cp u-boot.bin /uboot/u-boot_rpi0_w.bin + +# model 2 b +RUN make CROSS_COMPILE=arm-linux-gnueabi- distclean && \ + make CROSS_COMPILE=arm-linux-gnueabi- rpi_2_defconfig && \ + make CROSS_COMPILE=arm-linux-gnueabi- -j8 u-boot.bin && \ + cp u-boot.bin /uboot/u-boot_rpi2.bin + +# model 3 (32 bit) +RUN make CROSS_COMPILE=arm-linux-gnueabi- distclean && \ + make CROSS_COMPILE=arm-linux-gnueabi- rpi_3_32b_defconfig && \ + make CROSS_COMPILE=arm-linux-gnueabi- -j8 u-boot.bin && \ + cp u-boot.bin /uboot/u-boot_rpi3.bin + +# model 4 (32 bit) +RUN make CROSS_COMPILE=arm-linux-gnueabi- distclean && \ + make CROSS_COMPILE=arm-linux-gnueabi- rpi_4_32b_defconfig && \ + make CROSS_COMPILE=arm-linux-gnueabi- -j8 u-boot.bin && \ + cp u-boot.bin /uboot/u-boot_rpi4.bin + + FROM alpine:3.10 RUN apk update && \ apk add automake build-base git autoconf confuse-dev linux-headers \ - findutils mtools e2fsprogs-extra alpine-sdk dosfstools && \ + findutils mtools e2fsprogs-extra alpine-sdk dosfstools uboot-tools && \ rm -rf /var/cache/apk/* RUN git clone https://github.com/pengutronix/genimage.git /tmp/genimage && \ @@ -23,5 +69,6 @@ RUN cd /genext2fs && \ rm -rf /tmp/pkg/ ADD ./resources /resources +COPY --from=uboot /uboot/ /uboot/ WORKDIR /work diff --git a/Dockerfile.bak b/Dockerfile.bak new file mode 100644 index 0000000..cd21a5c --- /dev/null +++ b/Dockerfile.bak @@ -0,0 +1,30 @@ +FROM alpine:3.10 + +RUN apk update && \ + apk add automake build-base git autoconf confuse-dev linux-headers \ + findutils mtools e2fsprogs-extra alpine-sdk dosfstools && \ + rm -rf /var/cache/apk/* + +RUN git clone https://github.com/pengutronix/genimage.git /tmp/genimage && \ + cd /tmp/genimage && \ + ./autogen.sh && \ + ./configure CFLAGS='-g -O0' --prefix=/usr && \ + make install && \ + cd && \ + rm -rf /tmp/genimage + + +ADD ./resources/genext2fs /genext2fs + +RUN cd /genext2fs && \ + abuild-keygen -a -i -q && \ + abuild -F -P /tmp/pkg && \ + apk add /tmp/pkg/x86_64/genext2fs-1*.apk && \ + rm -rf /tmp/pkg/ + +ADD ./resources /resources + +RUN apk update +RUN apk add uboot-tools + +WORKDIR /work diff --git a/resources/boot.cmd b/resources/boot.cmd new file mode 100644 index 0000000..ad80b1b --- /dev/null +++ b/resources/boot.cmd @@ -0,0 +1,3 @@ +fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs +ext4load mmc 0:2 ${kernel_addr_r} /boot/uImage +bootm ${kernel_addr_r} - ${fdt_addr} diff --git a/resources/build.sh b/resources/build.sh index f6bac4c..15c45bd 100755 --- a/resources/build.sh +++ b/resources/build.sh @@ -72,7 +72,6 @@ apk --root ${ROOTFS_PATH} --update-cache --initdb --arch armhf add $BASE_PACKAGE # add google DNS to enable network access inside chroot echo "nameserver 8.8.8.8" > ${ROOTFS_PATH}/etc/resolv.conf - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # echo ">> Configure root FS" @@ -139,8 +138,15 @@ chmod +x ${ROOTFS_PATH}/etc/local.d/90-resizedata.start # mount data and boot partition (root is already mounted) cat >${ROOTFS_PATH}/etc/fstab <> Prepare kernel for uboot" + +# build uImage +mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Linux kernel" -d ${ROOTFS_PATH}/boot/vmlinuz-rpi2 ${ROOTFS_PATH}/boot/uImage + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # create boot FS @@ -164,16 +176,31 @@ mkdir -p ${BOOTFS_PATH} wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup_cd.dat +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup_db.dat wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup_x.dat +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup4.dat +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup4cd.dat +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup4db.dat +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/fixup4x.dat wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start.elf wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start_cd.elf +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start_db.elf wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start_x.elf +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start4cd.elf +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start4db.elf +wget -P ${BOOTFS_PATH} https://github.com/raspberrypi/firmware/raw/master/boot/start4x.elf -# copy linux kernel and overlays +# copy linux kernel and overlays to boot cp ${ROOTFS_PATH}/usr/lib/linux-*-rpi2/*.dtb ${BOOTFS_PATH}/ cp -r ${ROOTFS_PATH}/usr/lib/linux-*-rpi2/overlays ${BOOTFS_PATH}/ -cp ${ROOTFS_PATH}/boot/initramfs-rpi2 ${BOOTFS_PATH}/ -cp ${ROOTFS_PATH}/boot/vmlinuz-rpi2 ${BOOTFS_PATH}/ + +# copy u-boot +cp /uboot/* ${BOOTFS_PATH}/ + +# generate boot script +mkimage -A arm -T script -C none -n "Boot script" -d ${RES_PATH}/boot.cmd ${BOOTFS_PATH}/boot.scr + # write boot config cat >${BOOTFS_PATH}/config.txt <${BOOTFS_PATH}/cmdline.txt <> Create SD card image" # boot partition cat >${WORK_PATH}/genimage_boot.cfg <${WORK_PATH}/genimage_root.cfg <${WORK_PATH}/genimage_data.cfg <