Jelajahi Sumber

Add Rock64 support

Cameron Nemo 4 tahun lalu
induk
melakukan
388993eb51
3 mengubah file dengan 49 tambahan dan 21 penghapusan
  1. 8 0
      lib.sh.in
  2. 39 20
      mkimage.sh.in
  3. 2 1
      mkplatformfs.sh.in

+ 8 - 0
lib.sh.in

@@ -297,6 +297,7 @@ set_target_arch_from_platform() {
         GCP*) XBPS_TARGET_ARCH="x86_64";;
         pinebookpro*) XBPS_TARGET_ARCH="aarch64";;
         pinephone*) XBPS_TARGET_ARCH="aarch64";;
+        rock64*) XBPS_TARGET_ARCH="aarch64";;
         *) die "$PROGNAME: Unable to compute target architecture from platform";;
     esac
 
@@ -319,6 +320,13 @@ set_cachedir() {
     : "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}"
 }
 
+rk33xx_flash_uboot() {
+    local dir="$1"
+    local dev="$2"
+    dd if="${dir}/idbloader.img" of="${dev}" seek=64 conv=notrunc,fsync >/dev/null 2>&1
+    dd if="${dir}/u-boot.itb" of="${dev}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1
+}
+
 # These should all resolve even if they won't have the appropriate
 # repodata files for the selected architecture.
 : "${XBPS_REPOSITORY:=--repository=http://alpha.de.repo.voidlinux.org/current \

+ 39 - 20
mkimage.sh.in

@@ -117,14 +117,14 @@ PLATFORM="${PLATFORM%-PLATFORMFS*}"
 
 # Be absolutely certain the platform is supported before continuing
 case "$PLATFORM" in
-    bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|*-musl);;
+    bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|rock64|*-musl);;
     *) die "The $PLATFORM is not supported, exiting..."
 esac
 
-# Default for bigger boot partion on pinebookpro since it needs to fit
-# at least 2 Kernels + initramfs
+# Default for bigger boot partion on rk33xx devices since it needs to
+# fit at least 2 Kernels + initramfs
 case "$PLATFORM" in
-    pinebookpro*)
+    pinebookpro*|rock64*)
         : "${BOOT_FSSIZE:=256MiB}"
         ;;
 esac
@@ -172,17 +172,6 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then
     _args="-I -F16"
 fi
 
-BOOT_START=2048
-ROOT_START=
-case "$PLATFORM" in
-    pinebookpro*)
-        BOOT_START=32768
-        # Without this, sfdisk creates root partition starting at
-        # 2048, overlapping u-boot reserved space and boot partition.
-        ROOT_START=$BOOT_START
-        ;;
-esac
-
 case "$PLATFORM" in
     cubieboard2|cubietruck|ci20*|odroid-c2*)
         # These platforms use a single partition for the entire filesystem.
@@ -200,11 +189,26 @@ _EOF
         # partition (64M by default) and the rest of the space as the
         # root filesystem.  This is the generally preferred disk
         # layout for new platforms.
-        sfdisk "${FILENAME}" <<_EOF
+        case "$PLATFORM" in
+            pinebookpro*|rock64*)
+                # rk33xx devices use GPT and need more space reserved
+                sfdisk "$FILENAME" <<_EOF
+label: gpt
+unit: sectors
+first-lba: 32768
+name=BootFS, size=${BOOT_FSSIZE}, type=L, bootable
+name=RootFS,                      type=L
+_EOF
+                ;;
+            *)
+                # The rest use MBR and need less space reserved
+                sfdisk "${FILENAME}" <<_EOF
 label: dos
-${BOOT_START},${BOOT_FSSIZE},b,*
-${ROOT_START},+,L
+2048,${BOOT_FSSIZE},b,*
+,+,L
 _EOF
+                ;;
+        esac
         LOOPDEV=$(losetup --show --find --partscan "$FILENAME")
         # Normally we need to quote to prevent argument splitting, but
         # we explicitly want argument splitting here.
@@ -298,9 +302,24 @@ ci20*)
     dd if="${ROOTFS}/boot/u-boot-spl.bin" of="${LOOPDEV}" obs=512 seek=1 >/dev/null 2>&1
     dd if="${ROOTFS}/boot/u-boot.img" of="${LOOPDEV}" obs=1K seek=14 >/dev/null 2>&1
     ;;
+rock64*)
+    rk33xx_flash_uboot "${ROOTFS}/usr/lib/rock64-uboot" "$LOOPDEV"
+    # populate the extlinux.conf file
+    cat >"${ROOTFS}/etc/default/extlinux" <<_EOF
+TIMEOUT=10
+# Defaults to current kernel cmdline if left empty
+CMDLINE="panic=10 coherent_pool=1M console=ttyS2,1500000 root=UUID=${ROOT_UUID} rw"
+# set this to use a DEVICETREEDIR line in place of an FDT line
+USE_DEVICETREEDIR="yes"
+# relative dtb path supplied to FDT line, as long as above is unset
+DTBPATH=""
+_EOF
+    mkdir -p "${ROOTFS}/boot/extlinux"
+    run_cmd_chroot "${ROOTFS}" "/etc/kernel.d/post-install/60-extlinux"
+    cleanup_chroot
+    ;;
 pinebookpro*)
-    dd if="${ROOTFS}/usr/lib/pinebookpro-uboot/idbloader.img" of="${LOOPDEV}" seek=64 conv=notrunc,fsync >/dev/null 2>&1
-    dd if="${ROOTFS}/usr/lib/pinebookpro-uboot/u-boot.itb" of="${LOOPDEV}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1
+    rk33xx_flash_uboot "${ROOTFS}/usr/lib/pinebookpro-uboot" "$LOOPDEV"
     run_cmd_chroot "${ROOTFS}" "xbps-reconfigure -f pinebookpro-kernel"
     cleanup_chroot
     ;;

+ 2 - 1
mkplatformfs.sh.in

@@ -51,7 +51,7 @@ Usage: $PROGNAME [options] <platform> <base-tarball>
 Supported platforms: i686, x86_64, GCP, bananapi, beaglebone,
                      cubieboard2, cubietruck, odroid-c2, odroid-u2,
                      rpi, rpi2 (armv7), rpi3 (aarch64), rpi4 (aarch64), ci20,
-                     pinebookpro, pinephone
+                     pinebookpro, pinephone, rock64
 
 Options
     -b <syspkg> Set an alternative base-system package (defaults to base-system)
@@ -127,6 +127,7 @@ case "$PLATFORM" in
     GCP*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
     pinebookpro*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
     pinephone*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
+    rock64*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
     *) die "$PROGNAME: invalid platform!";;
 esac