odroidhc4: bump to u-boot v2024.04; drop most defconfig patches in favor of hooks

- add `pre_config_uboot_target` hook for switching BOOTCONFIG across the two targets
  - adapt `UBOOT_TARGET_MAP` to not call the defconfig Makefile targets directly, instead, just do a variable assignment (ignored by Make)
  - otherwise, when using the defconfig directly in the `UBOOT_TARGET_MAP`, the `post_config_uboot_target` .config changes are overwritten when Make is called
- only patch left is boot usb-nvme-scsi/sata first (still done in meson64.h)
- remove FIP handling from family file `meson-sm1.conf` into board file hook where it belongs
- u-boot: enable more compression methods, EFI debugging, i2c, leds, tcp networking
- use flashcp for mtd writing

- Unchanged:
  - confirmed as of v2024.04: using the C4 (not HC4) defconfig is still needed to be able to write to mtd when booted from SD
  - also confirmed: one still needs to erase Petitboot using Petitboot, then boot from SD, to be able to flash mainline u-boot to mtd
This commit is contained in:
Ricardo Pardini 2024-05-21 13:17:00 +02:00 committed by Igor
parent cbaf67f007
commit 3ac7c64d9e
6 changed files with 109 additions and 226 deletions

View File

@ -2,7 +2,7 @@
BOARD_NAME="Odroid HC4"
BOARDFAMILY="meson-sm1"
BOARD_MAINTAINER=""
BOOTCONFIG="odroid-c4_defconfig" # But also 'odroid-hc4_defconfig', see below at UBOOT_TARGET_MAP
BOOTCONFIG="odroid-c4_defconfig" # for the SD card; but also 'odroid-hc4_defconfig', see below at pre_config_uboot_target
KERNEL_TARGET="current,edge"
MODULES_BLACKLIST="simpledrm" # SimpleDRM conflicts with Panfrost
FULL_DESKTOP="no"
@ -11,19 +11,84 @@ BOOT_FDT_FILE="amlogic/meson-sm1-odroid-hc4.dtb"
PACKAGE_LIST_BOARD="lm-sensors fancontrol" # SPI, sensors, manual fan control via 'pwmconfig'
# Newer u-boot for the HC4. There's patches in `board_odroidhc4` for the defconfigs used in the UBOOT_TARGET_MAP below.
BOOTBRANCH_BOARD="tag:v2023.01"
BOOTPATCHDIR="v2023.01"
BOOTBRANCH_BOARD="tag:v2024.04"
BOOTPATCHDIR="v2024.04"
# We build u-boot twice: odroid-hc4_sd_defconfig config for SD cards, and HC4 (with SATA/PCI/SPI) config for SPI.
# Go look at the related patches for speculations on why.
# We build u-boot twice: C4 config for SD cards, and HC4 (with SATA/PCI/SPI) config for SPI.
UBOOT_TARGET_MAP="
odroid-hc4_sd_defconfig u-boot-dtb.img;;u-boot.bin.sd.bin:u-boot.bin u-boot-dtb.img
odroid-hc4_defconfig u-boot-dtb.img;;u-boot.bin:u-boot-spi.bin
armbian_target=sd u-boot-dtb.img;;u-boot.bin.sd.bin:u-boot.bin u-boot-dtb.img
armbian_target=spi u-boot-dtb.img;;u-boot.bin:u-boot-spi.bin
"
# The SPI version (u-boot-spi.bin, built from odroid-hc4_defconfig above) is then used by nand-sata-install
# The SPI version (u-boot-spi.bin, built from odroid-hc4_defconfig above) is then used by nand-sata-install / armbian-install
function write_uboot_platform_mtd() {
dd if=$1/u-boot-spi.bin of=/dev/mtdblock0
declare -a extra_opts_flashcp=("--verbose")
if flashcp -h | grep -q -e '--partition'; then
echo "Confirmed flashcp supports --partition -- read and write only changed blocks." >&2
extra_opts_flashcp+=("--partition")
else
echo "flashcp does not support --partition, will write full SPI flash blocks." >&2
fi
flashcp "${extra_opts_flashcp[@]}" "${1}/u-boot-spi.bin" /dev/mtd0
}
# FIP blobs; the C4 & HC4 fip blobs are actually the same, still LE carries both.
function post_uboot_custom_postprocess__odroid_hc4_uboot() {
display_alert "Signing u-boot FIP" "${BOARD}" "info"
uboot_g12_postprocess "${SRC}"/cache/sources/amlogic-boot-fip/odroid-hc4 g12a
}
# switch defconfig according to target, so we can still use the same post_config_uboot_target for both.
function pre_config_uboot_target__odroidhc4_defconfig_per_target() {
case "${target_make}" in
"armbian_target=spi "*)
BOOTCONFIG="odroid-hc4_defconfig"
;;
"armbian_target=sd "*)
BOOTCONFIG="odroid-c4_defconfig"
;;
*)
exit_with_error "Unknown target_make: '${target_make}', unknown BOOTCONFIG."
;;
esac
display_alert "setting BOOTCONFIG for target" "${target_make}: '${BOOTCONFIG}'" "info"
}
# Enable extra u-boot .config options, this way we avoid patching defconfig
function post_config_uboot_target__extra_configs_for_odroid_hc4() {
display_alert "u-boot for ${BOARD}" "u-boot: enable preboot & pci+usb start in preboot" "info"
run_host_command_logged scripts/config --enable CONFIG_USE_PREBOOT
run_host_command_logged scripts/config --set-str CONFIG_PREBOOT "'run boot_pci_enum; usb start'" # double quotes required due to run_host_command_logged's quirks
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
## WAIT ## display_alert "u-boot for ${BOARD}" "u-boot: disable EFI Video Framebuffer" "info"
## WAIT ## run_host_command_logged scripts/config --disable CONFIG_VIDEO_DT_SIMPLEFB # "Enables the code to pass the framebuffer to the kernel as a simple framebuffer in the device tree."
## WAIT ## # CONFIG_VIDEO_EFI is unrelated: its about _using_ an EFI framebuffer when booted by an EFI-capable bootloader earlier in the chain. Not about _providing_ an EFI framebuffer. That's simplefb.
## WAIT ## # CONFIG_FDT_SIMPLEFB seems to be rpi-specific and 100% unrelated here
display_alert "u-boot for ${BOARD}" "u-boot: enable I2C support" "info"
run_host_command_logged scripts/config --enable CONFIG_DM_I2C
run_host_command_logged scripts/config --enable CONFIG_SYS_I2C_MESON
run_host_command_logged scripts/config --enable CONFIG_CMD_I2C
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
}
# @TODO: this is no longer needed in `edge` branch -- Neil has sent a patch with a trip for the cooling map in the DT - also doesn't hurt.

