summaryrefslogtreecommitdiffstats
path: root/target/linux/starfive/image
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/starfive/image')
-rw-r--r--target/linux/starfive/image/Config.in5
-rw-r--r--target/linux/starfive/image/Makefile85
-rwxr-xr-xtarget/linux/starfive/image/gen_starfive_sdcard_img.sh24
-rw-r--r--target/linux/starfive/image/mmc.bootscript.jh71004
-rw-r--r--target/linux/starfive/image/mmc.bootscript.jh71105
5 files changed, 123 insertions, 0 deletions
diff --git a/target/linux/starfive/image/Config.in b/target/linux/starfive/image/Config.in
new file mode 100644
index 0000000000..e8e44e066e
--- /dev/null
+++ b/target/linux/starfive/image/Config.in
@@ -0,0 +1,5 @@
+config STARFIVE_SD_BOOT_PARTSIZE
+ int "Boot (SD Card) filesystem partition size (in MB)"
+ depends on TARGET_starfive
+ default 32
+
diff --git a/target/linux/starfive/image/Makefile b/target/linux/starfive/image/Makefile
new file mode 100644
index 0000000000..51bc9c3cc6
--- /dev/null
+++ b/target/linux/starfive/image/Makefile
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2023 Toco Technologies <info@toco.ae>
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/image.mk
+
+FAT32_BLOCK_SIZE=1024
+FAT32_BLOCKS=$(shell echo $$(($(CONFIG_STARFIVE_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
+
+define Build/boot-scr-jh7110
+ rm -f $@-boot.scr
+ mkimage -A riscv -O linux -T script -C none -a 0 -e 0 -d mmc.bootscript.jh7110 $@-boot.scr
+endef
+
+define Build/boot-scr-jh7100
+ rm -f $@-boot.scr
+ mkimage -A riscv -O linux -T script -C none -a 0 -e 0 -d mmc.bootscript.jh7100 $@-boot.scr
+endef
+
+define Build/riscv-sdcard
+ rm -f $@.boot #$(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
+ mkfs.fat $@.boot -C $(FAT32_BLOCKS)
+ mcopy -i $@.boot $(LINUX_DIR)/arch/riscv/boot/dts/$(DEVICE_DTS).dtb ::dtb
+ mcopy -i $@.boot $@-boot.scr ::boot.scr.uimg
+ mcopy -i $@.boot $(IMAGE_KERNEL) ::Image
+ ./gen_starfive_sdcard_img.sh \
+ $@ \
+ $@.boot \
+ $(IMAGE_ROOTFS) \
+ $(CONFIG_STARFIVE_SD_BOOT_PARTSIZE) \
+ $(CONFIG_TARGET_ROOTFS_PARTSIZE)
+endef
+
+define Device/Default
+ PROFILES := Default
+ KERNEL_NAME := Image
+ KERNEL := kernel-bin
+ IMAGES := sdcard.img.gz
+ IMAGE/sdcard.img.gz := boot-scr-jh7110 | riscv-sdcard | append-metadata | gzip
+endef
+
+define Device/JH7100
+ PROFILES := Default
+ KERNEL_NAME := Image
+ KERNEL := kernel-bin
+ IMAGES := sdcard.img.gz
+ IMAGE/sdcard.img.gz := boot-scr-jh7100 | riscv-sdcard | append-metadata | gzip
+endef
+
+define Device/visionfive2-v1.2a
+ DEVICE_VENDOR := StarFive
+ DEVICE_MODEL := VisionFive2 v1.2a
+ DEVICE_DTS := starfive/jh7110-starfive-visionfive-2-v1.2a
+ DEVICE_PACKAGES := kmod-eeprom-at24 kmod-pcie-starfive kmod-usb3 kmod-usb-cdns3-starfive
+endef
+TARGET_DEVICES += visionfive2-v1.2a
+
+define Device/visionfive2-v1.3b
+ DEVICE_VENDOR := StarFive
+ DEVICE_MODEL := VisionFive2 v1.3b
+ DEVICE_DTS := starfive/jh7110-starfive-visionfive-2-v1.3b
+ DEVICE_PACKAGES := kmod-eeprom-at24 kmod-pcie-starfive kmod-usb3 kmod-usb-cdns3-starfive
+endef
+TARGET_DEVICES += visionfive2-v1.3b
+
+define Device/beaglev-starlight
+ $(call Device/JH7100)
+ DEVICE_VENDOR := BeagleV
+ DEVICE_MODEL := Starlight
+ DEVICE_DTS := starfive/jh7100-beaglev-starlight
+endef
+TARGET_DEVICES += beaglev-starlight
+
+define Device/visionfive-v1
+ $(call Device/JH7100)
+ DEVICE_VENDOR := StarFive
+ DEVICE_MODEL := VisionFive v1
+ DEVICE_DTS := starfive/jh7100-starfive-visionfive-v1
+ DEVICE_PACKAGES := kmod-eeprom-at24 kmod-brcmfmac cypress-firmware-43430-sdio wpad-basic-mbedtls \
+ kmod-usb3 kmod-usb-cdns3-starfive
+endef
+TARGET_DEVICES += visionfive-v1
+
+$(eval $(call BuildImage))
diff --git a/target/linux/starfive/image/gen_starfive_sdcard_img.sh b/target/linux/starfive/image/gen_starfive_sdcard_img.sh
new file mode 100755
index 0000000000..ac0c30c5d9
--- /dev/null
+++ b/target/linux/starfive/image/gen_starfive_sdcard_img.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2023 OpenWrt.org
+#
+
+set -ex
+[ $# -eq 5 ] || {
+ echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
+ exit 1
+}
+
+OUTPUT="$1"
+BOOTFS="$2"
+ROOTFS="$3"
+BOOTFSSIZE="$4"
+ROOTFSSIZE="$5"
+
+set $(ptgen -o $OUTPUT -v -g -T sifiveu_spl -N loader1 -p 1024 -T sifiveu_uboot -N loader2 -p 4096 -t ef -N boot -p ${BOOTFSSIZE}M -N rootfs -p ${ROOTFSSIZE}M)
+
+ROOTFSOFFSET=$(($7 / 512))
+
+dd bs=512 if="$BOOTFS" of="$OUTPUT" seek=10274 conv=notrunc
+dd bs=512 if="$ROOTFS" of="$OUTPUT" seek=${ROOTFSOFFSET} conv=notrunc
diff --git a/target/linux/starfive/image/mmc.bootscript.jh7100 b/target/linux/starfive/image/mmc.bootscript.jh7100
new file mode 100644
index 0000000000..a6f19ae22e
--- /dev/null
+++ b/target/linux/starfive/image/mmc.bootscript.jh7100
@@ -0,0 +1,4 @@
+fatload mmc 0:3 0x84000000 Image
+fatload mmc 0:3 0x88000000 dtb
+setenv bootargs "earlyprintk console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/mmcblk0p4"
+booti 0x84000000 - 0x88000000
diff --git a/target/linux/starfive/image/mmc.bootscript.jh7110 b/target/linux/starfive/image/mmc.bootscript.jh7110
new file mode 100644
index 0000000000..aeb2e82275
--- /dev/null
+++ b/target/linux/starfive/image/mmc.bootscript.jh7110
@@ -0,0 +1,5 @@
+fatload mmc 1:3 0xa0000000 Image
+fatload mmc 1:3 0x46000000 dtb
+run chipa_set_linux
+setenv bootargs "earlyprintk console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/mmcblk1p4"
+booti 0xa0000000 - 0x46000000