本人是菜鸟,所以首先在网上找的资料,前提是你要把别人的程序读懂,才能改成自己的,这次大致花了2-3天时间搞定。
1,找到loader.h这个文件给logo.bin下载分配一定的block 如下
#define LOGO_BLOCK 6
#define LOGO_BLOCK_SIZE 20
#define LOGO_SECTOR BLOCK_TO_SECTOR(LOGO_BLOCK)
2,我们在eboot下main.c文件的mainmenu函数添加下载命令如下
EdbgOutputDebugString ( "W) Write Configuration Right Now\r\n");
EdbgOutputDebugString ( "G) DOWNLOAD Logo now(USB)\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 == 'L') || (KeySelect == 'l') ) ||
( (KeySelect == 'R') || (KeySelect == 'r') ) ||
( (KeySelect == 'U') || (KeySelect == 'u') ) ||
( (KeySelect == 'W') || (KeySelect == 'w') ) ||
( (KeySelect == 'G') || (KeySelect == 'g') )
) )
{
KeySelect = OEMReadDebugByte();
}
EdbgOutputDebugString ( "%c\r\n", KeySelect);
switch(KeySelect)
{
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;
3,我们在nanflash初始化之后读取nandflash第6块到显存,即在OEMPlatformInit函数FMD_GetInfo(&flashInfo);代码之后添加
DWORD dwReadAddr = (DWORD)EBOOT_FRAMEBUFFER_UA_START;
if (!DisplayLogoFromBootMedia(dwReadAddr, (DWORD)LCD_WIDTH*LCD_HEIGHT*2, dwReadAddr))
{
//OALMSG(TRUE, (TEXT("+DisplayLogoFromBootMedia error\r\n")));
// EdbgOutputDebugString("DisplayLogoFromBootMedia error\r\n");
int i;
unsigned short *pFB;
pFB = (unsigned short *)EBOOT_FRAMEBUFFER_UA_START;
for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
*pFB++ = 0xAE30;//0x001F; // Blue
// for (i=0; i<800*480; i++)
// *pFB++ =0xAE30;// Logo[i];//0xAE30;//0x001F;
OALMSG(TRUE,(TEXT("+DisplayLogoFromBootMedia error\r\n")));
}
4,大家可以看到我们涉及到两个函数WriteLogoToBootMedia和DisplayLogoFromBootMedia这两个函数都需要自己写,我们在nand.cpp定义,添加自己的.h声明这里两个函数方便我们调用
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));
// OALMSG(TRUE, (TEXT("^^^^^^^^ 0x%x ^^^^^^^^\r\n"),g_FlashInfo.wDataBytesPerSector));
OALMSG(TRUE, (TEXT(" g_FlashInfo.wDataBytesPerSector = 0x%x \r\n"), g_FlashInfo.wDataBytesPerSector));
OALMSG(TRUE, (TEXT("g_FlashInfo.wSectorsPerBlock = 0x%x \r\n"), g_FlashInfo.wSectorsPerBlock));
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")));
//DisplayLogoFromBootMedia( dwImageStart, dwImageLength, dwLaunchAddr) ;
svs=0;
return TRUE;
}
/*
Read the Logo data from Nand Flash
add by jazka 2014.06.04
*/
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));
// dwNumBlocks=0x60;
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;
//dst += 1024*128/4;
++dwBlock;
}
OALMSG(TRUE, (TEXT("_ReadLogoFromBootMedia\r\n")));
return TRUE;
}
5,我们生成IROM_SD_EBOOT.nb0等文件,进eboot通过g下载测试通过。