Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rockchip: add initial support for RK356x and RK3588 #7864

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/arch.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
fi

# TARGET_CPU:
# generic cortex-a35 cortex-a53 cortex-a57 cortex-a72 cortex-a76
# exynos-m1 qdf24xx thunderx xgene1 cortex-a57.cortex-a53
# cortex-a72.cortex-a53
# generic cortex-a35 cortex-a53 cortex-a55 cortex-a57 cortex-a72
# cortex-a76 exynos-m1 qdf24xx thunderx xgene1 cortex-a57.cortex-a53
# cortex-a72.cortex-a53 cortex-a76.cortex-a55

# determine architecture's family
case $TARGET_CPU in
generic|cortex-a35|cortex-a53|cortex-a57|cortex-a72|exynos-m1|qdf24xx|thunderx|xgene1|cortex-a57.cortex-a53|cortex-a72.cortex-a53|cortex-a73.cortex-a53)
TARGET_SUBARCH=aarch64
TARGET_VARIANT=armv8-a
;;
cortex-a76)
cortex-a55|cortex-a76|cortex-a76.cortex-a55)
TARGET_SUBARCH=aarch64
TARGET_VARIANT=armv8.2-a
;;
Expand Down
6 changes: 6 additions & 0 deletions config/arch.arm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
TARGET_FEATURES+=" neon"
;;
cortex-a55|cortex-a76|cortex-a76.cortex-a55)
TARGET_SUBARCH=armv8.2-a
TARGET_ABI=eabi
TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
TARGET_FEATURES+=" neon"
;;
esac

if [ "${TARGET_FLOAT}" = "hard" ]; then
Expand Down
49 changes: 47 additions & 2 deletions packages/tools/rkbin/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)

PKG_NAME="rkbin"
PKG_VERSION="b0c100f1a260d807df450019774993c761beb79d"
PKG_SHA256="c6ebf8ab556e071e3b067540e95aecff650143f0c97e129cd40c837a4f11a881"
PKG_VERSION="7c35e21a8529b3758d1f051d1a5dc62aae934b2b"
PKG_SHA256="18bde6ce71df308197db0e1d95fd73a19b6a32f4f0b6f5567333ef3c5b617452"
PKG_ARCH="arm aarch64"
PKG_LICENSE="nonfree"
PKG_SITE="https://github.com/rockchip-linux/rkbin"
PKG_URL="https://github.com/rockchip-linux/rkbin/archive/${PKG_VERSION}.tar.gz"
PKG_LONGDESC="rkbin: Rockchip Firmware and Tool Binaries"
PKG_TOOLCHAIN="manual"
PKG_STAMP="$UBOOT_SYSTEM"

make_target() {
if [ -n "${UBOOT_SYSTEM}" ]; then
PKG_SOC=$("${ROOT}/${SCRIPTS}/uboot_helper" "${PROJECT}" "${DEVICE}" "${UBOOT_SYSTEM}" soc)
fi
PKG_SOC=${PKG_SOC:-${DEVICE}}

PKG_BOOT_INI="RKBOOT/${PKG_SOC}MINIALL.ini"
if [ ! -f "${PKG_BOOT_INI}" ]; then
PKG_BOOT_INI="RKBOOT/${DEVICE}MINIALL.ini"
fi
if [ -f "${PKG_BOOT_INI}" ]; then
PKG_FILE=$(sed -nr "/^\[LOADER_OPTION\]/ { :l /^FlashData[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" "${PKG_BOOT_INI}")
if [ -f "${PKG_FILE}" ]; then
cp -av "${PKG_FILE}" ddr.bin

# Override sdram frequency
Kwiboo marked this conversation as resolved.
Show resolved Hide resolved
if [ "${PKG_SOC}" = "RK3328" ]; then
sed -s 's/\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i ddr.bin
sed -s 's/\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i ddr.bin
fi
fi
fi

PKG_TRUST_INI="RKTRUST/${PKG_SOC}TRUST.ini"
if [ ! -f "${PKG_TRUST_INI}" ]; then
PKG_TRUST_INI="RKTRUST/${DEVICE}TRUST.ini"
Kwiboo marked this conversation as resolved.
Show resolved Hide resolved
fi
if [ -f "${PKG_TRUST_INI}" ]; then
PKG_FILE=$(sed -nr "/^\[BL31_OPTION\]/ { :l /^PATH[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" "${PKG_TRUST_INI}")
if [ -f "${PKG_FILE}" ]; then
cp -av "${PKG_FILE}" bl31.elf
fi
fi
}

