With the attachment…
>From 85b1a011ce5f362cb363d9c6ce44946f2f4be754 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <nico...@debian.org> Date: Thu, 7 Jan 2021 21:12:43 +0100 Subject: Remove 64 suffix from u-boot-install-sunxi64
The tool can be used with custom targets. diff --git a/debian/bin/u-boot-install-sunxi b/debian/bin/u-boot-install-sunxi new file mode 100755 index 0000000000..2d29eed598 --- /dev/null +++ b/debian/bin/u-boot-install-sunxi @@ -0,0 +1,101 @@ +#!/bin/sh +set -e + +dtmodel="/sys/firmware/devicetree/base/model" +atf="/usr/lib/arm-trusted-firmware/sun50i_a64/bl31.bin" +if [ -z "$TARGET" ] && [ -f "${dtmodel}" ]; then + dtmodelname=$(cat $dtmodel) + case "$dtmodelname" in + Pinebook) TARGET="/usr/lib/u-boot/pinebook" ;; + "Pine64 PinePhone (1.2)") TARGET='/usr/lib/u-boot/pinephone' ;; + Pine64+) TARGET="/usr/lib/u-boot/pine64_plus" ;; + "Pine64 LTS") TARGET="/usr/lib/u-boot/pine64-lts" ;; + "Olimex A64-Olinuxino") TARGET="/usr/lib/u-boot/a64-olinuxino/" ;; + "Olimex A64-Olinuxino-eMMC") TARGET="/usr/lib/u-boot/a64-olinuxino-emmc" ;; + "Olimex A64 Teres-I") TARGET="/usr/lib/u-boot/teres_i/" ;; + "OrangePi Zero Plus2") TARGET="/usr/lib/u-boot/orangepi_zero_plus2/" ;; + "OrangePi One Plus") TARGET="/usr/lib/u-boot/orangepi_one_plus/" + atf="/usr/lib/arm-trusted-firmware/sun50i_h6/bl31.bin" ;; + "FriendlyARM NanoPi NEO 2") TARGET="/usr/lib/u-boot/nanopi_neo2/" ;; + "FriendlyARM NanoPi NEO Plus2") TARGET="/usr/lib/u-boot/nanopi_neo_plus2/" ;; + *) + echo >&2 "ERROR: Unknown system: ${dtmodelname}" + echo >&2 "Specify target: TARGET=/usr/lib/u-boot/UBOOT" + exit 1 + ;; + esac +fi + +if [ -z "$BL31" ] && [ -f "${atf}" ]; then + BL31="${atf}" +fi + +BL31=${BL31:-"/usr/lib/atf/sun50iw1p1/bl31.bin"} + +case "$1" in + -f|--force) + FORCE=y + shift;; + -*) + echo >&2 "$0: unknown option '$1'" + exit 1;; +esac + +if [ -z "$(which mkimage)" ]; then + echo >&2 "$0: mkimage: command not found. Please install u-boot-tools." + exit 1 +fi + +DEV="$1" +if [ -z "$DEV" ] || ! shift || [ -n "$*" ]; then + echo >&2 "Usage: $0 /dev/your-sd-or-mmc-or-image" + exit 1 +fi + +if [ ! -w "$DEV" ] && [ -z "$FORCE" ]; then + echo >&2 "$0: device/image ($DEV) must be writable" + exit 1 +fi +DEV="$(readlink -f "$DEV")" + +if [ ! -w "$DEV" ] && [ -z "$FORCE" ]; then + echo >&2 "$0: device/image ($DEV) not accessible via abs path?!?" + exit 1 +fi + +if [ -z "$FORCE" ]; then + # A very simple sanity check. GPT mandates a "protective MBR" so this works + # even with GPT partitioning. + printf '%b' '\0125\0252' >mbr-sign + if ! cmp -s -i 0:510 -n 2 mbr-sign "$DEV"; then + echo >&2 "$0: device/image ($DEV) has no MBR partition table" + exit 1 + fi + + # But, on sunxi64, spl will trample upon GPT. + printf "EFI PART" >gpt-sign + if cmp -s -i 0:512 -n 8 gpt-sign "$DEV"; then + echo >&2 "$0: device/image ($DEV) uses GPT partition table, unusable on sunxi64" + exit 1 + fi +fi + +itbfiles="u-boot.itb u-boot-sunxi-with-spl.fit.itb" +itb= +for i in $itbfiles ; do + i=${TARGET}/$i + if [ -f "$i" ]; then + itb=$i + fi +done + +if [ -z "$itb" ]; then + echo >&2 "$0: no known .itb file in ${TARGET}" + exit 1 +fi + +echo "Writing sunxi-spl" +dd conv=notrunc if=${TARGET}/sunxi-spl.bin of="$DEV" bs=8k seek=1 +echo "Writing u-boot FIT image" +dd conv=notrunc if=${itb} of="$DEV" bs=8k seek=5 +sync "$DEV" diff --git a/debian/bin/u-boot-install-sunxi64 b/debian/bin/u-boot-install-sunxi64 deleted file mode 100755 index 2d29eed598..0000000000 --- a/debian/bin/u-boot-install-sunxi64 +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh -set -e - -dtmodel="/sys/firmware/devicetree/base/model" -atf="/usr/lib/arm-trusted-firmware/sun50i_a64/bl31.bin" -if [ -z "$TARGET" ] && [ -f "${dtmodel}" ]; then - dtmodelname=$(cat $dtmodel) - case "$dtmodelname" in - Pinebook) TARGET="/usr/lib/u-boot/pinebook" ;; - "Pine64 PinePhone (1.2)") TARGET='/usr/lib/u-boot/pinephone' ;; - Pine64+) TARGET="/usr/lib/u-boot/pine64_plus" ;; - "Pine64 LTS") TARGET="/usr/lib/u-boot/pine64-lts" ;; - "Olimex A64-Olinuxino") TARGET="/usr/lib/u-boot/a64-olinuxino/" ;; - "Olimex A64-Olinuxino-eMMC") TARGET="/usr/lib/u-boot/a64-olinuxino-emmc" ;; - "Olimex A64 Teres-I") TARGET="/usr/lib/u-boot/teres_i/" ;; - "OrangePi Zero Plus2") TARGET="/usr/lib/u-boot/orangepi_zero_plus2/" ;; - "OrangePi One Plus") TARGET="/usr/lib/u-boot/orangepi_one_plus/" - atf="/usr/lib/arm-trusted-firmware/sun50i_h6/bl31.bin" ;; - "FriendlyARM NanoPi NEO 2") TARGET="/usr/lib/u-boot/nanopi_neo2/" ;; - "FriendlyARM NanoPi NEO Plus2") TARGET="/usr/lib/u-boot/nanopi_neo_plus2/" ;; - *) - echo >&2 "ERROR: Unknown system: ${dtmodelname}" - echo >&2 "Specify target: TARGET=/usr/lib/u-boot/UBOOT" - exit 1 - ;; - esac -fi - -if [ -z "$BL31" ] && [ -f "${atf}" ]; then - BL31="${atf}" -fi - -BL31=${BL31:-"/usr/lib/atf/sun50iw1p1/bl31.bin"} - -case "$1" in - -f|--force) - FORCE=y - shift;; - -*) - echo >&2 "$0: unknown option '$1'" - exit 1;; -esac - -if [ -z "$(which mkimage)" ]; then - echo >&2 "$0: mkimage: command not found. Please install u-boot-tools." - exit 1 -fi - -DEV="$1" -if [ -z "$DEV" ] || ! shift || [ -n "$*" ]; then - echo >&2 "Usage: $0 /dev/your-sd-or-mmc-or-image" - exit 1 -fi - -if [ ! -w "$DEV" ] && [ -z "$FORCE" ]; then - echo >&2 "$0: device/image ($DEV) must be writable" - exit 1 -fi -DEV="$(readlink -f "$DEV")" - -if [ ! -w "$DEV" ] && [ -z "$FORCE" ]; then - echo >&2 "$0: device/image ($DEV) not accessible via abs path?!?" - exit 1 -fi - -if [ -z "$FORCE" ]; then - # A very simple sanity check. GPT mandates a "protective MBR" so this works - # even with GPT partitioning. - printf '%b' '\0125\0252' >mbr-sign - if ! cmp -s -i 0:510 -n 2 mbr-sign "$DEV"; then - echo >&2 "$0: device/image ($DEV) has no MBR partition table" - exit 1 - fi - - # But, on sunxi64, spl will trample upon GPT. - printf "EFI PART" >gpt-sign - if cmp -s -i 0:512 -n 8 gpt-sign "$DEV"; then - echo >&2 "$0: device/image ($DEV) uses GPT partition table, unusable on sunxi64" - exit 1 - fi -fi - -itbfiles="u-boot.itb u-boot-sunxi-with-spl.fit.itb" -itb= -for i in $itbfiles ; do - i=${TARGET}/$i - if [ -f "$i" ]; then - itb=$i - fi -done - -if [ -z "$itb" ]; then - echo >&2 "$0: no known .itb file in ${TARGET}" - exit 1 -fi - -echo "Writing sunxi-spl" -dd conv=notrunc if=${TARGET}/sunxi-spl.bin of="$DEV" bs=8k seek=1 -echo "Writing u-boot FIT image" -dd conv=notrunc if=${itb} of="$DEV" bs=8k seek=5 -sync "$DEV" diff --git a/debian/manpages/u-boot-install-sunxi.8 b/debian/manpages/u-boot-install-sunxi.8 new file mode 100644 index 0000000000..af2edb0fa1 --- /dev/null +++ b/debian/manpages/u-boot-install-sunxi.8 @@ -0,0 +1,44 @@ +.TH u-boot-install-sunxi 8 2018-03-17 u-boot +.SH NAME +u-boot-install-sunxi \- install u-boot+ATF for sunxi (Allwinner) devices +.SH SYNOPSIS +.B u-boot-install-sunxi +.RI [ -f ] +.I card-device-or-image-file +.SH DESCRIPTION +This tool prepares a combined u-boot+ATF setup and writes it to the disk (or +possibly a disk image), allowing the machine to boot. The u-bootage is +written to an area between the partition table and the first partition; +there is no check if it's large enough \(em some ancient fdisk tools used to +reserve only 31KB there, which can result in data loss. +.PP +The device will usually be +.I /dev/mmcblk0 +for SD card, +.I /dev/mmcblk1 +for eMMC, +.I /dev/sdX +for USB SD card readers (be careful wrt your other disks!). +.PP +By default, the path where +.I .dtb +and +.I .bin +files are copied from is a subdirectory of +.I /usr/lib/u-boot +deduced from the current running system, but if the +.RB $ TARGET +environment variable is set, its contents are used instead. +.SH OPTIONS +.TP +-f | --force +Skip partition table sanity checks. Usually, a MBR partition table is +required (so u-boot has something to work with), but in rare setups you +may put the data on another disk. Likewise, GPT partition tables are +incompatible with the layout used on sunxi64 devices (spl is written at +offset 16384 while GPT occupies bytes [512..33280) ) but this option lets +you trample upon them anyway. +.SH CAVEATS +It has been so far tested only on Pine64+. If appropriate DTBs are provided, +it \fImay\fR work on Pinebook, SoPine, other A64 devices, or possibly even H5. +Reports are welcome! diff --git a/debian/manpages/u-boot-install-sunxi64.8 b/debian/manpages/u-boot-install-sunxi64.8 deleted file mode 100644 index e06596a00a..0000000000 --- a/debian/manpages/u-boot-install-sunxi64.8 +++ /dev/null @@ -1,44 +0,0 @@ -.TH u-boot-install-sunxi64 8 2018-03-17 u-boot -.SH NAME -u-boot-install-sunxi64 \- install u-boot+ATF for sunxi64 (Allwinner) devices -.SH SYNOPSIS -.B u-boot-install-sunxi64 -.RI [ -f ] -.I card-device-or-image-file -.SH DESCRIPTION -This tool prepares a combined u-boot+ATF setup and writes it to the disk (or -possibly a disk image), allowing the machine to boot. The u-bootage is -written to an area between the partition table and the first partition; -there is no check if it's large enough \(em some ancient fdisk tools used to -reserve only 31KB there, which can result in data loss. -.PP -The device will usually be -.I /dev/mmcblk0 -for SD card, -.I /dev/mmcblk1 -for eMMC, -.I /dev/sdX -for USB SD card readers (be careful wrt your other disks!). -.PP -By default, the path where -.I .dtb -and -.I .bin -files are copied from is a subdirectory of -.I /usr/lib/u-boot -deduced from the current running system, but if the -.RB $ TARGET -environment variable is set, its contents are used instead. -.SH OPTIONS -.TP --f | --force -Skip partition table sanity checks. Usually, a MBR partition table is -required (so u-boot has something to work with), but in rare setups you -may put the data on another disk. Likewise, GPT partition tables are -incompatible with the layout used on sunxi64 devices (spl is written at -offset 16384 while GPT occupies bytes [512..33280) ) but this option lets -you trample upon them anyway. -.SH CAVEATS -It has been so far tested only on Pine64+. If appropriate DTBs are provided, -it \fImay\fR work on Pinebook, SoPine, other A64 devices, or possibly even H5. -Reports are welcome! diff --git a/debian/u-boot-sunxi.README.Debian b/debian/u-boot-sunxi.README.Debian index b8899836df..9732affeb2 100644 --- a/debian/u-boot-sunxi.README.Debian +++ b/debian/u-boot-sunxi.README.Debian @@ -6,4 +6,4 @@ Many sunxi boards (Bananapi, Cubieboard) can be written to SD directly: dd conv=fsync,notrunc if=/usr/lib/u-boot/BOARD/u-boot-sunxi-with-spl.bin of=/dev/mmcblkX bs=1024 seek=8 -Pine64 plus can be installed using the u-boot-install-sunxi64 utility. +Pine64 plus can be installed using the u-boot-install-sunxi utility. diff --git a/debian/u-boot-sunxi.install b/debian/u-boot-sunxi.install index 8bfc86698f..ad5a39aa6f 100755 --- a/debian/u-boot-sunxi.install +++ b/debian/u-boot-sunxi.install @@ -1,4 +1,4 @@ #!/bin/sh -debian/bin/u-boot-install-targets sunxi "board/sunxi/README.sunxi64" +debian/bin/u-boot-install-targets sunxi -echo debian/bin/u-boot-install-sunxi64 /usr/bin/ +echo debian/bin/u-boot-install-sunxi /usr/bin/ diff --git a/debian/u-boot-sunxi.manpages b/debian/u-boot-sunxi.manpages index f72604d63f..f9c42c1d24 100644 --- a/debian/u-boot-sunxi.manpages +++ b/debian/u-boot-sunxi.manpages @@ -1 +1 @@ -debian/manpages/u-boot-install-sunxi64.8 +debian/manpages/u-boot-install-sunxi.8