2020-05-29 10:22:38 +00:00
# Rockchip RK3399 hexa core 2G/4GB SoC GBe eMMC USB3 WiFi
2018-08-17 11:08:55 +00:00
BOARD_NAME="RockPro 64"
2018-08-26 12:14:14 +00:00
BOARDFAMILY="rockchip64"
2023-06-19 15:30:35 +00:00
BOARD_MAINTAINER="joekhoobyar"
2018-08-17 13:39:13 +00:00
BOOTCONFIG="rockpro64-rk3399_defconfig"
2023-10-12 15:55:18 +00:00
KERNEL_TARGET="current,edge"
2023-11-25 18:38:58 +00:00
KERNEL_TEST_TARGET="current"
2019-09-01 20:13:13 +00:00
FULL_DESKTOP="yes"
2020-06-27 17:14:38 +00:00
BOOT_LOGO="desktop"
2023-05-21 15:58:45 +00:00
BOOT_SCENARIO="blobless"
2021-10-26 20:14:41 +00:00
BOOT_SUPPORT_SPI=yes
2023-05-21 15:58:45 +00:00
2025-01-09 21:31:06 +00:00
BOOTBRANCH_BOARD="tag:v2025.01"
BOOTPATCHDIR="v2025.01"
2024-03-22 13:55:09 +00:00
# Include fw_setenv, configured to point to the correct spot on the SPI Flash
PACKAGE_LIST_BOARD="libubootenv-tool" # libubootenv-tool provides fw_printenv and fw_setenv, for talking to U-Boot environment
2023-05-21 15:58:45 +00:00
2024-03-22 13:55:09 +00:00
function post_family_config__use_mainline_uboot_rockpro64() {
2025-01-09 21:31:06 +00:00
# Do not set ATFBRANCH; instead uses the default from rockchip64_common, tested with v2.12.0 as of 2025.01[.09]
2024-03-22 13:55:09 +00:00
display_alert "$BOARD" "using ATF (blobless) ${ATFBRANCH} for ${BOOTBRANCH_BOARD} u-boot" "info"
# bl31.elf is copied directly from ATF build dir to uboot dir (by armbian u-boot build system)
UBOOT_TARGET_MAP="BL31=bl31.elf;;u-boot-rockchip.bin u-boot-rockchip-spi.bin"
# Ignore most of the rockchip64_common stuff, we're using binman here which does all the work already
unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd
function write_uboot_platform() {
dd "if=$1/u-boot-rockchip.bin" "of=$2" bs=32k seek=1 conv=notrunc status=none
}
function write_uboot_platform_mtd() {
flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0
}
}
2023-05-21 15:58:45 +00:00
function post_config_uboot_target__extra_configs_for_rockpro64() {
2024-07-21 15:21:20 +00:00
# Specific for rockpro64? CONFIG_OF_LIBFDT_OVERLAY=y should be generic
2024-03-22 13:55:09 +00:00
display_alert "$BOARD" "u-boot configs for ${BOOTBRANCH_BOARD} u-boot config" "info"
2023-05-21 15:58:45 +00:00
run_host_command_logged scripts/config --set-val CONFIG_OF_LIBFDT_OVERLAY "y"
run_host_command_logged scripts/config --set-val CONFIG_MMC_HS400_SUPPORT "y"
2024-07-21 15:21:20 +00:00
2025-01-09 21:31:06 +00:00
# upstream defconfig already has env in SPI: https://github.com/u-boot/u-boot/blob/v2025.01/configs/rockpro64-rk3399_defconfig
2024-07-21 15:21:20 +00:00
display_alert "u-boot for ${BOARD}" "u-boot: enable EFI debugging command" "info"
run_host_command_logged scripts/config --enable CMD_EFIDEBUG
run_host_command_logged scripts/config --enable CMD_NVEDIT_EFI
display_alert "u-boot for ${BOARD}" "u-boot: enable more compression support" "info"
run_host_command_logged scripts/config --enable CONFIG_LZO
run_host_command_logged scripts/config --enable CONFIG_BZIP2
run_host_command_logged scripts/config --enable CONFIG_ZSTD
display_alert "u-boot for ${BOARD}" "u-boot: enable gpio LED support" "info"
run_host_command_logged scripts/config --enable CONFIG_LED
run_host_command_logged scripts/config --enable CONFIG_LED_GPIO
display_alert "u-boot for ${BOARD}" "u-boot: enable networking cmds" "info"
run_host_command_logged scripts/config --enable CONFIG_CMD_NFS
run_host_command_logged scripts/config --enable CONFIG_CMD_WGET
run_host_command_logged scripts/config --enable CONFIG_CMD_DNS
run_host_command_logged scripts/config --enable CONFIG_PROT_TCP
run_host_command_logged scripts/config --enable CONFIG_PROT_TCP_SACK
# UMS, RockUSB, gadget stuff
declare -a enable_configs=("CONFIG_CMD_USB_MASS_STORAGE" "CONFIG_USB_GADGET" "USB_GADGET_DOWNLOAD" "CONFIG_USB_FUNCTION_ROCKUSB" "CONFIG_USB_FUNCTION_ACM" "CONFIG_CMD_ROCKUSB" "CONFIG_CMD_USB_MASS_STORAGE")
for config in "${enable_configs[@]}"; do
display_alert "u-boot for ${BOARD}/${BRANCH}" "u-boot: enable ${config}" "info"
run_host_command_logged scripts/config --enable "${config}"
done
# Auto-enabled by the above, force off...
run_host_command_logged scripts/config --disable USB_FUNCTION_FASTBOOT
2023-05-21 15:58:45 +00:00
}
2024-03-22 13:55:09 +00:00
2025-01-09 21:31:06 +00:00
function pre_config_uboot_target__rockpro64_patch_uboot_dtsi_for_ums() {
display_alert "u-boot for ${BOARD}" "u-boot: add to u-boot dtsi for UMS" "info" # avoid a patch, just append to the dtsi file
cat <<- UBOOT_BOARD_DTSI_OTG >> arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
&usbdrd_dwc3_0 { status = "okay"; dr_mode = "otg"; };
UBOOT_BOARD_DTSI_OTG
}
# "rockchip-common: boot SD card first, then NVMe, then SATA, then USB, then mmc"
# On rockpro64, mmc0 is the eMMC, mmc1 is the SD card slot https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi#L15-L16
function pre_config_uboot_target__rockpro64_patch_rockchip_common_boot_order() {
declare -a rockchip_uboot_targets=("mmc1" "nvme" "scsi" "usb" "mmc0" "pxe" "dhcp" "spi") # for future make-this-generic delight
display_alert "u-boot for ${BOARD}/${BRANCH}" "u-boot: adjust boot order to '${rockchip_uboot_targets[*]}'" "info"
sed -i -e "s/#define BOOT_TARGETS.*/#define BOOT_TARGETS \"${rockchip_uboot_targets[*]}\"/" include/configs/rockchip-common.h
regular_git diff -u include/configs/rockchip-common.h || true
}
2024-03-22 13:55:09 +00:00
function post_family_tweaks__config_rockpro64_fwenv() {
display_alert "Configuring fw_printenv and fw_setenv" "for ${BOARD} and u-boot ${BOOTBRANCH_BOARD}" "info"
2024-07-21 15:21:20 +00:00
# Addresses below come from CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE in https://github.com/u-boot/u-boot/blob/v2024.07/configs/rockpro64-rk3399_defconfig
2024-03-22 13:55:09 +00:00
cat <<- 'FW_ENV_CONFIG' > "${SDCARD}"/etc/fw_env.config
# MTD on the SPI for the Rockpro64
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0x3F8000 0x8000
FW_ENV_CONFIG
}