Prepare rockchip64 for switch to mainline u-boot and switched ROCK Pi 4 (#1934)

This commit is contained in:
Piotr Szczepanik 2020-05-03 19:15:46 +02:00 committed by GitHub
parent bbaddc8aaa
commit 5a2b2c360b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 136 additions and 204 deletions

View File

@ -1,6 +1,6 @@
# RK3399 hexa core 1-4GB SoC GBe eMMC USB3
BOARD_NAME="RockPi-4A"
BOARDFAMILY="rockchip64"
BOOTCONFIG="rockpi4b-rk3399_defconfig"
BOOTCONFIG="rock-pi-4-rk3399_defconfig"
KERNEL_TARGET="legacy,current,dev"
FULL_DESKTOP="yes"

View File

@ -1,6 +1,6 @@
# RK3399 hexa core 1-4GB SoC GBe eMMC USB3 WiFi/BT
BOARD_NAME="RockPi-4B"
BOARDFAMILY="rockchip64"
BOOTCONFIG="rockpi4b-rk3399_defconfig"
BOOTCONFIG="rock-pi-4-rk3399_defconfig"
KERNEL_TARGET="legacy,current,dev"
FULL_DESKTOP="yes"

View File

@ -7,24 +7,28 @@ UBOOT_TARGET_MAP=";;idbloader.bin uboot.img trust.bin"
BOOTDELAY=0
OVERLAY_PREFIX='rockchip'
SERIALCON=${SERIALCON:-'ttyFIQ0:1500000'}
ATFSOURCE='https://github.com/ayufan-rock64/arm-trusted-firmware'
ATF_TARGET_MAP='M0_CROSS_COMPILE=arm-linux-gnueabi- PLAT=rk3399 DEBUG=1 bl31;;trust.bin'
ATF_TOOLCHAIN2="arm-linux-gnueabi-:> 5.0"
ATFDIR='arm-trusted-firmware-rockchip64'
ATFBRANCH='branch:rockchip'
ATF_USE_GCC='> 6.3'
GOVERNOR="ondemand"
CPUMAX="2016000"
CPUMIN="600000"
RKBIN_DIR="$SRC/cache/sources/rkbin-tools"
if [[ $BOOTCONFIG == *3328* ]]; then
ATF_TARGET_MAP='PLAT=rk322xh DEBUG=1 bl31;;trust.bin'
BOOT_RK3328_USE_AYUFAN_ATF=yes
CPUMAX="1390000"
elif [[ $BOARD == rockpro64 ]] || [[ $BOARD == rockpi-4* ]] || [[ $BOARD == pinebook-pro ]]; then
elif [[ $BOARD == rockpi-4* ]]; then
UBOOT_TARGET_MAP="BL31=$SRC/cache/sources/rkbin-tools/rk33/rk3399_bl31_v1.17.elf u-boot-dtb.bin spl/u-boot-spl.bin u-boot.itb;;spl/u-boot-spl.bin u-boot.itb"
BOOT_USE_BLOBS=yes
DDR_BLOB='rk33/rk3399_ddr_933MHz_v1.24.bin'
MINILOADER_BLOB='rk33/rk3399_miniloader_v1.19.bin'
BL31_BLOB='rk33/rk3399_bl31_v1.30.elf'
elif [[ $BOARD == rockpro64 ]] || [[ $BOARD == pinebook-pro ]]; then
BOOT_RK3399_LEGACY_HYBRID=yes
BL31_BLOB='rk33/rk3399_bl31_v1.17.elf'
elif [[ $BOARD == rockpi-s ]]; then
@ -59,18 +63,131 @@ case $BRANCH in
esac
prepare_boot_configuration()
{
if [[ $BOOT_USE_MAINLINE_ATF == yes ]]; then
UBOOT_TARGET_MAP="BL31=bl31.bin idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware'
ATFDIR='arm-trusted-firmware'
ATFBRANCH='tag:v2.2'
ATF_USE_GCC='> 6.3'
ATF_TARGET_MAP='M0_CROSS_COMPILE=arm-linux-gnueabi- PLAT=rk3399 bl31;;build/rk3399/release/bl31/bl31.elf:bl31.bin'
ATF_TOOLCHAIN2="arm-linux-gnueabi-:> 5.0"
elif [[ $BOOT_USE_TPL_SPL_BLOB == yes ]]; then
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE=''
ATF_COMPILE='no'
elif [[ $BOOT_USE_BLOBS == yes ]]; then
UBOOT_TARGET_MAP="u-boot-dtb.bin;;idbloader.bin uboot.img trust.bin"
ATFSOURCE=''
ATF_COMPILE='no'
elif [[ $BOOT_RK3399_LEGACY_HYBRID == yes ]]; then # to be removed
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB u-boot-dtb.bin spl/u-boot-spl.bin u-boot.itb;;spl/u-boot-spl.bin u-boot.itb"
ATFSOURCE=''
ATF_COMPILE='no'
legacy_uboot_locations
elif [[ $BOOT_RK3328_USE_AYUFAN_ATF == yes ]]; then # to be removed
UBOOT_TARGET_MAP=";;idbloader.bin uboot.img trust.bin"
ATFSOURCE='https://github.com/ayufan-rock64/arm-trusted-firmware'
ATFDIR='arm-trusted-firmware-rockchip64'
ATFBRANCH='branch:rockchip'
ATF_USE_GCC='> 6.3'
ATF_TARGET_MAP='PLAT=rk322xh DEBUG=1 bl31;;trust.bin'
ATF_TOOLCHAIN2="arm-linux-gnueabi-:> 5.0"
legacy_uboot_locations
fi
}
legacy_uboot_locations()
{
BOOTSOURCE='https://github.com/ayufan-rock64/linux-u-boot'
BOOTDIR='u-boot-rockchip64'
BOOTBRANCH='branch:rockchip-master'
case $BRANCH in
legacy)
BOOTPATCHDIR="u-boot-rockchip64"
;;
*)
BOOTPATCHDIR="u-boot-rockchip64-dev"
;;
esac
}
uboot_custom_postprocess()
{
if [[ $BOOT_USE_MAINLINE_ATF == yes || $BOOT_USE_TPL_SPL_BLOB == yes ]]; then
:
elif [[ $BOOT_USE_BLOBS == yes ]]; then
local tempfile=$(mktemp)
tools/mkimage -n $BOOT_SOC -T rksd -d $RKBIN_DIR/$DDR_BLOB idbloader.bin
cat $RKBIN_DIR/$MINILOADER_BLOB >> idbloader.bin
loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
trust_merger --replace ./build/rk3399/debug/bl31/bl31.elf $RKBIN_DIR/$BL31_BLOB trust.ini
elif [[ $BOOT_RK3399_LEGACY_HYBRID == yes ]]; then
# 3399
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rksd_loader.img
cat spl/u-boot-spl.bin >> rksd_loader.img
dd if=u-boot.itb of=rksd_loader.img seek=448 conv=notrunc
cp rksd_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rkspi_loader.img
cat spl/u-boot-spl.bin >> rkspi_loader.img
for i in `seq 1 128`; do dd count=4 status=none; dd if=/dev/zero count=4 status=none; done < rkspi_loader.img > rkspi_loader.tmp
mv rkspi_loader.tmp rkspi_loader.img
dd if=u-boot.itb of=rkspi_loader.img seek=1024 conv=notrunc
cp rkspi_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
elif [[ $BOOT_RK3328_USE_AYUFAN_ATF == yes ]]; then
# 3328
tools/mkimage -n rk3328 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3328_ddr_786MHz_v1.13.bin idbloader.bin
cat $SRC/cache/sources/rkbin-tools/rk33/rk3328_miniloader_v2.46.bin >> idbloader.bin
loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
else
echo "Unsupported u-boot processing configuration!"
exit 1
fi
}
write_uboot_platform()
{
if [[ -f $1/rksd_loader.img ]]; then # legacy rk3399 loader
if [[ -f $1/rksd_loader.img ]] ; then
dd if=$1/rksd_loader.img of=$2 seek=64 conv=notrunc status=none >/dev/null 2>&1
else
elif [[ -f $1/u-boot.itb ]]; then # $BOOT_USE_MAINLINE_ATF == yes || $BOOT_USE_TPL_SPL_BLOB == yes
dd if=$1/idbloader.img of=$2 seek=64 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/u-boot.itb of=$2 seek=16384 conv=notrunc status=none >/dev/null 2>&1
elif [[ -f $1/uboot.img ]]; then # $BOOT_USE_BLOBS == yes
dd if=$1/idbloader.bin of=$2 seek=64 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/uboot.img of=$2 seek=16384 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/trust.bin of=$2 seek=24576 conv=notrunc status=none >/dev/null 2>&1
fi
else
echo "Unsupported u-boot processing configuration!"
exit 1
fi
}

