Add TF-A and u-boot for rockpro64-rk3399

This commit is contained in:
Alex D. 2022-01-11 20:09:24 +00:00
parent 1569e6132e
commit e086c1357a
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
8 changed files with 467 additions and 0 deletions

View File

@ -0,0 +1,43 @@
# Contributor: Milan P. Stanić <mps@arvanta.net>
# Contributor: Maxim Karasev <begs@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=arm-trusted-firmware
pkgver=2.5
pkgrel=4
pkgdesc="ARM Trusted Firmware-A (TF-A)"
url="https://github.com/ARM-software/arm-trusted-firmware"
arch="aarch64"
license="BSD-3-Clause"
makedepends="dtc openssl1.1-compat-dev gcc-arm-none-eabi"
source="https://github.com/ARM-software/arm-trusted-firmware/archive/v$pkgver/arm-trusted-firmware-v$pkgver.tar.gz
rk3399-baudrate.patch"
options="!check" # No tests
_plats="sun50i_a64 sun50i_h6 rk3399"
build() {
unset LDFLAGS
for plat in $_plats; do
make PLAT=$plat bl31
done
}
package() {
for plat in $_plats; do
case $plat in
rk3399)
install -D "$builddir"/build/$plat/release/bl31/bl31.elf \
"$pkgdir"/usr/share/$pkgname/$plat/bl31.elf
;;
*)
install -D "$builddir"/build/$plat/release/bl31.bin \
"$pkgdir"/usr/share/$pkgname/$plat/bl31.bin
;;
esac
done
}
sha512sums="
3c99f1d849c3c536e8e2e4838ee48a1a431f0bef35eaf27eb14f9caebde71a577589b10efbbd7db49bed3b9763bed46583d0b26e72f61fcd0d34cc46ff684846 arm-trusted-firmware-v2.5.tar.gz
86d8c60157145ab05e9b870aad11d2acaf2137ba00bf71419f8a54a4fd2b1906c19bc8bfeccc735344d1dcf11ba81bd9396bfd8854cdb972a72503b632d1e900 rk3399-baudrate.patch
"

View File

