rockpro64: bump u-boot to v2024.04-rc4; use binman-produced bins

- `mmc-sdhci-allow-disabling-sdma-in-spl.patch` has landed in 3cd664dc92
- remove `CONFIG_SPL_MMC_SDHCI_SDMA=n`, as fix has landed in 3b804b370d (thanks Kwiboo for the pointer)
- use binman-produced binaries
- use `flashcp -p` to write fast to spi
- bump ATF (TF-A) to lts-v2.8.16
- configure /etc/fw_env.config userspace to SPI env coordinates
  - configure /etc/fw_env.config userspace to SPI env coordinates
  - include libubootenv-tool userspace for fw_printenv and fw_setenv
- use `bs=32k seek=1` instead of `seek=64` suggested by Kwiboo (thanks!) for speedy writing
- add a check for the u-boot.bin size (992KiB) suggested by Kwiboo (thanks!)
  - really a close call: we're at 994.920 bytes right now

Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
Co-authored-by: Jonas Karlman <jonas@kwiboo.se>
This commit is contained in:
Ricardo Pardini
2024-03-22 14:55:09 +01:00
parent 9905082d4e
commit 8d426f6c29
2 changed files with 55 additions and 80 deletions

View File

@@ -10,29 +10,73 @@ BOOT_LOGO="desktop"
BOOT_SCENARIO="blobless"
BOOT_SUPPORT_SPI=yes
# u-boot 2023.01 for rockpro64
BOOTBRANCH_BOARD="tag:v2023.01"
BOOTPATCHDIR="v2023.01"
# u-boot v2024.04-rc4 for rockpro64
BOOTBRANCH_BOARD="tag:v2024.04-rc4"
BOOTPATCHDIR="v2024.04"
# 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
function add_host_dependencies__new_uboot_wants_python3_rockpro64() {
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-pyelftools" # @TODO: convert to array later
}
function post_family_config__hacks_for_new_uboot_rockpro64() {
display_alert "$BOARD" "using ATF (blobless) for 2023.01 u-boot" "info"
function post_family_config__use_mainline_uboot_rockpro64() {
# Use latest lts 2.8 ATF
ATFBRANCH='tag:lts-v2.8.8'
ATFBRANCH='tag:lts-v2.8.16'
ATFPATCHDIR="atf-rockchip64" # patches for logging etc
# With recent-enough u-boot and ATF.
# bl31.elf is copied directly from ATF build dir to uboot dir anyway.
UBOOT_TARGET_MAP="BL31=bl31.elf;;idbloader.img u-boot.itb tpl/u-boot-tpl.bin spl/u-boot-spl.bin u-boot.itb rkspi_loader.img"
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
}
}
# From Kwiboo:
# ... "note that u-boot mainline for rk3328/rk3399 suffers from a limitation in that the u-boot.bin may not exceed 1000 KiB or the stack may overwrite part of it during runtime, resulting in strange unexplained issues.
# This has been fixed in current U-Boot next branch with https://github.com/u-boot/u-boot/commit/5e7cd8a119953dc2f466fea81e230d683ee03493 and should be included with v2024.07-rc1
# If your u-boot.bin build output is less than 950 KiB in size you should not suffer from this limitation/issue."
# ... "The real limit will be at most 1 MiB - 16 KiB (malloc heap on stack) = 1008 KiB and any additional runtime usage of the stack will take up until U-Boot has been relocated to top of RAM,
# lets say an additional 16 KiB (same as malloc heap) to be on the safer side, so I would suggest you check for e.g. < 992 KiB or similar instead of < 1 MiB.
# As long as the generated u-boot.bin is < 992 KiB I think it should be safe, and I do not think the stack usage will be that much before relocation so < 1000 KiB may also be fine 😎"
# rpardini: close call; the u-boot.bin is 994920 bytes. Let's check for >992KiB and break the build if it's too large.
function post_uboot_custom_postprocess__check_bin_size_less_than_992KiB() {
declare one_bin
declare -i uboot_bin_size
declare -a bins_to_check=("u-boot.bin")
for one_bin in "${bins_to_check[@]}"; do
uboot_bin_size=$(stat -c %s "${one_bin}")
display_alert "Checking u-boot ${BOARD} bin size" "'${one_bin}' is less than 992KiB (1015808 bytes): ${uboot_bin_size} bytes" "info"
if [[ ${uboot_bin_size} -ge 1015808 ]]; then
display_alert "u-boot for ${BOARD}" "'${one_bin}' is larger than 992KiB (1015808 bytes): ${uboot_bin_size} bytes" "err"
exit_with_error "u-boot ${BOARD} bin size check failed"
fi
done
}
function post_config_uboot_target__extra_configs_for_rockpro64() {
# Taken from https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-rockpro64/-/blob/master/PKGBUILD
display_alert "$BOARD" "u-boot configs for 2023.01 u-boot config" "info"
display_alert "$BOARD" "u-boot configs for ${BOOTBRANCH_BOARD} u-boot config" "info"
run_host_command_logged scripts/config --set-val CONFIG_OF_LIBFDT_OVERLAY "y"
run_host_command_logged scripts/config --set-val CONFIG_SPL_MMC_SDHCI_SDMA "n"
run_host_command_logged scripts/config --set-val CONFIG_MMC_HS400_SUPPORT "y"
run_host_command_logged scripts/config --set-val CONFIG_USE_PREBOOT "n"
}
function post_family_tweaks__config_rockpro64_fwenv() {
display_alert "Configuring fw_printenv and fw_setenv" "for ${BOARD} and u-boot ${BOOTBRANCH_BOARD}" "info"
# Addresses below come from CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE in https://github.com/u-boot/u-boot/blob/v2024.04-rc4/configs/rockpro64-rk3399_defconfig
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
}