View File

@ -1,6 +1,7 @@
source "${BASH_SOURCE%/*}/include/rockchip64_common.inc"
BOOTPATCHDIR="u-boot-rk3399"
BOOTPATCHDIR="u-boot-rockchip64-mainline"
BOOT_SOC="rk3399"
case $BRANCH in
@ -15,17 +16,10 @@ case $BRANCH in
esac
RKBIN_DIR="$SRC/cache/sources/rkbin-tools"
if [[ $BOARD == roc-rk3399-pc ]]; then
BOOT_USE_MAINLINE_ATF=yes
elif [[ $BOARD == rockpi-4* ]]; then
BOOT_USE_TPL_SPL_BLOB=yes
BL31_BLOB='rk33/rk3399_bl31_v1.30.elf'
elif [[ $BOARD == nanopim4v2 || $BOARD == orangepi4 ]]; then
BOOT_USE_BLOBS=yes
@ -42,70 +36,7 @@ else
fi
if [[ $BOOT_USE_MAINLINE_ATF == yes ]]; then
UBOOT_TARGET_MAP="BL31=bl31.bin idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware'
ATFDIR='arm-trusted-firmware'
ATFBRANCH='tag:v2.2'
ATF_USE_GCC='> 6.3'
ATF_TARGET_MAP='M0_CROSS_COMPILE=arm-linux-gnueabi- PLAT=rk3399 bl31;;build/rk3399/release/bl31/bl31.elf:bl31.bin'
ATF_TOOLCHAIN2="arm-linux-gnueabi-:> 5.0"
elif [[ $BOOT_USE_TPL_SPL_BLOB == yes ]]; then
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE=''
ATF_COMPILE='no'
elif [[ $BOOT_USE_BLOBS == yes ]]; then
UBOOT_TARGET_MAP="u-boot-dtb.bin;;idbloader.bin uboot.img trust.bin"
ATFSOURCE=''
ATF_COMPILE='no'
fi
write_uboot_platform()
{
if [[ -f $1/u-boot.itb ]]; then # $BOOT_USE_MAINLINE_ATF == yes || $BOOT_USE_TPL_SPL_BLOB == yes
dd if=$1/idbloader.img of=$2 seek=64 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/u-boot.itb of=$2 seek=16384 conv=notrunc status=none >/dev/null 2>&1
elif [[ -f $1/uboot.img ]]; then # $BOOT_USE_BLOBS == yes
dd if=$1/idbloader.bin of=$2 seek=64 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/uboot.img of=$2 seek=16384 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/trust.bin of=$2 seek=24576 conv=notrunc status=none >/dev/null 2>&1
else
echo "Unsupported u-boot processing configuration!"
exit 1
fi
}
uboot_custom_postprocess()
{
if [[ $BOOT_USE_MAINLINE_ATF == yes || $BOOT_USE_TPL_SPL_BLOB == yes ]]; then
:
elif [[ $BOOT_USE_BLOBS == yes ]]; then
local tempfile=$(mktemp)
tools/mkimage -n rk3399 -T rksd -d $RKBIN_DIR/$DDR_BLOB idbloader.bin
cat $RKBIN_DIR/$MINILOADER_BLOB >> idbloader.bin
loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
trust_merger --replace ./build/rk3399/debug/bl31/bl31.elf $RKBIN_DIR/$BL31_BLOB trust.ini
else
echo "Unsupported u-boot processing configuration!"
exit 1
fi
}
prepare_boot_configuration
atf_custom_postprocess()
{

View File

@ -1,15 +1,11 @@
source "${BASH_SOURCE%/*}/include/rockchip64_common.inc"
BOOTSOURCE='https://github.com/ayufan-rock64/linux-u-boot'
BOOTDIR='u-boot-rockchip64'
BOOTBRANCH='branch:rockchip-master'
BOOTPATCHDIR="u-boot-rockchip64-dev"
BOOTPATCHDIR="u-boot-rockchip64-mainline"
case $BRANCH in
legacy)
BOOTPATCHDIR="u-boot-rockchip64"
KERNELSOURCE='https://github.com/ayufan-rock64/linux-kernel'
KERNELBRANCH='tag:4.4.202-1237-rockchip-ayufan'
KERNELDIR='linux-rockchip64'
@ -19,25 +15,4 @@ case $BRANCH in
esac
uboot_custom_postprocess()
{
# bootloader image
if [[ $BOARD == rockpro64 ]] || [[ $BOARD == rockpi-4* ]] || [[ $BOARD == pinebook-pro ]]; then
# 3399
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rksd_loader.img
cat spl/u-boot-spl.bin >> rksd_loader.img
dd if=u-boot.itb of=rksd_loader.img seek=448 conv=notrunc
cp rksd_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rkspi_loader.img
cat spl/u-boot-spl.bin >> rkspi_loader.img
for i in `seq 1 128`; do dd count=4 status=none; dd if=/dev/zero count=4 status=none; done < rkspi_loader.img > rkspi_loader.tmp
mv rkspi_loader.tmp rkspi_loader.img
dd if=u-boot.itb of=rkspi_loader.img seek=1024 conv=notrunc
cp rkspi_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
else
# 3328
tools/mkimage -n rk3328 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3328_ddr_786MHz_v1.13.bin idbloader.bin
cat $SRC/cache/sources/rkbin-tools/rk33/rk3328_miniloader_v2.46.bin >> idbloader.bin
loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
fi
}
prepare_boot_configuration

