前言:
最近客户有个需要,通过adb push来动态替换开机logo。通过网上查阅相关资料,现整理如下。
参考:
RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo
解决方法:
通过自定义一个分区来存储开机logo,这样在恢复出厂时不会丢失开机logo。然后通过修改u-boot/drivers/video/drm/rockchip_display.c 文件,在开机时候先从自定义分区读取logo文件。如果读取失败,就使用默认的开机logo。
自定义分区的方法可以参考:RK3568 Anroid12新增自定义分区
补丁:
Index: u-boot/drivers/video/drm/rockchip_display.c =================================================================== --- u-boot/drivers/video/drm/rockchip_display.c (revision 2459) +++ u-boot/drivers/video/drm/rockchip_display.c (revision 2460) @@ -1309,6 +1309,7 @@ static int load_bmp_logo(struct logo_info *logo, const char *bmp_name) { +#define BUFFER_SIZE 128 #ifdef CONFIG_ROCKCHIP_RESOURCE_IMAGE struct rockchip_logo_cache *logo_cache; struct bmp_header *header; @@ -1317,6 +1318,7 @@ int ret = 0; int reserved = 0; int dst_size; + char cmd[BUFFER_SIZE] = {"0"}; if (!logo || !bmp_name) return -EINVAL; @@ -1333,12 +1335,25 @@ if (!header) return -ENOMEM; - len = rockchip_read_resource_file(header, bmp_name, 0, RK_BLK_SIZE); - if (len != RK_BLK_SIZE) { - ret = -EINVAL; - goto free_header; - } + // len = rockchip_read_resource_file(header, bmp_name, 0, RK_BLK_SIZE); + // if (len != RK_BLK_SIZE) { + // ret = -EINVAL; + // goto free_header; + // } + //---add start + sprintf(cmd, "ext4load mmc 0:e 0x%p %s %x", header,bmp_name, RK_BLK_SIZE); + printf("load_bmp_logo attempt to load from MMC %s...\n", bmp_name); + if(run_command(cmd, 0)){ + len = rockchip_read_resource_file(header, bmp_name, 0, RK_BLK_SIZE); + if (len != RK_BLK_SIZE) { + printf("load_bmp_logo Load from resource file %s fail\n", bmp_name); + ret = -EINVAL; + goto free_header; + } + } + //---add end + logo->bpp = get_unaligned_le16(&header->bit_count); logo->width = get_unaligned_le32(&header->width); logo->height = get_unaligned_le32(&header->height); @@ -1360,13 +1375,27 @@ dst = pdst; } - len = rockchip_read_resource_file(pdst, bmp_name, 0, size); - if (len != size) { - printf("failed to load bmp %s\n", bmp_name); - ret = -ENOENT; - goto free_header; - } + // len = rockchip_read_resource_file(pdst, bmp_name, 0, size); + // if (len != size) { + // printf("failed to load bmp %s\n", bmp_name); + // ret = -ENOENT; + // goto free_header; + // } + //---add start + memset(cmd, 0, BUFFER_SIZE); + sprintf(cmd, "ext4load mmc 0:e 0x%p %s %x", pdst, bmp_name, size); + if(run_command(cmd, 0)){ + len = rockchip_read_resource_file(pdst, bmp_name, 0, size); + if (len != size) { + printf("load_bmp_logo Load bmp %s fail\n", bmp_name); + printf("failed to load bmp %s\n", bmp_name); + ret = -ENOENT; + goto free_header; + } + } + //---add end + if (!can_direct_logo(logo->bpp)) { /* * TODO: force use 16bpp if bpp less than 16;
注意要点:
sprintf(cmd, "ext4load mmc 0:e 0x%p %s %x", header,bmp_name, RK_BLK_SIZE);
mmc 0:e 是你的自定义分区。查看方法:
1|rk3568_s:/ # ls -l /dev/block/by-name/ total 0 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 backup -> /dev/block/mmcblk2p9 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 baseparameter -> /dev/block/mmcblk2p12 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 boot -> /dev/block/mmcblk2p7 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 cache -> /dev/block/mmcblk2p10 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 dtbo -> /dev/block/mmcblk2p5 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 fos -> /dev/block/mmcblk2p14 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 metadata -> /dev/block/mmcblk2p11 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 misc -> /dev/block/mmcblk2p4 lrwxrwxrwx 1 root root 18 2023-12-18 07:29 mmcblk2 -> /dev/block/mmcblk2 lrwxrwxrwx 1 root root 23 2023-12-18 07:29 mmcblk2boot0 -> /dev/block/mmcblk2boot0 lrwxrwxrwx 1 root root 23 2023-12-18 07:29 mmcblk2boot1 -> /dev/block/mmcblk2boot1 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 recovery -> /dev/block/mmcblk2p8 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 security -> /dev/block/mmcblk2p1 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 super -> /dev/block/mmcblk2p13 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 trust -> /dev/block/mmcblk2p3 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 uboot -> /dev/block/mmcblk2p2 lrwxrwxrwx 1 root root 21 2023-12-18 07:29 userdata -> /dev/block/mmcblk2p15 lrwxrwxrwx 1 root root 20 2023-12-18 07:29 vbmeta -> /dev/block/mmcblk2p6
可以看到自定义分区fos是mmcblk2p14,对应的是mmc 0:e ,其中e代表的是第十四个分区。
然后adb remount之后,push 开机logo到fos分区下。重启就可以看到开机logo已经替换了。
疑点:
自定义分区的时候,我参考RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo这篇博客的时候,博客里面的某句话:例如,mmc 0:c中的0代表第0个存储设备,而c是一个十六进制数,代表12,所以它对应于第12个分区。
而大佬的mmcblk0p10 分区是cache,我的cache分区是mmcblk2p10。我一开始以为我的分区是 mmc 2:a,结果还是mmc 0:a。那是不是 mmcblk0p10和mmcblk2p10 中的0和2并不是对应 mmc的存储设备?
串口查看分区:
接好串口,开机的时候按下cart + c进入uboot 命令行模式。通过指令可以查看分区信息。
Net: eth1: ethernet@fe010000, eth0: ethernet@fe2a0000 Hit key to stop autoboot('CTRL+C'): 0 => <INTERRUPT> => <INTERRUPT> => <INTERRUPT> => <INTERRUPT> => ext4ls mmc 0:a <DIR> 4096 . <DIR> 4096 .. <DIR> 16384 lost+found <DIR> 4096 recovery <DIR> 4096 backup_stage <DIR> 4096 backup => ext4ls mmc 0:e <DIR> 4096 . <DIR> 4096 .. <DIR> 16384 lost+found 394040 logo.bmp 394040 logo_kernel.bmp =>
可以看到mmc 0:e 下面有开机logo。对应的分区是fos。而mmc 0:a 对应的分区是cache。
标签:12,RK3568,18,bmp,android12,logo,root,block From: https://www.cnblogs.com/dodo-asw/p/17911568.html