@ -0,0 +1,23 @@
From b3fc3a853b8357afd3a010a765072d27f640f5e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <andrius@stikonas.eu>
Date: Sat, 14 Sep 2019 11:09:01 +0100
Subject: [PATCH] Increase BAUD_RATE to 1500000, so that it matches U-Boot and
kernel.
---
plat/rockchip/rk3399/rk3399_def.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plat/rockchip/rk3399/rk3399_def.h b/plat/rockchip/rk3399/rk3399_def.h
index ba83242e..8d6ecfbe 100644
--- a/plat/rockchip/rk3399/rk3399_def.h
+++ b/plat/rockchip/rk3399/rk3399_def.h
@@ -17,7 +17,7 @@
/**************************************************************************
* UART related constants
**************************************************************************/
-#define RK3399_BAUDRATE 115200
+#define RK3399_BAUDRATE 1500000
#define RK3399_UART_CLOCK 24000000
/******************************************************************************

View File

@ -0,0 +1,24 @@
The new u-boot releases bring up HDMI and USB and it causes the kernel or u-boot to hang
on most boot tries. USE_PREBOOT is disabled so USB won't be brought up which causes an hang
after 2020.10 and HDMI being on confuses Linux enough to break everything.
diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
index ae11a8f5eb..aa8f55639c 100644
--- a/configs/rockpro64-rk3399_defconfig
+++ b/configs/rockpro64-rk3399_defconfig
@@ -12,7 +12,7 @@ CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y
CONFIG_DEBUG_UART=y
-CONFIG_USE_PREBOOT=y
+CONFIG_USE_PREBOOT=n
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_MISC_INIT_R=y
@@ -81,6 +81,6 @@ CONFIG_USB_ETHER_SMSC95XX=y
CONFIG_DM_VIDEO=y
CONFIG_DISPLAY=y
CONFIG_VIDEO_ROCKCHIP=y
-CONFIG_DISPLAY_ROCKCHIP_HDMI=y
+CONFIG_DISPLAY_ROCKCHIP_HDMI=n
CONFIG_SPL_TINY_MEMSET=y
CONFIG_ERRNO_STR=y

View File

@ -0,0 +1,11 @@
--- a/configs/rockpro64-rk3399_defconfig
+++ b/configs/rockpro64-rk3399_defconfig
@@ -60,7 +60,7 @@
CONFIG_DM_RESET=y
CONFIG_DM_RNG=y
CONFIG_RNG_ROCKCHIP=y
-CONFIG_BAUDRATE=1500000
+CONFIG_BAUDRATE=115200
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_ROCKCHIP_SPI=y
CONFIG_SYSRESET=y

188
main/u-boot/APKBUILD Normal file
View File

@ -0,0 +1,188 @@
# Contributor: He Yangxuan <yangxuan8282@gmail.com>
# Contributor: Timo Teras <timo.teras@iki.fi>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=u-boot
pkgver=2021.10
pkgrel=6
pkgdesc="u-boot bootloader common files"
url="https://www.denx.de/wiki/U-Boot/"
arch="all !s390x !ppc64le"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="$depends_dev bc dtc python3-dev swig bison flex
openssl1.1-compat-dev py3-setuptools linux-headers"
if [ "$CARCH" = "aarch64" ]; then
makedepends="$makedepends arm-trusted-firmware"
fi
source="https://ftp.denx.de/pub/u-boot/u-boot-${pkgver//_/-}.tar.bz2
README.txt
update-u-boot
hifive-unmatched-ramdisk.patch
"
builddir="$srcdir"/u-boot-${pkgver//_/-}
if [ "$CARCH" = "riscv64" ]; then
makedepends="$makedepends opensbi"
export OPENSBI=/usr/share/opensbi/generic/firmware/fw_dynamic.bin
fi
# secfixes:
# 2021.04-r0:
# - CVE-2021-27097
# - CVE-2021-27138
case "$CARCH" in
arm*) board_configs="
beagleboard:am335x_boneblack_vboot
cubieboard:Cubieboard,Cubieboard2
leemaker:Bananapi,Lamobo_R1
linksprite:Linksprite_pcDuino3_Nano
cuboxi:mx6cuboxi
raspberrypi:rpi_0_w,rpi,rpi_2,rpi_3_32b
wandboard:wandboard
qemu:qemu_arm
odroid:odroid-xu3
";;
aarch64) board_configs="
thunderx:thunderx_88xx
raspberrypi:rpi_3
odroid:odroid-c2,odroid-n2
libretech:libretech-cc
rockchip:rockpro64-rk3399
qemu:qemu_arm64
sunxi:pine64-lts,pinebook,orangepi_3,teres_i,a64-olinuxino,a64-olinuxino-emmc,nanopi_neo2
";;
riscv64) board_configs="
qemu:qemu-riscv64
unleashed:sifive_unleashed
unmatched:sifive_unmatched
";;
esac
_allboards=""
for board_config in $board_configs; do
_allboards="$_allboards $pkgname-${board_config%%:*}"
done
subpackages="$_allboards $pkgname-tools"
case "$CARCH" in
arm*|aarch64|riscv64) subpackages="$pkgname-all:_all $_allboards $pkgname-tools";;
esac
build() {
cd "$builddir"
touch include/config.h
LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h
local board_config board
for board_config in $board_configs; do
local configs="${board_config#*:}"
for board in ${configs//,/ }; do
msg "Building u-boot for $board"
case "$board" in
"pine64-lts"|"pinebook"|"teres_i"|"a64-olinuxino"|"a64-olinuxino-emmc")
export BL31="/usr/share/arm-trusted-firmware/sun50i_a64/bl31.bin";;
"orangepi_3")
export BL31="/usr/share/arm-trusted-firmware/sun50i_h6/bl31.bin";;
"rockpro64-rk3399")
export BL31="/usr/share/arm-trusted-firmware/rk3399/bl31.elf";;
esac
export BUILD_DIR="$builddir"/build/$board
mkdir -p "$BUILD_DIR"
make O="$BUILD_DIR" ${board}_config || return 1
make O="$BUILD_DIR" all || return 1
done
done
msg "Building u-boot-tools"
make tools-only_defconfig
make tools-all
}
package() {
case "$CARCH" in
mips64|x86*) return;;
esac
cd "$builddir"/build
mkdir -p "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/sbin
install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt || return 1
install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin || return 1
}
tools() {
pkgdesc="u-boot bootloader utility tools"
provides="uboot-tools"
replaces="uboot-tools"
mkdir -p $pkgdir
mkdir $subpkgdir
cd "$builddir"
for tool in bmp_logo dumpimage env/fw_printenv \
fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr img2srec \
mkenvimage mkimage ncb proftool ubsha1 xway-swap-bytes; do
install -D tools/$tool \
$subpkgdir/usr/bin/$(basename $tool)
done
install -Dm644 tools/env/fw_env.config \
"${subpkgdir}/usr/share/doc/${pkgname}/examples/fw_env.config"
cd "$subpkgdir"/usr/bin
ln -sf fw_printenv fw_setenv
}
_all() {
pkgdesc="u-boot for all boards (meta package)"
depends="$_allboards"
mkdir -p "$subpkgdir"/
}
_split_boards() {
cd "$builddir"/build
pkgdesc="u-boot for $1"
depends="u-boot"
shift
local board
for board; do
msg "Including board $board"
mkdir -p "$subpkgdir"/usr/share/$pkgname/$board
export BUILD_DIR="$builddir"/build/$board
local board_images=""
case "$board" in
"sifive_unleashed"|"sifive_unmatched")
board_images="u-boot.itb spl/u-boot-spl.bin --" ;;
"pine64-lts"|"pinebook"|"teres_i"|"a64-olinuxino"|"a64-olinuxino-emmc"|"orangepi_3")
board_images="u-boot-sunxi-with-spl.bin --" ;;
"rockpro64-rk3399")
board_images="tpl/u-boot-tpl.bin spl/u-boot-spl.bin u-boot.itb --" ;;
esac
local ok=no
for image in $board_images -- MLO SPL u-boot.img -- u-boot.bin; do
if [ "$image" = "--" ]; then
[ "$ok" = yes ] && break
continue
fi
if [ -e "$BUILD_DIR"/$image ]; then
cp "$BUILD_DIR"/$image "$subpkgdir"/usr/share/$pkgname/$board \
|| return 1
ok=yes
fi
done
[ "$ok" = yes ] || return 1
done
}
for board_config in $board_configs; do
_board="${board_config%%:*}"
_configs="${board_config#*:}"
eval "${_board}() { _split_boards $_board ${_configs//,/ }; }"
done
sha512sums="
be5be1c9a54b270307a04177d5577a21c57a02b307bf8b63d0fa2655d1f025c7ce010dca6a1f7f60d4e639c2e6fb6f0a292a2e5d190f1fad478eb12dd786c9da u-boot-2021.10.tar.bz2
f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1 README.txt
b5b5960a70c0edab38c208e5a41f2130c673334e05ef77dd4c839d59365d4243590a79bf3865914397b600550f4d0f69f8145e51a7ef05aa0190420fcc7ff02d update-u-boot
1e8c95a37e7efb74f6519f66da44a0050417066aa2bd6d38e8a7e7135f501a9578dcc3701f66a170bf4cbd5c17b87d69ff80760979b1aa31d26e75be7cf7b97f hifive-unmatched-ramdisk.patch
"

32
main/u-boot/README.txt Normal file
View File

@ -0,0 +1,32 @@
WandBoard
---------
- ROM loads boot loader from raw MMC sectors at fixed address
- NOTE: 1st partition needs to start after boot loader
- Install u-boot with:
dd if=wandboard/SPL of=/dev/mmcblk0 bs=1k seek=1
dd if=wandboard/u-boot.img of=/dev/mmcblk0 bs=1k seek=69
sync
(Note - the SD card node may vary, so adjust this as needed).
- Insert the SD card into the slot located in the bottom of the board
(same side as the mx6 processor)
BeagleBoard
-----------
- ROM looks for 1st partition with FAT, and loads MLO from it
- NOTE: MLO needs to be the first file created on this partition
- Install u-boot with:
cp am335x_boneblack/{MLO,u-boot.img} /media/mmcblk0p1/
Sunxi (Cubie* etc)
------------------
- ROM loads boot loader from SD-CARD sectors at fixed address
- Install u-boot with:
sudo dd if=<board>/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8

View File

@ -0,0 +1,19 @@
On the HiFive1 the ramdisk is occasionally loaded to the wrong address
range, causing boot to hang during ramdisk loading. This patch fixes
this occasionally occurring issue.
See https://lists.denx.de/pipermail/u-boot/2021-October/463798.html for
details. As per https://lists.denx.de/pipermail/u-boot/2021-October/463844.html
this patch should no longer be needed as soon as v2022.01 is released.
diff -upr u-boot-2021.10.orig/include/configs/sifive-unmatched.h u-boot-2021.10/include/configs/sifive-unmatched.h
--- u-boot-2021.10.orig/include/configs/sifive-unmatched.h 2021-10-15 19:07:43.123472870 +0200
+++ u-boot-2021.10/include/configs/sifive-unmatched.h 2021-10-15 19:08:27.357420781 +0200
@@ -25,6 +25,7 @@
#endif
+#define CONFIG_SYS_BOOTMAPSZ (256 << 20)
#define CONFIG_SYS_SDRAM_BASE 0x80000000
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)

127
main/u-boot/update-u-boot Executable file
View File

@ -0,0 +1,127 @@
#!/bin/sh
verbose=
board=
device=
dryrun=
imagedir=
get_defaults() {
if [ -z "$board" -a -e /sys/firmware/devicetree/base/compatible ]; then
case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in
wand,*) board=wand ;;
esac
fi
if [ -z "$device" ]; then
case "$board" in
wand|cubie|cubie2) device=/dev/mmcblk0p0 ;;
mx6cuboxi) device=/dev/mmcblk0 ;;
esac
fi
if [ -z "$imagedir" ]; then
imagedir="$(realpath $(dirname $0))"
[ -f "$imagedir/README.txt" ] || imagedir="/usr/share/u-boot"
fi
}
die() {
echo "ERROR: $@"
exit 1
}
usage() {
get_defaults
cat <<EOF
usage: $0 [-b|--board <board-type>] [-d|--device <device>]
options:
-b,--board <board> Specify the board type: wand, cubie, cubie2, cuboxi, pine64-lts, etc.
(current default: ${board:-none})
-d,--device <device> Specify the device where to install u-boot
(current default: ${device:-none})
-i,--imagedir <imagedir> Specify u-boot image directory
(current default: ${imagedir:-none})
-n,--dry-run Print commands but don't execute them
EOF
}
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
-b|--board)
case "$1" in
wand|wandboard) board="wand" ;;
cubie|cubieboard) board="cubie" ;;
cuboxi|mx6cuboxi) board="mx6cuboxi" ;;
pine64-lts|pinebook|orangepi_3|teres_i|a64-olinuxino|a64-olinuxino-emmc|nanopi_neo2) board="$1" ;;
*) usage; exit 1;;
esac
shift
;;
-d|--device)
device="$1"
shift
;;
-i|--imagedir)
imagedir="$1"
shift
;;
-n|--dry-run)
dryrun="echo"
;;
--)
break
;;
-*)
usage
exit 1
;;
esac
done
get_defaults
if [ -z "$board" -o -z "$device" -o -z "$imagedir" -o ! -e "$imagedir" ]; then
usage
exit 1
fi
if [ -z "$dryrun" ]; then
echo "Updating $board u-boot in $device in 3 seconds..."
sleep 3
fi
(
set -e
case "$board" in
wand)
[ -e "$imagedir/wandboard" ] || die "wandboard images not installed, apk add u-boot-wandboard"
$dryrun dd if=$imagedir/wandboard/SPL of=$device bs=1k seek=1 status=none
$dryrun dd if=$imagedir/wandboard/u-boot.img of=$device bs=1k seek=69 status=none
;;
cubie|cubie2)
[ -e "$imagedir/Cubieboard${board#cubie}" ] || die "Cubieboard images not installed, apk add u-boot-cubieboard"
$dryrun dd if=$imagedir/Cubieboard${board#cubie}/u-boot-sunxi-with-spl.bin of=$device bs=1024 seek=8 status=none
;;
mx6cuboxi)
[ -e "$imagedir/mx6cuboxi" ] || die "iMX6 Cubox-i images not installed, apk add u-boot-cuboxi"
$dryrun dd if=$imagedir/mx6cuboxi/SPL of=$device bs=1k seek=1 status=none
$dryrun dd if=$imagedir/mx6cuboxi/u-boot.img of=$device bs=1k seek=69 status=none
;;
pine64-lts|pinebook|orangepi_3|teres_i|a64-olinuxino|a64-olinuxino-emmc|nanopi_neo2)
[ -e "$imagedir/$board" ] || die "sunxi images not installed, apk add u-boot-sunxi"
$dryrun dd if=$imagedir/$board/u-boot-sunxi-with-spl.bin of=$device bs=1k seek=8 status=none
;;
esac
$dryrun sync
) || die "U-Boot installation in $device failed"
[ -z "$dryrun" ] && echo "Completed successfully."