diff options
author | Eric Woudstra | 2022-09-06 11:51:49 +0200 |
---|---|---|
committer | Eric Woudstra | 2022-09-06 11:51:49 +0200 |
commit | 7e9167048015424496c01b219e3588ea8cc8dc69 (patch) | |
tree | 4dcb87e8701a253ae6cfe7d4b484fd227be69caa | |
parent | 5463daa698b3a0ff21bbf221dac29c147813fbe2 (diff) | |
download | aur-7e9167048015424496c01b219e3588ea8cc8dc69.tar.gz |
v1.1 of build script, cleaning up packages
-rw-r--r-- | .SRCINFO | 7 | ||||
-rw-r--r-- | 95-atf.hook | 11 | ||||
-rw-r--r-- | PKGBUILD | 47 | ||||
-rw-r--r-- | bpir64-atf-git.install | 4 | ||||
-rwxr-xr-x | bpir64-writefip | 42 | ||||
-rw-r--r-- | incr-fip-decomp-size.patch | 11 |
6 files changed, 103 insertions, 19 deletions
@@ -8,11 +8,18 @@ pkgbase = bpir64-atf-git license = GPL makedepends = git depends = bpir64-mkimage + depends = linux source = bl31-inside-bl2-image.patch source = mmc-high-speed.patch source = move-bl33-base.patch + source = incr-fip-decomp-size.patch source = no-uboot-bl2.patch source = no-uboot-bl31.patch + source = 95-atf.hook + source = bpir64-writefip + sha256sums = SKIP + sha256sums = SKIP + sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP diff --git a/95-atf.hook b/95-atf.hook new file mode 100644 index 000000000000..9be80110560c --- /dev/null +++ b/95-atf.hook @@ -0,0 +1,11 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Target = boot/Image +Target = usr/lib/initcpio/* + +[Action] +Description = Updating fip partition... +When = PostTransaction +Exec = /usr/bin/bpir64-writefip @@ -4,24 +4,29 @@ _gitname="arm-trusted-firmware" _gitroot="https://github.com/mtk-openwrt/${_gitname}" -_gitbranch="mtksoc" +#_gitbranch="mtksoc" # v2.7 DOES NOT REBOOT! +_gitbranch="mtksoc-20210508" pkgname=bpir64-atf-git pkgver=r20210508214220.d2c75b2 pkgrel=1 pkgdesc='ATF bpir64 images including fiptool' url='https://github.com/mtk-openwrt/arm-trusted-firmware.git' arch=(aarch64) -depends=(bpir64-mkimage) -makedepends=(git) +depends=(linux) +makedepends=(git bpir64-mkimage) license=(GPL) source=('bl31-inside-bl2-image.patch' 'mmc-high-speed.patch' 'move-bl33-base.patch' + 'incr-fip-decomp-size.patch' 'no-uboot-bl2.patch' - 'no-uboot-bl31.patch') -sha256sums=(SKIP SKIP SKIP SKIP SKIP) + 'no-uboot-bl31.patch' + '95-atf.hook' + 'bpir64-writefip' +) +sha256sums=(SKIP SKIP SKIP SKIP SKIP SKIP SKIP SKIP) install=${pkgname}.install - + pkgver() { cd "${srcdir}/${_gitname}/" printf "r%s.%s" "$(git show -s --format=%cd --date=format:%Y%m%d%H%M%S HEAD)" "$(git rev-parse --short HEAD)" @@ -34,6 +39,10 @@ _patch () { patch -p1 -N -r - < "${srcdir}/move-bl33-base.patch" patch -p1 -N -r - < "${srcdir}/no-uboot-bl2.patch" patch -p1 -N -r - < "${srcdir}/no-uboot-bl31.patch" + if [ ! -z "$(cat ${srcdir}/${_gitname}/plat/mediatek/mt7622/include/platform_def.h | \ + grep FIP_DECOMP_TEMP_SIZE)" ]; then + patch -p1 -N -r - < "${srcdir}/incr-fip-decomp-size.patch" + fi } prepare() { @@ -63,9 +72,9 @@ build() { sed -i '/-Werror/d' ./Makefile make cd "${srcdir}/${_gitname}" - for _ATFDEVICE in sdmmc emmc; do - _ATFBUILDARGS="PLAT=mt7622 BOOT_DEVICE=$_ATFDEVICE DDR3_FLYBY=1 LOG_LEVEL=40" - sed -i 's/.*entry = get_partition_entry.*/\tentry = get_partition_entry("bpir64-'${_ATFDEVICE}'-fip");/' \ + for _atfdev in sdmmc emmc; do + _ATFBUILDARGS="PLAT=mt7622 BOOT_DEVICE=$_atfdev DDR3_FLYBY=1 LOG_LEVEL=40" + sed -i 's/.*entry = get_partition_entry.*/\tentry = get_partition_entry("bpir64-'${_atfdev}'-fip");/' \ plat/mediatek/mt7622/bl2_boot_mmc.c _makeatf="make $_ATFBUILDARGS USE_MKIMAGE=1 MKIMAGE=$(which bpir64-mkimage) DEVICE_HEADER_OFFSET=0" touch plat/mediatek/mt7622/platform.mk @@ -75,24 +84,24 @@ build() { # 0b0001 : incbin BL31.bin inside of BL2 image, disable it during BL31 build because of common code! $_makeatf PRELOADED_BL33_BASE=0b0000 bl31 $_makeatf PRELOADED_BL33_BASE=0b0001 bl2 ${srcdir}/${_gitname}/build/mt7622/release/bl2.img - dd of=build/mt7622/release/bpir64-atf-${_ATFDEVICE}-header.bin bs=1 count=440 if=build/mt7622/release/bl2.img - dd of=build/mt7622/release/bpir64-atf-${_ATFDEVICE}-atf.bin skip=34 if=build/mt7622/release/bl2.img + dd of=build/mt7622/release/bpir64-atf-${_atfdev}-header.bin bs=1 count=440 if=build/mt7622/release/bl2.img + dd of=build/mt7622/release/bpir64-atf-${_atfdev}-atf.bin skip=34 if=build/mt7622/release/bl2.img done } package() { + cd "${srcdir}" + install -m755 -vDt "$pkgdir/usr/bin" bpir64-writefip + install -Dt "${pkgdir}/usr/share/libalpm/hooks/" -m644 95-atf.hook cd "${srcdir}/${_gitname}/tools/fiptool" - install -m755 -vDt $pkgdir/usr/bin fiptool + install -m755 -vDt "$pkgdir/usr/bin" fiptool cd "${srcdir}/${_gitname}/build/mt7622/release" install -Dt "$pkgdir/boot" -m644 bpir64-atf-*.bin - } # Writing: -# _device="/dev/"$(lsblk -no pkname /dev/disk/by-partlabel/bpir64-${_ATFDEVICE}-atf) -# _atfdev="/dev/disk/by-partlabel/bpir64-${_ATFDEVICE}-atf" +# _device="/dev/"$(lsblk -no pkname /dev/disk/by-partlabel/bpir64-${_atfdev}-atf) +# _atfdev="/dev/disk/by-partlabel/bpir64-${_atfdev}-atf" # echo dd of="$atfdev" if=/dev/zero 2>/dev/null -# echo dd of="${device}" bs=1 if=bpir64-atf-${_ATFDEVICE}-header -# echo dd of="$atfdev" if=bpir64-atf-${_ATFDEVICE}-atf - - +# echo dd of="${device}" bs=1 if=bpir64-atf-${_atfdev}-header +# echo dd of="$atfdev" if=bpir64-atf-${_atfdev}-atf diff --git a/bpir64-atf-git.install b/bpir64-atf-git.install index b123e535f541..89109f407285 100644 --- a/bpir64-atf-git.install +++ b/bpir64-atf-git.install @@ -4,10 +4,14 @@ post_upgrade() { atfdev="/dev/disk/by-partlabel/bpir64-${dev}-atf" if [ -L $atfdev ]; then device="/dev/"$(lsblk -no pkname ${atfdev}) + echo Zeroing: $atfdev dd of="${atfdev}" if=/dev/zero 2>/dev/null + echo Writing HEADER to: $device dd of="${device}" if=/boot/bpir64-atf-${dev}-header.bin + echo Writing ATF to: $atfdev dd of="${atfdev}" if=/boot/bpir64-atf-${dev}-atf.bin fi + bpir64-writefip fi } diff --git a/bpir64-writefip b/bpir64-writefip new file mode 100755 index 000000000000..0667b8f6d835 --- /dev/null +++ b/bpir64-writefip @@ -0,0 +1,42 @@ +#!/bin/bash + +[ ! -d "/boot/bootcfg/" ] && exit +[ ! -d "/boot/dtbos/" ] && exit +fipdev=$(cat /boot/bootcfg/device) +linux=$(cat /boot/bootcfg/linux) +cmdline=$(cat /boot/bootcfg/cmdline) +initrd=$(cat /boot/bootcfg/initrd) +dtb=$(cat /boot/bootcfg/dtb) +tmp="/tmp/bpir64-atf-git" +mkdir -p $tmp +origargs=$(fdtget -ts "/boot/dtbs/${dtb}.dtb" "/chosen" "bootargs") +bootargs="root=PARTLABEL=bpir64-${fipdev}-root $origargs $cmdline" +echo BOOTARGS = "$bootargs" +for bp in /boot/dtbos/*.dts; do + dtc -q -I dts -O dtb -o ${bp/".dts"/".dtbo"} $bp +done +fdtoverlay -vi "/boot/dtbs/${dtb}.dtb" -o "/boot/atf-direct.dtb" /boot/dtbos/*.dtbo +fdtput -ts "/boot/atf-direct.dtb" "/chosen" "bootargs" "$bootargs" +fdtput -ts "/boot/atf-direct.dtb" "/memory" "device_type" "memory" +if [ -f "$initrd" ];then + ins="0x48000000" + ine="0x$(printf '%x\n' $(( 0x48000000 + $(du -b $initrd | cut -f1) )))" + fdtput -tx "/boot/atf-direct.dtb" "/chosen" "linux,initrd-end" "$ine" + fdtput -tx "/boot/atf-direct.dtb" "/chosen" "linux,initrd-start" "$ins" + initrdfile="$initrd" +else + echo -n "" > "$tmp/initrd" + initrdfile="$tmp/initrd" +fi +fiptool --verbose create $tmp/fip.bin \ + --tos-fw-extra2 $initrdfile \ + --nt-fw $linux \ + --nt-fw-config "/boot/atf-direct.dtb" +fiptool info $tmp/fip.bin +fipdev="/dev/disk/by-partlabel/bpir64-${fipdev}-fip" +[ ! -L $fipdev ] && exit 0 +echo Writing FIP to: $fipdev +dd of=$fipdev if=/dev/zero 2>/dev/null +dd of=$fipdev if=$tmp/fip.bin + +exit 0 diff --git a/incr-fip-decomp-size.patch b/incr-fip-decomp-size.patch new file mode 100644 index 000000000000..dbe0e56397e5 --- /dev/null +++ b/incr-fip-decomp-size.patch @@ -0,0 +1,11 @@ +--- ./plat/mediatek/mt7622/include/platform_def.h 2022-09-04 20:28:39.561486535 +0200 ++++ ./plat/mediatek/mt7622/include/platform_def.h 2022-08-26 21:06:11.192153274 +0200 +@@ -104,7 +104,7 @@ + * FIP decompression specific defines. + ******************************************************************************/ + #define FIP_DECOMP_TEMP_BASE (0x42000000) +-#define FIP_DECOMP_TEMP_SIZE (0x400000) ++#define FIP_DECOMP_TEMP_SIZE (0x4000000) + + /******************************************************************************* + * Platform specific page table and MMU setup constants |