首页 > 代码库 > sp5v210 开机logo
sp5v210 开机logo
1,在loader.h给logo分配块
// NAND Boot (loads into SteppingStone) @ Block 0
#define NBOOT_BLOCK 0
#define NBOOT_BLOCK_SIZE 1
#define NBOOT_SECTOR BLOCK_TO_SECTOR(NBOOT_BLOCK)
// Eboot @ Block 1
#define EBOOT_BLOCK 1
#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)
// LOGO @ Block 8
#define LOGO_BLOCK (6)
#define LOGO_SECTOR_SIZE FILE_TO_SECTOR_SIZE(LOGO_RAM_IMAGE_SIZE)
#define LOGO_BLOCK_SIZE 20
#define LOGO_SECTOR BLOCK_TO_SECTOR(LOGO_BLOCK)
// TOC @ Block 5
#define TOC_BLOCK (LOGO_BLOCK+EBOOT_BLOCK+EBOOT_BLOCK_SIZE+1)
#define TOC_BLOCK_SIZE 1
#define TOC_SECTOR BLOCK_TO_SECTOR(TOC_BLOCK)
#define RESERVED_BOOT_BLOCKS (NBOOT_BLOCK_SIZE + TOC_BLOCK_SIZE + EBOOT_BLOCK_SIZE+LOGO_BLOCK_SIZE)
// Images start after OEM Reserved Blocks
#define IMAGE_START_BLOCK RESERVED_BOOT_BLOCKS
#define IMAGE_START_SECTOR BLOCK_TO_SECTOR(IMAGE_START_BLOCK)
2,在nand.cpp
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;
}
3,在main.c
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,在menu.c添加
while(1)
{
selection = OEMReadDebugByte();
for(i = 0; i < nMenuItem; i++)
{
if (selection==‘x‘ || selection==‘X‘)
{
EdbgOutputDebugString("%c\r\n\r\n", selection);
return 0;
}
if (selection==‘P‘ || selection==‘p‘)
{ //OEMPlatformInit();
CheckUSBDownload();
OEMPreDownload();
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();
}
}
return 0;
}
sp5v210 开机logo