add boot.cmd and kernel defconfig for ok3568 board, now use sgdisk for partitioning

This commit is contained in:
alexander stefanov 2024-11-19 23:35:14 +03:00
parent b505dcd815
commit 73670bd9bf
7 changed files with 9698 additions and 34 deletions

View file

@ -1,6 +1,6 @@
RELEASE="rosa13" RELEASE="rosa13"
ABF_DOWNLOADS="https://abf-downloads.rosalinux.ru" ABF_DOWNLOADS="https://abf-downloads.rosalinux.ru"
PKGS="basesystem-minimal locales-en dbus coreutils findutils util-linux xz e2fsprogs passwd openssh-server" PKGS="basesystem systemd openssh-server"
WEAK_DEPS="false" WEAK_DEPS="false"
DEFAULT_USER="rosa" DEFAULT_USER="rosa"
DEFAULT_USER_PASSWORD="rosa" DEFAULT_USER_PASSWORD="rosa"

View file

@ -0,0 +1,21 @@
setenv fdtfile "dtbs/rockchip/rk3568-ok3568c.dtb"
setenv bootargs "root=/dev/mmcblk1p2 rootwait rootfstype=ext4 splash=verbose console=ttyS2,1500000 console=tty1 consoleblank=0 loglevel=1 earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 cma=256M"
test -n "${distro_bootpart}" || distro_bootpart=1
echo "Boot script loaded from ${devtype} ${devnum}:${distro_bootpart}"
load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${prefix}uInitrd
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}Image
load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
printenv bootargs
printenv fdtfile
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
# Recompile with:
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

View file

@ -3,7 +3,7 @@ BOOT_SOC="rk3568"
# kernel section # 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="kernel_ok3568_defconfig"
DTB="rockchip/rk3568-ok3568c" DTB="rockchip/rk3568-ok3568c"
# u-boot section # u-boot section
@ -13,13 +13,14 @@ UBOOT_CONFIG="rk3568-ok3568c_defconfig"
# cmdline # 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"
EXTRA_PKGS="uboot-tools dracut neovim"
# disk section # disk section
# /boot is vfat partition # /boot is vfat partition
BOOT_FSTYPE="vfat" BOOT_FSTYPE="vfat"
BOOT_SIZE="256MB" BOOT_SIZE="256MB"
# / is ext4 partition # / is ext4 partition
ROOT_SIZE="1024MB" ROOT_SIZE="1500MB"
ROOT_FSTYPE="ext4" ROOT_FSTYPE="ext4"
# platform section # platform section
@ -32,3 +33,9 @@ UBOOT_BUILD="make BL31={BL31} spl/u-boot-spl.bin u-boot.dtb u-boot.itb CROSS_COM
# dd if=idbloader.img of=/dev/loop1 seek=64 conv=notrunc status=none # 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 # dd if=u-boot.itb of=/dev/loop1 seek=16384 conv=notrunc status=none
# mkimage -A arm64 -O linux -T ramdisk -C gzip -n uInitrd -d /boot/initramfs-6.1.75.img /boot/uInitrd
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
# sgdisk --zap-all /dev/loop0
# sgdisk --new=1:15M:+256M --typecode=1:8300 /dev/loop0
# sgdisk --new=2:0:0 --typecode=2:8300 /dev/loop0
# dracut --regenerate-all --force

File diff suppressed because it is too large Load diff

View file

@ -70,7 +70,7 @@ def generate_spec_file(TMP_DIR, config, vendor, device):
"{DEVICE_NAME}": device_name, "{DEVICE_NAME}": device_name,
"{KERNEL_ARCH}": kernel_arch, "{KERNEL_ARCH}": kernel_arch,
"{ARCH}": arch, # Add ARCH replacement "{ARCH}": arch, # Add ARCH replacement
"{KERNEL_CONFIG}": kernel_config, # Add ARCH replacement "{KERNEL_CONFIG}": kernel_config,
"{CROSS_COMPILE}": cross_compile # Add CROSS_COMPILE replacement "{CROSS_COMPILE}": cross_compile # Add CROSS_COMPILE replacement
} }

View file

