summaryrefslogtreecommitdiff
path: root/alt-rootfs-installer/socs.d
diff options
context:
space:
mode:
authorAndrew Guschin <guschin@altlinux.org>2026-07-25 18:01:43 +0400
committerAndrew Guschin <guschin@altlinux.org>2026-07-25 18:01:43 +0400
commitc1bb6287d299628fa6753e155e82510c373a567a (patch)
treec8bfc3b324ddfd423fbe38fc1593b402f5c2af7a /alt-rootfs-installer/socs.d
vendor alt-rootfs-installer v0.7.4
Diffstat (limited to 'alt-rootfs-installer/socs.d')
-rw-r--r--alt-rootfs-installer/socs.d/AllWinner-aarch64.sh36
-rw-r--r--alt-rootfs-installer/socs.d/AllWinner-riscv64.sh47
-rwxr-xr-xalt-rootfs-installer/socs.d/K1x-riscv64.sh92
-rw-r--r--alt-rootfs-installer/socs.d/Rockchips-aarch64.sh60
-rw-r--r--alt-rootfs-installer/socs.d/SiFive-riscv64.sh61
-rw-r--r--alt-rootfs-installer/socs.d/StarFive-riscv64.sh79
-rwxr-xr-xalt-rootfs-installer/socs.d/unknown-soc.sh9
7 files changed, 384 insertions, 0 deletions
diff --git a/alt-rootfs-installer/socs.d/AllWinner-aarch64.sh b/alt-rootfs-installer/socs.d/AllWinner-aarch64.sh
new file mode 100644
index 0000000..ffc7908
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/AllWinner-aarch64.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+MEDIATABLE=msdos
+START_SECTOR=16 # MiB
+ROOTPART_NUM=1
+[ -n "$SYSCON" ] || SYSCON=ttyS0,115200n8
+
+soc_write_bootloader() {
+ [ -n "$TMPROOT" ] || mount_partition
+ # Write U-Boot
+ set_path_to_uboot
+ print_message "Searching U-Boot files for ${TARGET-}..."
+ [ -d "$UBOOT" ] ||
+ fatal_error "U-Boot files for ${TARGET-} were not found"
+ print_done
+ if [ -f "$UBOOT/u-boot.itb" ]; then
+ print_message "Writing sunxi-spl.bin for ${TARGET-}..."
+ dd if="$UBOOT/sunxi-spl.bin" of="${MEDIA-}" bs=8k seek=1 ||
+ fatal_error "failed to write SPL"
+ sync
+ print_done
+
+ print_message "Writing U-Boot image for ${TARGET-}..."
+ dd if="$UBOOT/u-boot.itb" of="${MEDIA-}" bs=8k seek=5 ||
+ fatal_error "failed to write U-Boot"
+ sync
+ print_done
+ else
+ print_message "Writing u-boot-sunxi-with-spl.bin..."
+ dd if="$UBOOT/u-boot-sunxi-with-spl.bin" of="${MEDIA-}" bs=1024 seek=8 ||
+ fatal_error "failed to write U-Boot"
+ sync
+ print_done
+ fi
+}
diff --git a/alt-rootfs-installer/socs.d/AllWinner-riscv64.sh b/alt-rootfs-installer/socs.d/AllWinner-riscv64.sh
new file mode 100644
index 0000000..1c2c828
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/AllWinner-riscv64.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+BBL=2E54B353-1271-4842-806F-E436D6AF6985
+FSBL=5B193300-FC78-40CD-8002-E86C45580B47
+
+MEDIATABLE=gpt
+START_SECTOR=34 # MiB
+ROOTPART_NUM=1
+CONSOLE=1
+[ -n "$SYSCON" ] || SYSCON=ttyS0,115200n8
+
+soc_write_bootloader() {
+ if [ "$MEDIATABLE" = gpt ]; then
+ [ -n "$ROOTFS" ] || clear_riscv64_bootloader_partition
+
+ # resize gpt table to 7 KiB (56 entries partition)
+ sgdisk -S 56 "${MEDIA-}"
+ fi
+
+ [ -n "$TMPROOT" ] || mount_partition
+ # Write U-Boot
+ set_path_to_uboot
+ print_message "Searching U-Boot files for ${TARGET-}..."
+ [ -d "$UBOOT" ] ||
+ fatal_error "U-Boot files for ${TARGET-} were not found"
+ print_done
+ if [ -f "$UBOOT/u-boot.itb" ]; then
+ print_message "Writing sunxi-spl.bin for ${TARGET-}..."
+ dd if="$UBOOT/sunxi-spl.bin" of="${MEDIA-}" bs=8k seek=1 ||
+ fatal_error "failed to write SPL"
+ sync
+ print_done
+
+ print_message "Writing U-Boot image for ${TARGET-}..."
+ dd if="$UBOOT/u-boot.itb" of="${MEDIA-}" bs=8k seek=5 ||
+ fatal_error "failed to write U-Boot"
+ sync
+ print_done
+ else
+ print_message "Writing u-boot-sunxi-with-spl.bin..."
+ dd if="$UBOOT/u-boot-sunxi-with-spl.bin" of="${MEDIA-}" bs=1024 seek=8 ||
+ fatal_error "failed to write U-Boot"
+ sync
+ print_done
+ fi
+}
diff --git a/alt-rootfs-installer/socs.d/K1x-riscv64.sh b/alt-rootfs-installer/socs.d/K1x-riscv64.sh
new file mode 100755
index 0000000..3ec7c35
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/K1x-riscv64.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+FSBL_UID=496846A9-9E0A-4ABA-9736-A41A9FC6B5D8
+ENV_UID=5F720A03-FF87-4B93-A46F-F5788594EA3B
+OPENSBI_UID=0FCB0F7C-4A6C-4C81-8C69-4F0A67F0D5E7
+UBOOT_UID=3E5B8F92-0BFF-4E20-8E88-7EEC40A7CC42
+
+MEDIATABLE=gpt
+ROOTPART_NUM=1
+START_SECTOR=4 # MiB
+CONSOLE=1
+
+soc_write_bootloader() {
+ unmount_partition
+
+ if [ -n "$ROOTFS" ]; then
+ print_message "Creating partitions for FSBL, ENV, OpenSBI and U-Boot..."
+
+ sgdisk -a 1 \
+ --new=0:256:+256K --change-name=0:fsbl \
+ --typecode=0:"$FSBL_UID" \
+ --new=0:768:+64K --change-name=0:env \
+ --typecode=0:"$ENV_UID" \
+ --new=0:2048:+1M --change-name=0:opensbi \
+ --typecode=0:"$OPENSBI_UID" \
+ --new=0:4096:+2M --change-name=0:uboot \
+ --typecode=0:"$UBOOT_UID" \
+ "$MEDIA" ||
+ fatal_error "failed to create bootloader partitions"
+
+ sgdisk --sort "$MEDIA" ||
+ fatal_error "failed to sort partitions by sector"
+ print_done
+ sync_partitions
+ fi
+
+ local FSBLPART ENVPART UBOOTPART OPENSBIPART
+ PART_NUMS=$(ls "$MEDIA"* | sed "s:$MEDIA::" | sed 's/^p//')
+ for PART_NUM in $PART_NUMS; do
+ local CODE
+ CODE=$(sgdisk -i "$PART_NUM" "$MEDIA" |
+ grep 'Partition GUID code:' | cut -d ' ' -f 4)
+ case "$CODE" in
+ "$FSBL_UID") FSBLPART="${MEDIA}${partsuffix-}${PART_NUM}";;
+ "$ENV_UID") ENVPART="${MEDIA}${partsuffix-}${PART_NUM}";;
+ "$OPENSBI_UID") OPENSBIPART="${MEDIA}${partsuffix-}${PART_NUM}";;
+ "$UBOOT_UID") UBOOTPART="${MEDIA}${partsuffix-}${PART_NUM}";;
+ esac
+ done
+
+ # ensure we have all necessary partitions
+ [ -n "$FSBLPART" ] && [ -n "$ENVPART" ] && [ -n "$OPENSBIPART" ] && [ -n "$UBOOTPART" ] ||
+ fatal_error "bootloader partitions not found: expected FSBL, ENV, OpenSBI, U-Boot"
+
+ # find actual rootfs after bootloader zone
+ local RAW_START=$((START_SECTOR * 2048))
+ local PART_NUMS PART_NUM PS
+ PART_NUMS=$(ls "$MEDIA"* | sed "s:$MEDIA::" | sed 's/^p//')
+ for PART_NUM in $PART_NUMS; do
+ PS=$(sgdisk -i "$PART_NUM" "$MEDIA" 2>/dev/null |
+ grep 'First sector:' | tr -s ' ' | cut -d ' ' -f 3)
+ if [ -n "$PS" ] && [ "$PS" -ge "$RAW_START" ]; then
+ ROOTPART_NUM=$PART_NUM
+ break
+ fi
+ done
+
+ ROOTPART="${MEDIA}${partsuffix-}${ROOTPART_NUM}"
+
+ mount_partition
+
+ TARGET=spacemit-k1x set_path_to_uboot
+ print_message "Searching for U-Boot files for ${TARGET-}..."
+ [ -d "$UBOOT" ] || fatal_error "U-Boot files for ${TARGET-} were not found"
+ print_done
+
+ print_message "Searching for OpenSBI files for ${TARGET-}..."
+ OPENSBI="${TMPROOT-}/usr/share/opensbi-spacemit/k1x"
+ [ -d "$OPENSBI" ] || fatal_error "OpenSBI files for ${TARGET-} were not found"
+ print_done
+
+ write_partition_blob "bootinfo" "$UBOOT/bootinfo_sd.bin" "$MEDIA" "1M"
+
+ write_partition_blob "FSBL" "$UBOOT/FSBL.bin" "$FSBLPART"
+
+ write_partition_blob "U-Boot environment" "$UBOOT/u-boot-env-default.bin" "$ENVPART"
+
+ write_partition_blob "U-Boot" "$UBOOT/u-boot.itb" "$UBOOTPART"
+
+ write_partition_blob "OpenSBI" "$OPENSBI/generic/firmware/fw_dynamic.itb" "$OPENSBIPART"
+}
diff --git a/alt-rootfs-installer/socs.d/Rockchips-aarch64.sh b/alt-rootfs-installer/socs.d/Rockchips-aarch64.sh
new file mode 100644
index 0000000..fccd090
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/Rockchips-aarch64.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+MEDIATABLE=msdos
+ROOTPART_NUM=1
+START_SECTOR=16 # MiB
+[ -n "$SYSCON" ] || SYSCON=ttyS2,1500000n8
+
+soc_write_bootloader() {
+ [ -n "$TMPROOT" ] || mount_partition
+ # Write U-Boot
+ set_path_to_uboot
+ local IDBSPL IDBLOADER FIT FIT_SEEK_FILE FIT_SEEK
+ UBOOT="$UBOOT/u-boot-rockchip.bin"
+ UBOOT_ZST="$UBOOT.zst"
+ IDBSPL="$UBOOT/idbspl.img"
+ IDBLOADER="$UBOOT/idbloader.img"
+ FIT="$UBOOT/u-boot.itb"
+ FIT_SEEK_FILE="$UBOOT/u-boot.itb.seek"
+ FIT_SEEK=16384
+
+ if [ -f "$UBOOT_ZST" ]; then
+ UBOOT="$UBOOT_ZST"
+ CAT="unzstd -c"
+ else
+ CAT=cat
+ fi
+ if [ -f "$UBOOT" ]; then
+ print_message "Writing u-boot-rockchip.bin..."
+ $CAT "$UBOOT" | dd of="$MEDIA" seek=64 || fatal_error "Error: Failed to write u-boot-rockchip.bin!!!"
+ sync
+ print_done
+ else
+ print_message "Warning: $UBOOT is missing. Try find idbspl.img..."
+ if [ -f "$IDBSPL" ]; then
+ print_message "Writing idbspl.img..."
+ dd if="$IDBSPL" of="$MEDIA" seek=64 || fatal_error "Error: Failed to write idbspl.img"
+ sync
+ print_done
+ else
+ print_message "Warning: idbspl.img is missing. Try find idbloader.img..."
+ if [ -f "$IDBLOADER" ]; then
+ print_message "Writing idbloader.img..."
+ dd if="$IDBLOADER" of="$MEDIA" seek=64 || fatal_error "Error: Failed to write idbloader.img"
+ sync
+ print_done
+ else
+ print_message "Warning: idbloader.img is missing. Try find and write u-boot.itb without first loader..."
+ fi
+ fi
+ [ -f "$FIT" ] || fatal_error "Error: u-boot.itb not found!!!"
+ print_message "Writing U-Boot FIT image..."
+ if [ -f "$FIT_SEEK_FILE" ]; then
+ FIT_SEEK="$(cat FIT_SEEK_FILE | head -n1)"
+ fi
+ dd if="$FIT" of="$MEDIA" seek="$FIT_SEEK" || fatal_error "Error: failed to write u-boot.itb!!!"
+ sync
+ print_done
+ fi
+}
diff --git a/alt-rootfs-installer/socs.d/SiFive-riscv64.sh b/alt-rootfs-installer/socs.d/SiFive-riscv64.sh
new file mode 100644
index 0000000..dd42613
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/SiFive-riscv64.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+BBL=2E54B353-1271-4842-806F-E436D6AF6985
+FSBL=5B193300-FC78-40CD-8002-E86C45580B47
+SPL=$FSBL
+UBOOT_CODE=$BBL
+
+MEDIATABLE=gpt
+ROOTPART_NUM=1
+# ~1 MiB for U-Boot SPL
+# ~4 MiB for OpenSBI + U-Boot
+# + some overhead for future usage
+START_SECTOR=34 # MiB
+[ -n "$EFI" ] || BOOTFLAG=legacy_boot
+[ -n "$VNC" ] ||
+ case "$TARGET" in
+ sifive_unleashed) VNC=1;;
+ *) VNC=0;;
+ esac
+CONSOLE=1
+[ -n "$SYSCON" ] || SYSCON=ttySIF0,115200n8
+
+soc_write_bootloader() {
+ unmount_partition
+ [ -n "$ROOTFS" ] || clear_riscv64_bootloader_partition
+
+ print_message "Creating partitions for U-Boot SPL and OpenSBI + U-Boot..."
+ LASTPART_NUM=$(sgdisk -p "$MEDIA" | tail -n1 | tr -s ' ' | cut -f 2 -d ' ')
+ let 'SPLPART_NUM = LASTPART_NUM + 1'
+ let 'UBOOTPART_NUM = LASTPART_NUM + 2'
+ sgdisk -a 1 \
+ --new=$SPLPART_NUM:34:2081 --change-name=$SPLPART_NUM:spl \
+ --typecode=$SPLPART_NUM:"$SPL" \
+ --new=$UBOOTPART_NUM:2082:10273 --change-name=$UBOOTPART_NUM:uboot \
+ --typecode=$UBOOTPART_NUM:"$UBOOT_CODE" \
+ "$MEDIA" ||
+ fatal_error "failed to create U-Boot SPL and OpenSBI + U-Boot partitions"
+ print_done
+
+ sync_partitions
+ mount_partition
+
+ set_path_to_uboot
+ print_message "Writing U-Boot SPL for ${TARGET-}..."
+ SPL_BLOB="$(readlink -e "$UBOOT/u-boot-spl.bin")"
+ [ -f "${SPL_BLOB-}" ] || fatal_error "${SPL_BLOB-} was not found"
+ SPLPART="${MEDIA}${partsuffix-}${SPLPART_NUM}"
+ [ -b "${SPLPART-}" ] || fatal_error "${SPLPART-} is not a block device or does not exist"
+ dd if="$SPL_BLOB" of="$SPLPART" bs=4M status=none || fatal_error "failed to write U-Boot SPL"
+ print_done
+
+ print_message "Writing OpenSBI + U-Boot for ${TARGET-}..."
+ UBOOT_BLOB="$(readlink -e "$UBOOT/u-boot.itb")"
+ [ -f "${UBOOT_BLOB-}" ] || fatal_error "${UBOOT_BLOB-}} was not found"
+ UBOOTPART="${MEDIA}${partsuffix-}${UBOOTPART_NUM}"
+ [ -b "${UBOOTPART-}" ] || fatal_error "${UBOOTPART-} is not a block device or does not exist"
+ dd if="$UBOOT_BLOB" of="$UBOOTPART" bs=4M status=none || fatal_error "failed to write OpenSBI+U-Boot"
+ sync
+ print_done
+}
diff --git a/alt-rootfs-installer/socs.d/StarFive-riscv64.sh b/alt-rootfs-installer/socs.d/StarFive-riscv64.sh
new file mode 100644
index 0000000..faae8d0
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/StarFive-riscv64.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+SPL_UID=2E54B353-1271-4842-806F-E436D6AF6985
+UBOOT_UID=BC13C2FF-59E6-4262-A352-B275FD6F7172
+FSBL=$SPL_UID
+BBL=$UBOOT_UID
+
+MEDIATABLE=gpt
+ROOTPART_NUM=1
+START_SECTOR=16 # MiB
+CONSOLE=1
+
+soc_write_bootloader() {
+ unmount_partition
+ [ -n "$ROOTFS" ] || clear_riscv64_bootloader_partition
+
+ print_message "Creating partitions for U-Boot SPL and OpenSBI + U-Boot..."
+ sgdisk \
+ --set-alignment=2 \
+ --new=0:4096:8191 \
+ --change-name=0:spl \
+ --typecode=0:"$SPL_UID" \
+ --new=0:8192:16383 \
+ --change-name=0:uboot \
+ --typecode=0:"$UBOOT_UID" \
+ "$MEDIA" ||
+ fatal_error "failed to create U-Boot SPL and OpenSBI + U-Boot partitions"
+ print_done
+
+ print_message "Checking partition numbers..."
+ SPLPART_NUM="" UBOOTPART_NUM=""
+ local PART_NUMS=$(ls "$MEDIA"* |sed "s:$MEDIA::" |sed 's/^p//')
+ local PART_NUM
+ for PART_NUM in $PART_NUMS; do
+ FIND_PART_CODE=$(sgdisk -i "$PART_NUM" "$MEDIA" |
+ grep 'Partition GUID code:' | cut -d ' ' -f 4)
+ case "$FIND_PART_CODE" in
+ "$SPL_UID") SPLPART_NUM="$PART_NUM";;
+ "$UBOOT_UID") UBOOTPART_NUM="$PART_NUM";;
+ esac
+ done
+ if [[ "$UBOOTPART_NUM" != 2 && "$SPLPART_NUM" == 2 ]]; then
+ sgdisk --transpose=$SPLPART_NUM:$UBOOTPART_NUM "$MEDIA" ||
+ fatal_error "failed to swap U-Boot SPL and OpenSBI + U-Boot partitions"
+ SPLPART_NUM=$UBOOTPART_NUM
+ UBOOTPART_NUM=2
+ elif [[ "$UBOOTPART_NUM" != 2 && "$SPLPART_NUM" != 2 ]]; then
+ print_message "WARNING: Swap $UBOOTPART_NUM with 2-nd partition or else it won't boot!"
+ print_message " # sgdisk --transpose=2:$UBOOTPART_NUM \"$MEDIA\""
+ fi
+ print_done
+
+ sync_partitions
+ mount_partition
+
+ print_message "Searching for U-Boot files..."
+ # All starfive boards use same binary
+ TARGET=starfive_visionfive2 set_path_to_uboot
+ SPL_BLOB="$(readlink -e "$UBOOT/u-boot-spl.bin.normal.out")"
+ [ -f "${SPL_BLOB-}" ] || fatal_error "${SPL_BLOB-} was not found"
+ UBOOT_BLOB="$(readlink -e "$UBOOT/u-boot.itb")"
+ [ -f "${UBOOT_BLOB-}" ] || fatal_error "${UBOOT_BLOB-}} was not found"
+ print_done
+
+ print_message "Writing U-Boot SPL for ${TARGET-}..."
+ SPLPART="${MEDIA}${partsuffix-}${SPLPART_NUM}"
+ [ -b "${SPLPART-}" ] || fatal_error "${SPLPART-} is not a block device or does not exist"
+ dd if="$SPL_BLOB" of="$SPLPART" bs=4M status=none || fatal_error "failed to write U-Boot SPL"
+ sync
+ print_done
+
+ print_message "Writing OpenSBI + U-Boot for ${TARGET-}..."
+ UBOOTPART="${MEDIA}${partsuffix-}${UBOOTPART_NUM}"
+ [ -b "${UBOOTPART-}" ] || fatal_error "${UBOOTPART-} is not a block device or does not exist"
+ dd if="$UBOOT_BLOB" of="$UBOOTPART" bs=4M status=none || fatal_error "failed to write OpenSBI+U-Boot"
+ sync
+ print_done
+}
diff --git a/alt-rootfs-installer/socs.d/unknown-soc.sh b/alt-rootfs-installer/socs.d/unknown-soc.sh
new file mode 100755
index 0000000..c5fdebb
--- /dev/null
+++ b/alt-rootfs-installer/socs.d/unknown-soc.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim:sw=8:noet
+
+[ -n "${MEDIATABLE-}" ] || MEDIATABLE=msdos
+ROOTPART_NUM=1
+
+soc_write_bootloader() {
+ [ -n "$TMPROOT" ] || mount_partition
+}