WinCE6.0 修改开机Logo方法
生活随笔
收集整理的這篇文章主要介紹了
WinCE6.0 修改开机Logo方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
中秋假期已過,回來繼續(xù)該博文主題。今天講解第二種方法,將
Logo
圖片的數(shù)據(jù)寫入到
Nand Flash
中,在啟動初始化
LCD
的時候,從固定的地址將數(shù)據(jù)讀出并填充到顯示緩存中。
??????實(shí)驗(yàn)平臺:WinCE6.0+Android6410 +4.3寸CLD。
??????以下內(nèi)容參考自CSDN論壇的一個帖子,不過里面的描述不是特別清楚,該主題博文進(jìn)行了整理。為尊重原創(chuàng),給出鏈接http://topic.csdn.net/u/20100126/14/ef1fc7c4-d8db-426b-b6bf-b74d74cdd05a.html。
??????
??????將Logo圖片寫Flash的思路繼續(xù)細(xì)分,又可以分為幾種不同的實(shí)現(xiàn)方法,今天先描述實(shí)現(xiàn)方法一,這是其中比較簡單的一種方法,不需要修改bib文件等配置性文件,只需要修改代碼即可。
??????首先提幾個問題:
??????1、在什么時候?qū)?/span>Logo數(shù)據(jù)寫入Nand Flash?
??????2、在什么時候讀Nand Flash數(shù)據(jù)到顯示緩存?
??????3、要寫的Logo的數(shù)據(jù)是什么?
??????4、寫入Flash的什么位置,又從什么位置讀數(shù)據(jù)?
??????5、寫Flash的函數(shù)和讀Flash的函數(shù)如何實(shí)現(xiàn)?
??????上面幾個問題弄清楚了,方法一基本就出來了。給出上面幾個問題的解決方法:
??????1、答:為了增加后期更加方便的升級開機(jī)啟動Logo,在啟動Eboot的主菜單中添加下載Logo的選項(xiàng),如下圖所示,選項(xiàng)G)便是通過USB下載Logo數(shù)據(jù),同時將Logo數(shù)據(jù)寫入到Nand F ?????? lash的某一位置上。
??????????????2、答:在Eboot的初始化InitializeDisplay中,可以找到關(guān)于填充顯示緩存的代碼,改為從Flash的某一位置讀取即可。
?????3、答:關(guān)于寫Logo的數(shù)據(jù),可以是bin格式的,也可以是原始的bmp格式。其實(shí)bin格式的內(nèi)容也都是通過讀取bmp文件的位圖陣列而生成的。兩者的差別就在于一個在Eboot里面實(shí)現(xiàn)讀取bmp的位圖陣列,一個是在獨(dú)立的應(yīng)用程序中讀取的。
?????4、答:關(guān)于操作Nand Flash的位置問題,需要查看loader.h文件的相關(guān)代碼,有關(guān)于Block的使用情況,如下所示。在這里為Logo數(shù)據(jù)分配一定的Block。
// NAND Boot (loads into SteppingStone) @ Block 0
#define NBOOT_BLOCK???????????????????????????????? 0
#define NBOOT_BLOCK_SIZE????????????????????????1
#define NBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(NBOOT_BLOCK)
// TOC @ Block 1
#define TOC_BLOCK???????????????????????????????????? 1
#define TOC_BLOCK_SIZE????????????????????????????1
#define TOC_SECTOR????????????????????????????????????BLOCK_TO_SECTOR(TOC_BLOCK)
// Eboot @ Block 2
#define EBOOT_BLOCK???????????????????????????????? 2
#define EBOOT_SECTOR_SIZE???????????????????? FILE_TO_SECTOR_SIZE(EBOOT_RAM_IMAGE_SIZE)
#define EBOOT_BLOCK_SIZE????????????????????????SECTOR_TO_BLOCK(EBOOT_SECTOR_SIZE)
#define EBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(EBOOT_BLOCK) ??????5、答:Flash的讀寫操作函數(shù)實(shí)現(xiàn)主要在nand.cpp文件中,具體實(shí)現(xiàn)可以參考函數(shù)ReadOSImageFromBootMedia和WriteOSImageToBootMedia。 ?????下面給出詳細(xì)的修改步驟: ?????1、首先修改loader.h文件,為Logo數(shù)據(jù)分配一定的Block空間。添加如下代碼: // Eboot @ Block 2
#define EBOOT_BLOCK???????????????????????????????? 2
#define EBOOT_SECTOR_SIZE???????????????????? FILE_TO_SECTOR_SIZE(EBOOT_RAM_IMAGE_SIZE)
#define EBOOT_BLOCK_SIZE????????????????????????SECTOR_TO_BLOCK(EBOOT_SECTOR_SIZE)
#define EBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(EBOOT_BLOCK)
//-----------------------add by jazka 2011.09.04-------------------------
//-----------------------------start--------------------------------------
// Logo @ Block 6~
#define LOGO_BLOCK????????????????????6
#define LOGO_BLOCK_SIZE????????????????20
#define LOGO_SECTOR????????????????????????????BLOCK_TO_SECTOR(LOGO_BLOCK)
//----------------------------- end ---------------------------------------
//-----------------------modify by jazka 2011.09.04-----------------------
//-----------------------------start---------------------------------------
//#define RESERVED_BOOT_BLOCKS????????????????(NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE)
#define RESERVED_BOOT_BLOCKS????????????????(NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE + LOGO_BLOCK_SIZE) 從上面可以看出從Block6開始,為Logo分配了20個Block的Flash空間,這樣可以存放64KB*20=1280KB大小的Logo數(shù)據(jù),即1M以內(nèi)的圖片數(shù)據(jù)。由于Logo占用了一定的Block空間,所以后面Nk的起始位置RESERVED_BOOT_BLOCKS需要向后移動。 ??????2、在Eboot啟動主菜單中增加下載Logo數(shù)據(jù)的相應(yīng)的選項(xiàng)。修改的代碼如下: EdbgOutputDebugString ( "F) Low-level format the Smart Media card\r\n");
????//add by jazka 2011.09.05
????//-----------------------------start---------------------------------
????EdbgOutputDebugString ( "G) DOWNLOAD Logo now(USB)\r\n");
????//----------------------------- end ---------------------------------
????????????????EdbgOutputDebugString ( "L) LAUNCH existing Boot Media image\r\n");
????????????????EdbgOutputDebugString ( "R) Read Configuration \r\n");
????????????????EdbgOutputDebugString ( "U) DOWNLOAD image now(USB)\r\n");
????????????????EdbgOutputDebugString ( "W) Write Configuration Right Now\r\n");
????????????????EdbgOutputDebugString ( "\r\nEnter your selection: ");
????????????????while (! ( ( (KeySelect >= '0') && (KeySelect <= '9') ) ||
???????????????????????????????????? ( (KeySelect == 'A') || (KeySelect == 'a') ) ||
???????????????????????????????????? ( (KeySelect == 'B') || (KeySelect == 'b') ) ||
???????????????????????????????????? ( (KeySelect == 'C') || (KeySelect == 'c') ) ||
???????????????????????????????????? ( (KeySelect == 'D') || (KeySelect == 'd') ) ||
???????????????????????????????????? ( (KeySelect == 'E') || (KeySelect == 'e') ) ||
???????????????????????????????????? ( (KeySelect == 'F') || (KeySelect == 'f') ) ||
???????????? ( (KeySelect == 'G') || (KeySelect == 'g') ) ||???????????????? //add by jazak 2011.09.05
???????????????????????????????????? ( (KeySelect == 'L') || (KeySelect == 'l') ) ||
???????????????????????????????????? ( (KeySelect == 'R') || (KeySelect == 'r') ) ||
???????????????????????????????????? ( (KeySelect == 'U') || (KeySelect == 'u') ) ||
???????????????????????????????????? ( (KeySelect == 'W') || (KeySelect == 'w') ) ))
????????????????{
????????????????????????KeySelect = OEMReadDebugByte();
????????????????} //add by jazka 2011.09.05
????//--------------------------start-----------------------------
????case 'G':
????case 'g':
??????{
????????OALMSG(TRUE, (TEXT("Please send the Logo through USB.\r\n")));
????????g_bUSBDownload = TRUE;
????????{
??????????DWORD dwStartAddr = 0;
??????????LPBYTE lpDes = NULL;????????
??????????lpDes = (LPBYTE)(FILE_CACHE_START);
??????????if (!OEMReadData(LCD_WIDTH*LCD_HEIGHT*2, lpDes))
??????????{
????????????OALMSG(TRUE, (TEXT("Error when sending the Logo through USB.\r\n")));
????????????SpinForever();
??????????}
??????????dwStartAddr = (DWORD)lpDes;
??????????if (!WriteLogoToBootMedia(dwStartAddr, (DWORD)(LCD_WIDTH*LCD_HEIGHT*2), dwStartAddr))
??????????{
????????????OALMSG(TRUE, (TEXT("Error when WriteLogoToBootMedia.\r\n")));
????????????SpinForever();
??????????}
????????}
??????}
??????break;
????//-------------------------- end ----------------------------- 這里把g_bUSBDownload設(shè)置為TRUE,以便后面選擇USB進(jìn)行下載。由于USB下載的速度和寫Flash速度不匹配,所以先下載到內(nèi)存中,然后在一下子寫入Flash中(這部分詳解見博客http://jazka.blog.51cto.com/809003/605776)。WriteLogoToBootMedia便是Flash的寫函數(shù),后面給出實(shí)現(xiàn)。 ??????3、修改LCD初始化函數(shù)InitializeDisplay,修改代碼如下: // Fill Framebuffer
#if(SMDK6410_LCD_MODULE == LCD_MODULE_UT_LCD35A)
????????memcpy((void *)EBOOT_FRAMEBUFFER_UA_START, (void *)InitialImage_rgb16_320x240, 320*240*2);
#elif????????(LCD_BPP == 16)
????????{
????//delete by jazka 2011.08.31????修改開機(jī)啟動界面
???????????? /* int i;
????????????????unsigned short *pFB;
????????????????pFB = (unsigned short *)EBOOT_FRAMEBUFFER_UA_START;
????????????????for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
????{
????????????????????????//*pFB++ = 0x0000;//0x001F;????????????????// Blue
??????//*pFB++ = 0x001F;???????????????????????????????????????????? //modify by jazka 2011.07.22
??????*pFB++ = InitialImage_rgb16_480x272[i];
????}
????*/
????//add by jazka 2011.08.31
????//memcpy((void *)EBOOT_FRAMEBUFFER_UA_START, (void *)InitialImage_rgb16_480x272, 480*272*2);
????//modify by jazka 2011.09.07
????DWORD dwReadAddr = (DWORD)EBOOT_FRAMEBUFFER_UA_START;
????if (!DisplayLogoFromBootMedia(dwReadAddr, (DWORD)LCD_WIDTH*LCD_HEIGHT*2, dwReadAddr))
????{
??????int i;
??????unsigned short *pFB;
??????pFB = (unsigned short *)EBOOT_FRAMEBUFFER_UA_START;
??????for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
????????*pFB++ = 0x0000;//0x001F;????????????????// Blue
????} DisplayLogoFromBootMedia函數(shù)便是Flash的度函數(shù),這里將讀出的數(shù)據(jù)寫入到顯示緩存EBOOT_FRAMEBUFFER_US_START中,該函數(shù)的實(shí)現(xiàn)后面給出。 ?????4、修改nand.cpp文件,添加WriteLogoToBootMedia和DisplayLogoFromBootMedia兩個函數(shù)的實(shí)現(xiàn)。 /*
??Write the Logo data to Nand Flash
??add by jazka 2011.09.05
*/
BOOL WriteLogoToBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr)
{
??DWORD dwBlock,dwNumBlocks;
??LPBYTE pbBuffer;
??SectorInfo si;
??OALMSG(TRUE, (TEXT("+WriteLogoToBootMedia\r\n")));
??dwBlock = LOGO_BLOCK;
??pbBuffer = (LPBYTE)dwImageStart;
??OALMSG(TRUE, (TEXT("^^^^^^^^ 0x%x ^^^^^^^^\r\n"), (unsigned short *)pbBuffer));
??dwNumBlocks = (dwImageLength/(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock)) +????
???????????????????????????????????????????????? (dwImageLength%(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock) ? 1: 0);
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), dwImageLength));
??OALMSG(TRUE, (TEXT("dwNumBlocks = 0x%x \r\n"), dwNumBlocks));
??while (dwNumBlocks--)
??{
????OALMSG(TRUE, (TEXT("dwBlock(0x%x) X "), dwBlock));
????OALMSG(TRUE, (TEXT("g_FlashInfo.wSectorsPerBlock(0x%x)"), g_FlashInfo.wSectorsPerBlock));
????OALMSG(TRUE, (TEXT(" = 0x%x \r\n"), dwBlock*g_FlashInfo.wSectorsPerBlock));
????FMD_ReadSector(dwBlock*g_FlashInfo.wSectorsPerBlock, NULL, &si, 1);
????// Stepldr & Eboot image in nand flash
????// block mark as BLOCK_STATUS_RESERVED & BLOCK_STATUS_READONLY & BLOCK_STATUS_BAD
????if ((si.bBadBlock == 0x0) && (si.bOEMReserved !=3 ))
????{
??????++dwBlock;
??????++dwNumBlocks;????????????????// Compensate for fact that we didn't write any blocks.
??????continue;
????}
????if (!ReadBlock(dwBlock, NULL, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to read block (0x%x).\r\n"), dwBlock));
??????return(FALSE);
????}
????if (!FMD_EraseBlock(dwBlock))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to erase block (0x%x).\r\n"), dwBlock));
??????return FALSE;
????}
????if (!WriteBlock(dwBlock, pbBuffer, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to write block (0x%x).\r\n"), dwBlock));
??????return(FALSE);
????}
????++dwBlock;
????pbBuffer += g_FlashInfo.dwBytesPerBlock;
????OALMSG(TRUE, (TEXT("dwBytesPerBlock : %d\r\n"), g_FlashInfo.dwBytesPerBlock));
??}
??OALMSG(TRUE, (TEXT("_WriteLogoToBootMedia\r\n")));
??return TRUE;
} /*
??Read the Logo data from Nand Flash
??add by jazka 2011.09.05
*/
BOOL DisplayLogoFromBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr)
{
??unsigned int * pFB32 = (unsigned int *)EBOOT_FRAMEBUFFER_UA_START;
??unsigned int * dst = pFB32;????????
??//unsigned int * p = NULL;
??SectorInfo si;
??DWORD dwBlock,dwNumBlocks;
??OALMSG(TRUE, (TEXT("+ReadLogoFromBootMedia\r\n")));
??dwBlock = LOGO_BLOCK;
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), dwImageLength));
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), g_FlashInfo.wDataBytesPerSector));
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), g_FlashInfo.wSectorsPerBlock));
??if (0 == g_FlashInfo.wDataBytesPerSector || 0 == g_FlashInfo.wSectorsPerBlock)
??{
????return FALSE;
??}
??dwNumBlocks = (dwImageLength / (g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock)) +
????????????????(dwImageLength%(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock) ? 1: 0);
??OALMSG(TRUE, (TEXT("dwNumBlocks = 0x%x \r\n"), dwNumBlocks));
??while (dwNumBlocks--)
??{????
????OALMSG(TRUE, (TEXT("dwBlock(0x%x) X "), dwBlock));
????OALMSG(TRUE, (TEXT("g_FlashInfo.wSectorsPerBlock(0x%x)"), g_FlashInfo.wSectorsPerBlock));
????OALMSG(TRUE, (TEXT(" = 0x%x \r\n"), dwBlock*g_FlashInfo.wSectorsPerBlock));
????//BOOL ReadBlock(DWORD dwBlock, LPBYTE pbBlock, PSectorInfo pSectorInfoTable)
????if (!ReadBlock(dwBlock, (LPBYTE)dst, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to read block (0x%x).\r\n"), dwBlock));
??????return(FALSE);????
????}
????dst += g_FlashInfo.dwBytesPerBlock/4;
????++dwBlock;
??}
??OALMSG(TRUE, (TEXT("_ReadLogoFromBootMedia\r\n")));
??return TRUE;
} ??????5、關(guān)于Logo數(shù)據(jù)的文件bin的生成,網(wǎng)上有很多工具可以實(shí)現(xiàn),其實(shí)可以自己寫一個應(yīng)用程序完成該功能。本人編寫了24位Bmp文件生成RGB565格式的bin文件的程序,這部分代碼也可以在nand.app中寫成一個函數(shù),在寫入Flash時調(diào)用轉(zhuǎn)換為相應(yīng)的RGB565數(shù)據(jù)即可,這樣更新Logo時可以更直接。注意下載時的數(shù)據(jù)量是現(xiàn)在的3倍。 ??????這里就不給出源代碼了,如果需要,請留言。 ? ?????? 今天就到這里,改天上實(shí)現(xiàn)方法二:將 Logo.bin 做成和 Eboot.bin 一樣的格式,這樣下載 Eboot.bin 的很多代碼就可以直接使用。
#define NBOOT_BLOCK???????????????????????????????? 0
#define NBOOT_BLOCK_SIZE????????????????????????1
#define NBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(NBOOT_BLOCK)
// TOC @ Block 1
#define TOC_BLOCK???????????????????????????????????? 1
#define TOC_BLOCK_SIZE????????????????????????????1
#define TOC_SECTOR????????????????????????????????????BLOCK_TO_SECTOR(TOC_BLOCK)
// Eboot @ Block 2
#define EBOOT_BLOCK???????????????????????????????? 2
#define EBOOT_SECTOR_SIZE???????????????????? FILE_TO_SECTOR_SIZE(EBOOT_RAM_IMAGE_SIZE)
#define EBOOT_BLOCK_SIZE????????????????????????SECTOR_TO_BLOCK(EBOOT_SECTOR_SIZE)
#define EBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(EBOOT_BLOCK) ??????5、答:Flash的讀寫操作函數(shù)實(shí)現(xiàn)主要在nand.cpp文件中,具體實(shí)現(xiàn)可以參考函數(shù)ReadOSImageFromBootMedia和WriteOSImageToBootMedia。 ?????下面給出詳細(xì)的修改步驟: ?????1、首先修改loader.h文件,為Logo數(shù)據(jù)分配一定的Block空間。添加如下代碼: // Eboot @ Block 2
#define EBOOT_BLOCK???????????????????????????????? 2
#define EBOOT_SECTOR_SIZE???????????????????? FILE_TO_SECTOR_SIZE(EBOOT_RAM_IMAGE_SIZE)
#define EBOOT_BLOCK_SIZE????????????????????????SECTOR_TO_BLOCK(EBOOT_SECTOR_SIZE)
#define EBOOT_SECTOR????????????????????????????????BLOCK_TO_SECTOR(EBOOT_BLOCK)
//-----------------------add by jazka 2011.09.04-------------------------
//-----------------------------start--------------------------------------
// Logo @ Block 6~
#define LOGO_BLOCK????????????????????6
#define LOGO_BLOCK_SIZE????????????????20
#define LOGO_SECTOR????????????????????????????BLOCK_TO_SECTOR(LOGO_BLOCK)
//----------------------------- end ---------------------------------------
//-----------------------modify by jazka 2011.09.04-----------------------
//-----------------------------start---------------------------------------
//#define RESERVED_BOOT_BLOCKS????????????????(NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE)
#define RESERVED_BOOT_BLOCKS????????????????(NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE + LOGO_BLOCK_SIZE) 從上面可以看出從Block6開始,為Logo分配了20個Block的Flash空間,這樣可以存放64KB*20=1280KB大小的Logo數(shù)據(jù),即1M以內(nèi)的圖片數(shù)據(jù)。由于Logo占用了一定的Block空間,所以后面Nk的起始位置RESERVED_BOOT_BLOCKS需要向后移動。 ??????2、在Eboot啟動主菜單中增加下載Logo數(shù)據(jù)的相應(yīng)的選項(xiàng)。修改的代碼如下: EdbgOutputDebugString ( "F) Low-level format the Smart Media card\r\n");
????//add by jazka 2011.09.05
????//-----------------------------start---------------------------------
????EdbgOutputDebugString ( "G) DOWNLOAD Logo now(USB)\r\n");
????//----------------------------- end ---------------------------------
????????????????EdbgOutputDebugString ( "L) LAUNCH existing Boot Media image\r\n");
????????????????EdbgOutputDebugString ( "R) Read Configuration \r\n");
????????????????EdbgOutputDebugString ( "U) DOWNLOAD image now(USB)\r\n");
????????????????EdbgOutputDebugString ( "W) Write Configuration Right Now\r\n");
????????????????EdbgOutputDebugString ( "\r\nEnter your selection: ");
????????????????while (! ( ( (KeySelect >= '0') && (KeySelect <= '9') ) ||
???????????????????????????????????? ( (KeySelect == 'A') || (KeySelect == 'a') ) ||
???????????????????????????????????? ( (KeySelect == 'B') || (KeySelect == 'b') ) ||
???????????????????????????????????? ( (KeySelect == 'C') || (KeySelect == 'c') ) ||
???????????????????????????????????? ( (KeySelect == 'D') || (KeySelect == 'd') ) ||
???????????????????????????????????? ( (KeySelect == 'E') || (KeySelect == 'e') ) ||
???????????????????????????????????? ( (KeySelect == 'F') || (KeySelect == 'f') ) ||
???????????? ( (KeySelect == 'G') || (KeySelect == 'g') ) ||???????????????? //add by jazak 2011.09.05
???????????????????????????????????? ( (KeySelect == 'L') || (KeySelect == 'l') ) ||
???????????????????????????????????? ( (KeySelect == 'R') || (KeySelect == 'r') ) ||
???????????????????????????????????? ( (KeySelect == 'U') || (KeySelect == 'u') ) ||
???????????????????????????????????? ( (KeySelect == 'W') || (KeySelect == 'w') ) ))
????????????????{
????????????????????????KeySelect = OEMReadDebugByte();
????????????????} //add by jazka 2011.09.05
????//--------------------------start-----------------------------
????case 'G':
????case 'g':
??????{
????????OALMSG(TRUE, (TEXT("Please send the Logo through USB.\r\n")));
????????g_bUSBDownload = TRUE;
????????{
??????????DWORD dwStartAddr = 0;
??????????LPBYTE lpDes = NULL;????????
??????????lpDes = (LPBYTE)(FILE_CACHE_START);
??????????if (!OEMReadData(LCD_WIDTH*LCD_HEIGHT*2, lpDes))
??????????{
????????????OALMSG(TRUE, (TEXT("Error when sending the Logo through USB.\r\n")));
????????????SpinForever();
??????????}
??????????dwStartAddr = (DWORD)lpDes;
??????????if (!WriteLogoToBootMedia(dwStartAddr, (DWORD)(LCD_WIDTH*LCD_HEIGHT*2), dwStartAddr))
??????????{
????????????OALMSG(TRUE, (TEXT("Error when WriteLogoToBootMedia.\r\n")));
????????????SpinForever();
??????????}
????????}
??????}
??????break;
????//-------------------------- end ----------------------------- 這里把g_bUSBDownload設(shè)置為TRUE,以便后面選擇USB進(jìn)行下載。由于USB下載的速度和寫Flash速度不匹配,所以先下載到內(nèi)存中,然后在一下子寫入Flash中(這部分詳解見博客http://jazka.blog.51cto.com/809003/605776)。WriteLogoToBootMedia便是Flash的寫函數(shù),后面給出實(shí)現(xiàn)。 ??????3、修改LCD初始化函數(shù)InitializeDisplay,修改代碼如下: // Fill Framebuffer
#if(SMDK6410_LCD_MODULE == LCD_MODULE_UT_LCD35A)
????????memcpy((void *)EBOOT_FRAMEBUFFER_UA_START, (void *)InitialImage_rgb16_320x240, 320*240*2);
#elif????????(LCD_BPP == 16)
????????{
????//delete by jazka 2011.08.31????修改開機(jī)啟動界面
???????????? /* int i;
????????????????unsigned short *pFB;
????????????????pFB = (unsigned short *)EBOOT_FRAMEBUFFER_UA_START;
????????????????for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
????{
????????????????????????//*pFB++ = 0x0000;//0x001F;????????????????// Blue
??????//*pFB++ = 0x001F;???????????????????????????????????????????? //modify by jazka 2011.07.22
??????*pFB++ = InitialImage_rgb16_480x272[i];
????}
????*/
????//add by jazka 2011.08.31
????//memcpy((void *)EBOOT_FRAMEBUFFER_UA_START, (void *)InitialImage_rgb16_480x272, 480*272*2);
????//modify by jazka 2011.09.07
????DWORD dwReadAddr = (DWORD)EBOOT_FRAMEBUFFER_UA_START;
????if (!DisplayLogoFromBootMedia(dwReadAddr, (DWORD)LCD_WIDTH*LCD_HEIGHT*2, dwReadAddr))
????{
??????int i;
??????unsigned short *pFB;
??????pFB = (unsigned short *)EBOOT_FRAMEBUFFER_UA_START;
??????for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
????????*pFB++ = 0x0000;//0x001F;????????????????// Blue
????} DisplayLogoFromBootMedia函數(shù)便是Flash的度函數(shù),這里將讀出的數(shù)據(jù)寫入到顯示緩存EBOOT_FRAMEBUFFER_US_START中,該函數(shù)的實(shí)現(xiàn)后面給出。 ?????4、修改nand.cpp文件,添加WriteLogoToBootMedia和DisplayLogoFromBootMedia兩個函數(shù)的實(shí)現(xiàn)。 /*
??Write the Logo data to Nand Flash
??add by jazka 2011.09.05
*/
BOOL WriteLogoToBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr)
{
??DWORD dwBlock,dwNumBlocks;
??LPBYTE pbBuffer;
??SectorInfo si;
??OALMSG(TRUE, (TEXT("+WriteLogoToBootMedia\r\n")));
??dwBlock = LOGO_BLOCK;
??pbBuffer = (LPBYTE)dwImageStart;
??OALMSG(TRUE, (TEXT("^^^^^^^^ 0x%x ^^^^^^^^\r\n"), (unsigned short *)pbBuffer));
??dwNumBlocks = (dwImageLength/(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock)) +????
???????????????????????????????????????????????? (dwImageLength%(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock) ? 1: 0);
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), dwImageLength));
??OALMSG(TRUE, (TEXT("dwNumBlocks = 0x%x \r\n"), dwNumBlocks));
??while (dwNumBlocks--)
??{
????OALMSG(TRUE, (TEXT("dwBlock(0x%x) X "), dwBlock));
????OALMSG(TRUE, (TEXT("g_FlashInfo.wSectorsPerBlock(0x%x)"), g_FlashInfo.wSectorsPerBlock));
????OALMSG(TRUE, (TEXT(" = 0x%x \r\n"), dwBlock*g_FlashInfo.wSectorsPerBlock));
????FMD_ReadSector(dwBlock*g_FlashInfo.wSectorsPerBlock, NULL, &si, 1);
????// Stepldr & Eboot image in nand flash
????// block mark as BLOCK_STATUS_RESERVED & BLOCK_STATUS_READONLY & BLOCK_STATUS_BAD
????if ((si.bBadBlock == 0x0) && (si.bOEMReserved !=3 ))
????{
??????++dwBlock;
??????++dwNumBlocks;????????????????// Compensate for fact that we didn't write any blocks.
??????continue;
????}
????if (!ReadBlock(dwBlock, NULL, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to read block (0x%x).\r\n"), dwBlock));
??????return(FALSE);
????}
????if (!FMD_EraseBlock(dwBlock))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to erase block (0x%x).\r\n"), dwBlock));
??????return FALSE;
????}
????if (!WriteBlock(dwBlock, pbBuffer, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to write block (0x%x).\r\n"), dwBlock));
??????return(FALSE);
????}
????++dwBlock;
????pbBuffer += g_FlashInfo.dwBytesPerBlock;
????OALMSG(TRUE, (TEXT("dwBytesPerBlock : %d\r\n"), g_FlashInfo.dwBytesPerBlock));
??}
??OALMSG(TRUE, (TEXT("_WriteLogoToBootMedia\r\n")));
??return TRUE;
} /*
??Read the Logo data from Nand Flash
??add by jazka 2011.09.05
*/
BOOL DisplayLogoFromBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr)
{
??unsigned int * pFB32 = (unsigned int *)EBOOT_FRAMEBUFFER_UA_START;
??unsigned int * dst = pFB32;????????
??//unsigned int * p = NULL;
??SectorInfo si;
??DWORD dwBlock,dwNumBlocks;
??OALMSG(TRUE, (TEXT("+ReadLogoFromBootMedia\r\n")));
??dwBlock = LOGO_BLOCK;
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), dwImageLength));
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), g_FlashInfo.wDataBytesPerSector));
??OALMSG(TRUE, (TEXT("dwImageLength = 0x%x \r\n"), g_FlashInfo.wSectorsPerBlock));
??if (0 == g_FlashInfo.wDataBytesPerSector || 0 == g_FlashInfo.wSectorsPerBlock)
??{
????return FALSE;
??}
??dwNumBlocks = (dwImageLength / (g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock)) +
????????????????(dwImageLength%(g_FlashInfo.wDataBytesPerSector*g_FlashInfo.wSectorsPerBlock) ? 1: 0);
??OALMSG(TRUE, (TEXT("dwNumBlocks = 0x%x \r\n"), dwNumBlocks));
??while (dwNumBlocks--)
??{????
????OALMSG(TRUE, (TEXT("dwBlock(0x%x) X "), dwBlock));
????OALMSG(TRUE, (TEXT("g_FlashInfo.wSectorsPerBlock(0x%x)"), g_FlashInfo.wSectorsPerBlock));
????OALMSG(TRUE, (TEXT(" = 0x%x \r\n"), dwBlock*g_FlashInfo.wSectorsPerBlock));
????//BOOL ReadBlock(DWORD dwBlock, LPBYTE pbBlock, PSectorInfo pSectorInfoTable)
????if (!ReadBlock(dwBlock, (LPBYTE)dst, g_pSectorInfoBuf))
????{
??????OALMSG(OAL_ERROR, (TEXT("WriteData: failed to read block (0x%x).\r\n"), dwBlock));
??????return(FALSE);????
????}
????dst += g_FlashInfo.dwBytesPerBlock/4;
????++dwBlock;
??}
??OALMSG(TRUE, (TEXT("_ReadLogoFromBootMedia\r\n")));
??return TRUE;
} ??????5、關(guān)于Logo數(shù)據(jù)的文件bin的生成,網(wǎng)上有很多工具可以實(shí)現(xiàn),其實(shí)可以自己寫一個應(yīng)用程序完成該功能。本人編寫了24位Bmp文件生成RGB565格式的bin文件的程序,這部分代碼也可以在nand.app中寫成一個函數(shù),在寫入Flash時調(diào)用轉(zhuǎn)換為相應(yīng)的RGB565數(shù)據(jù)即可,這樣更新Logo時可以更直接。注意下載時的數(shù)據(jù)量是現(xiàn)在的3倍。 ??????這里就不給出源代碼了,如果需要,請留言。 ? ?????? 今天就到這里,改天上實(shí)現(xiàn)方法二:將 Logo.bin 做成和 Eboot.bin 一樣的格式,這樣下載 Eboot.bin 的很多代碼就可以直接使用。
本文出自 “飛雪待劍” 博客,請務(wù)必保留此出處http://jazka.blog.51cto.com/809003/664131
總結(jié)
以上是生活随笔為你收集整理的WinCE6.0 修改开机Logo方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux logo和屏幕光标
- 下一篇: 神十四发射前神十五就准备好了:能作为救援