您的位置:首页 > 其它

WinCE5.0 SMDK2410 BSP在GEC2410开发板上的移植(2)-基于Nand Flash的Eboot

2009-07-06 20:58 871 查看
有了NBoot进行复制引导,Eboot就能运行在RAM中了,WinCE5.0自带SMDK2410 BSP与GEC2410硬件配置很接近,只要进行少量的修改就能运行在GEC2410上了。

一、开发环境
编译器: Platform Builder 5.0
目标板: GEC2410 S3C2410A,NAND Flash:64M K9F1208,NOR Flash:2M SST39VF1601 SDRAM 64M,CS8900

二、开始移植
1.Clone一个SMDK2410的BSP,并改名为GEC2410
2.GEC2410/src/bootloader/eboot/下为Eboot的代码,打开main.c,只有LCD和Eboot配置信息两块代码需要修改,网卡用的都是CS8900A,不需要修改,如果网卡不一样需要修改网卡驱动,网卡驱动在/WINCE500/PUBLIC/COMMON/OAK/DRIVERS/ETHDBG下
3.LCD驱动
由于LCD和原BSP中的不一样,相关参数需要修改,到板子自带的eboot中找到相应参数的数值
static void InitDisplay(void)
{
volatile S3C2410X_IOPORT_REG *s2410IOP = (S3C2410X_IOPORT_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2410X_LCD_REG    *s2410LCD = (S3C2410X_LCD_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_LCD, FALSE);

// Set up the LCD controller registers to display a power-on bitmap image.
//
s2410IOP->GPCUP     = 0xFFFFFFFF;
s2410IOP->GPCCON    = 0xAAAA56A9;//0xAAAAAAAA

s2410IOP->GPDUP     = 0xFFFFFFFF;
s2410IOP->GPDCON    = 0xAAAAAAAA;

s2410LCD->LCDCON1   =  (5           <<  8) |       /* VCLK = HCLK / ((CLKVAL + 1) * 2) -> About 7 Mhz  */
(0   <<  7)  |       /* 0 : Each Frame                                   */
(3           <<  5) |       /* TFT LCD Pannel                                   */
(12          <<  1) |       /* 16bpp Mode                                       */
(0           <<  0) ;       /* Disable LCD Output                               */

s2410LCD->LCDCON2   =  (2        << 24) |   /* VBPD          :   2                              */
(LCD_LINEVAL_TFT << 14) |   /* Vertical Size : 320 - 1                          */
(2        <<  6) |   /* VFPD          :   2                              */
(4        <<  0) ;   /* VSPW          :   4                              */

s2410LCD->LCDCON3   =  (8        << 19) |   /* HBPD          :   8                              */
(LCD_HOZVAL_TFT  <<  8) |   /* HOZVAL_TFT    : 240 - 1                          */
(8        <<  0) ;   /* HFPD          :   8                              */

s2410LCD->LCDCON4   =  (LCD_MVAL        <<  8) |   /* MVAL          :  13                              */
(6        <<  0) ;   /* HSPW          :   6                              */

s2410LCD->LCDCON5   =  (0           << 12) |       /* BPP24BL       : LSB valid                        */
(1           << 11) |       /* FRM565 MODE   : 5:6:5 Format                     */
(0           << 10) |       /* INVVCLK       : VCLK Falling Edge                */
(0           <<  9) |       /* INVVLINE      : Inverted Polarity                */
(0           <<  8) |       /* INVVFRAME     : Inverted Polarity                */
(0           <<  7) |       /* INVVD         : Normal                           */
(0           <<  6) |       /* INVVDEN       : Normal                           */
(0           <<  5) |       /* INVPWREN      : Normal                           */
(0           <<  4) |       /* INVENDLINE    : Normal                           */
(0           <<  3) |       /* PWREN         : Disable PWREN                    */
(0           <<  2) |       /* ENLEND        : Disable LEND signal              */
(0           <<  1) |       /* BSWP          : Swap Disable                     */
(1           <<  0) ;       /* HWSWP         : Swap Enable                      */

s2410LCD->LCDSADDR1 = ((IMAGE_FRAMEBUFFER_DMA_BASE >> 22)     << 21) |
((M5D(IMAGE_FRAMEBUFFER_DMA_BASE >> 1)) <<  0);

s2410LCD->LCDSADDR2 = M5D((IMAGE_FRAMEBUFFER_DMA_BASE + (LCD_XSIZE_TFT * LCD_YSIZE_TFT * 2)) >> 1);

s2410LCD->LCDSADDR3 = (((LCD_XSIZE_TFT - LCD_XSIZE_TFT) / 1) << 11) | (LCD_XSIZE_TFT / 1);

s2410LCD->LCDINTMSK |=3; // MASK LCD Sub Interrupt
s2410LCD->LPCSEL   |= ~0x7;

s2410LCD->TPAL      = 0x0;
s2410LCD->LCDCON1  |= 1;

// Display a bitmap image on the LCD...
//
memcpy((void *)IMAGE_FRAMEBUFFER_UA_BASE, ScreenBitmap, LCD_ARRAY_SIZE_TFT_16BIT);

}

这样Eboot就可以显示一副图片了,要是想减少Eboot的尺寸,LCD这块也可不要

4.Eboot 配置信息
(1)函数ResetBootConfig中有Eboot配置的初始信息
static void ResetBootConfig(PBOOT_CFG pBootCfg)
{
// Default eboot configuration values (leave the MAC address field alone)...
//
pBootCfg->Signature        = CONFIG_SIGNATURE;
pBootCfg->VerMajor         = EBOOT_VERSION_MAJOR;
pBootCfg->VerMinor         = EBOOT_VERSION_MINOR;
pBootCfg->BootDelay        = CONFIG_AUTOBOOT_DEFAULT_COUNT;
pBootCfg->ConfigFlags      = CONFIG_FLAGS_AUTOBOOT;//not use DHCP CONFIG_FLAGS_DHCP;
pBootCfg->IPAddr           = inet_addr("192.168.0.5");
pBootCfg->SubnetMask       = inet_addr("255.255.255.0");
pBootCfg->LoadDeviceOrder  = 0;

return;
}

(2)该信息保存在Flash中,由于Eboot目前保存在Nand Flash中,因此该信息也保存在Nand Flash中。
定义Eboot配置在Nand Flash中的位置大小,只需要一个Sector就可以了(512Bytes)
//EBOOT CONFIG IN NAND FLASH
#define EBOOT_CONFIG_BLOCK        19
#define EBOOT_CONFIG_SECTOR       19*32
#define EBOOT_CONFIG_SECTOR_SIZE  1

(3)原Eboot用的Nor Flash(AM29LV800),需要在OEMPlatformInit函数中注释掉AM29LV800_Init((UINT32)AMD_FLASH_START)的初始化函数
(4)实现ReadBootConfig和WriteBootConfig函数
我们用的NandFlash(K9F1208)的驱动已经有了,只需调用fmd下的flash读写函数即可。该库位于src/common/smartmedia/fmd/fmd.cpp
static BOOL ReadBootConfig(PBOOT_CFG pBootCfg)
{
BOOLEAN bResult = FALSE;
char temp[512];//store EBOOT_CONFIG_SECTOR
OALMSG(OAL_FUNC, (TEXT("+ReadBootConfig./r/n")));

// Valid caller buffer?
if (!pBootCfg)
{
OALMSG(OAL_ERROR, (TEXT("ERROR: Bad caller buffer./r/n")));
goto CleanUp;
}

// Read settings from flash...
//
if (!FMD_ReadSector(EBOOT_CONFIG_SECTOR, (PBYTE)temp, NULL, EBOOT_CONFIG_SECTOR_SIZE))
{
OALMSG(OAL_ERROR, (TEXT("ERROR: Flash read failed./r/n")));
goto CleanUp;
}
memcpy(pBootCfg,(PBOOT_CFG)temp,sizeof(BOOT_CFG));

// Check configuration signature...
//
if (pBootCfg->Signature != CONFIG_SIGNATURE)
{
OALMSG(OAL_WARN, (TEXT("WARNING: Boot configuration signature invalid - choosing defaults.../r/n")));
ResetBootConfig(pBootCfg);
WriteBootConfig(pBootCfg);
}

bResult = TRUE;

CleanUp:

OALMSG(OAL_FUNC, (TEXT("-ReadBootConfig/r/n")));

return(bResult);
}

static BOOL WriteBootConfig(PBOOT_CFG pBootCfg)
{
BOOL bResult = FALSE;

OALMSG(OAL_FUNC, (TEXT("+WriteBootConfig./r/n")));

if (!pBootCfg)
{
goto CleanUp;
}

// First, erase the eboot settings area in flash...
//
if (!FMD_EraseBlock(EBOOT_CONFIG_BLOCK))
{
OALMSG(OAL_ERROR, (TEXT("ERROR: WriteEbootConfig: Flash erase failed./r/n")));
goto CleanUp;
}
// Write settings to flash...
//
if (!FMD_WriteSector(EBOOT_CONFIG_SECTOR, (PBYTE)pBootCfg, NULL,EBOOT_CONFIG_SECTOR_SIZE))
{
OALMSG(OAL_ERROR, (TEXT("ERROR: WriteEbootConfig: Flash write failed./r/n")));
goto CleanUp;
}

bResult = TRUE;

CleanUp:
OALMSG(OAL_FUNC, (TEXT("-WriteBootConfig./r/n")));
return(bResult);
}

5.Debug Serial
为了不与之后的内核串口驱动冲突,Eboot使用UART1 38400bps的串口输出
代码位于src/kernel/oal/debug.c
#ifdef UART1_38400
// GPH4 and GHP5 are UART1 Tx and Rx, respectively.
//
CLRREG32(&pIOPortReg->GPHCON, (3 << 8)|(3 << 10));
SETREG32(&pIOPortReg->GPHCON, (2 << 8)|(2 << 10));
// Disable pull-up on TXD1 and RXD1.
//
SETREG32(&pIOPortReg->GPHUP, (1 << 4)|(1 << 5));
// UART1 (TXD1 & RXD1) used for debug serial.
//
g_pUARTReg = (S3C2410X_UART_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_UART1, FALSE);
// Configure the UART.
//
OUTREG32(&g_pUARTReg->UFCON,  BSP_UART1_UFCON);
OUTREG32(&g_pUARTReg->UMCON,  BSP_UART1_UMCON);
OUTREG32(&g_pUARTReg->ULCON,  BSP_UART1_ULCON);
OUTREG32(&g_pUARTReg->UCON,   BSP_UART1_UCON);
OUTREG32(&g_pUARTReg->UBRDIV, BSP_UART1_UBRDIV);
#endif

三、移植结果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