[Android7.1][rk3288/rk3399]添加logo和开机动画分区

需求

不同客户要求使用不同的开机logo和开机动画,为实现对不同需求的兼容,减少不同系统版本的维护工作

以往的实现方式

rockchip 平台默认logo存放在resource.img中,bootanimation存放在system分区,因此以往需要针对不同的需求单独建立分支进行维护,不同分支的区别仅仅在logo和动画。

改进方案

添加logo和oem分区,烧录时针对不同的需求选择对应的文件即可。

实现

修改分区表,确定各个分区大小

  • oem分区:oem分区用于存放开机动画,考虑到不同分辨率和帧数的动画体积较大,因此分配了300M空间

    console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive androidboot.hardware=rk30board androidboot.console=ttyFIQ0
    init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),
    0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),
    0x00040000@0x00074000(cache),0x00400000@0x000B4000(system),0x00008000@0x004B4000(metadata),0x00019000@0x004BC000(vendor0),0x00019000@0x004D5000(vendor1),

0x00096000@0x004EE000(oem),0x00002000@0x00584000(logo),-@0x00586000(userdata)

其中 0x004EE000表示该分区的起始地址,0x00096000 表示分区大小
大小以block为单位,即共有0x00096000个block,每个block的大小为512byte,

  • logo分区:由于rockchip对开机logo有特定要求,8bit bmp,因此logo并不会占用很大空间,计算方法同oem分区

  • 添加完分区后,需要修改userdata分区的起始地址

修改fstab,挂载oem分区

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w b/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
index 05d7f16667..5c5e491657 100644
--- a/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
+++ b/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
@@ -7,6 +7,7 @@
# use this line below instead to enable verity
#/dev/block/platform/ff0f0000.rksdmmc/by-name/system /system ext4 ro,noatime,nodiratime,noauto_da_alloc wait,check,verify
/dev/block/platform/ff0f0000.dwmmc/by-name/vendor1 /vendor ext4 ro,noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait
+/dev/block/platform/ff0f0000.dwmmc/by-name/oem /oem ext4 ro,noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait
/dev/block/platform/ff0f0000.dwmmc/by-name/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/platform/ff0f0000.dwmmc/by-name/metadata /metadata ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/platform/ff0f0000.dwmmc/by-name/userdata /data f2fs noatime,nodiratime,nosuid,nodev,discard,inline_xattr wait,check,notrim,encryptable=/metadata/key_file

uboot修改

rockchip 在uboot已经实现使用单独logo分区的功能,其实现存在一个bug具体修改如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/u-boot/common/resource.c b/u-boot/common/resource.c
index 1d343b5a99..1bf709c5ba 100755
--- a/u-boot/common/resource.c
+++ b/u-boot/common/resource.c
@@ -305,7 +305,7 @@ struct bmp_header *get_bmp_header(const char *bmp_name)
return NULL;

