From 4db330178fbe93b52e7987e8ce69ab9eaddd5377 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sat, 14 Jan 2023 19:07:11 +0100 Subject: [PATCH] `odroidhc4`: u-boot to 23.01; add HC4-SPI target preboot for USB; change HC4-SD target defconfig to new `hc4_sd`, similar to `c4` - `odroidhc4`: pre-configure `fancontrol` so fans work right out of the box --- config/boards/odroidhc4.conf | 33 +++- ....hc4_sd_defconfig.for.writing.to.mtd.patch | 145 ++++++++++++++++++ ...odroidhc4.preboot.pci.enum.usb.start.patch | 41 +++++ .../meson64-boot-usb-nvme-scsi-first.patch | 34 ++++ 4 files changed, 249 insertions(+), 4 deletions(-) create mode 100644 patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.hc4_sd_defconfig.for.writing.to.mtd.patch create mode 100644 patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.preboot.pci.enum.usb.start.patch create mode 100644 patch/u-boot/v2023.01/meson64-boot-usb-nvme-scsi-first.patch diff --git a/config/boards/odroidhc4.conf b/config/boards/odroidhc4.conf index 4747122e66..59804cd754 100644 --- a/config/boards/odroidhc4.conf +++ b/config/boards/odroidhc4.conf @@ -8,12 +8,37 @@ SERIALCON="ttyAML0" BOOT_FDT_FILE="amlogic/meson-sm1-odroid-hc4.dtb" PACKAGE_LIST_BOARD="mtd-utils lm-sensors fancontrol" # SPI, sensors, manual fan control via 'pwmconfig' -# We build u-boot twice: C4 config for SD cards, and HC4 (with SATA) config for SPI. -# To be able to flash to SPI (via nand-sata-install), you need to use the C4 (SD) version. -UBOOT_TARGET_MAP="odroid-c4_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" +# 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" + +# 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. +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 +" # The SPI version (u-boot-spi.bin, built from odroid-hc4_defconfig above) is then used by nand-sata-install function write_uboot_platform_mtd() { dd if=$1/u-boot-spi.bin of=/dev/mtdblock0 } + +# @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. +function post_family_tweaks__config_odroidhc4_fancontrol() { + display_alert "Configuring fancontrol" "for Odroid HC4" "info" + cat <<- FANCONTROL > "${SDCARD}"/etc/fancontrol + # Default config for the Odroid HC4 -- adjust to your needs (MINTEMP=40) + INTERVAL=10 + DEVPATH=hwmon0=devices/virtual/thermal/thermal_zone0 hwmon2=devices/platform/pwm-fan + DEVNAME=hwmon0=cpu_thermal hwmon2=pwmfan + FCTEMPS=hwmon2/pwm1=hwmon0/temp1_input + FCFANS= hwmon2/pwm1=hwmon2/fan1_input + MINTEMP=hwmon2/pwm1=40 + MAXTEMP=hwmon2/pwm1=60 + MINSTART=hwmon2/pwm1=150 + MINSTOP=hwmon2/pwm1=30 + MAXPWM=hwmon2/pwm1=180 + FANCONTROL + chroot_sdcard systemctl enable fancontrol.service +} diff --git a/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.hc4_sd_defconfig.for.writing.to.mtd.patch b/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.hc4_sd_defconfig.for.writing.to.mtd.patch new file mode 100644 index 0000000000..f2dd2005d9 --- /dev/null +++ b/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.hc4_sd_defconfig.for.writing.to.mtd.patch @@ -0,0 +1,145 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +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 0000000000..7d2736b2bb +--- /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 + diff --git a/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.preboot.pci.enum.usb.start.patch b/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.preboot.pci.enum.usb.start.patch new file mode 100644 index 0000000000..d032204019 --- /dev/null +++ b/patch/u-boot/v2023.01/board_odroidhc4/board.odroidhc4.preboot.pci.enum.usb.start.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +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 1af9c11395..a006ef924e 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 + diff --git a/patch/u-boot/v2023.01/meson64-boot-usb-nvme-scsi-first.patch b/patch/u-boot/v2023.01/meson64-boot-usb-nvme-scsi-first.patch new file mode 100644 index 0000000000..64bdb51a03 --- /dev/null +++ b/patch/u-boot/v2023.01/meson64-boot-usb-nvme-scsi-first.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Mon, 14 Nov 2022 14:59:45 +0100 +Subject: meson64: change `BOOT_TARGET_DEVICES` to try to boot USB, NVME and + SCSI before SD, MMC, PXE, DHCP + +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 726f33c26c..d21899c335 100644 +--- a/include/configs/meson64.h ++++ b/include/configs/meson64.h +@@ -71,12 +71,12 @@ + #ifndef BOOT_TARGET_DEVICES + #define BOOT_TARGET_DEVICES(func) \ + func(ROMUSB, romusb, 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 +