diff --git a/config/boards/odroidm1.wip b/config/boards/odroidm1.wip index 25348cd800..7d0f382319 100644 --- a/config/boards/odroidm1.wip +++ b/config/boards/odroidm1.wip @@ -1,32 +1,72 @@ # Rockchip RK3568 quad core 4GB-8GB GBE PCIe USB3 SATA NVMe BOARD_NAME="ODROID M1" -BOARDFAMILY="rk3568-odroid" # Separate kernel, has its own family. Uses rockchip64_common for most stuff. +BOARDFAMILY="rk3568-odroid" # Separate kernel, has its own family. Uses rockchip64_common for most stuff. BOARD_MAINTAINER="rpardini" -BOOT_SOC="rk3568" # This determined BOOT_SCENARIO et al. -KERNEL_TARGET="edge" # Only mainline based kernel -BOOT_FDT_FILE="rockchip/rk3568-odroid-m1.dtb" # HK's DTB -SRC_EXTLINUX="no" # NO EXTLINUX! Family defines a custom bootscript too. -ASOUND_STATE="asound.state.station-m2" # @TODO: probably should fix this later. -IMAGE_PARTITION_TABLE="gpt" # HK's bootloader in SPI requires GPT partition table. -DDR_BLOB="rk35/rk3568_ddr_1560MHz_v1.10.bin" # Real blob, is actually used. in rkbin repository. HK uses 1.09, 1.10 seems to work just as well. -BL31_BLOB="rk35/rk356x_usbplug_v1.10.bin--FAKE" # Not really used for anything, as the name proves. +BOOT_SOC="rk3568" +KERNEL_TARGET="edge" +BOOT_FDT_FILE="rockchip/rk3568-odroid-m1.dtb" +SRC_EXTLINUX="no" +ASOUND_STATE="asound.state.station-m2" +IMAGE_PARTITION_TABLE="gpt" FULL_DESKTOP="yes" BOOT_LOGO="desktop" -# Include fw_setenv, configured to point to Petitboot's u-env mtd partition, so users can re-enable Petitboot -# with `fw_setenv skip_spiboot false` in Armbian. -PACKAGE_LIST_BOARD="libubootenv-tool" # libubootenv-tool provides fw_printenv and fw_setenv, for talking to U-Boot environment / Petitboot +BOOTSOURCE="https://github.com/Kwiboo/u-boot-rockchip.git" +BOOTBRANCH_BOARD="commit:a6e84f9f5b90ff0fa3ac4e6b7e0d6e2c3ac9bb1b" # specific commit, from "branch:rk3568-2023.10" which is v2023.10-rc2 + kwiboo's patches (including GMAC) +BOOTPATCHDIR="v2023.10" +BOOTCONFIG="odroid-m1-rk3568_defconfig" +BOOTDIR="u-boot-${BOARD}" # do not share u-boot directory + +# Newer blobs... +DDR_BLOB="rk35/rk3568_ddr_1560MHz_v1.18.bin" +BL31_BLOB="rk35/rk3568_bl31_v1.43.elf" + +# HK's SPI partition on MTD: +# mtd0: start 0 size 917.504 end 917.504 : SPL == start 0x0 size 0xe0000 : SPL +# mtd1: start 917.504 size 131.072 end 1.048.576 : U-Boot Env == start 0xe0000 size 0x20000 : U-Boot Env +# mtd2: start 1.048.576 size 2.097.152 end 3.145.728 : U-Boot == start 0x100000 size 0x200000 : U-Boot +function post_family_config__uboot_config() { + display_alert "$BOARD" "u-boot ${BOOTBRANCH_BOARD} overrides" "info" + BOOTDELAY=2 # Wait for UART interrupt to enter UMS/RockUSB mode etc + UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/$BL31_BLOB ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin u-boot.itb idbloader.img idbloader-spi.img" + unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd # disable stuff from rockchip64_common; we're using binman here which does all the work already + + # Just use the binman-provided u-boot-rockchip.bin, which is ready-to-go + function write_uboot_platform() { + dd if=${1}/u-boot-rockchip.bin of=${2} bs=32k seek=1 conv=fsync + } + + # We don't use u-boot-rockchip-spi.bin here; instead, write SPL and u-boot individually + # If we're deinfesting from Petitboot, clear the environment too; PREBOOT will save a new one for mainline + function write_uboot_platform_mtd() { + flashcp -v -p "${1}/idbloader-spi.img" /dev/mtd0 # write SPL + flashcp -v -p "${1}/u-boot.itb" /dev/mtd2 # write u-boot + if fw_printenv | grep -q -i petitboot; then # Petitboot leaves a horrible env behind, clear it off if so + echo "Found traces of Petitboot in SPI u-boot environment, clearing SPI environment..." >&2 + flash_erase /dev/mtd1 0 0 # clear u-boot env + fi + } +} + +function add_host_dependencies__new_uboot_wants_python3_odroidm1() { + declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-pyelftools" # @TODO: convert to array later +} + +# Include fw_setenv, configured to point to Petitboot's u-env mtd partition +PACKAGE_LIST_BOARD="libubootenv-tool" # libubootenv-tool provides fw_printenv and fw_setenv, for talking to U-Boot environment function post_family_tweaks__config_odroidm1_fwenv() { display_alert "Configuring fw_printenv and fw_setenv" "for Odroid M1" "info" # Addresses below come from - # - https://github.com/hardkernel/u-boot/blob/356906e6445378a45ac14ec184fc6e666b22338a/configs/odroid_rk3568_defconfig#L212-L213 - # - https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts#L637-L662 + # - (we use mainline, not vendor, so this is only for reference) + # https://github.com/hardkernel/u-boot/blob/356906e6445378a45ac14ec184fc6e666b22338a/configs/odroid_rk3568_defconfig#L212-L213 + # - (armbian's uboot patches try to keep this mtd partition layout valid) + # https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts#L637-L662 # The kernel DT has a convenient partition table, so mtd1 is ready to use, just gotta set the size. cat <<- 'FW_ENV_CONFIG' > "${SDCARD}"/etc/fw_env.config # MTD on the SPI for the Odroid-M1; this requires the MTD partition table in the board kernel DTS # MTD device name Device offset Env. size Flash sector size Number of sectors - /dev/mtd1 0x0000 0x20000 + /dev/mtd1 0x0000 0x20000 FW_ENV_CONFIG } diff --git a/config/sources/families/rk3568-odroid.conf b/config/sources/families/rk3568-odroid.conf index 236c0ce61d..55efc3939c 100644 --- a/config/sources/families/rk3568-odroid.conf +++ b/config/sources/families/rk3568-odroid.conf @@ -8,12 +8,6 @@ # source "${BASH_SOURCE%/*}/include/rockchip64_common.inc" -# Disable uboot compilation; this board boots from HK stuff in SPI first. -# We apply a bootscript, and use GPT partitions, so HK-stuff-in-SPI loads our boot.scr. -unset BOOTSOURCE -BOOTCONFIG="none" -BOOTSCRIPT='boot-rockchip64-vendor.cmd:boot.cmd' # Use ramaddr_r for loading fdt and armbianEnv; more flexible with overlays - LINUXFAMILY="rk3568-odroid" # a separate family for this (separate kernel deb) LINUXCONFIG='linux-rk3568-odroid-'$BRANCH WIREGUARD="no" diff --git a/patch/kernel/archive/rk3568-odroid-6.5/general-rockchip-overlays.patch b/patch/kernel/archive/rk3568-odroid-6.5/general-rockchip-overlays.patch new file mode 100644 index 0000000000..7c39c266c9 --- /dev/null +++ b/patch/kernel/archive/rk3568-odroid-6.5/general-rockchip-overlays.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Ayotte +Date: Wed, 5 Dec 2018 15:00:44 -0500 +Subject: add overlays framework for rockchip (scripts/Makefile.lib only) + +- rpardini: real overlays are now bare in "overlay" directory and are handled + directly by the patching scripts. No more null-patching of overlays. +--- + scripts/Makefile.lib | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib +index 9ea801a22569..3cde7d57e261 100644 +--- a/scripts/Makefile.lib ++++ b/scripts/Makefile.lib +@@ -88,6 +88,9 @@ base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, + + always-y += $(dtb-y) + ++# Overlay targets ++extra-y += $(dtbo-y) $(scr-y) $(dtbotxt-y) ++ + # Add subdir path + + ifneq ($(obj),.) +-- +Armbian + diff --git a/patch/kernel/archive/rk3568-odroid-6.5/overlay/README.rockchip-overlays b/patch/kernel/archive/rk3568-odroid-6.5/overlay/README.rockchip-overlays index 6f0b30acb6..2052bc8fad 100644 --- a/patch/kernel/archive/rk3568-odroid-6.5/overlay/README.rockchip-overlays +++ b/patch/kernel/archive/rk3568-odroid-6.5/overlay/README.rockchip-overlays @@ -1,69 +1 @@ -This document describes overlays provided in the kernel packages -For generic Armbian overlays documentation please see -https://docs.armbian.com/User-Guide_Allwinner_overlays/ - -### Platform: - -rockchip (Rockchip) - -### Provided overlays: - -- i2c0, i2c1, spi-spidev, uart0, uart1, pwm1, pwm2, pwm9 - -### Overlay details: - -### i2c0 - -Activates TWI/I2C bus I2C3 but it will be named as I2C0 on the userspace - -I2C3/I2C0 pins (SCL, SDA): GPIO3B.5, GPIO3B.6 - -### i2c1 - -Activates TWI/I2C bus I2C1 - -I2C1 pins (SCL, SDA): GPIO0B.3, GPIO0B.4 - -### spi-spidev - -Activates SPIdev device node (/dev/spidev0.0) for userspace SPI access, - -SPI 0 pins (MOSI, MISO, SCK, CS): GPIO2D.1, GPIO2D.0, GPIO2D.3, GPIO2D.2 - -Parameters: - -param_spidev_max_freq (int) - Maximum SPIdev frequency - Optional - Default: 1000000 - Range: 3000 - 100000000 - -### uart0 - -Activates UART0 (alias to serial1) - -UART0 pins (RX, TX): GPIO3D.7, GPIO3D.6 - -### uart1 - -Activates UART1 (alias to serial0) - -UART1 pins (RX, TX): GPIO0C.0, GPIO0C.1 - -### pwm1 - -Activates PWM1 (pwm1_m1) - -PWM1 pins: GPIO0B.5 - -### pwm2 - -Activates PWM2 (pwm2_m1) - -PWM2 pins: GPIO0B.6 - -### pwm9 - -Activates PWM9 (pwm9_m0) - -PWM9 pins: GPIO3B.2 +Overlays for the ODROID-M1, from HardKernel diff --git a/patch/u-boot/v2023.10/board_odroidm1/0001-rockchip-common-boot-USB-devices-first-then-mmc-s-nvme-scsi.patch b/patch/u-boot/v2023.10/board_odroidm1/0001-rockchip-common-boot-USB-devices-first-then-mmc-s-nvme-scsi.patch new file mode 100644 index 0000000000..a6cb0b4563 --- /dev/null +++ b/patch/u-boot/v2023.10/board_odroidm1/0001-rockchip-common-boot-USB-devices-first-then-mmc-s-nvme-scsi.patch @@ -0,0 +1,26 @@ +From 469ec598330cc46b01bd1f33a9fe422b9230d22c Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Wed, 16 Aug 2023 13:54:31 +0200 +Subject: [PATCH 1/4] rockchip-common: boot USB devices first, then mmc's, + nvme, scsi + +--- + include/configs/rockchip-common.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h +index 9121bba3738..1204113f63e 100644 +--- a/include/configs/rockchip-common.h ++++ b/include/configs/rockchip-common.h +@@ -13,7 +13,7 @@ + + #ifndef CONFIG_SPL_BUILD + +-#define BOOT_TARGETS "mmc1 mmc0 nvme scsi usb pxe dhcp spi" ++#define BOOT_TARGETS "usb mmc1 mmc0 nvme scsi pxe dhcp spi" + + #ifdef CONFIG_ARM64 + #define ROOT_UUID "B921B045-1DF0-41C3-AF44-4C6F280D3FAE;\0" +-- +2.41.0 + diff --git a/patch/u-boot/v2023.10/board_odroidm1/0002-board-rockchip-ODROID-M1-override-kernel-DT-for-xhci-otg-dr_mode.patch b/patch/u-boot/v2023.10/board_odroidm1/0002-board-rockchip-ODROID-M1-override-kernel-DT-for-xhci-otg-dr_mode.patch new file mode 100644 index 0000000000..0dd08dea59 --- /dev/null +++ b/patch/u-boot/v2023.10/board_odroidm1/0002-board-rockchip-ODROID-M1-override-kernel-DT-for-xhci-otg-dr_mode.patch @@ -0,0 +1,25 @@ +From 1b476772c1e8559e8acc0f50361e90ee0e8355fa Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Fri, 18 Aug 2023 00:22:23 +0200 +Subject: [PATCH 2/4] board: rockchip: ODROID-M1: override kernel DT for xhci + otg dr_mode + +--- + arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi b/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi +index 0fc360b06df..b4dec9d7a60 100644 +--- a/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi ++++ b/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi +@@ -35,3 +35,7 @@ + clock-frequency = <24000000>; + status = "okay"; + }; ++ ++&usb_host0_xhci { ++ dr_mode = "otg"; ++}; +-- +2.41.0 + diff --git a/patch/u-boot/v2023.10/board_odroidm1/0003-board-rockchip-ODROID-M1-enable-DM_USB_GADGET-UMS-RockUSB.patch b/patch/u-boot/v2023.10/board_odroidm1/0003-board-rockchip-ODROID-M1-enable-DM_USB_GADGET-UMS-RockUSB.patch new file mode 100644 index 0000000000..7a024d5feb --- /dev/null +++ b/patch/u-boot/v2023.10/board_odroidm1/0003-board-rockchip-ODROID-M1-enable-DM_USB_GADGET-UMS-RockUSB.patch @@ -0,0 +1,51 @@ +From e888d156c517613984d3cba08a8abaf48dc1c209 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Fri, 18 Aug 2023 00:38:03 +0200 +Subject: [PATCH 3/4] board: rockchip: ODROID-M1: enable DM_USB_GADGET & UMS & + RockUSB + +--- + configs/odroid-m1-rk3568_defconfig | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/configs/odroid-m1-rk3568_defconfig b/configs/odroid-m1-rk3568_defconfig +index 96b4e9ecdaf..f1dee2e0e24 100644 +--- a/configs/odroid-m1-rk3568_defconfig ++++ b/configs/odroid-m1-rk3568_defconfig +@@ -52,6 +52,8 @@ CONFIG_CMD_MMC=y + CONFIG_CMD_MTD=y + CONFIG_CMD_PCI=y + CONFIG_CMD_USB=y ++CONFIG_CMD_ROCKUSB=y ++CONFIG_CMD_USB_MASS_STORAGE=y + # CONFIG_CMD_SETEXPR is not set + CONFIG_CMD_INI=y + CONFIG_CMD_PMIC=y +@@ -68,6 +70,7 @@ CONFIG_SPL_SYSCON=y + CONFIG_AHCI_PCI=y + CONFIG_DWC_AHCI=y + CONFIG_SPL_CLK=y ++# CONFIG_USB_FUNCTION_FASTBOOT is not set + CONFIG_ROCKCHIP_GPIO=y + CONFIG_SYS_I2C_ROCKCHIP=y + CONFIG_MISC=y +@@ -103,6 +106,7 @@ CONFIG_SYS_NS16550_MEM32=y + CONFIG_ROCKCHIP_SFC=y + CONFIG_SYSRESET=y + CONFIG_USB=y ++CONFIG_DM_USB_GADGET=y + CONFIG_USB_XHCI_HCD=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_EHCI_GENERIC=y +@@ -110,5 +114,8 @@ CONFIG_USB_OHCI_HCD=y + CONFIG_USB_OHCI_GENERIC=y + CONFIG_USB_DWC3=y + CONFIG_USB_DWC3_GENERIC=y ++CONFIG_USB_GADGET=y ++CONFIG_USB_GADGET_DOWNLOAD=y ++CONFIG_USB_FUNCTION_ROCKUSB=y + CONFIG_FS_CRAMFS=y + CONFIG_ERRNO_STR=y +-- +2.41.0 + diff --git a/patch/u-boot/v2023.10/board_odroidm1/0004-board-rockchip-ODROID-M1-use-env-in-SPI-use-HK-s-offset-size-for-SPI-env-enable-LED_GPIO-use-preboot-to-blink-all-leds-leave-red-one-on-clear-env-once.patch b/patch/u-boot/v2023.10/board_odroidm1/0004-board-rockchip-ODROID-M1-use-env-in-SPI-use-HK-s-offset-size-for-SPI-env-enable-LED_GPIO-use-preboot-to-blink-all-leds-leave-red-one-on-clear-env-once.patch new file mode 100644 index 0000000000..bd6d6db744 --- /dev/null +++ b/patch/u-boot/v2023.10/board_odroidm1/0004-board-rockchip-ODROID-M1-use-env-in-SPI-use-HK-s-offset-size-for-SPI-env-enable-LED_GPIO-use-preboot-to-blink-all-leds-leave-red-one-on-clear-env-once.patch @@ -0,0 +1,54 @@ +From bb3fa48c0b803c8d42ad5b38279062ef4cfaa2d6 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Fri, 18 Aug 2023 00:40:38 +0200 +Subject: [PATCH 4/4] board: rockchip: ODROID-M1: use env in SPI; use HK's + offset/size for SPI env; enable LED_GPIO; use preboot to blink all leds & + leave red one on; clear env once + +--- + configs/odroid-m1-rk3568_defconfig | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/configs/odroid-m1-rk3568_defconfig b/configs/odroid-m1-rk3568_defconfig +index f1dee2e0e24..9b79fb77883 100644 +--- a/configs/odroid-m1-rk3568_defconfig ++++ b/configs/odroid-m1-rk3568_defconfig +@@ -10,6 +10,8 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y + CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc00000 + CONFIG_SF_DEFAULT_SPEED=24000000 + CONFIG_SF_DEFAULT_MODE=0x1000 ++CONFIG_ENV_SIZE=0x20000 ++CONFIG_ENV_OFFSET=0xe0000 + CONFIG_DEFAULT_DEVICE_TREE="rk3568-odroid-m1" + CONFIG_ROCKCHIP_RK3568=y + CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y +@@ -31,6 +33,8 @@ CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y + CONFIG_SPL_LOAD_FIT=y + CONFIG_LEGACY_IMAGE_FORMAT=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="echo armbian leds; led led-0 on; led led-1 on; sleep 0.1; led led-0 off; led led-1 off; sleep 0.1; led led-0 on; if test \"${armbian}\" = \"once\"; then echo armbian env already set once; else echo armbian resetting environment once; setenv armbian once; saveenv; fi" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3568-odroid-m1.dtb" + # CONFIG_DISPLAY_CPUINFO is not set + CONFIG_DISPLAY_BOARDINFO_LATE=y +@@ -64,6 +68,8 @@ CONFIG_MTDPARTS_DEFAULT="nor0:0x100000(reserved),0x200000(uboot),0x100000(splash + CONFIG_SPL_OF_CONTROL=y + CONFIG_OF_LIVE=y + CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" ++CONFIG_ENV_IS_IN_SPI_FLASH=y ++CONFIG_VERSION_VARIABLE=y + CONFIG_SPL_DM_SEQ_ALIAS=y + CONFIG_SPL_REGMAP=y + CONFIG_SPL_SYSCON=y +@@ -73,6 +79,8 @@ CONFIG_SPL_CLK=y + # CONFIG_USB_FUNCTION_FASTBOOT is not set + CONFIG_ROCKCHIP_GPIO=y + CONFIG_SYS_I2C_ROCKCHIP=y ++CONFIG_LED=y ++CONFIG_LED_GPIO=y + CONFIG_MISC=y + CONFIG_SUPPORT_EMMC_RPMB=y + CONFIG_MMC_DW=y +-- +2.41.0 +