@ -35,12 +35,10 @@ make V=1 modules_install ARCH={KERNEL_ARCH} \
make dtbs_install ARCH={KERNEL_ARCH} \ make dtbs_install ARCH={KERNEL_ARCH} \
INSTALL_MOD_PATH=%{buildroot} \ INSTALL_MOD_PATH=%{buildroot} \
INSTALL_DTBS_PATH=%{buildroot}/boot INSTALL_DTBS_PATH=%{buildroot}/boot/dtbs
cp arch/arm64/boot/Image %{buildroot}/boot/vmlinuz-%{version} cp arch/arm64/boot/Image %{buildroot}/boot/vmlinuz-%{version}
find %{buildroot} -type f -name "*.ko" -exec %{_bindir}/{ARCH}-linux-gnu-strip {} \;
%files %files
/boot/* /boot/*
%{_modulesdir}/* %{_modulesdir}/*

View file

@ -55,43 +55,49 @@ def setup_loop_device(disk_image_path):
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", "0").rstrip("MB") # Default to 0 if not specified
boot_fstype = config.get("BOOT_FSTYPE") boot_fstype = config.get("BOOT_FSTYPE", "ext4") # Default to ext4 if not specified
print(f"Creating partitions on {loop_device}...") print(f"Creating partitions on {loop_device} using sgdisk...")
if boot_size: try:
boot_size = boot_size.rstrip("MB") # Clear existing partitions
subprocess.run(["sgdisk", "--zap-all", loop_device], check=True)
# boot partition with BOOT_SIZE from config if int(boot_size) > 0:
fdisk_commands = f"""\nn\np\n\n\n+{boot_size}M\n""" # Create boot partition
# change partition type here to W95 FAT # 16M here s empty space for u-boot
if boot_fstype == "vfat": subprocess.run(["sgdisk",
fdisk_commands += "t\nc\n" "--new=1:16M:+{}M".format(boot_size),
fdisk_commands += f"""n\np\n\n\n\nw""" "--typecode=1:8300", loop_device], check=True)
# Применяем команды fdisk # Create root partition
subprocess.run(["fdisk", "--wipe", "always", loop_device], input=fdisk_commands, text=True, check=True) subprocess.run(["sgdisk",
"--new=2:0:0",
"--typecode=2:8300", loop_device], check=True)
# Format partitions
if boot_fstype == "vfat":
subprocess.run(["mkfs.vfat", "-F", "32", f"{loop_device}p1"], check=True)
else:
subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True)
subprocess.run(["mkfs.ext4", f"{loop_device}p2"], check=True)
print(f" - Boot partition ({boot_size}MB) created and formatted as {boot_fstype}")
print(f" - Root partition created and formatted as {root_fstype}")
if boot_fstype == "vfat":
print(f" - Formatting /boot as {boot_fstype} ({boot_size} MB)")
subprocess.run(["mkfs.vfat", "-F", "32", f"{loop_device}p1"], check=True)
else: else:
print(f" - Formatting /boot as {boot_fstype or 'ext4'} ({boot_size} MB)") # Create single root partition
subprocess.run(["sgdisk", "--new=1:0:0", "--typecode=1:8300", loop_device], check=True)
subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True) subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True)
print(f" - Single root partition created and formatted as {root_fstype}")
print(f" - Formatting root (/) as {root_fstype} ({root_size} MB)") except subprocess.CalledProcessError as e:
subprocess.run(["mkfs.ext4", f"{loop_device}p2"], check=True) print(f"Error creating partitions with sgdisk: {e}")
return False
else:
fdisk_commands = f"""o\nn\np\n\n\n\nw\n"""
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)")
subprocess.run(["mkfs.ext4", f"{loop_device}p1"], check=True)
print("Partitioning and formatting complete.") print("Partitioning and formatting complete.")
return True
def mount_partitions(config, loop_device, tmp_dir, vendor, device): def mount_partitions(config, loop_device, tmp_dir, vendor, device):
rootfs_dir = os.path.join(tmp_dir, vendor, device, "rootfs") rootfs_dir = os.path.join(tmp_dir, vendor, device, "rootfs")