mirror of
https://github.com/rosalinux/image-builder.git
synced 2025-02-23 18:32:51 +00:00
download blobs in-build time
This commit is contained in:
parent
f6f43175b9
commit
b31758ca7c
3 changed files with 56 additions and 15 deletions
|
@ -26,12 +26,14 @@ ROOT_FSTYPE="ext4"
|
||||||
|
|
||||||
# platform section
|
# platform section
|
||||||
# # put it in blobs dir
|
# # put it in blobs dir
|
||||||
RK_DDR="rk3568_ddr_1560MHz_v1.21.bin"
|
RK_DDR="rk3568_ddr_1560MHz_v1.23.bin"
|
||||||
BL31="rk3568_bl31_v1.44.elf"
|
BL31="rk3568_bl31_v1.44.elf"
|
||||||
|
UBOOT_BUILD="make KCFLAGS='-Wno-error' BL31={BL31} spl/u-boot-spl.bin u-boot.dtb u-boot.itb CROSS_COMPILE='{ARCH}-linux-gnu-'"
|
||||||
MKIMAGE_CMD="tools/mkimage -n {BOOT_SOC} -T rksd -d {RK_DDR}:spl/u-boot-spl.bin idbloader.img"
|
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-'"
|
# url to download rockchip bootloader blobs
|
||||||
# make BL31=rk3568_bl31_v1.44.elf spl/u-boot-spl.bin u-boot.dtb u-boot.itb CROSS_COMPILE="aarch64-linux-gnu-"
|
BLOBS_URL="https://github.com/rockchip-linux/rkbin/raw/refs/heads/master/bin/rk35/"
|
||||||
|
|
||||||
|
# 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=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 -A arm64 -O linux -T ramdisk -C gzip -n uInitrd -d /boot/initramfs-6.1.75.img /boot/uInitrd
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from urllib.request import urlretrieve
|
||||||
|
|
||||||
def load_config(config_path):
|
def load_config(config_path):
|
||||||
config = {}
|
config = {}
|
||||||
|
@ -18,3 +19,16 @@ def clone_repo(repo_url, branch, dest_dir, name):
|
||||||
else:
|
else:
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
subprocess.run(["git", "clone", "--depth", "1", repo_url, "-b", branch, dest_dir], check=True)
|
subprocess.run(["git", "clone", "--depth", "1", repo_url, "-b", branch, dest_dir], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def download_blob(blob_url, destination):
|
||||||
|
"""Download a file from the given URL and save it to the destination."""
|
||||||
|
try:
|
||||||
|
print(f"Downloading {blob_url} to {destination}...")
|
||||||
|
os.makedirs(os.path.dirname(destination), exist_ok=True)
|
||||||
|
urlretrieve(blob_url, destination)
|
||||||
|
print(f"Downloaded: {destination}")
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Unable to download {blob_url}. {e}")
|
||||||
|
return False
|
||||||
|
|
|
@ -5,9 +5,9 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from utils.common import clone_repo
|
from utils.common import clone_repo
|
||||||
|
from utils.common import download_blob
|
||||||
from utils.patch import apply_uboot_patches
|
from utils.patch import apply_uboot_patches
|
||||||
|
|
||||||
|
|
||||||
def build_uboot(TMP_DIR, BASE_DIR, config, vendor, device):
|
def build_uboot(TMP_DIR, BASE_DIR, config, vendor, device):
|
||||||
if "UBOOT" not in config or "UBOOT_VERSION" not in config:
|
if "UBOOT" not in config or "UBOOT_VERSION" not in config:
|
||||||
print("U-Boot configuration not found. Skipping U-Boot build.")
|
print("U-Boot configuration not found. Skipping U-Boot build.")
|
||||||
|
@ -18,28 +18,53 @@ def build_uboot(TMP_DIR, BASE_DIR, config, vendor, device):
|
||||||
uboot_config = config.get("UBOOT_CONFIG")
|
uboot_config = config.get("UBOOT_CONFIG")
|
||||||
uboot_build_cmd = config.get("UBOOT_BUILD")
|
uboot_build_cmd = config.get("UBOOT_BUILD")
|
||||||
mkimage_cmd = config.get("MKIMAGE_CMD")
|
mkimage_cmd = config.get("MKIMAGE_CMD")
|
||||||
|
blobs_url = config.get("BLOBS_URL", "")
|
||||||
|
|
||||||
blobs_dir = os.path.join(BASE_DIR, "device", vendor, device, "blobs")
|
# Clone U-Boot repository
|
||||||
rk_ddr = os.path.join(blobs_dir, config.get("RK_DDR", ""))
|
|
||||||
bl31 = os.path.join(blobs_dir, config.get("BL31", ""))
|
|
||||||
|
|
||||||
if not os.path.isfile(rk_ddr) or not os.path.isfile(bl31):
|
|
||||||
print(f"Missing required files in blobs directory: {rk_ddr}, {bl31}")
|
|
||||||
return
|
|
||||||
|
|
||||||
uboot_dir = os.path.join(TMP_DIR, vendor, device, "u-boot")
|
uboot_dir = os.path.join(TMP_DIR, vendor, device, "u-boot")
|
||||||
clone_repo(uboot_git, uboot_branch, uboot_dir, "u-boot")
|
clone_repo(uboot_git, uboot_branch, uboot_dir, "u-boot")
|
||||||
apply_uboot_patches(BASE_DIR, vendor, device, uboot_dir)
|
apply_uboot_patches(BASE_DIR, vendor, device, uboot_dir)
|
||||||
|
|
||||||
|
# Download RK_DDR blob to uboot_dir
|
||||||
|
rk_ddr = None
|
||||||
|
if "RK_DDR" in config:
|
||||||
|
rk_ddr = os.path.join(uboot_dir, os.path.basename(config.get("RK_DDR")))
|
||||||
|
rk_ddr_url = os.path.join(blobs_url, os.path.basename(rk_ddr))
|
||||||
|
if not os.path.isfile(rk_ddr):
|
||||||
|
if not download_blob(rk_ddr_url, rk_ddr):
|
||||||
|
print(f"Warning: RK_DDR blob {rk_ddr_url} could not be downloaded.")
|
||||||
|
|
||||||
|
# Download BL31 blob to uboot_dir
|
||||||
|
bl31 = None
|
||||||
|
if "BL31" in config:
|
||||||
|
bl31 = os.path.join(uboot_dir, os.path.basename(config.get("BL31")))
|
||||||
|
bl31_url = os.path.join(blobs_url, os.path.basename(bl31))
|
||||||
|
if not os.path.isfile(bl31):
|
||||||
|
if not download_blob(bl31_url, bl31):
|
||||||
|
print(f"Warning: BL31 blob {bl31_url} could not be downloaded.")
|
||||||
|
|
||||||
|
# Build U-Boot
|
||||||
os.chdir(uboot_dir)
|
os.chdir(uboot_dir)
|
||||||
try:
|
try:
|
||||||
print(f"Building U-Boot for {vendor}/{device} {uboot_config}...")
|
print(f"Building U-Boot for {vendor}/{device} {uboot_config}...")
|
||||||
subprocess.run(["make", uboot_config], check=True)
|
subprocess.run(["make", uboot_config], check=True)
|
||||||
build_command = uboot_build_cmd.format(BL31=bl31, ARCH=config.get("ARCH", "aarch64"))
|
|
||||||
|
# Format U-Boot build command
|
||||||
|
build_command = uboot_build_cmd.format(
|
||||||
|
BL31=bl31 or "",
|
||||||
|
ARCH=config.get("ARCH", "aarch64")
|
||||||
|
)
|
||||||
subprocess.run(build_command, shell=True, check=True)
|
subprocess.run(build_command, shell=True, check=True)
|
||||||
mkimage_command = mkimage_cmd.format(BOOT_SOC=config.get("BOOT_SOC", ""), RK_DDR=rk_ddr)
|
|
||||||
|
# Format mkimage command
|
||||||
|
mkimage_command = mkimage_cmd.format(
|
||||||
|
BOOT_SOC=config.get("BOOT_SOC", ""),
|
||||||
|
RK_DDR=rk_ddr or ""
|
||||||
|
)
|
||||||
|
print(mkimage_command)
|
||||||
subprocess.run(mkimage_command, shell=True, check=True)
|
subprocess.run(mkimage_command, shell=True, check=True)
|
||||||
|
|
||||||
print("U-Boot build completed successfully.")
|
print("U-Boot build completed successfully.")
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Error during U-Boot build: {e}")
|
print(f"Error during U-Boot build: {e}")
|
||||||
|
os.chdir(BASE_DIR)
|
||||||
|
|
Loading…
Add table
Reference in a new issue