if (ptn) {
- if (read_storage(ptn->start, bmp, 1))
+ if (!read_storage(ptn->start, bmp, 1))
goto free_bmp;

} else {

其他修改

  • rk3288.mk bootanimation不再需要拷贝到system/media目录下
  • mkimage.sh 添加拷贝logo及bootanimation的相关操作
  • vendor下添加制作好的oem.img 和logo.bmp

    同时添加了修改用的脚本modify-oem.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
script_dir=`dirname "$BASH_SOURCE"`

if [ ! -f oem.img ]; then
echo "oem.img is not found"
return
fi

if [ ! -f bootanimation.zip ]; then
echo "bootanimation.zip is not found"
return
fi

$script_dir/simg2img oem.img oem.img.ext4
mkdir tmp
sudo mount -t ext4 -o loop oem.img.ext4 tmp
sudo cp ./bootanimation.zip tmp/media/

sudo $script_dir/make_ext4fs -s -l 300M oem_new.img tmp
sudo umount tmp
rm -rf oem.img.ext4
rm -rf tmp

完整patch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
diff --git a/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w b/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
index 05d7f16667..5c5e491657 100644
--- a/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
+++ b/device/rockchip/rk3288/fstab.rk30board.bootmode.emmc.rk3288w
@@ -7,6 +7,7 @@
# use this line below instead to enable verity
#/dev/block/platform/ff0f0000.rksdmmc/by-name/system /system ext4 ro,noatime,nodiratime,noauto_da_alloc wait,check,verify
/dev/block/platform/ff0f0000.dwmmc/by-name/vendor1 /vendor ext4 ro,noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait
+/dev/block/platform/ff0f0000.dwmmc/by-name/oem /oem ext4 ro,noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait
/dev/block/platform/ff0f0000.dwmmc/by-name/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/platform/ff0f0000.dwmmc/by-name/metadata /metadata ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/platform/ff0f0000.dwmmc/by-name/userdata /data f2fs noatime,nodiratime,nosuid,nodev,discard,inline_xattr wait,check,notrim,encryptable=/metadata/key_file
diff --git a/device/rockchip/rk3288/parameter.txt b/device/rockchip/rk3288/parameter.txt
index 37ab61ed2e..8f323e4638 100755
--- a/device/rockchip/rk3288/parameter.txt
+++ b/device/rockchip/rk3288/parameter.txt
@@ -7,4 +7,4 @@ ATAG: 0x60000800
MACHINE: 3288
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
-CMDLINE: console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive androidboot.hardware=rk30board androidboot.console=ttyFIQ0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),0x00040000@0x00074000(cache),0x00400000@0x000B4000(system),0x00008000@0x004B4000(metadata),0x00019000@0x004BC000(vendor0),0x00019000@0x004D5000(vendor1),-@0x004EE000(userdata)
+CMDLINE: console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive androidboot.hardware=rk30board androidboot.console=ttyFIQ0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),0x00040000@0x00074000(cache),0x00400000@0x000B4000(system),0x00008000@0x004B4000(metadata),0x00019000@0x004BC000(vendor0),0x00019000@0x004D5000(vendor1),0x00096000@0x004EE000(oem),0x00002000@0x00584000(logo),-@0x00586000(userdata)
diff --git a/device/rockchip/rk3288/parameter_view.txt b/device/rockchip/rk3288/parameter_view.txt
index 89f809c6ea..1da3dc59f6 100755
--- a/device/rockchip/rk3288/parameter_view.txt
+++ b/device/rockchip/rk3288/parameter_view.txt
@@ -7,4 +7,4 @@ ATAG: 0x60000800
MACHINE: 3288
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
-CMDLINE: console= androidboot.baseband=N/A androidboot.selinux=permissive androidboot.hardware=rk30board androidboot.console= init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),0x00040000@0x00074000(cache),0x00400000@0x000B4000(system),0x00008000@0x004B4000(metadata),0x00019000@0x004BC000(vendor0),0x00019000@0x004D5000(vendor1),-@0x004EE000(userdata) rk_display_lvds_view
+CMDLINE: console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive androidboot.hardware=rk30board androidboot.console=ttyFIQ0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),0x00040000@0x00074000(cache),0x00400000@0x000B4000(system),0x00008000@0x004B4000(metadata),0x00019000@0x004BC000(vendor0),0x00019000@0x004D5000(vendor1),0x00096000@0x004EE000(oem),0x00002000@0x00584000(logo),-@0x00586000(userdata) rk_display_lvds_view
diff --git a/device/rockchip/rk3288/rk3288.mk b/device/rockchip/rk3288/rk3288.mk
index 09bec4646f..55fc3b1cde 100644
--- a/device/rockchip/rk3288/rk3288.mk
+++ b/device/rockchip/rk3288/rk3288.mk
@@ -33,6 +33,3 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.product.version = 1.0.0 \
ro.product.ota.host = www.rockchip.com:2300 \
ro.sys.sdcardfs = true
-
-PRODUCT_COPY_FILES += \
- device/rockchip/rk3288/bootanimation.zip:system/media/bootanimation.zip
diff --git a/kernel/arch/arm/Makefile b/kernel/arch/arm/Makefile
index 612277d817..3defc11a63 100644
--- a/kernel/arch/arm/Makefile
+++ b/kernel/arch/arm/Makefile
@@ -395,7 +395,7 @@ endif
%.img: %.dtb kernel.img $(LOGO) $(LOGO_KERNEL)
$(Q) if [ -f $(srctree)/$(LOGO) -a "$(srctree)" != "$(objtree)" ]; then cp -a $(srctree)/$(LOGO) $(objtree)/; fi
$(Q) if [ -f $(srctree)/$(LOGO_KERNEL) -a "$(srctree)" != "$(objtree)" ]; then cp -a $(srctree)/$(LOGO_KERNEL) $(objtree)/; fi
- $(Q)$(srctree)/scripts/resource_tool $(objtree)/arch/arm/boot/dts/$*.dtb $(LOGO) $(LOGO_KERNEL)
+ $(Q)$(srctree)/scripts/resource_tool $(objtree)/arch/arm/boot/dts/$*.dtb $(LOGO_KERNEL)
@echo ' Image: resource.img (with $*.dtb $(LOGO) $(LOGO_KERNEL)) is ready'
$(Q) if [ -x $(srctree)/scripts/mkbootimg ]; then \
$(srctree)/scripts/mkbootimg \
diff --git a/mkimage.sh b/mkimage.sh
index 131f964c4b..dba4d2374a 100755
--- a/mkimage.sh
+++ b/mkimage.sh
@@ -30,6 +30,8 @@ IMAGE_PATH=rockdev/Image-$TARGET_PRODUCT
UBOOT_PATH=u-boot
KERNEL_PATH=kernel
KERNEL_CONFIG=$KERNEL_PATH/.config
+LOGO_PATH=vendor/xxx/logo
+OEM_PATH=vendor/xxx/oem
rm -rf $IMAGE_PATH
mkdir -p $IMAGE_PATH

