From 43eb1eaa6483a33c6043443966cb02f27bf18454 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 20 Apr 2021 02:40:59 +0200 Subject: [PATCH] First commit --- Dockerfile | 19 ++++++++++++ README.md | 64 ++++++++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 18 +++++++++++ src/make_uboot.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 docker/entrypoint.sh create mode 100755 src/make_uboot.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ce79c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:bullseye-slim + +RUN apt update \ + && apt install -y --no-install-recommends \ + gcc-aarch64-linux-gnu \ + device-tree-compiler \ + make \ + bc \ + build-essential \ + bison \ + flex \ + bash \ + git \ + ca-certificates + +COPY docker/entrypoint.sh /tmp +COPY src/ /tmp +WORKDIR /tmp +CMD /tmp/entrypoint.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..dfcdeb8 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +u-boot for MNT Reform build script +---------------------------------- + +Work in progress script for building uboot for the MNT Refom 2 computer. + +## Howto + +To compile the script, you'll need to install some packages. On Debian : + +``` +apt install -y --no-install-recommends gcc-aarch64-linux-gnu \ + device-tree-compiler \ + make \ + bc \ + build-essential \ + bison \ + flex \ + bash \ + git \ + ca-certificates +``` + +You just need to launch `make_uboot.sh`. By default, script build uboot with +sdcard support. to build it with emmc support you need to pass the `emmc` +argument: + +``` +./make_uboot.sh emmc +``` + +You can also define `UBOOT_BUILD` environment variable with `emmc` or `sdcard` +variable. + +The `flash.bin` is located in the `u-boot/` directory. + +## Build with docker + +Build the image : + +``` +docker build -t reform_kernel_build . +``` + +Then run the container with with a directory mapped to `/output`: + +``` +docker run -v /home/docker/output:/output --env UBOOT_BUILD=sdcard --rm reform_kernel_build +``` + +You could pass the `UBOOT_BUILD` environment variable to your container do tell +`make_uboot.sh` which version to compile : + + * `sdcard` or not defined if you'll install to the SDCard + * `emmc` for the internal memomry of the IMX card + +Flash.bin file will be in the directory mapped to `/output` in the +container. + +## Licence + +This work is derivated from MNT script found [here][l_mnt_image] and licenced +under the GPLv3 Licence + +[l_mnt_image]:https://source.mnt.re/reform/reform-system-image/ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..6bd585f --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Entrypoint for reform-build-kernel docker image + +if [ -f /output/flash.bin ] +then + printf "Kernel image exist in destination aborting compilation.\n" + exit 0 +fi + +if ./make_uboot.sh +then + cp u-boot/flash.bin /output/flash.bin +else + printf "Error when building uBoot\n" >&2 + exit 10 +fi +exit 0 diff --git a/src/make_uboot.sh b/src/make_uboot.sh new file mode 100755 index 0000000..65a79aa --- /dev/null +++ b/src/make_uboot.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e + +function usage { + + cat < + +where can be: + + sdcard: build uboot for sdcard (default) + emmc: build uboot for emmc + +The arguments can be replaced by UBOOT_BUILD environment variable + +EOF + +} + +function error { + >&2 printf "\e[31mE\e[0m %s\n" "$1" +} + +export ARCH=arm64 +export CROSS_COMPILE=aarch64-linux-gnu- +GIT_URL="https://source.mnt.re/reform/reform-boundary-uboot" + + + +if [ -n "$1" ] +then + UBOOT_BUILD="$1" +fi + +if [ -z "$UBOOT_BUILD" ] +then + UBOOT_BUILD="sdcard" +fi + +if [ ! -d u-boot ] +then + printf "Cloning uboot form MNTMN repo...\n" + if ! git clone --depth 1 "$GIT_URL" u-boot + then + error "Can't clone uboot from MNT, check version" + exit 11 + fi +fi + +cp u-boot/mntreform-config u-boot/.config + +cd u-boot + +case $UBOOT_BUILD in + " emmc") + make -j$(nproc) flash.bin KCPPFLAGS='-DMNTREFORM_BOOT_EMMC' + ;; + "sdcard") + make -j$(nproc) flash.bin + ;; + *) + error "${UBOOT_BUILD} is not a valid option" +esac +cd .. + +exit 0