diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-07-24 04:37:57 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-07-26 19:24:58 +0200 |
commit | 91f70df974f8c2604e3aebba4833d90f4beb8bb8 (patch) | |
tree | 321b434a7a382248c282c9ea6c2c8c65959317d2 | |
parent | 5826571a7b026cf2f70f69d36f61b9163cfb85a4 (diff) |
WIP: uboot4extlinux-imx: sync with uboot4extlinux-sunxiGNUtoo/bootloaders/u-boot-wip
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | libre/uboot4extlinux-imx/PKGBUILD | 279 |
1 files changed, 216 insertions, 63 deletions
diff --git a/libre/uboot4extlinux-imx/PKGBUILD b/libre/uboot4extlinux-imx/PKGBUILD index 64e25a608..533d3447e 100644 --- a/libre/uboot4extlinux-imx/PKGBUILD +++ b/libre/uboot4extlinux-imx/PKGBUILD @@ -2,7 +2,34 @@ # Contributor: Isaac David <isacdaavid@at@isacdaavid@dot@info> # Contributor: André Silva <emulatorman@hyperbola.info> # Contributor: Timothy Redaelli <timothy.redaelli@gmail.com> -# Maintainer: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +# Contributor: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> + +# To add a new board (that uses an I.MX System On a Chip) you need: +# - The package name. Example: uboot4extlinux-tbs2910 +# - The u-boot configuration. Example: tbs2910_defconfig +# - The name of the board(s). Example: TBS2910 Matrix ARM mini PC +# A single package / u-boot configuration sometimes support multiple +# boards and the configuration name doesn't always have the boards names +# in it. Example: uboot4extlinux-am335x_bone supports various BeagleBones, +# the AM335x GP EVM and the EVM SK all in one u-boot binary and package. +# - If relevant, the packages it replaces, if there are older u-boot packages +# also supporting that board. Example:uboot-a20-olinuxino-micro +# +# Ideally we'd like to enable people to only add these 4 variables in this +# package to add a new board. These 4 variables could go in something like +# a CVS file that is parsed, but that would require to be able to dynamically +# define packages, but even if eval package_{$_pkgname}() { [...] } works, +# it doesn't make that package function visible to makepkg. +# +# Because of that, contributors wanting to add new boards will have to search +# for example of the information mentioned above and add it in the PKGBUILD +# for their boards. +# +# After adding a new board in this PKGBUILD, to get the board officially +# supported by Parabola.you also need to create a page for it in the +# Parabola wiki for that board and update the ARM installation guide to +# point to it when relevant. Examples of that are available for other +# boards in the ARM installation guide. # TODO: # - Add the following boards @@ -11,87 +38,213 @@ # - 'udoo' # - 'usbarmory' # - 'wandboard' -# - Improve the .install: -# - Make it more generic: share the main part of the code. -# - Check for the machine name with the device tree and ask for confirmation -# if the machine is not the same but don't prevent users from installing -# this bootloader on a totally different machine as the installation could -# be done in a chroot or in other ways that packagers can't predict. -# - Handle more than one boot device (microSD, eMMC, USB, etc) -# - Point to the device documentation if there is some pkgbase=uboot4extlinux-imx -pkgname=('uboot4extlinux-tbs2910') -pkgver=2020.04 +pkgname=("${pkgbase}" + 'uboot4extlinux-tbs2910') + +pkgver=2021.07 pkgrel=2 -arch=('armv7h') +arch=('armv7h' 'i686' 'x86_64') url="http://git.denx.de/u-boot.git/" license=('GPL') -makedepends=('bc' 'dtc' 'python' 'python2' 'swig') -backup=(boot/extlinux/extlinux.conf) +makedepends=('bc' 'dtc' 'python' 'python-setuptools' 'python2' 'swig') +makedepends_i686+=('arm-none-eabi-gcc') +makedepends_ppc64le+=('arm-none-eabi-gcc') +makedepends_x86_64+=('arm-none-eabi-gcc') source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2" - 'extlinux.conf') -sha256sums=('fe732aaf037d9cc3c0909bad8362af366ae964bbdac6913a34081ff4ad565372' + 'extlinux.conf' + "${pkgbase}.hook.in" + 'install-uboot4extlinux.sh.in' + "generate-${pkgbase}-install-text.sh") +sha256sums=('312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e' + 'SKIP' + 'SKIP' + 'SKIP' 'SKIP') -# Distro boot config and documentation for the TBS TBS2910 -# The patches are from the next branch of u-boot git -# a bit after the v2020.07-rc4 tag. They should make it in 1 or two -# u-boot release. -source+=('0001-board-tbs2910-disable-loadb-and-loads-commands.patch' - '0002-board-tbs2910-disable-CONFIG_GZIP.patch' - '0003-board-tbs2910-move-CONFIG_BOOTCOMMAND-from-header-to.patch' - '0004-board-tbs2910_defconfig-Add-support-for-booting-gene.patch' - '0005-board-tbs2910-Enable-distro_boot-support.patch' - '0006-board-tbs2910-add-documentation.patch') -sha256sums+=('SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP') - -boards=('tbs2910') - -prepare() { +_defconfigs=('tbs2910_defconfig') + +# Offset at which to install u-boot +u_boot_with_spl_offset=1024 + +case "$CARCH" in + armv7h) ARCH=arm;; + i686|ppc64le|x86_64) ARCH=arm;CROSS_COMPILE=arm-none-eabi-;; +esac + +_nr_targets=0 +for _defconfig in ${_defconfigs[@]}; do + _nr_targets=$(expr ${_nr_targets} + 1) +done + +_get_target_name() +{ + _defconfig="$1" + + echo ${_defconfig} | \ + sed 's/_defconfig$//' | \ + awk '{print tolower($0)}' +} + +_get_target_destdir() +{ + _defconfig="$1" + + _target_name="$(_get_target_name ${_defconfig})" + + echo "build/uboot4extlinux-${_target_name}" +} + +_build_uboot_target() +{ + _defconfig="$1" + + _destdir="$(_get_target_destdir ${_defconfig})" + _target_name="$(_get_target_name ${_defconfig})" + + unset CFLAGS CXXFLAGS LDFLAGS + + make "ARCH=${ARCH}" distclean + make "ARCH=${ARCH}" ${_defconfig} + + echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config + + if [ "$CARCH" = "armv7h" ]; then + make "ARCH=${ARCH}" EXTRAVERSION=-${pkgrel} + else + make "ARCH=${ARCH}" "CROSS_COMPILE=${CROSS_COMPILE}" \ + EXTRAVERSION=-${pkgrel} + fi + + echo "==> Installing ${_target_name} to ${_destdir}" + install -d ${_destdir} + mv -f -boot.imx "${_destdir}" + +} + +build() +{ cd u-boot-${pkgver} - # TBS2910 patches - patch -Np1 -i ../0001-board-tbs2910-disable-loadb-and-loads-commands.patch - patch -Np1 -i ../0002-board-tbs2910-disable-CONFIG_GZIP.patch - patch -Np1 -i ../0003-board-tbs2910-move-CONFIG_BOOTCOMMAND-from-header-to.patch - patch -Np1 -i ../0004-board-tbs2910_defconfig-Add-support-for-booting-gene.patch - patch -Np1 -i ../0005-board-tbs2910-Enable-distro_boot-support.patch - patch -Np1 -i ../0006-board-tbs2910-add-documentation.patch + _target_nr=0 + for _defconfig in ${_defconfigs[@]}; do + _target_nr=$(expr ${_target_nr} + 1) + _target_name="$(_get_target_name ${_defconfig})" + + echo "==> Building ${_target_name} " \ + "[${_target_nr} of ${_nr_targets} targets]" + + _build_uboot_target "${_defconfig}" + done +} + +_check_uboot_target() +{ + _defconfig="$1" + + _image="$(_get_target_destdir ${_defconfig})/u-boot.img" + _image_size="$(du --bytes --apparent-size ${_image} | awk '{print $1}')" + _offset="${u_boot_with_spl_offset}" + + _image_end=$(expr ${_image_size} + ${_offset}) + + # This test comes from install-uboot4extlinux.sh.in + if [ ${_image_end} -gt $(expr 1024 \* 1024) ] ; then + echo "Error: ${_image} is too big:" + echo " offset: ${_offset}" + echo " size: ${_image_size}" + echo " By default, "\ + "partitioing tools makes the first partition start at 1MiB" + echo " Instaling ${_image} "\ + "would overwrite that first partition (if it's present)." + + false # Fail the test + fi } -build() { +check() +{ cd u-boot-${pkgver} - unset CFLAGS CXXFLAGS LDFLAGS + _target_nr=0 + for _defconfig in ${_defconfigs[@]}; do + _target_nr=$(expr ${_target_nr} + 1) + _target_name="$(_get_target_name ${_defconfig})" - for i in ${boards[@]}; do - mkdir -p ../bin_${i} - make distclean - make ${i}_defconfig - echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config - make EXTRAVERSION=-${pkgrel} - mv -f u-boot.imx ../bin_${i} + echo "==> Testing target ${_target_name} " \ + "[${_target_nr} of ${_nr_targets} targets]" + _check_uboot_target "${_defconfig}" done + } -package_uboot4extlinux-tbs2910() { - pkgdesc="U-Boot with Extlinux support for the TBS2910 Matrix ARM mini PC" - install=tbs2910.install - provides=('uboot4extlinux-imx') +_make_uboot_package() +{ + _pkgname="$1" + + if [ -n "${pkgdir}" ] ; then + cd "u-boot-${pkgver}" + + # Install the u-boot binary + install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/" + install -Dm644 "build/${_pkgname}/u-boot.imx" \ + "${pkgdir}/usr/lib/u-boot/${_pkgname}" + + # Install the u-boot installation script + sed < "${srcdir}/install-uboot4extlinux.sh.in" > \ + "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" \ + -e "s|@u_boot_with_spl[@]|/usr/lib/u-boot/${_pkgname}/u-boot.imx|g" \ + -e "s|@u_boot_with_spl_offset[@]|${u_boot_with_spl_offset}|g" + + chmod +x \ + "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" + + # Install what is required for the pacman hook + install -d "${pkgdir}/usr/share/libalpm/hooks/" + sed < "${srcdir}/${pkgbase}.hook.in" > \ + "${pkgdir}/usr/share/libalpm/hooks/${_pkgname}.hook" \ + -e "s|@pkgname[@]|${_pkgname}|g" + + install -d "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/" + # If we install several uboot4extlinux, we need a way to clearly + # separate each postinstall message. To do that we wrapped the + # text in an ASCII art square, but doing that is complicated when + # using sed as the package name as well as the installation script + # path both have variable length. + sh "${srcdir}/generate-${pkgbase}-install-text.sh" \ + "${_pkgname}" \ + "${pkgbase}" \ + "/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" > \ + "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/install-uboot4extlinux.txt" + fi +} + +_make_pkgdesc() +{ + board_name="$1" + echo "U-Boot with Extlinux support for ${board_name}" +} + +package_uboot4extlinux-imx() +{ + pkgdesc="Scripts for managing U-Boot installations for computers with Allwinner System On a Chip" + + depends=('uboot-tools') + + # Users are expected to use this as a base for /boot/extlinux/extlinux.conf + install -d "${pkgdir}/usr/lib/u-boot/${pkgname}/" + install -Dm644 \ + "${srcdir}/extlinux.conf" \ + "${pkgdir}/usr/lib/u-boot/${pkgname}/" +} - install -d "${pkgdir}"/boot/extlinux - install -d "${pkgdir}"/boot/u-boot/images/ - install -Dm644 bin_tbs2910/u-boot.imx "${pkgdir}"/boot/u-boot/images/ +package_uboot4extlinux-tbs2910() +{ + pkgdesc=$(_make_pkgdesc "TBS2910 Matrix ARM mini PC") - install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux + # util-linux is needed for blkid for install-uboot4extlinux.sh + depends=("${pkgbase}" 'util-linux') - # Package documentation as well - install -d "${pkgdir}"/usr/share/doc/u-boot - install -Dm644 u-boot-${pkgver}/doc/board/tbs/tbs2910.rst "${pkgdir}"/usr/share/doc/u-boot + _make_uboot_package "${pkgname}" } |