From 0a3ab3b4fa096cf06842f391496576ed9e23f2d0 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 19 Nov 2023 19:20:19 +0100 Subject: [PATCH] ayufan: dev: rework all boards config to group them by chips --- configs/pinebook-pro-rk3399_defconfig | 1 + configs/rock-pi-4-rk3399_defconfig | 7 ++- configs/rock5b-rk3588_defconfig | 4 +- configs/rock64-rk3328_defconfig | 17 +++---- configs/rockpro64-rk3399_defconfig | 23 ++-------- dev-ayufan/blobs/pinebookpro/board.mk | 9 +--- dev-ayufan/blobs/quartz64a/board.mk | 12 +---- dev-ayufan/blobs/quartz64b/board.mk | 12 +---- dev-ayufan/blobs/quartz64b/erase-spi.cmd | 9 ---- dev-ayufan/blobs/quartz64b/flash-spi.cmd | 28 ----------- dev-ayufan/blobs/rock5b/board.mk | 12 +---- dev-ayufan/blobs/rock5b/erase-spi.cmd | 9 ---- dev-ayufan/blobs/rock5b/flash-spi.cmd | 28 ----------- dev-ayufan/blobs/rock64/board.mk | 14 +----- dev-ayufan/blobs/rockpi4b/board.mk | 8 +--- dev-ayufan/blobs/rockpi4b/erase-spi.cmd | 9 ---- dev-ayufan/blobs/rockpro64/board.mk | 15 +----- dev-ayufan/blobs/rockpro64/flash-spi.cmd | 28 ----------- dev-ayufan/build.mk | 35 +++----------- dev-ayufan/chips/rk3328/board.mk | 11 +++++ .../rock64 => chips/rk3328}/erase-spi.cmd | 0 .../quartz64a => chips/rk3328}/flash-spi.cmd | 12 ++--- dev-ayufan/chips/rk3399/board.mk | 7 +++ .../rk3399}/erase-spi.cmd | 0 .../rk3399}/flash-spi.cmd | 0 dev-ayufan/chips/rk3566/board.mk | 8 ++++ .../quartz64a => chips/rk3566}/erase-spi.cmd | 2 +- .../rock64 => chips/rk3566}/flash-spi.cmd | 4 +- dev-ayufan/chips/rk3588/board.mk | 10 ++++ .../rockpro64 => chips/rk3588}/erase-spi.cmd | 2 +- .../rockpi4b => chips/rk3588}/flash-spi.cmd | 10 ++-- dev-ayufan/deps.mk | 2 +- dev-ayufan/images.mk | 2 +- dev-ayufan/rockchip.mk | 13 ++++-- .../local/lib/u-boot-rockchip/loader-common | 4 +- dev-ayufan/scripts/build_loader | 46 +++++++++++++++++++ 36 files changed, 147 insertions(+), 266 deletions(-) delete mode 100644 dev-ayufan/blobs/quartz64b/erase-spi.cmd delete mode 100644 dev-ayufan/blobs/quartz64b/flash-spi.cmd delete mode 100644 dev-ayufan/blobs/rock5b/erase-spi.cmd delete mode 100644 dev-ayufan/blobs/rock5b/flash-spi.cmd delete mode 100644 dev-ayufan/blobs/rockpi4b/erase-spi.cmd delete mode 100644 dev-ayufan/blobs/rockpro64/flash-spi.cmd create mode 100644 dev-ayufan/chips/rk3328/board.mk rename dev-ayufan/{blobs/rock64 => chips/rk3328}/erase-spi.cmd (100%) rename dev-ayufan/{blobs/quartz64a => chips/rk3328}/flash-spi.cmd (62%) create mode 100644 dev-ayufan/chips/rk3399/board.mk rename dev-ayufan/{blobs/pinebookpro => chips/rk3399}/erase-spi.cmd (100%) rename dev-ayufan/{blobs/pinebookpro => chips/rk3399}/flash-spi.cmd (100%) create mode 100644 dev-ayufan/chips/rk3566/board.mk rename dev-ayufan/{blobs/quartz64a => chips/rk3566}/erase-spi.cmd (68%) rename dev-ayufan/{blobs/rock64 => chips/rk3566}/flash-spi.cmd (88%) create mode 100644 dev-ayufan/chips/rk3588/board.mk rename dev-ayufan/{blobs/rockpro64 => chips/rk3588}/erase-spi.cmd (68%) rename dev-ayufan/{blobs/rockpi4b => chips/rk3588}/flash-spi.cmd (66%) create mode 100755 dev-ayufan/scripts/build_loader diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig index 29c31891c4a4..44c304cf8b3c 100644 --- a/configs/pinebook-pro-rk3399_defconfig +++ b/configs/pinebook-pro-rk3399_defconfig @@ -116,3 +116,4 @@ CONFIG_VIDEO_ROCKCHIP=y CONFIG_DISPLAY_ROCKCHIP_EDP=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig index 086d5d09c07c..eecc77a3292f 100644 --- a/configs/rock-pi-4-rk3399_defconfig +++ b/configs/rock-pi-4-rk3399_defconfig @@ -11,10 +11,13 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock-pi-4a" CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_DM_RESET=y CONFIG_ROCKCHIP_RK3399=y +CONFIG_ROCKCHIP_SPI_IMAGE=y CONFIG_TARGET_EVB_RK3399=y CONFIG_SPL_STACK=0x400000 CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 +CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_SPI=y CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_PCI=y CONFIG_DEBUG_UART=y @@ -33,8 +36,10 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 -CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 +CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x80000 +CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y CONFIG_TPL=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_NVEDIT_EFI=y diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig index 06bf586388de..86040160ef59 100644 --- a/configs/rock5b-rk3588_defconfig +++ b/configs/rock5b-rk3588_defconfig @@ -21,7 +21,6 @@ CONFIG_TARGET_ROCK5B_RK3588=y CONFIG_SPL_STACK=0x400000 CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_SYS_LOAD_ADDR=0xc00800 @@ -45,8 +44,9 @@ CONFIG_SPL_BSS_MAX_SIZE=0x4000 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_STACK_R=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 CONFIG_SPL_SPI_LOAD=y -CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 +CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_SPL_ATF=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/configs/rock64-rk3328_defconfig b/configs/rock64-rk3328_defconfig index 99576806f5c3..a3608a83a417 100644 --- a/configs/rock64-rk3328_defconfig +++ b/configs/rock64-rk3328_defconfig @@ -11,25 +11,22 @@ CONFIG_SF_DEFAULT_SPEED=20000000 CONFIG_ENV_OFFSET=0x3F8000 CONFIG_DEFAULT_DEVICE_TREE="rk3328-rock64" CONFIG_DM_RESET=y -CONFIG_SPL_DM_SPI=y CONFIG_ROCKCHIP_RK3328=y CONFIG_TPL_ROCKCHIP_COMMON_BOARD=y +CONFIG_ROCKCHIP_SPI_IMAGE=y CONFIG_TPL_LIBCOMMON_SUPPORT=y CONFIG_TPL_LIBGENERIC_SUPPORT=y CONFIG_SPL_DRIVERS_MISC=y -CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_TARGET_ROCK64_RK3328=y CONFIG_SPL_STACK_R_ADDR=0x600000 CONFIG_SPL_STACK=0x400000 CONFIG_TPL_SYS_MALLOC_F_LEN=0x800 CONFIG_DEBUG_UART_BASE=0xFF130000 CONFIG_DEBUG_UART_CLOCK=24000000 -CONFIG_SYS_LOAD_ADDR=0x800800 -CONFIG_SMBIOS_PRODUCT_NAME="rock64_rk3328" CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y +CONFIG_SPL_SPI=y +CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 # CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y @@ -47,12 +44,11 @@ CONFIG_SPL_BOARD_INIT=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_STACK_R=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 CONFIG_SPL_I2C=y CONFIG_SPL_POWER=y -CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_POWER_SUPPORT=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_SPL_ATF=y CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y CONFIG_TPL_SYS_MALLOC_SIMPLE=y @@ -86,14 +82,13 @@ CONFIG_FASTBOOT_BUF_ADDR=0x800800 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y +CONFIG_LED=y CONFIG_MISC=y CONFIG_ROCKCHIP_EFUSE=y -CONFIG_LED=y CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y CONFIG_SPI_FLASH_GIGADEVICE=y CONFIG_SPI_FLASH_WINBOND=y -CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y CONFIG_PHY_ROCKCHIP_INNO_USB2=y diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig index ec9d56670397..26bb0da00906 100644 --- a/configs/rockpro64-rk3399_defconfig +++ b/configs/rockpro64-rk3399_defconfig @@ -7,8 +7,6 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x300000 CONFIG_ENV_SIZE=0x8000 -CONFIG_SPL_DM_SPI=y -CONFIG_ROCKCHIP_RK3399=y CONFIG_ENV_OFFSET=0x3F8000 CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64" CONFIG_DM_RESET=y @@ -23,13 +21,12 @@ CONFIG_SPL_SPI=y CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_PCI=y CONFIG_DEBUG_UART=y +# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_SPL_FIT_SIGNATURE=y CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_USE_PREBOOT=y -CONFIG_AHCI=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_MISC_INIT_R=y @@ -64,8 +61,6 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_SCSI_AHCI=y -CONFIG_AHCI_PCI=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SATA=y CONFIG_SCSI_AHCI=y @@ -73,7 +68,6 @@ CONFIG_AHCI_PCI=y CONFIG_SATA_SIL=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y -CONFIG_DM_KEYBOARD=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_MISC=y @@ -86,14 +80,11 @@ CONFIG_MMC_SDHCI_ROCKCHIP=y CONFIG_SF_DEFAULT_BUS=1 CONFIG_SPI_FLASH_GIGADEVICE=y CONFIG_SPI_FLASH_WINBOND=y -CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y CONFIG_NVME_PCI=y CONFIG_PHY_ROCKCHIP_INNO_USB2=y CONFIG_PHY_ROCKCHIP_TYPEC=y -CONFIG_DM_PCI=y -CONFIG_PCIE_ROCKCHIP=y CONFIG_PMIC_RK8XX=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y @@ -116,29 +107,21 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC3=y -CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_KEYBOARD=y CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_ROCKCHIP_USB2_PHY=y CONFIG_USB_KEYBOARD=y -CONFIG_USB_KEYBOARD_FN_KEYS=y -CONFIG_USB_GADGET=y CONFIG_USB_HOST_ETHER=y CONFIG_USB_ETHER_ASIX=y CONFIG_USB_ETHER_ASIX88179=y CONFIG_USB_ETHER_MCS7830=y CONFIG_USB_ETHER_RTL8152=y CONFIG_USB_ETHER_SMSC95XX=y +CONFIG_USB_GADGET=y CONFIG_VIDEO=y -CONFIG_DM_VIDEO=y -CONFIG_VIDEO_BPP16=y -CONFIG_VIDEO_BPP32=y CONFIG_DISPLAY=y CONFIG_VIDEO_ROCKCHIP=y -CONFIG_VIDEO_ROCKCHIP_MAX_XRES=3840 -CONFIG_VIDEO_ROCKCHIP_MAX_YRES=2160 CONFIG_DISPLAY_ROCKCHIP_HDMI=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y diff --git a/dev-ayufan/blobs/pinebookpro/board.mk b/dev-ayufan/blobs/pinebookpro/board.mk index b4bf9cc168dc..66f1abd4ba8c 100644 --- a/dev-ayufan/blobs/pinebookpro/board.mk +++ b/dev-ayufan/blobs/pinebookpro/board.mk @@ -1,8 +1,3 @@ +include dev-ayufan/chips/rk3399/board.mk + UBOOT_DEFCONFIG ?= pinebook-pro-rk3399_defconfig -BL31 ?= tmp/rkbin/bin/rk33/rk3399_bl31_v1.36.elf -BOARD_CHIP ?= rk3399 -LOADER_BIN ?= tmp/rkbin/loaders/rk3399_loader_v1.30.130.bin -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -IMAGES ?= flash-spi erase-spi -LOADERS ?= rksd_loader rkspi_loader diff --git a/dev-ayufan/blobs/quartz64a/board.mk b/dev-ayufan/blobs/quartz64a/board.mk index 679149907ab5..61f925a86828 100644 --- a/dev-ayufan/blobs/quartz64a/board.mk +++ b/dev-ayufan/blobs/quartz64a/board.mk @@ -1,11 +1,3 @@ +include dev-ayufan/chips/rk3566/board.mk + UBOOT_DEFCONFIG ?= quartz64-a-rk3566_defconfig -BL31 ?= tmp/rkbin/bin/rk35/rk3568_bl31_v1.43.elf -BOARD_CHIP ?= rk3568 -UBOOT_TPL = -ROCKCHIP_TPL ?= tmp/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.18.bin -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -IMAGES ?= flash-spi erase-spi -LOADERS ?= rksd_loader rkspi_loader -RKSD_LOADER ?= idbloader.img -RKSPI_LOADER ?= idbloader-spi.img diff --git a/dev-ayufan/blobs/quartz64b/board.mk b/dev-ayufan/blobs/quartz64b/board.mk index 45bfdb1c274b..7841ff1c4548 100644 --- a/dev-ayufan/blobs/quartz64b/board.mk +++ b/dev-ayufan/blobs/quartz64b/board.mk @@ -1,11 +1,3 @@ +include dev-ayufan/chips/rk3566/board.mk + UBOOT_DEFCONFIG ?= quartz64-b-rk3566_defconfig -BL31 ?= tmp/rkbin/bin/rk35/rk3568_bl31_v1.43.elf -BOARD_CHIP ?= rk3568 -UBOOT_TPL = -ROCKCHIP_TPL ?= tmp/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.18.bin -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -IMAGES ?= flash-spi erase-spi -LOADERS ?= rksd_loader rkspi_loader -RKSD_LOADER ?= idbloader.img -RKSPI_LOADER ?= idbloader-spi.img diff --git a/dev-ayufan/blobs/quartz64b/erase-spi.cmd b/dev-ayufan/blobs/quartz64b/erase-spi.cmd deleted file mode 100644 index c0754b50d6bd..000000000000 --- a/dev-ayufan/blobs/quartz64b/erase-spi.cmd +++ /dev/null @@ -1,9 +0,0 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' - -# erase flash -run blink_power blink_power -sf probe -sf erase 0 400000 - -# blink forever -while true; do run blink_power; sleep 1; done diff --git a/dev-ayufan/blobs/quartz64b/flash-spi.cmd b/dev-ayufan/blobs/quartz64b/flash-spi.cmd deleted file mode 100644 index b9fbd100ffe6..000000000000 --- a/dev-ayufan/blobs/quartz64b/flash-spi.cmd +++ /dev/null @@ -1,28 +0,0 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' -setenv blink_standby 'led diy off; sleep 0.1; led diy on' - -# first read existing loader -run blink_power -sf probe - -# or load rkspi_loader.img and write it to 0 offset of spi -# or fail badly - -if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then - load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} rkspi_loader.img - - # erase flash - run blink_power blink_power - sf erase 0 400000 - - # write flash - run blink_power blink_power blink_power - sf write ${kernel_addr_r} 0 ${filesize} - - # blink forever - while true; do run blink_power; sleep 1; done -else - # blink forever - echo "missing rkspi_loader.img" - while true; do run blink_standby; sleep 1; done -fi diff --git a/dev-ayufan/blobs/rock5b/board.mk b/dev-ayufan/blobs/rock5b/board.mk index efb2fb782398..9b33ffa278d3 100644 --- a/dev-ayufan/blobs/rock5b/board.mk +++ b/dev-ayufan/blobs/rock5b/board.mk @@ -1,11 +1,3 @@ +include dev-ayufan/chips/rk3588/board.mk + UBOOT_DEFCONFIG ?= rock5b-rk3588_defconfig -BL31 ?= tmp/rkbin/bin/rk35/rk3588_bl31_v1.40.elf -BOARD_CHIP ?= rk3588 -UBOOT_TPL = -ROCKCHIP_TPL ?= tmp/rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.12.bin -LOADER_BIN ?= tmp/rkbin/loaders/rk3588_spl_loader_v1.12.112.bin -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -IMAGES ?= flash-spi erase-spi -LOADERS ?= rksd_loader -RKSD_LOADER ?= idbloader.img diff --git a/dev-ayufan/blobs/rock5b/erase-spi.cmd b/dev-ayufan/blobs/rock5b/erase-spi.cmd deleted file mode 100644 index 9ad0dd25e4da..000000000000 --- a/dev-ayufan/blobs/rock5b/erase-spi.cmd +++ /dev/null @@ -1,9 +0,0 @@ -setenv blink_power 'led status off; sleep 0.1; led status on' - -# erase flash -run blink_power blink_power -sf probe -sf erase 0 400000 - -# blink forever -while true; do run blink_power; sleep 1; done diff --git a/dev-ayufan/blobs/rock5b/flash-spi.cmd b/dev-ayufan/blobs/rock5b/flash-spi.cmd deleted file mode 100644 index 617964000f67..000000000000 --- a/dev-ayufan/blobs/rock5b/flash-spi.cmd +++ /dev/null @@ -1,28 +0,0 @@ -setenv blink_power 'led status off; sleep 0.1; led status on' -setenv blink_standby 'led status off; sleep 0.1; led status on' - -# first read existing loader -run blink_power -sf probe - -# or load rksd_loader.img and write it to 8000 offset of spi -# or fail badly - -if size ${devtype} ${devnum}:${distro_bootpart} rksd_loader.img; then - load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} rksd_loader.img - - # erase flash - run blink_power blink_power - sf erase 0 400000 - - # write flash - run blink_power blink_power blink_power - sf write ${kernel_addr_r} 8000 ${filesize} - - # blink forever - while true; do run blink_power; sleep 1; done -else - # blink forever - echo "missing rksd_loader.img" - while true; do run blink_standby; sleep 1; done -fi diff --git a/dev-ayufan/blobs/rock64/board.mk b/dev-ayufan/blobs/rock64/board.mk index d615e9b25e2e..cc6e6798e286 100644 --- a/dev-ayufan/blobs/rock64/board.mk +++ b/dev-ayufan/blobs/rock64/board.mk @@ -1,13 +1,3 @@ +include dev-ayufan/chips/rk3328/board.mk + UBOOT_DEFCONFIG ?= rock64-rk3328_defconfig -BL31 ?= tmp/rkbin/bin/rk33/rk322xh_bl31_v1.49.elf -BOARD_CHIP ?= rk3328 -ifneq (,$(FLASH_SPI)) -LOADER_BIN ?= tmp/rkbin/loaders/rk3328_loader_v1.08.244_for_spi_nor_build_Aug_7_2017.bin -else -LOADER_BIN ?= tmp/rkbin/loaders/rk3328_loader_v1.19.250.bin -endif -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -IMAGES ?= flash-spi erase-spi -FLASH_LOADER ?= rksd_loader -LOADERS ?= rksd_loader diff --git a/dev-ayufan/blobs/rockpi4b/board.mk b/dev-ayufan/blobs/rockpi4b/board.mk index dd5cb8e3e7d3..63ac1d29ea3a 100644 --- a/dev-ayufan/blobs/rockpi4b/board.mk +++ b/dev-ayufan/blobs/rockpi4b/board.mk @@ -1,7 +1,3 @@ +include dev-ayufan/chips/rk3399/board.mk + UBOOT_DEFCONFIG ?= rock-pi-4-rk3399_defconfig -BL31 ?= tmp/rkbin/bin/rk33/rk3399_bl31_v1.36.elf -BOARD_CHIP ?= rk3399 -LOADER_BIN ?= tmp/rkbin/loaders/rk3399_loader_v1.30.130.bin -IMAGES ?= flash-spi erase-spi -FLASH_LOADER ?= rksd_loader -LOADERS ?= rksd_loader rkspi_loader diff --git a/dev-ayufan/blobs/rockpi4b/erase-spi.cmd b/dev-ayufan/blobs/rockpi4b/erase-spi.cmd deleted file mode 100644 index 9ad0dd25e4da..000000000000 --- a/dev-ayufan/blobs/rockpi4b/erase-spi.cmd +++ /dev/null @@ -1,9 +0,0 @@ -setenv blink_power 'led status off; sleep 0.1; led status on' - -# erase flash -run blink_power blink_power -sf probe -sf erase 0 400000 - -# blink forever -while true; do run blink_power; sleep 1; done diff --git a/dev-ayufan/blobs/rockpro64/board.mk b/dev-ayufan/blobs/rockpro64/board.mk index 5c1c40f8328b..82445a2792cf 100644 --- a/dev-ayufan/blobs/rockpro64/board.mk +++ b/dev-ayufan/blobs/rockpro64/board.mk @@ -1,14 +1,3 @@ +include dev-ayufan/chips/rk3399/board.mk + UBOOT_DEFCONFIG ?= rockpro64-rk3399_defconfig -BL31 ?= tmp/rkbin/bin/rk33/rk3399_bl31_v1.36.elf -BOARD_CHIP ?= rk3399 -ifneq (,$(FLASH_SPI)) -LOADER_BIN ?= tmp/rkbin/loaders/rk3399_loader_spinor_v1.30.114.bin -LOADER_OFFSET ?= 0 -LOADER_FLASH ?= rkspi_loader -else -LOADER_BIN ?= tmp/rkbin/loaders/rk3399_loader_v1.30.130.bin -LOADER_OFFSET ?= 64 -LOADER_FLASH ?= rksd_loader -endif -IMAGES ?= flash-spi erase-spi -LOADERS ?= rksd_loader rkspi_loader diff --git a/dev-ayufan/blobs/rockpro64/flash-spi.cmd b/dev-ayufan/blobs/rockpro64/flash-spi.cmd deleted file mode 100644 index b9fbd100ffe6..000000000000 --- a/dev-ayufan/blobs/rockpro64/flash-spi.cmd +++ /dev/null @@ -1,28 +0,0 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' -setenv blink_standby 'led diy off; sleep 0.1; led diy on' - -# first read existing loader -run blink_power -sf probe - -# or load rkspi_loader.img and write it to 0 offset of spi -# or fail badly - -if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then - load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} rkspi_loader.img - - # erase flash - run blink_power blink_power - sf erase 0 400000 - - # write flash - run blink_power blink_power blink_power - sf write ${kernel_addr_r} 0 ${filesize} - - # blink forever - while true; do run blink_power; sleep 1; done -else - # blink forever - echo "missing rkspi_loader.img" - while true; do run blink_standby; sleep 1; done -fi diff --git a/dev-ayufan/build.mk b/dev-ayufan/build.mk index 3de9063aa107..0f47aca99854 100644 --- a/dev-ayufan/build.mk +++ b/dev-ayufan/build.mk @@ -6,7 +6,6 @@ UBOOT_MAKE ?= make KBUILD_OUTPUT=$(UBOOT_OUTPUT_DIR) BL31=$(realpath $(BL31)) RO UBOOT_LOADERS ?= $(addprefix $(UBOOT_OUTPUT_DIR)/, $(addsuffix .img, $(LOADERS))) UBOOT_TPL ?= $(UBOOT_OUTPUT_DIR)/tpl/u-boot-tpl.bin UBOOT_SPL ?= $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin -UBOOT_OFFSET ?= 0x200 tmp/u-boot-$(BOARD_TARGET)/.config: configs/$(UBOOT_DEFCONFIG) $(UBOOT_MAKE) $(UBOOT_DEFCONFIG) @@ -23,36 +22,14 @@ $(UBOOT_OUTPUT_DIR)/u-boot.itb: $(UBOOT_OUTPUT_DIR)/u-boot.bin $(UBOOT_TPL) $(UBOOT_SPL): $(UBOOT_OUTPUT_DIR)/u-boot.itb $(UBOOT_OUTPUT_DIR)/rksd_loader.img: $(UBOOT_OUTPUT_DIR)/u-boot.itb $(UBOOT_TPL) $(UBOOT_SPL) -ifeq (,$(RKSD_LOADER)) - $(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(word 1,$(UBOOT_TPL) $(UBOOT_SPL)) $@.tmp -ifneq (,$(UBOOT_TPL)) - cat $(UBOOT_SPL) >> $@.tmp -endif -else - cp $(UBOOT_OUTPUT_DIR)/$(RKSD_LOADER) $@.tmp -endif - CUR_SIZE=$$(stat -c%s $@.tmp); MAX_SIZE=$$((($$(($(UBOOT_OFFSET)))-64)*512)); \ - [ $$CUR_SIZE -le $$MAX_SIZE ] || ( echo "Too big $$CUR_SIZE < $$MAX_SIZE" && exit 1 ) - dd if=$(UBOOT_OUTPUT_DIR)/u-boot.itb of=$@.tmp seek=$$(($$(($(UBOOT_OFFSET)))-64)) conv=notrunc - mv $@.tmp $@ + grep CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR= $(UBOOT_OUTPUT_DIR)/.config + dev-ayufan/scripts/build_loader $@ $(UBOOT_OUTPUT_DIR)/idbloader.img $(IDBLOADER_OFFSET) $(UBOOT_OUTPUT_DIR) CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 512 $(UBOOT_OUTPUT_DIR)/rkspi_loader.img: $(UBOOT_OUTPUT_DIR)/u-boot.itb $(UBOOT_TPL) $(UBOOT_SPL) -ifeq (,$(RKSPI_LOADER)) - $(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(word 1,$(UBOOT_TPL) $(UBOOT_SPL)) $@.tmp -ifneq (,$(UBOOT_TPL)) - cat $(UBOOT_SPL) >> $@.tmp -endif -else - cp $(UBOOT_OUTPUT_DIR)/$(RKSPI_LOADER) $@.tmp -endif - @CUR_SIZE=$$(stat -c%s $@.tmp); MAX_SIZE=$$((($$(($(UBOOT_OFFSET)))-64)*512)); \ - [ $$CUR_SIZE -le $$MAX_SIZE ] || ( echo "Too big $$CUR_SIZE < $$MAX_SIZE" && exit 1 ) - # pad every 2k with 2k of zeros - for i in $$(seq 1 $$(($$(($$UBOOT_OFFSET))/4))); do dd count=4 status=none; dd if=/dev/zero count=4 status=none; done < $@.tmp > $@.tmp2 - mv $@.tmp2 $@.tmp - # We write at 1024 offset - dd if=$(UBOOT_OUTPUT_DIR)/u-boot.itb of=$@.tmp seek=$$(($$(($(UBOOT_OFFSET)))*2)) conv=notrunc - mv $@.tmp $@ + grep CONFIG_SPL_SPI_LOAD=y $(UBOOT_OUTPUT_DIR)/.config + grep CONFIG_SYS_SPI_U_BOOT_OFFS= $(UBOOT_OUTPUT_DIR)/.config + grep CONFIG_ROCKCHIP_SPI_IMAGE=y $(UBOOT_OUTPUT_DIR)/.config + dev-ayufan/scripts/build_loader $@ $(UBOOT_OUTPUT_DIR)/idbloader-spi.img $$(($(IDBLOADER_SPI_OFFSET)*512)) $(UBOOT_OUTPUT_DIR) CONFIG_SYS_SPI_U_BOOT_OFFS 1 .PHONY: u-boot-menuconfig # edit u-boot config and save as defconfig u-boot-menuconfig: diff --git a/dev-ayufan/chips/rk3328/board.mk b/dev-ayufan/chips/rk3328/board.mk new file mode 100644 index 000000000000..f8adf697a1a9 --- /dev/null +++ b/dev-ayufan/chips/rk3328/board.mk @@ -0,0 +1,11 @@ +BL31 ?= tmp/rkbin/bin/rk33/rk322xh_bl31_v1.49.elf +BOARD_CHIP ?= rk3328 +ifneq (,$(FLASH_SPI)) +RKDEV_LOADER_BIN ?= tmp/rkbin/loaders/rk3328_loader_v1.08.244_for_spi_nor_build_Aug_7_2017.bin +else +RKDEV_LOADER_BIN ?= tmp/rkbin/loaders/rk3328_loader_v1.19.250.bin +endif +IMAGES ?= flash-spi erase-spi +LOADERS ?= rksd_loader rkspi_loader +IDBLOADER_OFFSET ?= 64 +IDBLOADER_SPI_OFFSET ?= 64 diff --git a/dev-ayufan/blobs/rock64/erase-spi.cmd b/dev-ayufan/chips/rk3328/erase-spi.cmd similarity index 100% rename from dev-ayufan/blobs/rock64/erase-spi.cmd rename to dev-ayufan/chips/rk3328/erase-spi.cmd diff --git a/dev-ayufan/blobs/quartz64a/flash-spi.cmd b/dev-ayufan/chips/rk3328/flash-spi.cmd similarity index 62% rename from dev-ayufan/blobs/quartz64a/flash-spi.cmd rename to dev-ayufan/chips/rk3328/flash-spi.cmd index b9fbd100ffe6..6aa6394e2548 100644 --- a/dev-ayufan/blobs/quartz64a/flash-spi.cmd +++ b/dev-ayufan/chips/rk3328/flash-spi.cmd @@ -1,11 +1,11 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' -setenv blink_standby 'led diy off; sleep 0.1; led diy on' +setenv blink_power 'led power off; sleep 0.1; led power on' +setenv blink_standby 'led standby off; sleep 0.1; led standby on' # first read existing loader run blink_power sf probe -# or load rkspi_loader.img and write it to 0 offset of spi +# or load rkspi_loader.img and write it to 8000 offset of spi # or fail badly if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then @@ -13,16 +13,16 @@ if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then # erase flash run blink_power blink_power - sf erase 0 400000 + sf erase 8000 3f8000 # write flash run blink_power blink_power blink_power - sf write ${kernel_addr_r} 0 ${filesize} + sf write ${kernel_addr_r} 8000 ${filesize} # blink forever while true; do run blink_power; sleep 1; done else # blink forever - echo "missing rkspi_loader.img" + echo "missing rksd_loader.img" while true; do run blink_standby; sleep 1; done fi diff --git a/dev-ayufan/chips/rk3399/board.mk b/dev-ayufan/chips/rk3399/board.mk new file mode 100644 index 000000000000..9053cfe78070 --- /dev/null +++ b/dev-ayufan/chips/rk3399/board.mk @@ -0,0 +1,7 @@ +BOARD_CHIP ?= rk3399 +BL31 ?= tmp/rkbin/bin/rk33/rk3399_bl31_v1.36.elf +RKDEV_LOADER_BIN ?= tmp/rkbin/loaders/rk3399_loader_v1.30.130.bin +IMAGES ?= flash-spi erase-spi +LOADERS ?= rksd_loader rkspi_loader +IDBLOADER_OFFSET ?= 64 +IDBLOADER_SPI_OFFSET ?= 0 diff --git a/dev-ayufan/blobs/pinebookpro/erase-spi.cmd b/dev-ayufan/chips/rk3399/erase-spi.cmd similarity index 100% rename from dev-ayufan/blobs/pinebookpro/erase-spi.cmd rename to dev-ayufan/chips/rk3399/erase-spi.cmd diff --git a/dev-ayufan/blobs/pinebookpro/flash-spi.cmd b/dev-ayufan/chips/rk3399/flash-spi.cmd similarity index 100% rename from dev-ayufan/blobs/pinebookpro/flash-spi.cmd rename to dev-ayufan/chips/rk3399/flash-spi.cmd diff --git a/dev-ayufan/chips/rk3566/board.mk b/dev-ayufan/chips/rk3566/board.mk new file mode 100644 index 000000000000..c9da02f1f31d --- /dev/null +++ b/dev-ayufan/chips/rk3566/board.mk @@ -0,0 +1,8 @@ +BL31 ?= tmp/rkbin/bin/rk35/rk3568_bl31_v1.43.elf +BOARD_CHIP ?= rk3566 +UBOOT_TPL = +ROCKCHIP_TPL ?= tmp/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.18.bin +IMAGES ?= flash-spi erase-spi +LOADERS ?= rksd_loader rkspi_loader +IDBLOADER_OFFSET ?= 64 +IDBLOADER_SPI_OFFSET ?= 64 diff --git a/dev-ayufan/blobs/quartz64a/erase-spi.cmd b/dev-ayufan/chips/rk3566/erase-spi.cmd similarity index 68% rename from dev-ayufan/blobs/quartz64a/erase-spi.cmd rename to dev-ayufan/chips/rk3566/erase-spi.cmd index c0754b50d6bd..4921013f078d 100644 --- a/dev-ayufan/blobs/quartz64a/erase-spi.cmd +++ b/dev-ayufan/chips/rk3566/erase-spi.cmd @@ -1,4 +1,4 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' +setenv blink_power 'led power off; sleep 0.1; led power on' # erase flash run blink_power blink_power diff --git a/dev-ayufan/blobs/rock64/flash-spi.cmd b/dev-ayufan/chips/rk3566/flash-spi.cmd similarity index 88% rename from dev-ayufan/blobs/rock64/flash-spi.cmd rename to dev-ayufan/chips/rk3566/flash-spi.cmd index 856be70f2224..bd37ef5df5ab 100644 --- a/dev-ayufan/blobs/rock64/flash-spi.cmd +++ b/dev-ayufan/chips/rk3566/flash-spi.cmd @@ -8,8 +8,8 @@ sf probe # or load rksd_loader.img and write it to 8000 offset of spi # or fail badly -if size ${devtype} ${devnum}:${distro_bootpart} rksd_loader.img; then - load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} rksd_loader.img +if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then + load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} rkspi_loader.img # erase flash run blink_power blink_power diff --git a/dev-ayufan/chips/rk3588/board.mk b/dev-ayufan/chips/rk3588/board.mk new file mode 100644 index 000000000000..f537788be7c2 --- /dev/null +++ b/dev-ayufan/chips/rk3588/board.mk @@ -0,0 +1,10 @@ +BL31 ?= tmp/rkbin/bin/rk35/rk3588_bl31_v1.40.elf +BOARD_CHIP ?= rk3588 +UBOOT_TPL = +ROCKCHIP_TPL ?= tmp/rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.12.bin +RKDEV_LOADER_BIN ?= tmp/rkbin/loaders/rk3588_spl_loader_v1.12.112.bin +LOADER_FLASH ?= rksd_loader +IMAGES ?= flash-spi erase-spi +LOADERS ?= rksd_loader rkspi_loader +IDBLOADER_OFFSET ?= 64 +IDBLOADER_SPI_OFFSET ?= 64 diff --git a/dev-ayufan/blobs/rockpro64/erase-spi.cmd b/dev-ayufan/chips/rk3588/erase-spi.cmd similarity index 68% rename from dev-ayufan/blobs/rockpro64/erase-spi.cmd rename to dev-ayufan/chips/rk3588/erase-spi.cmd index c0754b50d6bd..4921013f078d 100644 --- a/dev-ayufan/blobs/rockpro64/erase-spi.cmd +++ b/dev-ayufan/chips/rk3588/erase-spi.cmd @@ -1,4 +1,4 @@ -setenv blink_power 'led work off; sleep 0.1; led work on' +setenv blink_power 'led power off; sleep 0.1; led power on' # erase flash run blink_power blink_power diff --git a/dev-ayufan/blobs/rockpi4b/flash-spi.cmd b/dev-ayufan/chips/rk3588/flash-spi.cmd similarity index 66% rename from dev-ayufan/blobs/rockpi4b/flash-spi.cmd rename to dev-ayufan/chips/rk3588/flash-spi.cmd index b0c51693bdb8..d27a26479900 100644 --- a/dev-ayufan/blobs/rockpi4b/flash-spi.cmd +++ b/dev-ayufan/chips/rk3588/flash-spi.cmd @@ -1,11 +1,11 @@ -setenv blink_power 'led status off; sleep 0.1; led status on' -setenv blink_standby 'led status off; sleep 0.1; led status on' +setenv blink_power 'led power off; sleep 0.1; led power on' +setenv blink_standby 'led standby off; sleep 0.1; led standby on' # first read existing loader run blink_power sf probe -# or load rkspi_loader.img and write it to 0 offset of spi +# or load rkspi_loader.img and write it to 8000 offset of spi # or fail badly if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then @@ -13,11 +13,11 @@ if size ${devtype} ${devnum}:${distro_bootpart} rkspi_loader.img; then # erase flash run blink_power blink_power - sf erase 0 400000 + sf erase 8000 3f8000 # write flash run blink_power blink_power blink_power - sf write ${kernel_addr_r} 0 ${filesize} + sf write ${kernel_addr_r} 8000 ${filesize} # blink forever while true; do run blink_power; sleep 1; done diff --git a/dev-ayufan/deps.mk b/dev-ayufan/deps.mk index 1421dea6d5a6..9d192680af2b 100644 --- a/dev-ayufan/deps.mk +++ b/dev-ayufan/deps.mk @@ -1,4 +1,4 @@ -$(filter tmp/rkbin/%, $(BL31) $(UBOOT_TPL) $(UBOOT_SPL) $(LOADER_BIN) $(ROCKCHIP_TPL)): +$(filter tmp/rkbin/%, $(BL31) $(UBOOT_TPL) $(UBOOT_SPL) $(RKDEV_LOADER_BIN) $(ROCKCHIP_TPL)): mkdir -p $$(dirname "$@") curl --fail -L https://github.com/ayufan-rock64/rkbin/raw/master/$(subst tmp/rkbin/,,$@) > $@.tmp mv $@.tmp $@ diff --git a/dev-ayufan/images.mk b/dev-ayufan/images.mk index a5dce8b29d2e..e9b54e7ec2d2 100644 --- a/dev-ayufan/images.mk +++ b/dev-ayufan/images.mk @@ -1,4 +1,4 @@ -$(UBOOT_OUTPUT_DIR)/%/boot.scr: dev-ayufan/blobs/$(BOARD_TARGET)/%.cmd +$(UBOOT_OUTPUT_DIR)/%/boot.scr: dev-ayufan/chips/$(BOARD_CHIP)/%.cmd mkdir -p $$(dirname $@) mkimage -C none -A arm -T script -d $< $@ diff --git a/dev-ayufan/rockchip.mk b/dev-ayufan/rockchip.mk index 39da4bed580a..67cac5c315a5 100644 --- a/dev-ayufan/rockchip.mk +++ b/dev-ayufan/rockchip.mk @@ -1,13 +1,16 @@ +RKDEV_OFFSET ?= $(IDBLOADER_OFFSET) +RKDEV_IMAGE ?= rksd_loader + .PHONY: loader-download-mode -loader-download-mode: $(LOADER_BIN) - rkdeveloptool db $(LOADER_BIN) +loader-download-mode: $(RKDEV_LOADER_BIN) + rkdeveloptool db $(RKDEV_LOADER_BIN) sleep 1s .PHONY: loader-write-clear loader-write-clear: rkdeveloptool rid dd if=/dev/zero of=$(UBOOT_OUTPUT_DIR)/clear.img count=1 - rkdeveloptool wl $(LOADER_OFFSET) $(UBOOT_OUTPUT_DIR)/clear.img + rkdeveloptool wl $(RKDEV_OFFSET) $(UBOOT_OUTPUT_DIR)/clear.img ifneq (,$(FULL_WIPE)) rkdeveloptool wl 512 $(UBOOT_OUTPUT_DIR)/clear.img rkdeveloptool wl 1024 $(UBOOT_OUTPUT_DIR)/clear.img @@ -16,10 +19,10 @@ endif .PHONY: loader-write-flash loader-write-flash: rkdeveloptool rid - rkdeveloptool wl $(LOADER_OFFSET) $(UBOOT_OUTPUT_DIR)/$(LOADER_FLASH).img + rkdeveloptool wl $(RKDEV_OFFSET) $(UBOOT_OUTPUT_DIR)/$(RKDEV_IMAGE).img .PHONY: loader-boot # boot loader over USB -loader-boot: $(UBOOT_OUTPUT_DIR)/$(LOADER_FLASH).img +loader-boot: $(UBOOT_OUTPUT_DIR)/$(RKDEV_IMAGE).img ./dev-make loader-download-mode ./dev-make loader-write-flash ./dev-make loader-write-clear diff --git a/dev-ayufan/root/usr/local/lib/u-boot-rockchip/loader-common b/dev-ayufan/root/usr/local/lib/u-boot-rockchip/loader-common index bce96c9cb21f..b26343fa929c 100644 --- a/dev-ayufan/root/usr/local/lib/u-boot-rockchip/loader-common +++ b/dev-ayufan/root/usr/local/lib/u-boot-rockchip/loader-common @@ -36,7 +36,7 @@ fi case "$PACKAGE_NAME" in *-rock64-*) SD_LOADER=/usr/lib/u-boot-rock64/rksd_loader.img - SPI_LOADER=/usr/lib/u-boot-rock64/rksd_loader.img + SPI_LOADER=/usr/lib/u-boot-rock64/rkspi_loader.img SPI_OFFSET=$((64*512)) BOARD=pine64,rock64 ;; @@ -64,7 +64,7 @@ case "$PACKAGE_NAME" in *-rock5b-*) SD_LOADER=/usr/lib/u-boot-rock5b/rksd_loader.img - SPI_LOADER=/usr/lib/u-boot-rock5b/rksd_loader.img + SPI_LOADER=/usr/lib/u-boot-rock5b/rkspi_loader.img SPI_OFFSET=$((64*512)) BOARD=radxa,rock-5b ;; diff --git a/dev-ayufan/scripts/build_loader b/dev-ayufan/scripts/build_loader new file mode 100755 index 000000000000..2f95eaaa2f14 --- /dev/null +++ b/dev-ayufan/scripts/build_loader @@ -0,0 +1,46 @@ +#!/bin/bash + +if [[ $# -ne 6 ]]; then + echo "usage: $0 " + exit 1 +fi + +set -eo pipefail + +OUTPUT="$1" +IDBLOADER="$2" +IDBLOADER_OFFSET="$3" +UBOOT_DIR="$4" +UBOOT_CONFIG="$5" +BLOCK_SIZE="$6" + +eval $(cat "$UBOOT_DIR/.config" | grep "^$UBOOT_CONFIG=") +UBOOT_OFFSET="${!UBOOT_CONFIG}" +if [[ -z "$UBOOT_OFFSET" ]]; then + echo "The '${UBOOT_CONFIG}' is undefined." + exit 1 +fi + +IDBLOADER_SIZE=$(stat -c%s "$IDBLOADER") + +echo "IDBLOADER_OFFSET=${IDBLOADER_OFFSET}" +echo "UBOOT_OFFSET=${UBOOT_OFFSET}" +echo "BLOCK_SIZE=${BLOCK_SIZE}" + +if [[ $((IDBLOADER_SIZE+IDBLOADER_OFFSET*BLOCK_SIZE)) -gt $((UBOOT_OFFSET*BLOCK_SIZE)) ]]; then + echo "Cannot write u-boot.itb at $UBOOT_OFFSET, since it will overlap with idbloader.img" + exit 1 +fi + +cp "$IDBLOADER" "$OUTPUT.tmp" +echo "Appending u-boot.itb at $((UBOOT_OFFSET-IDBLOADER_OFFSET)), block size $BLOCK_SIZE..." +dd if="$UBOOT_DIR/u-boot.itb" of="$OUTPUT.tmp" seek=$((UBOOT_OFFSET-IDBLOADER_OFFSET)) bs="$BLOCK_SIZE" conv=notrunc + +SIZE=$(stat -c%s "$OUTPUT.tmp") +MAX_SIZE=$((4*1024*1024-IDBLOADER_OFFSET*BLOCK_SIZE)) + +if [[ $SIZE -gt $MAX_SIZE ]]; then + echo "The resulting image is $SIZE which is larger than $MAX_SIZE." + exit 1 +fi +mv "$OUTPUT.tmp" "$OUTPUT"