sun60iw2: load Armbian logo from rootfs boot

This commit is contained in:
Qubot 2026-06-03 08:21:33 +08:00
parent b4e8f91dd0
commit 3051398316
2 changed files with 48 additions and 17 deletions

View File

@ -28,6 +28,9 @@ CONFIG_SUNXI_HDCP_IN_SECURESTORAGE=y
CONFIG_SUNXI_RKP=y
CONFIG_SUNXI_RNG_SEED=y
CONFIG_CMD_FASTBOOT=y
CONFIG_CMD_EXT2=y
CONFIG_CMD_EXT4=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_PART=y
CONFIG_CMD_USB=y
CONFIG_CMD_SUNXI_TIMER=y

View File

@ -72,28 +72,23 @@ static int armbian_print_file_info(struct file_info_t *file)
return 0;
}
static struct file_info_t *load_armbian_boot_logo(const char *name)
static struct file_info_t *load_armbian_boot_logo_from(const char *dev_part,
int fstype,
const char *path)
{
loff_t file_size, read_size;
struct file_info_t *file;
static bool mmc_ready;
if (!name)
if (!dev_part || !path)
return NULL;
if (!mmc_ready) {
run_command("mmc dev 0", 0);
run_command("mmc rescan", 0);
mmc_ready = true;
}
if (fs_set_blk_dev("mmc", "0:1", FS_TYPE_FAT))
if (fs_set_blk_dev("mmc", dev_part, fstype))
return NULL;
if (!fs_exists(name))
if (!fs_exists(path))
return NULL;
if (fs_size(name, &file_size) || !file_size)
if (fs_size(path, &file_size) || !file_size)
return NULL;
file = malloc(sizeof(*file));
@ -102,16 +97,16 @@ static struct file_info_t *load_armbian_boot_logo(const char *name)
memset(file, 0, sizeof(*file));
file->file_size = (unsigned int)file_size;
file->name = malloc(strlen(name) + 1);
file->path = malloc(strlen("mmc0:1") + 1);
file->name = malloc(strlen(path) + 1);
file->path = malloc(strlen("mmc") + strlen(dev_part) + 1);
file->file_addr = memalign(4096, file->file_size);
if (!file->name || !file->path || !file->file_addr)
goto err_free;
strncpy(file->name, name, strlen(name) + 1);
strncpy(file->path, "mmc0:1", strlen("mmc0:1") + 1);
strncpy(file->name, path, strlen(path) + 1);
sprintf(file->path, "mmc%s", dev_part);
if (fs_read(name, (ulong)file->file_addr, 0, 0, &read_size) ||
if (fs_read(path, (ulong)file->file_addr, 0, 0, &read_size) ||
read_size != file_size)
goto err_free;
@ -135,6 +130,39 @@ err_free:
return NULL;
}
static struct file_info_t *load_armbian_boot_logo(const char *name)
{
struct file_info_t *file;
char boot_path[64];
static bool mmc_ready;
if (!name)
return NULL;
if (!mmc_ready) {
run_command("mmc dev 0", 0);
run_command("mmc rescan", 0);
mmc_ready = true;
}
/* FAT /boot partition layout: mmc 0:1 root contains boot.bmp. */
file = load_armbian_boot_logo_from("0:1", FS_TYPE_FAT, name);
if (file)
return file;
/*
* H618-style Armbian logo loading reads /boot/boot.bmp from rootfs.
* Keep this fallback for images where the splash is installed in
* rootfs /boot rather than the FAT boot partition root.
*/
snprintf(boot_path, sizeof(boot_path), "/boot/%s", name);
file = load_armbian_boot_logo_from("0:2", FS_TYPE_EXT, boot_path);
if (file)
return file;
return load_armbian_boot_logo_from("0:2", FS_TYPE_EXT, name);
}
int check_drm_debug_mode(void)
{
int debug_mode;