View File

@@ -1,69 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Geis <pgwipeout@gmail.com>
Date: Mon, 21 Feb 2022 20:31:21 -0500
Subject: mmc: sdhci: allow disabling sdma in spl
Rockchip emmc devices have a similar issue to Rockchip dwmmc devices,
where performing dma to sram causes errors with suspend/resume.
Allow us to toggle sdma in spl for sdhci similar to adma support, so we
can ensure dma is not used when loading the sram code.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
---
drivers/mmc/Kconfig | 7 +++++++
drivers/mmc/sdhci.c | 6 +++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index bf4d994ff695..6a959db956f4 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -471,6 +471,13 @@ config MMC_SDHCI_SDMA
This enables support for the SDMA (Single Operation DMA) defined
in the SD Host Controller Standard Specification Version 1.00 .
+config SPL_MMC_SDHCI_SDMA
+ bool "Support SDHCI SDMA in SPL"
+ depends on MMC_SDHCI
+ help
+ This enables support for the SDMA (Single Operation DMA) defined
+ in the SD Host Controller Standard Specification Version 1.00 in SPL.
+
config MMC_SDHCI_ADMA
bool "Support SDHCI ADMA2"
depends on MMC_SDHCI
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index a80ad8329a38..3c44e5d8d4d2 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -70,7 +70,7 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data)
}
}
-#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
+#if (CONFIG_IS_ENABLED(MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data,
int *is_aligned, int trans_bytes)
{
@@ -177,7 +177,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data)
}
} while (!(stat & SDHCI_INT_DATA_END));
-#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
+#if (CONFIG_IS_ENABLED(MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
dma_unmap_single(host->start_addr, data->blocks * data->blocksize,
mmc_get_dma_dir(data));
#endif
@@ -856,7 +856,7 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
#endif
debug("%s, caps: 0x%x\n", __func__, caps);
-#ifdef CONFIG_MMC_SDHCI_SDMA
+#if CONFIG_IS_ENABLED(MMC_SDHCI_SDMA)
if ((caps & SDHCI_CAN_DO_SDMA)) {
host->flags |= USE_SDMA;
} else {
--
Armbian