View File

@ -22,7 +22,8 @@ uboot_custom_postprocess() {
if [[ $BOARD == odroidc4 ]]; then
uboot_g12_postprocess $SRC/cache/sources/amlogic-boot-fip/odroid-c4 g12a
elif [[ $BOARD == odroidhc4 ]]; then
uboot_g12_postprocess $SRC/cache/sources/amlogic-boot-fip/odroid-hc4 g12a
# do nothing. odroid HC4 has its own post_uboot_custom_postprocess hook, directly in the board file.
:
elif [[ $BOARD == khadas-vim3l ]]; then
# do nothing. VIM3L has its own post_uboot_custom_postprocess hook, directly in the board file.
:

View File

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jihoon Han <rapid_renard@renard.kr>
Date: Mon, 11 Dec 2023 04:47:08 +0900
Subject: HACK: configs: meson64: prevent stdout/stderr on videoconsole
Several devices have CONFIG_DM_VIDEO enabled which causes stdout/stderr
to appear on videoconsole, so remove videoconsole from STDOUT so that
early u-boot boot remains silent unless using the uart/serial console.
Signed-off-by: Jihoon Han <rapid_renard@renard.kr>
---
include/configs/meson64.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index 726f33c26c2a..f97f83d8607f 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -25,7 +25,7 @@
/* For splashscreen */
#ifdef CONFIG_VIDEO
-#define STDOUT_CFG "vidconsole,serial"
+#define STDOUT_CFG "serial"
#else
#define STDOUT_CFG "serial"
#endif
--
Armbian

View File

@ -1,145 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ricardo Pardini <ricardo@pardini.net>
Date: Mon, 14 Nov 2022 14:59:45 +0100
Subject: odroidhc4: add a marker boot-from-SD-write-to-SPI defconfig for the
HC4 based the C4 DT
For reasons I don't understand, using the HC4 DT + SPI + PCI stuff in odroid-hc4_defconfig
causes the HC4 to be unable to talk to the SPI MTD. Since it's quite common that an user
booting an Armbian SD card on the HC4 will want to write to the SPI MTD (with intent to
de-infest their machine from Petitboot), Armbian has for a long time shipped the
odroid-c4_defconfig for the HC4 image (usually written to SD card), while shipping the
proper odroid-hc4_defconfig for the SPI version (deployed to MTD by armbian-install).
This patch is thus, not required; we could simply use the c4_defconfig for the SD image.
See below, but it seems to boil down to the DT, not any other defconfig changes.
Below are a few different tries I've made:
## SPI Crazy vs C4/HC4 defconfig
- all below tests done on the following conditions:
- wiped/zeroed SPI flash (`cat /dev/zero > /dev/mtdblock0; sync`)
- u-boot.bin.sd.bin flashed SD card
- SD card inserted
- "button" not pressed at all
- initial cold boot, then some warm reboots.
- on `odroid-hc4_defconfig`:
- `SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;CHK:1F;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;`
- u-boot `sf probe`: `jedec_spi_nor spi-flash@0: unrecognized JEDEC id bytes: 00, 00, 00`
- kernel: `spi-nor spi0.0: unrecognized JEDEC id bytes: 00 00 00 00 00 00`
- new `odroid-hc4_sd_defconfig`: (a copy of C4 version, but without the SPI stuff)
- `SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;CHK:1F;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;`
- no u-boot `sf probe` since I left it out
- kernel: `spi-nor spi0.0: unrecognized JEDEC id bytes: 00 00 00 00 00 00`
- bootloop! (unrelated? kernel meson-gx-mmc stuff? BLxx says `sdio read data fail` and resets to `SM1:BL...`)
- new `odroid-hc4_sd_defconfig` (a copy of C4 version, sans-SPI, sans-PCI, sans GPIO-reg, only DT change):
- no bootloop, on try 1 -- why?
- no bootloop, on try 2 -- disabling pci, keeping dtb, avoids bootloop? some other change?
- no u-boot `sf probe` since I left it out
- kernel: `spi-nor spi0.0: unrecognized JEDEC id bytes: 00 00 00 00 00 00`
- new `odroid-hc4_sd_defconfig` (a copy of C4 version, sans-SPI, sans-PCI, sans GPIO-reg, using C4 DT)
- `SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;CHK:1F;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;`
- SPI MTD works in kernel: `spi-nor spi0.0: xt25f128b (16384 Kbytes)`
- bootloop! (unrelated? kernel meson-gx-mmc stuff? BLxx says `sdio read data fail` and resets to `SM1:BL...`)
- this is the version that's actually included in this patch; essentially just c4_defconfig.
- now flashed SPI, booting from SPI, with HC4 defconfig +preboot for USB
- `SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;0.0;CHK:0;`
- kernel: `spi-nor spi0.0: xt25f128b (16384 Kbytes)`
- u-boot `sf probe`: `SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB`
- everything works once SoC boots from SPI and uses the HC4 defconfig; no bootloops since SD is not involved at all
---
configs/odroid-hc4_sd_defconfig | 77 ++++++++++
1 file changed, 77 insertions(+)
diff --git a/configs/odroid-hc4_sd_defconfig b/configs/odroid-hc4_sd_defconfig
new file mode 100644
index 000000000000..7d2736b2bbf5
--- /dev/null
+++ b/configs/odroid-hc4_sd_defconfig
@@ -0,0 +1,77 @@
+CONFIG_ARM=y
+CONFIG_SYS_BOARD="odroid-n2"
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x01000000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-odroid-c4"
+CONFIG_MESON_G12A=y
+CONFIG_DEBUG_UART_BASE=0xff803000
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_IDENT_STRING=" odroid-hc4"
+CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x20000000
+CONFIG_REMAKE_ELF=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_SYS_MAXARGS=32
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_MDIO_MUX=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_MDIO_MUX_MESON_G12A=y
+CONFIG_MESON_G12A_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_G12A=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_MESON_G12A=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y
--
Armbian

View File

@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ricardo Pardini <ricardo@pardini.net>
Date: Tue, 31 Jan 2023 00:11:35 +0100
Subject: odroidhc4: u-boot: spi: add pci enum & usb start to preboot
Under investigation; Neil Armstrong has determined that forcing PCI
enumeration on the HC4 allows the USB to be used for booting.
This adds a preboot command to the u-boot config run PCI enumeration
and start USB. (Starting USB is not required, since distroboot would
start it anyway, but has the added benefit of (maybe?) allowing USB
keyboard interaction during u-boot, which might be useful for users
sans-UART)
I have a strong suspicion that the real underlying issue is somehow
related to GPIOH_4:
- on the C4 DT, a gpio-hog usb-hub-reset `GPIOH_4 GPIO_ACTIVE_HIGH`
- on the HC4 DT: pcie reset-gpios `GPIOH_4 GPIO_ACTIVE_LOW`
See also: https://lore.kernel.org/all/20230121175639.12818-1-linux.amoon@gmail.com/
specially the c4 patch https://lore.kernel.org/all/20230121175639.12818-8-linux.amoon@gmail.com/
---
configs/odroid-hc4_defconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configs/odroid-hc4_defconfig b/configs/odroid-hc4_defconfig
index 1af9c1139538..a006ef924eaf 100644
--- a/configs/odroid-hc4_defconfig
+++ b/configs/odroid-hc4_defconfig
@@ -17,6 +17,8 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x20000000
CONFIG_REMAKE_ELF=y
CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="run boot_pci_enum; usb start"
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_MISC_INIT_R=y
CONFIG_SYS_MAXARGS=32
--
Armbian

View File

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ricardo Pardini <ricardo@pardini.net>
Date: Sun, 14 Jan 2024 13:44:58 +0100
Subject: meson64: change `BOOT_TARGET_DEVICES` to try to boot USB, NVME and
SCSI before SD, MMC, PXE, DHCP
---
include/configs/meson64.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index 111111111111..222222222222 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -99,12 +99,12 @@
#define BOOT_TARGET_DEVICES(func) \
func(ROMUSB, romusb, na) \
func(USB_DFU, usbdfu, na) \
- func(MMC, mmc, 0) \
- func(MMC, mmc, 1) \
- func(MMC, mmc, 2) \
BOOT_TARGET_DEVICES_USB(func) \
BOOT_TARGET_NVME(func) \
BOOT_TARGET_SCSI(func) \
+ func(MMC, mmc, 0) \
+ func(MMC, mmc, 1) \
+ func(MMC, mmc, 2) \
func(PXE, pxe, na) \
func(DHCP, dhcp, na)
#endif
--
Armbian