mirror of
https://github.com/rosalinux/image-builder.git
synced 2025-02-23 10:22:50 +00:00
add boot.cmd and kernel defconfig for ok3568 board, now use sgdisk for partitioning
This commit is contained in:
parent
b505dcd815
commit
73670bd9bf
7 changed files with 9698 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
RELEASE="rosa13"
|
||||
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"
|
||||
DEFAULT_USER="rosa"
|
||||
DEFAULT_USER_PASSWORD="rosa"
|
||||
|
|
21
device/rockchip/ok3568c/boot.cmd
Normal file
21
device/rockchip/ok3568c/boot.cmd
Normal 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
|
|
@ -3,7 +3,7 @@ BOOT_SOC="rk3568"
|
|||
|
||||
# kernel section
|
||||
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"
|
||||
|
||||
# u-boot section
|
||||
|
@ -13,13 +13,14 @@ UBOOT_CONFIG="rk3568-ok3568c_defconfig"
|
|||
|
||||
# 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"
|
||||
EXTRA_PKGS="uboot-tools dracut neovim"
|
||||
|
||||
# disk section
|
||||
# /boot is vfat partition
|
||||
BOOT_FSTYPE="vfat"
|
||||
BOOT_SIZE="256MB"
|
||||
# / is ext4 partition
|
||||
ROOT_SIZE="1024MB"
|
||||
ROOT_SIZE="1500MB"
|
||||
ROOT_FSTYPE="ext4"
|
||||
|
||||
# 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=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
|
||||
|
|
9632
device/rockchip/ok3568c/kernel_ok3568_defconfig
Normal file
9632
device/rockchip/ok3568c/kernel_ok3568_defconfig
Normal file
File diff suppressed because it is too large
Load diff
|
@ -70,7 +70,7 @@ def generate_spec_file(TMP_DIR, config, vendor, device):
|
|||
"{DEVICE_NAME}": device_name,
|
||||
"{KERNEL_ARCH}": kernel_arch,
|
||||
"{ARCH}": arch, # Add ARCH replacement
|
||||
"{KERNEL_CONFIG}": kernel_config, # Add ARCH replacement
|
||||
"{KERNEL_CONFIG}": kernel_config,
|
||||
"{CROSS_COMPILE}": cross_compile # Add CROSS_COMPILE replacement
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,10 @@ make V=1 modules_install ARCH={KERNEL_ARCH} \
|
|||
|
||||
make dtbs_install ARCH={KERNEL_ARCH} \
|
||||
INSTALL_MOD_PATH=%{buildroot} \
|
||||
INSTALL_DTBS_PATH=%{buildroot}/boot
|
||||
INSTALL_DTBS_PATH=%{buildroot}/boot/dtbs
|
||||
|
||||
cp arch/arm64/boot/Image %{buildroot}/boot/vmlinuz-%{version}
|
||||
|
||||
find %{buildroot} -type f -name "*.ko" -exec %{_bindir}/{ARCH}-linux-gnu-strip {} \;
|
||||
|
||||
%files
|
||||
/boot/*
|
||||
%{_modulesdir}/*
|
||||
|
|
|
@ -55,43 +55,49 @@ def setup_loop_device(disk_image_path):
|
|||
def create_partitions(loop_device, config):
|
||||
root_size = config.get("ROOT_SIZE", "1024MB").rstrip("MB")
|
||||
root_fstype = config.get("ROOT_FSTYPE", "ext4")
|
||||
boot_size = config.get("BOOT_SIZE")
|
||||
boot_fstype = config.get("BOOT_FSTYPE")
|
||||
boot_size = config.get("BOOT_SIZE", "0").rstrip("MB") # Default to 0 if not specified
|
||||
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:
|
||||
boot_size = boot_size.rstrip("MB")
|
||||
try:
|
||||
# Clear existing partitions
|
||||
subprocess.run(["sgdisk", "--zap-all", loop_device], 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 int(boot_size) > 0:
|
||||
# Create boot partition
|
||||
# 16M here s empty space for u-boot
|
||||
subprocess.run(["sgdisk",
|
||||
"--new=1:16M:+{}M".format(boot_size),
|
||||
"--typecode=1:8300", loop_device], check=True)
|
||||
|
||||
# Create root partition
|
||||
subprocess.run(["sgdisk",
|
||||
"--new=2:0:0",
|
||||
"--typecode=2:8300", loop_device], check=True)
|
||||
|
||||
# Format partitions
|
||||
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)")
|
||||
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)")
|
||||
subprocess.run(["mkfs.ext4", f"{loop_device}p2"], check=True)
|
||||
|
||||
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" - Boot partition ({boot_size}MB) created and formatted as {boot_fstype}")
|
||||
print(f" - Root partition created and formatted as {root_fstype}")
|
||||
|
||||
print(f" - Formatting single root (/) partition as {root_fstype} ({root_size} MB)")
|
||||
else:
|
||||
# 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)
|
||||
print(f" - Single root partition created and formatted as {root_fstype}")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error creating partitions with sgdisk: {e}")
|
||||
return False
|
||||
|
||||
print("Partitioning and formatting complete.")
|
||||
|
||||
return True
|
||||
|
||||
def mount_partitions(config, loop_device, tmp_dir, vendor, device):
|
||||
rootfs_dir = os.path.join(tmp_dir, vendor, device, "rootfs")
|
||||
|
|
Loading…
Add table
Reference in a new issue