@@ -104,8 +106,8 @@ else
fi
echo -n "create misc.img.... "
cp -a rkst/Image/misc.img $IMAGE_PATH/misc.img
- cp -a rkst/Image/pcba_small_misc.img $IMAGE_PATH/pcba_small_misc.img
- cp -a rkst/Image/pcba_whole_misc.img $IMAGE_PATH/pcba_whole_misc.img
+ # cp -a rkst/Image/pcba_small_misc.img $IMAGE_PATH/pcba_small_misc.img
+ # cp -a rkst/Image/pcba_whole_misc.img $IMAGE_PATH/pcba_whole_misc.img
echo "done."

if [ `grep "CONFIG_WIFI_BUILD_MODULE=y" $KERNEL_CONFIG` ]; then
@@ -195,12 +197,12 @@ fi
if [ -f $UBOOT_PATH/*_loader_*.bin ]
then
echo -n "create loader..."
- cp -a $UBOOT_PATH/*_loader_*.bin $IMAGE_PATH/
+ cp -a $UBOOT_PATH/*_loader_*.bin $IMAGE_PATH/MiniLoaderAll.bin
echo "done."
else
if [ -f $UBOOT_PATH/*loader*.bin ]; then
echo -n "create loader..."
- cp -a $UBOOT_PATH/*loader*.bin $IMAGE_PATH/
+ cp -a $UBOOT_PATH/*_loader_*.bin $IMAGE_PATH/MiniLoaderAll.bin
echo "done."
elif [ "$TARGET_PRODUCT" == "px3" -a -f $UBOOT_PATH/RKPX3Loader_miniall.bin ]; then
echo -n "create loader..."
@@ -255,4 +257,17 @@ if [[ $TARGET_BOARD_PLATFORM = "rk3288" ]]; then
cp -a $OUT/vendor1.img $IMAGE_PATH/vendor1.img
echo "done."
fi
+
+if [ -d $LOGO_PATH ]; then
+ echo -n "create logo..."
+ cp -a $LOGO_PATH/* $IMAGE_PATH/
+ echo "done."
+fi
+
+if [ -d $OEM_PATH ]; then
+ echo -n "create oem.img..."
+ cp -a $OEM_PATH/* $IMAGE_PATH/
+ echo "done."
+fi
+
chmod a+r -R $IMAGE_PATH/
diff --git a/u-boot/common/resource.c b/u-boot/common/resource.c
index 1d343b5a99..1bf709c5ba 100755
--- a/u-boot/common/resource.c
+++ b/u-boot/common/resource.c
@@ -305,7 +305,7 @@ struct bmp_header *get_bmp_header(const char *bmp_name)
return NULL;

if (ptn) {
- if (read_storage(ptn->start, bmp, 1))
+ if (!read_storage(ptn->start, bmp, 1))
goto free_bmp;

} else {
diff --git a/vendor/xxx/logo/logo_inspur.bmp b/vendor/xxx/logo/logo_inspur.bmp
new file mode 100644
index 0000000000..c64b93430b
Binary files /dev/null and b/vendor/xxx/logo/logo_inspur.bmp differ
diff --git a/vendor/xxx/logo/logo_xxx.bmp b/vendor/xxx/logo/logo_xxx.bmp
new file mode 100644
index 0000000000..a9e5adb480
Binary files /dev/null and b/vendor/xxx/logo/logo_xxx.bmp differ
diff --git a/vendor/xxx/oem/oem_inspur.img b/vendor/xxx/oem/oem_inspur.img
new file mode 100644
index 0000000000..f5071830f1
Binary files /dev/null and b/vendor/xxx/oem/oem_inspur.img differ
diff --git a/device/rockchip/rk3288/bootanimation.zip b/vendor/xxx/oem/oem_xxx.img
similarity index 92%
rename from device/rockchip/rk3288/bootanimation.zip
rename to vendor/xxx/oem/oem_xxx.img
index 9a890dbbb9..530e1e649c 100644
Binary files a/device/rockchip/rk3288/bootanimation.zip and b/vendor/xxx/oem/oem_xxx.img differ
diff --git a/vendor/xxx/script/make_ext4fs b/vendor/xxx/script/make_ext4fs
new file mode 100755
index 0000000000..47bc672dae
Binary files /dev/null and b/vendor/xxx/script/make_ext4fs differ
diff --git a/vendor/xxx/script/modify-oem.sh b/vendor/xxx/script/modify-oem.sh
new file mode 100755
index 0000000000..268de0e565
--- /dev/null
+++ b/vendor/xxx/script/modify-oem.sh
@@ -0,0 +1,21 @@
+script_dir=`dirname "$BASH_SOURCE"`
+
+if [ ! -f oem.img ]; then
+ echo "oem.img is not found"
+ return
+fi
+
+if [ ! -f bootanimation.zip ]; then
+ echo "bootanimation.zip is not found"
+ return
+fi
+
+$script_dir/simg2img oem.img oem.img.ext4
+mkdir tmp
+sudo mount -t ext4 -o loop oem.img.ext4 tmp
+sudo cp ./bootanimation.zip tmp/media/
+
+sudo $script_dir/make_ext4fs -s -l 300M oem_new.img tmp
+sudo umount tmp
+rm -rf oem.img.ext4
+rm -rf tmp
diff --git a/vendor/xxx/script/readme.txt b/vendor/xxx/script/readme.txt
new file mode 100644
index 0000000000..b6a4e3aa1e
--- /dev/null
+++ b/vendor/xxx/script/readme.txt
@@ -0,0 +1,8 @@
+使用说明:
+
+1. 将新的开机动画bootanimation.zip 文件拷贝到当前目录
+2. 将需要修改的oem.img拷贝到当前目录
+3. 执行modify-oem.sh 脚本,生成的oem_new.img为修改好的oem.img
+
+注:
+ make_ext4fs modify-oem.sh simg2img bootanimation.zip oem.img 要在同一个目录下
diff --git a/vendor/xxx/script/simg2img b/vendor/xxx/script/simg2img
new file mode 100755
index 0000000000..c1de246a9d
Binary files /dev/null and b/vendor/xxx/script/simg2img differ
您的支持将鼓励我继续创作!