View File

@ -1,53 +0,0 @@
From 91bf3be540a2f3f1bc329cd560fc40448903da01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20R=C3=BCger?= <manuel@rueg.eu>
Date: Tue, 25 Jun 2019 10:45:46 +0200
Subject: [PATCH] ayufan: rockpi: Match upstream naming
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 2fdb32a8ce..be19c6fdff 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -57,7 +57,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += \
rk3399-puma-ddr1333.dtb \
rk3399-puma-ddr1600.dtb \
rk3399-puma-ddr1866.dtb \
- rk3399-rockpi4b.dtb \
+ rk3399-rock-pi-4.dtb \
rk3399-rockpro64.dtb \
rv1108-evb.dtb
dtb-$(CONFIG_ARCH_MESON) += \
diff --git a/arch/arm/dts/rk3399-rockpi4b.dts b/arch/arm/dts/rk3399-rock-pi-4.dts
similarity index 99%
rename from arch/arm/dts/rk3399-rockpi4b.dts
rename to arch/arm/dts/rk3399-rock-pi-4.dts
index 5574e9bcec..e860ab7149 100644
--- a/arch/arm/dts/rk3399-rockpi4b.dts
+++ b/arch/arm/dts/rk3399-rock-pi-4.dts
@@ -10,8 +10,8 @@
#include "rk3399.dtsi"
/ {
- model = "RockPi-4B";
- compatible = "radxa,rockpi-4b", "rockchip,rk3399";
+ model = "Radxa ROCK Pi 4";
+ compatible = "radxa,rockpi4", "rockchip,rk3399";
chosen {
stdout-path = &uart2;
diff --git a/configs/rockpi4b-rk3399_defconfig b/configs/rockpi4b-rk3399_defconfig
index 61435d304f..a332654be1 100644
--- a/configs/rockpi4b-rk3399_defconfig
+++ b/configs/rockpi4b-rk3399_defconfig
@@ -9,7 +9,7 @@ CONFIG_TARGET_ROCKPRO64_RK3399=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y
CONFIG_SPL_STACK_R_ADDR=0x600000
-CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpi4b"
+CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock-pi-4"
CONFIG_DEBUG_UART=y
CONFIG_FIT=y
CONFIG_SPL_LOAD_FIT=y
--
2.22.0

View File

@ -1,38 +0,0 @@
diff --git a/arch/arm/dts/rk3399-rockpi4b.dts b/arch/arm/dts/rk3399-rockpi4b.dts
index 5574e9b..d1b50cc 100644
--- a/arch/arm/dts/rk3399-rock-pi-4.dts
+++ b/arch/arm/dts/rk3399-rock-pi-4.dts
@@ -15,6 +15,7 @@
chosen {
stdout-path = &uart2;
+ u-boot,spl-boot-order = &sdmmc, &sdhci;
};
aliases {
diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h
index 1b00ef4..c490a21 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -11,18 +11,18 @@
#ifndef CONFIG_SPL_BUILD
#include <config_distro_defaults.h>
-/* First try to boot from SD (index 0), then eMMC (index 1 */
+/* First try to boot from SD (index 1), then eMMC (index 0) */
#ifdef CONFIG_CMD_USB
#define BOOT_TARGET_DEVICES(func) \
- func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
+ func(MMC, mmc, 0) \
func(USB, usb, 0) \
func(PXE, pxe, na) \
func(DHCP, dchp, na)
#else
#define BOOT_TARGET_DEVICES(func) \
- func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
+ func(MMC, mmc, 0) \
func(PXE, pxe, na) \
func(DHCP, dchp, na)
#endif