ad lot of improvements

This commit is contained in:
alexander stefanov 2024-11-18 21:58:37 +03:00
parent 422d19e932
commit a68c5dac73
4 changed files with 71 additions and 36 deletions

View file

@ -1,11 +1,34 @@
ARCH="aarch64" ARCH="aarch64"
BOOT_SOC="rk3568"
# kernel section
KERNEL="https://github.com/armbian/linux-rockchip.git#rk-6.1-rkr3" KERNEL="https://github.com/armbian/linux-rockchip.git#rk-6.1-rkr3"
KERNEL_CONFIG="rockchip_linux_defconfig" KERNEL_CONFIG="rockchip_linux_defconfig"
DTB="rockchip/rk3568-ok3568c"
# u-boot section
UBOOT="https://github.com/radxa/u-boot.git" UBOOT="https://github.com/radxa/u-boot.git"
UBOOT_VERSION="next-dev-v2024.03" UBOOT_VERSION="next-dev-v2024.03"
UBOOT_CONFIG="ok3568c-rk3568_defconfig" UBOOT_CONFIG="rk3568-ok3568c_defconfig"
DTB="rockchip/rk3568-ok3568c"
# cmdline
CMDLINE="earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1" CMDLINE="earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"
# disk section
# /boot is vfat partition
BOOT_FSTYPE="vfat"
BOOT_SIZE="256MB"
# / is ext4 partition
ROOT_SIZE="1024MB" ROOT_SIZE="1024MB"
ROOT_FSTYPE="ext4" ROOT_FSTYPE="ext4"
# platform section
# # put it in blobs dir
RK_DDR="rk3568_ddr_1560MHz_v1.21.bin"
BL31="rk3568_bl31_v1.44.elf"
MKIMAGE_CMD="tools/mkimage -n {BOOT_SOC} -T rksd -d {RK_DDR}:spl/u-boot-spl.bin idbloader.img"
UBOOT_BUILD="make BL31={BL31} spl/u-boot-spl.bin u-boot.dtb u-boot.itb CROSS_COMPILE='{ARCH}-linux-gnu-'"
# make BL31=rk3568_bl31_v1.44.elf spl/u-boot-spl.bin u-boot.dtb u-boot.itb CROSS_COMPILE="aarch64-linux-gnu-"
# dd if=idbloader.img of=/dev/loop1 seek=64 conv=notrunc status=none
# dd if=u-boot.itb of=/dev/loop1 seek=16384 conv=notrunc status=none

View file