makeinstall_target() {
mkdir -p "${INSTALL}/.noinstall"
for PKG_FILE in ddr.bin bl31.elf; do
if [ -f "${PKG_FILE}" ]; then
cp -av "${PKG_FILE}" "${INSTALL}/.noinstall"
fi
done
}
9 changes: 3 additions & 6 deletions projects/Rockchip/bootloader/config
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
CONFIG_BOOTDELAY=1
# CONFIG_VIDEO is not set
# CONFIG_BOOTMETH_VBE is not set
# CONFIG_DISPLAY is not set
# CONFIG_EFI_LOADER is not set
# CONFIG_ENV_IS_IN_MMC is not set
# CONFIG_ENV_IS_IN_SPI_FLASH is not set
# CONFIG_NET_RANDOM_ETHADDR is not set
# CONFIG_USB_KEYBOARD is not set
# CONFIG_TPL_DRIVERS_MISC is not set
CONFIG_MISC=y
CONFIG_MISC_INIT_R=y
CONFIG_ROCKCHIP_EFUSE=y
CONFIG_SHA256=y
# CONFIG_VIDEO is not set
8 changes: 8 additions & 0 deletions projects/Rockchip/bootloader/firmware
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ else
export UBOOT_TARGET=""
fi

if [ -f "$(get_install_dir rkbin)/.noinstall/ddr.bin" ]; then
export ROCKCHIP_TPL="$(get_install_dir rkbin)/.noinstall/ddr.bin"
fi

if [ -f "$(get_install_dir rkbin)/.noinstall/bl31.elf" ]; then
export BL31="$(get_install_dir rkbin)/.noinstall/bl31.elf"
fi
Kwiboo marked this conversation as resolved.
Show resolved Hide resolved

if [ -n "${ATF_PLATFORM}" ]; then
if [ -f "$(get_install_dir atf)/usr/share/bootloader/bl31.elf" ]; then
export BL31="$(get_install_dir atf)/usr/share/bootloader/bl31.elf"
Expand Down
9 changes: 1 addition & 8 deletions projects/Rockchip/bootloader/install
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,10 @@ if [ "${ROCKCHIP_LEGACY_BOOT}" = "1" ]; then
exit 1
fi

PKG_DDR_BIN="${PKG_RKBIN}"/$(sed -n "/FlashData/s/FlashData=//p" "${PKG_BOOT_INI}")
PKG_MINILOADER="${PKG_RKBIN}"/$(sed -n "/FlashBoot/s/FlashBoot=//p" "${PKG_BOOT_INI}")
PKG_LOAD_ADDR=$(sed -n "/CONFIG_TEXT_BASE/s/#define CONFIG_TEXT_BASE //p" u-boot.cfg)

# Override sdram frequency
if [ "${DEVICE}" = "RK3328" ]; then
sed -s 's/\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i "${PKG_DDR_BIN}"
sed -s 's/\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i "${PKG_DDR_BIN}"
fi

${QEMU} ${PKG_RKBIN}/tools/mkimage -n "${PKG_SOC}" -T rksd -d "${PKG_DDR_BIN}":"${PKG_MINILOADER}" idbloader.img.rk || exit 1
tools/mkimage -n "${PKG_SOC}" -T rksd -d "${PKG_DDR_BIN}":"${PKG_MINILOADER}" idbloader.img.rk || exit 1
${QEMU} ${PKG_RKBIN}/tools/loaderimage --pack --uboot u-boot-dtb.bin uboot.img.rk "${PKG_LOAD_ADDR}" || exit 1

dd if=idbloader.img.rk of="${UBOOT_FIT_IMAGE}" seek=0 conv=fsync,notrunc > /dev/null 2>&1 || exit 1
Expand Down
16 changes: 16 additions & 0 deletions projects/Rockchip/bootloader/mkimage
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)

if [ -z "${DTB}" ]; then
echo "image: copying device tree blobs..."
mmd rockchip >"${SAVE_ERROR}" 2>&1 || show_error
mcopy "${RELEASE_DIR}/3rdparty/bootloader/"*.dtb ::/rockchip >"${SAVE_ERROR}" 2>&1 || show_error

echo "image: copying extlinux.conf..."
mkdir -p "${LE_TMP}/extlinux"
cat <<EOF >"${LE_TMP}/extlinux/extlinux.conf"
LABEL ${DISTRO}
LINUX /${KERNEL_NAME}
FDTDIR /
APPEND boot=UUID=${UUID_SYSTEM} disk=UUID=${UUID_STORAGE} quiet ${EXTRA_CMDLINE}
EOF
mcopy -s "${LE_TMP}/extlinux" :: >"${SAVE_ERROR}" 2>&1 || show_error
fi

if [ -n "${UBOOT_SYSTEM}" ]; then
BOOTLOADER_PATH="${RELEASE_DIR}/3rdparty/bootloader/u-boot-rockchip.bin"
if [ -f "${BOOTLOADER_PATH}" ]; then
Expand Down
3 changes: 2 additions & 1 deletion projects/Rockchip/bootloader/release
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ if [ -n "${UBOOT_SYSTEM}" ]; then
fi
fi

cp -av "${SRCDIR}"/"${DEVICE,,}"*.dtb "${DSTDIR}"
DTB_PREFIX="${DEVICE//X/}"
cp -av "${SRCDIR}"/"${DTB_PREFIX,,}"*.dtb "${DSTDIR}"
23 changes: 18 additions & 5 deletions projects/Rockchip/bootloader/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fi

