WinCE开机启动Logo使用Eboot读取NandFlash中的图片数据,然后显示的方式。对于开机logo的方式网友http://jazka.blog.51cto.com/809003/664131有了详细的描述。但是自己在运用的时候遇到了一些问题。现在重新进行整理。
在loader.h中增加保留的block提供给图片用。
[cpp] view
plaincopy
plaincopy
- #define LOGO_BLOCK 8
- #define LOGO_SECTOR_SIZE FILE_TO_SECTOR_SIZE(LOGO_RAM_IMAGE_SIZE)
- #define LOGO_BLOCK_SIZE 8//SECTOR_TO_BLOCK(LOGO_SECTOR_SIZE)
- #define LOGO_SECTOR BLOCK_TO_SECTOR(LOGO_BLOCK)
- /*
- #define CONFIG_BLOCK 16
- #define CONFIG_BLOCK_SIZE 1
- #define CONFIG_SECTOR BLOCK_TO_SECTOR(CONFIG_BLOCK)
- */
- #define RESERVED_BOOT_BLOCKS (NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE + LOGO_BLOCK_SIZE )
main.c中的MainMenu函数中增加通过USB下载图片的菜单
[cpp] view
plaincopy
plaincopy
- case 'G':
- case 'g':
- {
- DWORD dwDWNAddress;
- DWORD dwDWNlength;
- DWORD i;
- BYTE Temp[10];
- DWORD dwStartAddr = 0;
- LPBYTE lpDes = NULL;
- lpDes = (LPBYTE)(FILE_CACHE_START);
- OALMSG(TRUE, (TEXT("Please send the Logo through USB.\r\n")));
- g_bUSBDownload = TRUE;
- <span style="white-space:pre"> </span>if (!OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNlength))
- {
- <span style="white-space:pre"> </span>KITLOutputDebugString ("\r\nUnable to read add + size message.\r\n");
- return (FALSE);
- }
- else
- {
- <span style="white-space:pre"> </span>KITLOutputDebugString ("\rAddr: 0x%x ; Size: 0x%x\n",dwDWNAddress,dwDWNlength);
- }
- if (!OEMReadData(640*480*2, lpDes))
- {
- <span style="white-space:pre"> </span>OALMSG(TRUE, (TEXT("Error when sending the Logo through USB.\r\n")));
- SpinForever();
- }
- for( i=0; i<20; i++)
- <span style="white-space:pre"> </span>OALMSG(0, (TEXT("->0x%x\r\n"),*(lpDes+(640*480*2-10)+i)));
- dwStartAddr = (DWORD)lpDes;
- if (!WriteLogoToBootMedia(dwStartAddr, (DWORD)(640*480*2), dwStartAddr))
- {
- <span style="white-space:pre"> </span>OALMSG(TRUE, (TEXT("Error when WriteLogoToBootMedia.\r\n")));
- SpinForever();
- }
- break;
- }
在OEMPlatformInit()函数初始化LCD完成之后进行读取NandFlash中的数据进行显示,EXT_Logo()函数在nand.cpp中
[cpp] view
plaincopy
plaincopy
- void EXT_Logo(void)
- {
- SectorInfo si;
- DWORD i,j,k;
- UINT32 start_addr = 0x100000;
- k = start_addr >> 9;
- for (i=0;i<2048;i++)
- {
- j = i + k;
- FMD_ReadSector(j, (PUCHAR)(IMAGE_FRAMEBUFFER_UA_BASE_eboot+(512*i)), &si, 1);
- }
- }
在Nand.cpp中添加写图片数据到NandFlash的函数WriteLogoToBootMedia()
[cpp] view
plaincopy
plaincopy
- 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(0, (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(0, (TEXT("dwImageLength = 0x%x \r\n"), dwImageLength)); // 600k = 640 * 480 * 2
- OALMSG(0, (TEXT("dwNumBlocks = 0x%x \r\n"), dwNumBlocks)); // 5 = 600 /128
- while (dwNumBlocks--)
- {
- OALMSG(0, (TEXT("dwBlock(0x%x) X "), dwBlock)); // 8, 9, a, b, c
- OALMSG(0, (TEXT("g_FlashInfo.wSectorsPerBlock(0x%x)"), g_FlashInfo.wSectorsPerBlock)); // 64
- OALMSG(0, (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))
- { <pre name="code" class="cpp">if (!OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNlength))
- {
- KITLOutputDebugString ("\r\nUnable to read add + size message.\r\n");
- return (FALSE);
- }
- else
- {
- KITLOutputDebugString ("\rAddr: 0x%x ; Size: 0x%x\n",dwDWNAddress,dwDWNlength);
- }</pre><br>
- OALMSG(OAL_ERROR, (TEXT("WriteData: failed to write block (0x%x).\r\n"), dwBlock)); return(FALSE); } ++dwBlock; pbBuffer += g_FlashInfo.dwBytesPerBlock; OALMSG(0, (TEXT("dwBytesPerBlock : %d\r\n"), g_FlashInfo.dwBytesPerBlock)); } OALMSG(1, (TEXT(" DownLoading
- Logo success!\r\n"))); return TRUE; }<p></p>
- <pre></pre>
- <br>
- <br>
- 对于图片提取可以直接写入到NandFlash格式的数据使用Image2LCD这个软件选择16位彩色,RGB565生成BIN文件。下载地址<a href="http://download.csdn.net/detail/qq236106303/4371268">http://download.csdn.net/detail/qq236106303/4371268</a>
- <p></p>
- <p><br>
- </p>
- <p>开始使用USB下载图片时候,遇到花屏的问题,使用H-JTAG下载上面生成的bin格式的图片。能够正常显示。因此确定是USB下载有问题。而显示函数和图片格式已经正确。但是HJTAG并口下载速度太慢,不适合生产使用。所以找了下原因。 发现时因为DNW通过USB下载的时候会自动在我们选择的文件之前加上头信息。因此在程序mainMenu中,我使用了</p><pre name="code" class="cpp">if (!OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNlength))
- {
- KITLOutputDebugString ("\r\nUnable to read add + size message.\r\n");
- return (FALSE);
- }
- else
- {
- KITLOutputDebugString ("\rAddr: 0x%x ; Size: 0x%x\n",dwDWNAddress,dwDWNlength);
- }</pre>先读取DNW强加的非图片的数据,之后没有出现花屏的现象。但是对于DNW的源码没有研究,所以也不是特别确定,幸亏问题可以解决。 调试的时候可以采用打印SDRAM中的数据的方法进行调试,因为程序中指定的下载到SDRAM的地址是FILE_CACHE_START这个地址。<p></p>
- <p><br>
- </p>
- <p>下载完成logo以后,选择菜单马上进行下载NK.BIN文件,发现出现错误,说BIN文件的格式不支持。以为下载内核BIN文件,会根据开始7个字节的数据判断文件时Eboot还是nk。打印出来的信息看到开始的几个字节和NK,BIN里面的数据出现了偏移。因此也怀疑是DNW搞的鬼,最后在blcommon.c的DownloadImage函数中修改</p>
- <p></p><pre name="code" class="cpp">if (!OEMReadData (2*sizeof (UCHAR), (LPBYTE) &dwDWNAddress) || //根据打印调试出来看,出现的2个字节偏移是因为在这里读取了DWORD,所以改成2个char
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNAddress) ||
- !OEMReadData (sizeof (DWORD), (LPBYTE) &dwDWNlength))
- {
- KITLOutputDebugString ("\r\nUnable to read add + size message.\r\n");
- return (FALSE);
- }
- else
- {
- KITLOutputDebugString ("\rAddr: 0x%x ; Size: 0x%x\n",dwDWNAddress,dwDWNlength);
- }
- </pre><p></p>
- <p><br>
- </p>
- <span style="white-space:pre"></span>通过上面的修改可以顺利的使用USB先下载LOGO.BIN然后再下载NK.BIN。<br>
- <br>
- <p><br>
- </p>
- <div style="padding-top:20px">
- <p style="font-size:12px;">版权声明:本文为博主原创文章,未经博主允许不得转载。</p>