@ -1,20 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 9d0b75e07f457afb6f3f27186e73daf251b9d88c Mon Sep 17 00:00:00 2001
From: John Doe <john.doe@somewhere.on.planet> From: alexander stefanov <alexander@mezon.ru>
Date: Fri, 25 Oct 2024 14:54:00 +0000 Date: Sat, 16 Nov 2024 14:13:14 +0300
Subject: Patching u-boot rk35xx files arch/arm/dts/OK3568-C.dts Subject: [PATCH] add rk3568-ok3568c board
configs/OK3568-rk3568_defconfig
Signed-off-by: John Doe <john.doe@somewhere.on.planet>
--- ---
arch/arm/dts/OK3568-C.dts | 475 ++++++++++ arch/arm/dts/rk3568-ok3568c.dts | 475 +++++++++++++++++++++++++++++++
configs/OK3568-rk3568_defconfig | 220 +++++ configs/rk3568-ok3568c_defconfig | 220 ++++++++++++++
2 files changed, 695 insertions(+) 2 files changed, 695 insertions(+)
create mode 100644 arch/arm/dts/rk3568-ok3568c.dts
create mode 100644 configs/rk3568-ok3568c_defconfig
diff --git a/arch/arm/dts/OK3568-C.dts b/arch/arm/dts/OK3568-C.dts diff --git a/arch/arm/dts/rk3568-ok3568c.dts b/arch/arm/dts/rk3568-ok3568c.dts
new file mode 100644 new file mode 100644
index 00000000000..21131dbba6b index 0000000..ae3003e
--- /dev/null --- /dev/null
+++ b/arch/arm/dts/OK3568-C.dts +++ b/arch/arm/dts/rk3568-ok3568c.dts
@@ -0,0 +1,475 @@ @@ -0,0 +1,475 @@
+/* +/*
+ * SPDX-License-Identifier: GPL-2.0+ + * SPDX-License-Identifier: GPL-2.0+
@ -491,11 +491,11 @@ index 00000000000..21131dbba6b
+ }; + };
+ }; + };
+}; +};
diff --git a/configs/OK3568-rk3568_defconfig b/configs/OK3568-rk3568_defconfig diff --git a/configs/rk3568-ok3568c_defconfig b/configs/rk3568-ok3568c_defconfig
new file mode 100644 new file mode 100644
index 00000000000..65ecbfcd904 index 0000000..0832186
--- /dev/null --- /dev/null
+++ b/configs/OK3568-rk3568_defconfig +++ b/configs/rk3568-ok3568c_defconfig
@@ -0,0 +1,220 @@ @@ -0,0 +1,220 @@
+CONFIG_ARM=y +CONFIG_ARM=y
+CONFIG_ARCH_ROCKCHIP=y +CONFIG_ARCH_ROCKCHIP=y
@ -514,7 +514,7 @@ index 00000000000..65ecbfcd904
+CONFIG_SPL_NAND_SUPPORT=y +CONFIG_SPL_NAND_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y +CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="OK3568-C" +CONFIG_DEFAULT_DEVICE_TREE="rk3568-ok3568c"
+CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_SMBIOS_PRODUCT_NAME=""
+CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART=y
+CONFIG_FIT=y +CONFIG_FIT=y
@ -718,4 +718,5 @@ index 00000000000..65ecbfcd904
+CONFIG_OPTEE_CLIENT=y +CONFIG_OPTEE_CLIENT=y
+CONFIG_OPTEE_V2=y +CONFIG_OPTEE_V2=y
-- --
Created with Armbian build tools https://github.com/armbian/build 2.46.1

View file

@ -31,7 +31,7 @@ grep -Irl /lib/modules | xargs sed -i -e 's,/lib/modules,%{_modulesdir},g' -e 's
# Install kernel modules, if any # Install kernel modules, if any
make V=1 modules_install ARCH={KERNEL_ARCH} \ make V=1 modules_install ARCH={KERNEL_ARCH} \
INSTALL_MOD_PATH=%{buildroot} \ INSTALL_MOD_PATH=%{buildroot} \
INSTALL_DTBS_PATH=%{buildroot}/boot INSTALL_DTBS_PATH=%{buildroot}/boot/dtbs
make dtbs_install ARCH={KERNEL_ARCH} \ make dtbs_install ARCH={KERNEL_ARCH} \
INSTALL_MOD_PATH=%{buildroot} \ INSTALL_MOD_PATH=%{buildroot} \

View file

@ -40,43 +40,55 @@ def cleanup_loop_devices():
loop_device = loop_device.strip() loop_device = loop_device.strip()
if loop_device: if loop_device:
print(f"Detaching {loop_device}") print(f"Detaching {loop_device}")
subprocess.run(["sudo", "losetup", "-d", loop_device], check=False) subprocess.run(["losetup", "-d", loop_device], check=False)
def setup_loop_device(disk_image_path): def setup_loop_device(disk_image_path):
cleanup_loop_devices() cleanup_loop_devices()
cmd = ["sudo", "losetup", "-fP", "--show", disk_image_path] cmd = ["losetup", "-fP", "--show", disk_image_path]
result = subprocess.run(cmd, check=True, capture_output=True, text=True) result = subprocess.run(cmd, check=True, capture_output=True, text=True)
loop_device = result.stdout.strip() loop_device = result.stdout.strip()
print(f"Disk image mounted to loop device {loop_device}") print(f"Disk image mounted to loop device {loop_device}")
return loop_device return loop_device
def create_partitions(loop_device, config): def create_partitions(loop_device, config):
root_size = config.get("ROOT_SIZE", "1024MB").rstrip("MB") root_size = config.get("ROOT_SIZE", "1024MB").rstrip("MB")
root_fstype = config.get("ROOT_FSTYPE", "ext4") root_fstype = config.get("ROOT_FSTYPE", "ext4")
boot_size = config.get("BOOT_SIZE") boot_size = config.get("BOOT_SIZE")
boot_fstype = config.get("BOOT_FSTYPE", "vfat") if boot_size else None boot_fstype = config.get("BOOT_FSTYPE")
print(f"Creating partitions on {loop_device}...") print(f"Creating partitions on {loop_device}...")
if boot_size: if boot_size:
boot_size = boot_size.rstrip("MB") boot_size = boot_size.rstrip("MB")
fdisk_commands = f"""\nn\np\n\n\n+{boot_size}M\nn\np\n\n\n\nw"""
subprocess.run(["sudo", "fdisk", "--wipe", "always", loop_device], input=fdisk_commands, text=True, check=True) # boot partition with BOOT_SIZE from config
fdisk_commands = f"""\nn\np\n\n\n+{boot_size}M\n"""
# change partition type here to W95 FAT
if boot_fstype == "vfat":
fdisk_commands += "t\nc\n"
fdisk_commands += f"""n\np\n\n\n\nw"""
# Применяем команды fdisk
subprocess.run(["fdisk", "--wipe", "always", loop_device], input=fdisk_commands, text=True, check=True)
if boot_fstype == "vfat":
print(f" - Formatting /boot as {boot_fstype} ({boot_size} MB)") print(f" - Formatting /boot as {boot_fstype} ({boot_size} MB)")
subprocess.run(["sudo", "mkfs.vfat", "-F", "32", f"{loop_device}p1"], check=True) subprocess.run(["mkfs.vfat", "-F", "32", f"{loop_device}p1"], check=True)
else:
print(f" - Formatting /boot as {boot_fstype or 'ext4'} ({boot_size} MB)")
subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True)
print(f" - Formatting root (/) as {root_fstype} ({root_size} MB)") print(f" - Formatting root (/) as {root_fstype} ({root_size} MB)")
subprocess.run(["sudo", "mkfs.ext4", f"{loop_device}p2"], check=True) subprocess.run(["mkfs.ext4", f"{loop_device}p2"], check=True)
else: else:
fdisk_commands = f"""o\nn\np\n\n\n\nw\n""" fdisk_commands = f"""o\nn\np\n\n\n\nw\n"""
subprocess.run(["sudo", "fdisk", "--wipe", "always", loop_device], input=fdisk_commands, text=True, check=True) subprocess.run(["fdisk", "--wipe", "always", loop_device], input=fdisk_commands, text=True, check=True)
print(f" - Formatting single root (/) partition as {root_fstype} ({root_size} MB)") print(f" - Formatting single root (/) partition as {root_fstype} ({root_size} MB)")
subprocess.run(["sudo", "mkfs.ext4", f"{loop_device}p1"], check=True) subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True)
print("Partitioning and formatting complete.") print("Partitioning and formatting complete.")
@ -87,14 +99,13 @@ def mount_partitions(config, loop_device, tmp_dir, vendor, device):
boot_partition = f"{loop_device}p1" boot_partition = f"{loop_device}p1"
root_partition = f"{loop_device}p2" if "BOOT_SIZE" in config else f"{loop_device}p1" root_partition = f"{loop_device}p2" if "BOOT_SIZE" in config else f"{loop_device}p1"
print(f"Mounting root (/) partition at {rootfs_dir}")
subprocess.run(["mount", root_partition, rootfs_dir], check=True)
if "BOOT_SIZE" in config: if "BOOT_SIZE" in config:
boot_dir = os.path.join(rootfs_dir, "boot") boot_dir = os.path.join(rootfs_dir, "boot")
os.makedirs(boot_dir, exist_ok=True) os.makedirs(boot_dir, exist_ok=True)
print(f"Mounting /boot partition at {boot_dir}") print(f"Mounting /boot partition at {boot_dir}")
subprocess.run(["sudo", "mount", boot_partition, boot_dir], check=True) subprocess.run(["mount", boot_partition, boot_dir], check=True)
print(f"Mounting root (/) partition at {rootfs_dir}")
subprocess.run(["sudo", "mount", root_partition, rootfs_dir], check=True)
print("Mounting complete.") print("Mounting complete.")