# update device tree
for all_dtb in ${BOOT_ROOT}/*.dtb; do
[ -f "$all_dtb" ] || continue
dtb=$(basename ${all_dtb})

# device tree mappings for update from vendor to mainline kernel
Expand All @@ -39,7 +40,7 @@ fi
esac

if [ "${dtb}" != "${new_dtb}" -a -f ${SYSTEM_ROOT}/usr/share/bootloader/${new_dtb} ]; then
echo -n "Replacing ${dtb} with ${new_dtb} ... "
echo -n "Replacing ${dtb} with ${new_dtb}... "
cp -p ${SYSTEM_ROOT}/usr/share/bootloader/${new_dtb} ${BOOT_ROOT} && \
sed -e "s/FDT \/${dtb}/FDT \/${new_dtb}/g" \
-i ${BOOT_ROOT}/extlinux/extlinux.conf && \
Expand All @@ -51,15 +52,28 @@ fi
cp -p ${SYSTEM_ROOT}/usr/share/bootloader/${dtb} ${BOOT_ROOT}
echo "done"
elif [ "$(grep -c "FDT /${dtb}" ${BOOT_ROOT}/extlinux/extlinux.conf)" -ne 0 ]; then
non_existend_dtb="${dtb}"
non_existend_dtb="${dtb}"
fi
fi
done

# update /rockchip device tree blobs
if [ -d ${BOOT_ROOT}/rockchip ]; then
echo -n "Updating Device Tree Blobs... "
for all_dtb in ${BOOT_ROOT}/rockchip/*.dtb; do
[ -f "$all_dtb" ] || continue
dtb=$(basename ${all_dtb})
if [ -f ${SYSTEM_ROOT}/usr/share/bootloader/${dtb} ]; then
cp -p ${SYSTEM_ROOT}/usr/share/bootloader/${dtb} ${BOOT_ROOT}/rockchip
fi
done
echo "done"
fi

# update bootloader
if [ -f ${SYSTEM_ROOT}/usr/share/bootloader/u-boot-rockchip.bin ]; then
echo -n "Updating fit image u-boot-rockchip.bin ... "
dd if=${SYSTEM_ROOT}/usr/share/bootloader/u-boot-rockchip.bin of=${BOOT_DISK} bs=32k seek=1 conv=fsync,notrunc &>/dev/null
echo -n "Updating U-Boot... "
dd if=${SYSTEM_ROOT}/usr/share/bootloader/u-boot-rockchip.bin of=${BOOT_DISK} bs=32k seek=1 conv=fsync &>/dev/null
echo "done"
fi

Expand All @@ -74,4 +88,3 @@ fi
echo "Please check documentation to find out which boards are supported by this package."
sleep 10
fi

8 changes: 0 additions & 8 deletions projects/Rockchip/devices/RK3288/filesystem/usr/bin/cputemp

This file was deleted.

8 changes: 0 additions & 8 deletions projects/Rockchip/devices/RK3288/filesystem/usr/bin/gputemp

This file was deleted.

30 changes: 30 additions & 0 deletions projects/Rockchip/devices/RK356X/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# RK356X

This is a work-in-progress SoC device for RK3566/RK3568

**Known Issues/Limitations**

* uses rkbin ddr init blob instead of u-boot tpl
- u-boot does not have any ddr init code
* uses rkbin atf blob
- open source atf has not been tested
* press spi switch on odroid-m1 during boot to run ddr init and u-boot from sd-card/emmc
* ram is limited to ~4gb with `mem=3838M` (memory range `0x00200000` - `0xefffffff`)
- there is an issue with importing decoded video frames into display stack
- old work-in-progress patches broke display stack for older socs
* display stack drivers is missing features for 10-bit and YCbCr output
* hw decoding is limited to vdpu121 (mpeg2, h264 1080p and vp8)
- there is currently no support for vdpu346 (h264 4k, hevc, vp9) in rkvdec driver

**Build**

* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=nanopi-r5c make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=nanopi-r5s make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=odroid-m1 make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=orangepi-3b make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=quartz64-a make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=quartz64-b make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=radxa-zero-3 make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=rock-3a make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=rock-3b make image`
* `PROJECT=Rockchip DEVICE=RK356X ARCH=aarch64 UBOOT_SYSTEM=rock-3c make image`
13 changes: 13 additions & 0 deletions projects/Rockchip/devices/RK356X/config/kernel-firmware-any.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rockchip/*
ath10k/QCA6174
ath10k/QCA9377
ath10k/QCA9887
ath10k/QCA9888
ath10k/QCA988X
ath10k/QCA9984
ath10k/QCA99X0
iwlwifi-4965-2.ucode
iwlwifi-5*
iwlwifi-6*
mwlwifi/
rtl_nic/rtl8125b-2.fw
Loading