開機邏輯分析
增加暗碼命令切換開關機logo功能
u-boot logo顯示原理:
1.————Little Kernel會在platform_early_init階段首先會獲取lcm params,其工作流
程就是透過讀id找到現在插入的LCM,根據LCM的分辨率申請相應大小的frame buffer
並確定frame buffer起始地址
2. 為logo.bin預留4M Ram
3. 之後在platform_init階段,直接將logo.bin載入到4M Ram中
4, 完成載入後,在platform_init中mt_disp_show_boot_logo();會調用
show_logo(0);完成第一張logo顯示。其中的index=0代表在logo.bin中壓縮的第一張
圖片,logo.bin中的圖片壓縮順序可以察看文件
mediatek\custom\common\lk\logo\rules.mk
2.————4.2的kernel logo顯示原理:
Kernel logo的工作方式與U-boot logo不同,是透過init.rc中註冊的
boot_logo_updater service完成讀取raw data文件,進行繪畫的,所以在kernel
logo只是經過了bmp向raw的轉換,在目錄mediatek\custom\common\lk\logo\下生成
raw data 文件boot_logo。之後透過腳本文件將boot_logo文件搬移到
out\target\product\xxxx\system\media\images下,打包為system.img,download
到手機種,並存放於/system/media/images目錄下。
3.————4.2對於ipo快速開機,請在目錄mediatek\external\ipod\bootlogo.cpp中的
mt65xx_disp_show_boot_logo();做相應修改
4.————4.4的kernel logo和ipo快速開機用的是同一個接口。
在boot_logo_updater.c的main中與4.2的方法不同使用了show_kernel_logo函數調用
顯示了包在logo.bin中的kernel.logo,修改方法可以在alps\mediatek\external\libshowlogo\charging_animation.cpp
中對這部分代碼進行嘗試讀取nv顯示修改,kernel層的logoindex可以查看文件
mediatek\custom\common\lk\logo\rules.mk中kernel.bmp的順序
void show_kernel_logo()
{
LOG_ANIM("[charging_animation: %s %d]show kernel logo, index = 38 \n",__FUNCTION__,__LINE__);
if (error_flag == 0)
{
anim_show_logo(kernel_logo_position);
}
}
由於快速開關機部分alps\mediatek\external\ipod\bootlogo.cpp
也是使用了此接口,若添加,應該就可以做到暗碼修改了。
對於U-boot logo,只需要將不同分辨率的圖片壓縮至logo.bin中,在讀取時根據不
同的NVflag顯示相應的圖片即可
而對於Kernel logo,我們需要將不同分辨率的boot_logo raw data文件生成出來並
copy到手機中,boot_logo_updater根據不同的分辨率進行識別,讀取相應的logo文
件。在boot_logo_updater識別部分對NVflag進行判斷,進而調用不同的boot_logo。
一、主要修改文件:
1.mediatek/external.git
boot_logo_custom這部分代碼在4.4上是沒有編譯的,所以不用增加這部分的編譯機制
這部分的logo是動畫之前的那個logo,可以使用adb shell,cd 到/system/bin,執行
boot_logo_updater查看這個logo具體是哪張圖片
diff --git a/boot_logo_updater/Android.mk b/boot_logo_updater/Android.mk
index 5a28913..1b046f8 100755
--- a/boot_logo_updater/Android.mk
+++ b/boot_logo_updater/Android.mk
@@ -66,3 +66,17 @@ LOCAL_SRC_FILES := custom/$(LOCAL_MODULE)
include $(BUILD_PREBUILT)
endif
+############################################################
+ifneq ($(strip $(MTK_PLATFORM)),)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := boot_logo_custom
+
+LOCAL_MODULE_CLASS := DATA
+LOCAL_MODULE_PATH := $(TARGET_OUT)/media/images
+
+LOCAL_GENERATE_CUSTOM_FOLDER := custom:lk/logo
+LOCAL_SRC_FILES := custom/$(LOCAL_MODULE)
+
+include $(BUILD_PREBUILT)
+endif
這部分腳本編譯是為了將生成的boot_logo_custom搬到system/media/images下的
diff --git a/boot_logo_updater/boot_logo_updater.c b/boot_logo_updater/boot_logo_updater.c
index 5836f21..745d64f 100755
--- a/boot_logo_updater/boot_logo_updater.c
+++ b/boot_logo_updater/boot_logo_updater.c
@@ -93,7 +93,7 @@ extern void bootlogo_fb_init();
extern void bootlogo_fb_deinit();
*/
const char LOGO_PATH[] = "/system/media/images/boot_logo";
-
+const char LOGO_CUSTOM_PATH[] = "/system/media/images/boot_logo_custom";// **** add changeLogo 20140508
#define RGB565_TO_ARGB8888(x) \
((((x) & 0x1F) << 3) | \
(((x) & 0x7E0) << 5) | \
@@ -113,8 +113,8 @@ const char LOGO_PATH[] = "/system/media/images/boot_logo";
#define LCD_BACKLIGHT_PATH "/sys/class/leds/lcd-backlight/brightness"
#define BOOT_REASON_SYS_PROPERTY "sys.boot.reason"
#define BOOT_PACKAGE_SYS_PROPERTY "persist.sys.bootpackage"
-
-
+#define MAX_RETRY_COUNT 20 // **** add changeLogo 20140508
+#define uchar unsigned char
/*
* return value:
* 0: normal
@@ -210,7 +210,61 @@ void set_int_value(const char * path, const int value)
write_to_file(path, buf, strlen(buf));
}
-
+// **** add changeLogo 20140508 begin
+int do_read()
+{
+int fd,of,i=0,n,sectorSize,index;
+
+char *buffer = NULL;
+sectorSize=512;
+buffer = (char*)malloc(sectorSize);
+if(buffer == NULL)
+{
+printf("ERROR buffer malloc fail!");
+return -1;
+}
+memset(buffer, 0, sectorSize);
+char PN[20];
+sprintf(PN,"/dev/pro_info");
+printf("PN:%s\n",PN);//open your raw data partiton
+
+fd= open(PN,O_RDWR);
+if(fd<= 0)
+{
+printf("ERROR open fail %d\n",fd);
+return -1;
+}
+
+//read
+buffer = NULL;
+buffer = (char*)malloc(sectorSize);
+if(buffer == NULL)
+{
+printf("ERROR buffer malloc fail!");
+return -1;
+}
+of=lseek(fd,0,SEEK_SET);
+printf("lseek offset: %d\n",of);
+if(of == -1)
+{
+printf("ERROR lseek file fail!\n");
+return -1;
+}
+memset(buffer,0,sectorSize);
+n=read(fd,buffer,sectorSize);
+if(n != sectorSize)
+{
+printf("ERROR read fail\n");
+close(fd);
+return -1;
+}
+printf("result:%s",buffer);
+printf("(buffer+104):%s",*(buffer+104));
+index = atoi(*(buffer+104));
+close(fd);
+return index;
+}
+// **** add changeLogo 20140508 end
//讀取/dev/pro_info文件內的第104個字節,可以adb pull出來查看
int main(void)
{
@@ -279,12 +333,29 @@ int main(void)
printf("[boot_logo_updater] fbsize= %d\n",fbsize);
printf("[boot_logo_updater] rgb565_logo_size = %d\n",rgb565_logo_size);
// (3) open logo file
-
- if ((fd = open(LOGO_PATH, O_RDONLY)) < 0) {
- fprintf(stderr, "failed to open logo file: %s\n", LOGO_PATH);
- goto done;
- }
-
+// **** add changeLogo 20140508 begin
+#if MTK_COMMAND_SWITCH_LOGO
+ if(do_read()==0)
+ {
+ if ((fd = open(LOGO_PATH, O_RDONLY)) < 0) {
+ fprintf(stderr, "failed to open logo file: %s\n", LOGO_PATH);
+ goto done;
+ }
+ }
+ else if(do_read()==1)
+ {
+ if ((fd = open(LOGO_CUSTOM_PATH, O_RDONLY)) < 0) {
+ fprintf(stderr, "failed to open logo file: %s\n", LOGO_CUSTOM_PATH);
+ goto done;
+ }
+ }
+#else
+ if ((fd = open(LOGO_PATH, O_RDONLY)) < 0) {
+ fprintf(stderr, "failed to open logo file: %s\n", LOGO_PATH);
+ goto done;
+ }
+#endif
+// **** add changeLogo 20140508 end
// (4) map framebuffer
fbbuf = mmap(0, fbsize*2, PROT_READ|PROT_WRITE, MAP_SHARED, fb, 0);
2. mediatek/platorm.git
diff --git a/mt6572/lk/load_image.c b/mt6572/lk/load_image.c
此處是讀取dev/pro_info中第104個字節的值存儲到logoindex供mt_logo.c調用
old mode 100644
new mode 100755
index 5c8d0cb..9b0bc5a
--- a mediatek/platorm/mt6572/lk/load_image.c
+++ b mediatek/platorm/mt6572/lk/load_image.c
@@ -28,7 +28,7 @@ unsigned int g_rcimg_sz = 0;
unsigned int g_fcimg_sz = 0;
unsigned int g_kimg_sz = 0;
unsigned int g_rimg_sz = 0;
-
+unsigned char logoindex = 0;
#if 1
static int mboot_common_load_part_info(part_dev_t *dev, char *part_name, part_hdr_t *part_hdr)
@@ -168,6 +168,74 @@ exit:
return len;
}
+//Added by [email protected]
+int mboot_common_load_part_get_logo_index(char *part_name, unsigned long addr)
+{
+ long len;
+ unsigned long begin;
+#ifdef MTK_EMMC_SUPPORT
+ unsigned long long start_addr;
+#else
+ unsigned long start_addr;
+#endif
+ part_t *part;
+ part_dev_t *dev;
+ //part_hdr_t *part_hdr;
+
+ dev = mt_part_get_device();
+ if (!dev)
+ {return -ENODEV;
+ }
+
+ part = mt_part_get_partition(part_name);
+ if (!part)
+ {return -ENOENT;
+ }
+
+#ifdef MTK_EMMC_SUPPORT
+start_addr = (u64)part->startblk * BLK_SIZE;
+#else
+ start_addr = part->startblk * BLK_SIZE;
+#endif
+ printf("dai part_name = %s, start_addr = 0x%x",part_name,start_addr);
+
+ //Marked by [email protected]