[PATCH] board: odroid-n2: Add script and update docs for signing
Neil Armstrong
neil.armstrong at linaro.org
Mon Dec 30 11:04:05 CET 2024
Hi,
On 23/12/2024 23:23, Baltazár Radics wrote:
> The previous instructions resulted in a bootloader that wouldn't fit in
> an mbr gap. I have updated the docs based on upstream's build process.
>
> Note that the script should be compatible with other g12 based odroid
> boards, but I'm unable to test those boards.
>
> Signed-off-by: Baltazár Radics <baltazar.radics at gmail.com>
> ---
>
> doc/board/amlogic/odroid-n2.rst | 71 ++-------------------------------
> tools/amlogic-odroidg12-sign.sh | 67 +++++++++++++++++++++++++++++++
I'm not a big fan of moving the instructions in a script,
the script is already avaible in the amlogic-boot-fip project,
so rather could you fix the documentation instead ?
Thanks,
Neil
> 2 files changed, 70 insertions(+), 68 deletions(-)
> create mode 100755 tools/amlogic-odroidg12-sign.sh
>
> diff --git a/doc/board/amlogic/odroid-n2.rst b/doc/board/amlogic/odroid-n2.rst
> index 883720f8fb..f81e8222f8 100644
> --- a/doc/board/amlogic/odroid-n2.rst
> +++ b/doc/board/amlogic/odroid-n2.rst
> @@ -54,10 +54,9 @@ image so it is necessary to obtain binaries from sources published by the board
> $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
> $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
>
> - $ DIR=odroid-n2
> - $ git clone --depth 1 https://github.com/hardkernel/u-boot.git -b odroidn2-v2015.01 $DIR
> + $ git clone --depth 1 https://github.com/hardkernel/u-boot.git -b odroidg12-v2015.01 odroidg12
>
> - $ cd odroid-n2
> + $ cd odroidg12
> $ make odroidn2_defconfig
> $ make
> $ export UBOOTDIR=$PWD
> @@ -66,71 +65,7 @@ Go back to the mainline U-Boot source tree then:
>
> .. code-block:: bash
>
> - $ mkdir fip
> -
> - $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
> - $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
> - $ cp $UBOOTDIR/build/board/hardkernel/odroidn2/firmware/acs.bin fip/
> - $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
> - $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/
> - $ cp $UBOOTDIR/fip/g12b/bl31.img fip/
> - $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/piei.fw fip/
> - $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
> - $ cp u-boot.bin fip/bl33.bin
> -
> - $ sh fip/blx_fix.sh \
> - fip/bl30.bin \
> - fip/zero_tmp \
> - fip/bl30_zero.bin \
> - fip/bl301.bin \
> - fip/bl301_zero.bin \
> - fip/bl30_new.bin \
> - bl30
> -
> - $ sh fip/blx_fix.sh \
> - fip/bl2.bin \
> - fip/zero_tmp \
> - fip/bl2_zero.bin \
> - fip/acs.bin \
> - fip/bl21_zero.bin \
> - fip/bl2_new.bin \
> - bl2
> -
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
> - --output fip/bl30_new.bin.g12a.enc \
> - --level v3
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
> - --output fip/bl30_new.bin.enc \
> - --level v3 --type bl30
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
> - --output fip/bl31.img.enc \
> - --level v3 --type bl31
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
> - --output fip/bl33.bin.enc \
> - --level v3 --type bl33 --compress lz4
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
> - --output fip/bl2.n.bin.sig
> - $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
> - --output fip/u-boot.bin \
> - --bl2 fip/bl2.n.bin.sig \
> - --bl30 fip/bl30_new.bin.enc \
> - --bl31 fip/bl31.img.enc \
> - --bl33 fip/bl33.bin.enc \
> - --ddrfw1 fip/ddr4_1d.fw \
> - --ddrfw2 fip/ddr4_2d.fw \
> - --ddrfw3 fip/ddr3_1d.fw \
> - --ddrfw4 fip/piei.fw \
> - --ddrfw5 fip/lpddr4_1d.fw \
> - --ddrfw6 fip/lpddr4_2d.fw \
> - --ddrfw7 fip/diag_lpddr4.fw \
> - --ddrfw8 fip/aml_ddr.fw \
> - --level v3
> + $ ./tools/amlogic-odroidg12-sign.sh "$UBOOTDIR"
>
> Then write U-Boot to SD or eMMC with:
>
> diff --git a/tools/amlogic-odroidg12-sign.sh b/tools/amlogic-odroidg12-sign.sh
> new file mode 100755
> index 0000000000..30a81e0374
> --- /dev/null
> +++ b/tools/amlogic-odroidg12-sign.sh
> @@ -0,0 +1,67 @@
> +#!/bin/sh -e
> +# SPDX-License-Identifier: GPL-2.0+
> +
> +error() {
> + echo "$@" >&2
> + exit 1
> +}
> +
> +[ $# -lt 1 ] && error "usage: $0 <built u-boot odroidg12> [out dir] [binary]"
> +
> +src=$1 # hardkernel's u-boot tree (built)
> +out=${2:-fip}
> +bl33=${3:-u-boot.bin}
> +
> +. "$src/build/include/config/auto.conf"
> +SOC=$CONFIG_SYS_SOC
> +BOARDDIR=board/$CONFIG_SYS_VENDOR/$CONFIG_SYS_BOARD
> +[ "$CONFIG_ODROID_N2L" = y ] && ddr='lp'
> +
> +fix_blx() {
> + [ "$(wc -c <"$1")" -gt "$2" ] && error "Error: $1 too big."
> + [ "$(wc -c <"$3")" -gt "$4" ] && error "Error: $2 too big."
> +
> + cat "$1" /dev/zero | head -c "$2"
> + cat "$3" /dev/zero | head -c "$4"
> +}
> +
> +encrypt_step() {
> + "$src/fip/$SOC/aml_encrypt_$SOC" "$@"
> +}
> +
> +mkdir -p "$out"
> +
> +fix_blx \
> + "$src/fip/$SOC/bl30.bin" 40960 \
> + "$src/build/scp_task/bl301.bin" 13312 \
> + >"$out/bl30_new.bin"
> +fix_blx \
> + "$src/fip/$SOC/bl2.bin" 57344 \
> + "$src/build/$BOARDDIR/firmware/acs.bin" 4096 \
> + >"$out/bl2_new.bin"
> +
> +encrypt_step --bl30sig --level v3 \
> + --input "$out/bl30_new.bin" \
> + --output "$out/bl30_new.bin.g12.enc"
> +encrypt_step --bl3sig --level v3 --type bl30 \
> + --input "$out/bl30_new.bin.g12.enc" \
> + --output "$out/bl30_new.bin.enc"
> +encrypt_step --bl3sig --level v3 --type bl31 \
> + --input "$src/fip/$SOC/bl31.img" \
> + --output "$out/bl31.img.enc"
> +encrypt_step --bl3sig --level v3 --type bl33 --compress lz4 \
> + --input "$bl33" \
> + --output "$out/bl33.bin.enc"
> +encrypt_step --bl2sig \
> + --input "$out/bl2_new.bin" \
> + --output "$out/bl2.n.bin.sig"
> +encrypt_step --bootmk --level v3 \
> + --bl2 "$out/bl2.n.bin.sig" \
> + --bl30 "$out/bl30_new.bin.enc" \
> + --bl31 "$out/bl31.img.enc" \
> + --bl33 "$out/bl33.bin.enc" \
> + --ddrfw1 "$src/fip/$SOC/${ddr}ddr4_1d.fw" \
> + --ddrfw2 "$src/fip/$SOC/${ddr}ddr4_2d.fw" \
> + --ddrfw4 "$src/fip/$SOC/piei.fw" \
> + --ddrfw8 "$src/fip/$SOC/aml_ddr.fw" \
> + --output "$out/u-boot.bin"
More information about the U-Boot
mailing list