Commit 220f60ed authored by Guido Gunther's avatar Guido Gunther

Merge branch 'debianpkg' into 'librem5'

Add Debian packaging

Closes #20 and image-builder#3

See merge request Librem5/uboot-imx!34
parents 586f4040 27ff339b
Pipeline #57369 passed with stage
in 2 minutes and 54 seconds
......@@ -65,10 +65,6 @@ fit-dtb.blob
patches-*
.stgit-edit.txt
# quilt's files
patches
series
# gdb files
.gdb_history
......
stages:
- build
.buster_vars: &buster_vars
variables:
CI_REPO: "deb [arch=amd64,arm64] http://ci.puri.sm/ scratch librem5"
DIST: buster
DEPS: libfdt-dev arm-trusted-firmware:arm64 libc6-dev:arm64 gcc-aarch64-linux-gnu
.build_step: &build_step
script:
- DEB_BUILD_PROFILES="pkg.uboot.subarch.imx" dpkg-buildpackage -uc -us -B --host-arch=arm64
- rm -rf debian/output/
- mkdir debian/output/
- cp ../*.deb debian/output
before_script:
- export DEBIAN_FRONTEND=noninteractive
- dpkg --add-architecture arm64
- apt-get -y update
- apt-get -y install wget ca-certificates gnupg eatmydata
- echo "Using CI repo ${CI_REPO}"
- echo "$CI_REPO" > /etc/apt/sources.list.d/ci.list
- wget -O- https://ci.puri.sm/ci-repo.key | apt-key add -
- echo "deb [arch=amd64,arm64] http://deb.debian.org/debian/ buster main" > /etc/apt/sources.list.d/cross.list
- eatmydata apt-get -y update
- eatmydata apt-get -y build-dep .
- eatmydata apt-get -y install $DEPS
.tags: &tags
tags:
- librem5
build:cross:debian-buster:
<<: *tags
stage: build
image: debian:buster
<<: *buster_vars
<<: *build_step
artifacts:
paths:
- debian/output
#!/bin/bash
set -e
URL_BASE=https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/
FIRMWARE=firmware-imx-8.7.bin
function cleanup()
{
[ -z "${DLDIR}" ] || rm -rf "${DLDIR}"
}
trap cleanup EXIT
if [ -z "$1" ]; then
echo "No output dir given" 1>&2
exit 1
fi
OUT=$1
DLDIR=$(mktemp -d)
cd "${DLDIR}"
wget "${URL_BASE}/${FIRMWARE}"
chmod +x "${FIRMWARE}"
./"${FIRMWARE}" --auto-accept
cd -
for f in ddr/synopsys/lpddr4_pmu_train_?d_?mem.bin hdmi/cadence/signed_*_imx8m.bin; do
cp -v ${DLDIR}/$(basename "${FIRMWARE}" .bin)/firmware/$f "${OUT}"
done
#!/bin/sh
set -x
set -e
builddir="$1"
platform="$2"
subarch="$3"
case $platform in
dragonboard820c)
pagesize=4096
base=0x80000000
;;
dragonboard410c)
pagesize=2048
base=0x80000000
;;
*)
echo "unknown platform ${platform}"
exit 1
;;
esac
touch ${builddir}/rd
skales-dtbtool -o "${builddir}/dt.img" "${builddir}/arch/arm/dts"
skales-mkbootimg --kernel "${builddir}/u-boot-dtb.bin" \
--output="${builddir}/u-boot.img" --dt="${builddir}/dt.img" \
--pagesize "${pagesize}" --base "${base}" \
--ramdisk="${builddir}/rd" --cmdline=""
echo "${builddir}/u-boot.img" "/usr/lib/u-boot/${platform}/" \
>> "debian/build/targets.${subarch}"
#!/bin/sh
set -e
dtmodel="/sys/firmware/devicetree/base/model"
if [ -z "$TARGET" ] && [ -f "${dtmodel}" ]; then
case $(cat "${dtmodel}") in
"Purism Librem 5 devkit")
TARGET="/usr/lib/u-boot/librem5_devkit"
;;
"Purism Librem 5")
TARGET="/usr/lib/u-boot/librem5"
;;
*)
echo >&2 "ERROR: Unknown system: ${dtmodel}"
echo >&2 "Specify target: TARGET=/usr/lib/u-boot/UBOOT"
exit 1
;;
esac
fi
UBOOT_IMAGE=${UBOOT_IMAGE:-"u-boot.imx"}
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
echo "Writing u-boot image"
dd if=/dev/zero of="$DEV" bs=1024 count=1055 seek=2
dd if="${TARGET}/${UBOOT_IMAGE}" conv=notrunc of="$DEV" bs=1024 seek=33
sync "$DEV"
#!/bin/sh
set -e
dtmodel="/sys/firmware/devicetree/base/model"
if [ -z "$TARGET" ] && [ -f "${dtmodel}" ]; then
case $(cat "${dtmodel}") in
Firefly-RK3288)
TARGET="/usr/lib/u-boot/firefly-rk3288"
UBOOT_IMAGE="u-boot.img"
;;
Firefly-RK3399|"Firefly-RK3399 Board")
TARGET="/usr/lib/u-boot/firefly-rk3399"
;;
"Pine64 Pinebook Pro")
TARGET="/usr/lib/u-boot/pinebook-pro-rk3399"
;;
"Pine64 Rock64")
TARGET="/usr/lib/u-boot/rock64-rk3328"
;;
"Pine64 RockPro64")
TARGET="/usr/lib/u-boot/rockpro64-rk3399"
;;
"Radxa ROCK Pi 4")
TARGET="/usr/lib/u-boot/rock-pi-4-rk3399"
;;
*)
echo >&2 "ERROR: Unknown system: ${dtmodel}"
echo >&2 "Specify target: TARGET=/usr/lib/u-boot/UBOOT"
exit 1
;;
esac
fi
LOADER_IMAGE=${LOADER_IMAGE:-"idbloader.img"}
UBOOT_IMAGE=${UBOOT_IMAGE:-"u-boot.itb"}
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
# FIXME/TODO: check for overwriting partitions overlapping sectors
# 16384-24575, unless using a compatible partition layout:
# http://opensource.rock-chips.com/wiki_Partitions
# loader1 64-7168 idbloader.img
# loader2 16384-24575 u-boot.itb/u-boot.img
# trust 24576-32767
echo "Writing idbloader"
dd conv=notrunc if=${TARGET}/${LOADER_IMAGE} of="$DEV" seek=64
echo "Writing u-boot image"
dd conv=notrunc if=${TARGET}/${UBOOT_IMAGE} of="$DEV" seek=16384
sync "$DEV"
#!/bin/sh
set -e
dtmodel="/sys/firmware/devicetree/base/model"
if [ -z "$TARGET" ] && [ -f "${dtmodel}" ]; then
case $(cat "${dtmodel}") in
Pinebook) TARGET="/usr/lib/u-boot/pinebook" ;;
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/" ;;
"FriendlyARM NanoPi NEO 2") TARGET="/usr/lib/u-boot/nanopi_neo2/" ;;
"FriendlyARM NanoPi NEO Plus2") TARGET="/usr/lib/u-boot/nanopi_neo_plus2/" ;;
esac
fi
atf="/usr/lib/arm-trusted-firmware/sun50i_a64/bl31.bin"
if [ -z "$BL31" ] && [ -f "${atf}" ]; then
BL31="${atf}"
fi
TARGET=${TARGET:-"/usr/lib/u-boot/pine64_plus"}
BL31=${BL31:-"/usr/lib/atf/sun50iw1p1/bl31.bin"}
FIT_GENERATOR=${FIT_GENERATOR:-"mksunxi_fit_atf"}
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")"
DIR="$(mktemp -d)"
trap 'rm -rf "$DIR"' 0
# Build tools get confused by paths, thus let's copy all the pieces into
# one dir.
if [ ! -w "$DEV" ] && [ -z "$FORCE" ]; then
echo >&2 "$0: device/image ($DEV) not accessible via abs path?!?"
exit 1
fi
cd "$DIR"
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
cp -p $TARGET/*.dtb $TARGET/*.bin .
BL31=$BL31 \
$FIT_GENERATOR *.dtb > u-boot.its
mkimage -f u-boot.its u-boot.itb
echo "Writing sunxi-spl"
dd conv=notrunc if=sunxi-spl.bin of="$DEV" bs=8k seek=1
echo "Writing u-boot FIT image"
dd conv=notrunc if=u-boot.itb of="$DEV" bs=8k seek=5
sync "$DEV"
#!/bin/sh
target=$1
docs="$2"
subarch_install_file="debian/build/targets.${target}"
if [ -f "${subarch_install_file}" ]; then
cat "${subarch_install_file}"
fi
for doc in ${docs} ; do
echo ${doc} /usr/share/doc/u-boot-${target}/
done
#!/bin/sh
target_file=debian/targets
awk '/^[a-z0-9]/{print $2}' ${target_file} | sort -u | while read subarch ; do
case ${subarch} in
-) package=u-boot ;;
*) package=u-boot-${subarch} ;;
esac
overrides=debian/${package}.lintian-overrides
cat >${overrides}<<EOF
# There are no file conflicts across architectures for u-boot, as each
# target is only installed on a single architecture. In theory, some
# targets could be built on multiple architectures, but could instead install
# the package for the architecture needed.
EOF
sed -n "/^[a-z0-9].*[[:space:]]$subarch[[:space:]]/p" ${target_file} | while read arch subarch2 platform targets ; do
echo "${package} binary: arch-dependent-file-not-in-arch-specific-directory usr/lib/u-boot/*/uboot.elf"
done | LC_ALL=C sort -u >> ${overrides}
cat >>${overrides}<<EOF
# These bootloaders need to be statically linked.
EOF
sed -n "/^[a-z0-9].*[[:space:]]$subarch[[:space:]]/p" ${target_file} | while read arch subarch2 platform targets ; do
echo "${package} binary: statically-linked-binary usr/lib/u-boot/*/uboot.elf"
done | LC_ALL=C sort -u >> ${overrides}
cat >>${overrides}<<EOF
# These are bootloader binaries, and have no external dependency information
EOF
sed -n "/^[a-z0-9].*[[:space:]]$subarch[[:space:]]/p" ${target_file} | while read arch subarch2 platform targets ; do
echo "${package} binary: shared-library-lacks-prerequisites usr/lib/u-boot/*/uboot.elf"
done | LC_ALL=C sort -u >> ${overrides}
cat >>${overrides}<<EOF
${package}: description-synopsis-starts-with-article
EOF
done
package=u-boot-qemu
overrides=debian/${package}.lintian-overrides
cat >>${overrides}<<EOF
# These are binary firmware blobs
EOF
sed -n "/^all:.*[[:space:]]qemu[[:space:]]/p" ${target_file} | while read arch subarch2 platform targets ; do
echo "${package} binary: arch-independent-package-contains-binary-or-object usr/lib/u-boot/*/uboot.elf"
done | LC_ALL=C sort -u >> ${overrides}
#!/bin/sh
for file in debian/build/platforms.* ; do
subarch=$(echo ${file} | sed -e 's,.*platforms.,,g')
case "${subarch}" in
-) package=u-boot ;;
*) package=u-boot-${subarch} ;;
esac
echo $(LC_ALL=C sort -u ${file}) | \
sed -e 's, ,${Newline},g' \
-e 's,^,uboot:platforms=${Newline}Included platforms:${Newline},g' \
>> debian/${package}.substvars
case "${subarch}" in
rockchip|sunxi)
printf "uboot:Built-Using=$(dpkg-query -f '${source:Package} (= ${source:Version}) [arm64]' -W arm-trusted-firmware)\n"\
>> debian/${package}.substvars
;;
esac
done
u-boot-imx (2019.04~rc1-0.1+librem5.1) amber-phone; urgency=medium
* Packaging based on Debian's uboot package as
of 2020.07~rc4+dfsg-1 by Vagrant Cascadian.
-- Guido Günther <agx@sigxcpu.org> Tue, 07 Jul 2020 12:41:19 +0200
Source: u-boot-imx
Section: non-free/admin
Priority: optional
Maintainer: Vagrant Cascadian <vagrant@debian.org>
Uploaders: Loïc Minier <lool@debian.org>, Clint Adams <clint@debian.org>
Build-Depends:
arm-trusted-firmware [arm64],
bc,
bison,
debhelper-compat (= 12),
device-tree-compiler,
dpkg-dev (>= 1.17.14),
flex,
libfdt-dev:native [arm64],
libc6:arm64 [arm64] <cross !pkg.uboot.notools>,
libpython3-dev:native [linux-any],
python3:any [linux-any],
python3-distutils [linux-any],
swig [linux-any],
lzop [armhf] <!cross> | lzop:native [armhf] <cross>,
Rules-Requires-Root: no
Standards-Version: 4.5.0
Homepage: http://www.denx.de/wiki/U-Boot/
Vcs-Browser: https://salsa.debian.org/debian/u-boot
Vcs-Git: https://salsa.debian.org/debian/u-boot.git
Package: u-boot-imx
Architecture: armhf
Multi-Arch: same
Depends: ${misc:Depends}
Breaks: u-boot (<< 2014.10~rc2+dfsg1-2~)
Replaces: u-boot (<< 2014.10~rc2+dfsg1-2~)
Description: A boot loader for imx systems
Das U-Boot is a cross-platform bootloader for embedded systems,
used as the default boot loader by several board vendors. It is
intended to be easy to port and to debug, and runs on many
supported architectures, including PPC, ARM, MIPS, x86, m68k,
NIOS, and Microblaze.
.
This package includes boot loaders for various imx platforms.
${uboot:platforms}
Package: u-boot-librem5
Architecture: arm64
Multi-Arch: same
Depends: ${misc:Depends}
Breaks: u-boot (<< 2014.10~rc2+dfsg1-2~)
Replaces: u-boot (<< 2014.10~rc2+dfsg1-2~)
Description: A boot loader for the Librem 5
Das U-Boot is a cross-platform bootloader for embedded systems,
used as the default boot loader by several board vendors. It is
intended to be easy to port and to debug, and runs on many
supported architectures, including PPC, ARM, MIPS, x86, m68k,
NIOS, and Microblaze.
.
This package includes boot loaders for the Librem 5 and the
Librem 5 Devkit.
${uboot:platforms}
Package: u-boot-tools
Architecture: linux-any
Build-Profiles: <!pkg.uboot.notools>
Multi-Arch: foreign
Depends: ${shlibs:Depends}, ${misc:Depends}
Recommends: device-tree-compiler,
libubootenv-tool,
Breaks: uboot-envtools (<< 20081215-3~),
uboot-mkimage (<= 0.4build1),
u-boot (<< 2010.12-2)
Replaces: uboot-envtools (<< 20081215-3~),
uboot-mkimage (<= 0.4build1),
u-boot (<< 2010.12-2)
Description: companion tools for Das U-Boot bootloader
This package includes programs for generating and listing U-Boot
images in various formats:
- mkimage
- dumpimage
- mksunxiboot
- mkenvimage
This diff is collapsed.
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd1 0x00000 0x10000 0x01000
# Configuration file for fw_(printenv/saveenv) utility.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd1 0x0 0x20000 0x20000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x3F000 0x1000 0x1000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundand
# environment sector is assumed present.
# for Buffalo Linkstation Mini
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x3f000 0x01000 0x01000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x3F000 0x1000 0x1000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x30000 0x10000 0x10000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd4 0x360000 0x10000 0x10000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mmcblk0 0x80000 0x2000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd1 0x0000 0x4000 0x4000 2
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd2 0x0000 0x40000 0x20000 2
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
# Legacy u-boot versions:
#/dev/mtd0 0xa0000 0x20000 0x20000
# New u-boot versions:
/dev/mtd0 0x60000 0x20000 0x20000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd5 0x00000 0x20000 0x20000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd4 0x0000 0x20000 0x20000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# This config is for QNAP TS-119, TS-219 and TS-219P boards.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mtd4 0x0000 0x1000 0x40000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
# Legacy u-boot versions:
#/dev/mtd0 0x60000 0x20000 0x20000
# New u-boot versions:
/dev/mtd0 0x80000 0x20000 0x20000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mmcblk0 0xC0000 0x2000
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#
# XXX this configuration might miss a fifth parameter for the "Number of
# sectors"
# MTD device name Device offset Env. size Flash sector size
/dev/mmcblk0 0x60000 0x2000
.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!).
.SH OPTIONS