wince 5.0 移植到 utu2440 开发板记录 |
|
|
;Apollo +
;PLLVAL EQU (((0x6e << 12) + (0x3 << 4) + 0x1)) ; 2440A 399MHz
PLLVAL EQU (((0x5C << 12) + (0x1 << 4) + 0x1)) ; Fin=12MHz,Fout=400MHz
UPLLVAL EQU (((0x38 << 12) + (0x2 << 4) + 0x2)) ; Fin=12MHz,Fout=48MHz
;Apollo -
ldr r0, = UPLLCON ; Fin=16MHz, Fout=48MHz
;Apollo +
; ldr r1, = ((0x3c << 12) + (0x4 << 4) + 0x2) ; 16Mhz
; ldr r1, = ((0x38 << 12) + (0x2 << 4) + 0x2) ; 12Mhz
ldr r1, = UPLLVAL
;Apollo -
Src/Kernel/Oal/startup.s
;Apollo +
ldr r0, = UPLLCON
; ldr r1, = ((0x3c << 12) + (0x4 << 4) + 0x2)
ldr r1, = ((0x38 << 12) + (0x2 << 4) + 0x2)
;Apollo -
ldr r0, = MPLLCON
;Apollo +
; ldr r1, = ((0x3e << 12) + (0x2 << 4) + 0x1) ; 296MHz
; ldr r1, = ((0x6e << 12) + (0x3 << 4) + 0x1) ; 399MHz
ldr r1, = ((0x5C << 12) + (0x1 << 4) + 0x1) ; 400MHz
;Apollo -
src/Inc/bsp_cfg.h
//Apollo + 修改为12M晶振
//#define S3C2440A_FCLK (2 * (((PLLVALUE >> 12) & 0xff) + 8L) * (16934400L / (((PLLVALUE >> 4) & 0x3f)+2L) / (1<<((PLLVALUE >> 0) & 0x3)))) // PLLVALUE = v_pCLKPWRreg->MPLLCON
#define S3C2440A_FCLK (2 * (((PLLVALUE >> 12) & 0xff) + 8L) * (12000000L / (((PLLVALUE >> 4) & 0x3f)+2L) / (1<<((PLLVALUE >> 0) & 0x3)))) // PLLVALUE = v_pCLKPWRreg->MPLLCON
//Apollo -
特别注意,bootloader中时钟频率的设置与内核中必须一致,否则会导致一些问题,比如usb host驱动的问题
另外,在bootloader中必须设置upllcon
uboot/cpu/arm920t/start.S
ldr r0, = 0x4c000008 ; Fin=12MHz, Fout=48MHz
ldr r1, = ((0x38 << 12) + (0x2 << 4) + 0x2) ; 12Mhz
str r1, [r0]
2、修改调试串口
默认的调试串口是UART1,需要修改为UART0
src/Inc/bsp_cfg.h
//Apollo +
#define BSP_UART0_ULCON 0x03 // 8 bits, 1 stop, no parity
#define BSP_UART0_UCON 0x0245 // pool mode, PCLK for UART
#define BSP_UART0_UFCON 0x00 // disable FIFO
#define BSP_UART0_UMCON 0x00 // disable auto flow control
#define BSP_UART0_UBRDIV (S3C2440A_PCLK/(DEBUG_BAUDRATE*16) - 1)
//Apollo -
src/Kernel/Oal/debug.c
修改 OEMInitDebugSerial()函数
//Apollo +
/*
// GPH2 and GHP3 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 = (S3C2440A_UART_REG *)OALPAtoVA(S3C2440A_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);
*/
// GPH2 and GHP3 are UART0 Tx and Rx, respectively.
//
CLRREG32(&pIOPortReg->GPHCON, (3 << 4)|(3 << 6));
SETREG32(&pIOPortReg->GPHCON, (2 << 4)|(2 << 6));
// Disable pull-up on TXD0 and RXD0.
//
SETREG32(&pIOPortReg->GPHUP, (1 << 2)|(1 << 3));
// UART0 (TXD0 & RXD0) used for debug serial.
//
g_pUARTReg = (S3C2440A_UART_REG *)OALPAtoVA(S3C2440A_BASE_REG_PA_UART0, FALSE);
// Configure the UART.
//
OUTREG32(&g_pUARTReg->UFCON, BSP_UART0_UFCON);
OUTREG32(&g_pUARTReg->UMCON, BSP_UART0_UMCON);
OUTREG32(&g_pUARTReg->ULCON, BSP_UART0_ULCON);
OUTREG32(&g_pUARTReg->UCON, BSP_UART0_UCON);
OUTREG32(&g_pUARTReg->UBRDIV, BSP_UART0_UBRDIV);
//Apollo -
为了打印调试信息,先临时关闭系统的UART0串口驱动
smdk2440.bat
@REM Apollo +
@REM set BSP_NOUART0=
set BSP_NOUART0=1
@REM Apollo -
3、修改NAND FLASH驱动
src/Common/Smartmedia/fmd/fmd.cpp
FMD_Init()函数(使用uboot启动时,未在内存中初始化该参数)
//Apollo +
pBSPArgs->nfsblk = 0x0;
//Apollo -
为flash添加自动格式化功能
Files/platform.reg
[HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/SMFLASH]
添加
;Apollo +
"AutoFormat"=dword:1
;Apollo -
4、屏蔽前32Mflash(自定义功能,可不实现)
src/Common/Smartmedia/fmd/nand.h
//Apollo +
//#define SB_BLOCK_LOOP 8
//#define PAGES_PER_BLOCK 256 // Phisical 64 * logical 4
#define SB_BLOCK_LOOP 8
#define PAGES_PER_BLOCK (32*SB_BLOCK_LOOP)
#define USE_UBOOT
#ifdef USE_UBOOT
#define RESERVED_BLOCK (0x800/SB_BLOCK_LOOP)
#define RESERVED_SECTOR (RESERVED_BLOCK*PAGES_PER_BLOCK)
#define TRANSLATE_SECTOR(s) ((s) = (s) + RESERVED_SECTOR)
#define BLOCK_TO_ADDRESS(b) ((b) = (b) + RESERVED_BLOCK)
#endif
//Apollo -
src/Common/Smartmedia/fmd/fmd.cpp 中相关USE_UBOOT宏定义地方
5、LCD驱动
Src/Inc/s2c2440a_lcd.h
添加新的分辨率定义
//Apollo +
#define LCD_TYPE_TFT240_320 (3)
#define LCD_TYPE_TFT480_272 (4)
//Apollo -
//Apollo +
//#define LCD_TYPE LCD_TYPE_TFT16BPP
#define LCD_TYPE LCD_TYPE_TFT480_272
//Apollo -
//添加新的显示屏参数定义
//Apollo +
#if (LCD_TYPE == LCD_TYPE_TFT240_320)
#define LCD_XSIZE_TFT (240)
#define LCD_YSIZE_TFT (320)
#define CLKVAL_TFT (6)
#define LCD_VBPD ((1)&0xff)
#define LCD_VFPD ((2)&0xff)
#define LCD_VSPW ((1)&0x3f)
#define LCD_HBPD ((6)&0x7f)
#define LCD_HFPD ((2)&0xff)
#define LCD_HSPW ((4)&0xff)
#elif (LCD_TYPE == LCD_TYPE_TFT480_272)
#define LCD_XSIZE_TFT (480)
#define LCD_YSIZE_TFT (272)
#define CLKVAL_TFT (7)
#define LCD_VBPD ((7)&0xff)
#define LCD_VFPD ((42)&0xff)
#define LCD_VSPW ((3)&0x3f)
#define LCD_HBPD ((48)&0x7f)
#define LCD_HFPD ((16)&0xff)
#define LCD_HSPW ((128)&0xff)
#endif
//Apollo -
//修改缓冲区大小定义
//Apollo +
//#define LCD_ARRAY_SIZE_TFT_8BIT (LCD_SCR_XSIZE/1*LCD_SCR_YSIZE)
//#define LCD_ARRAY_SIZE_TFT_16BIT (LCD_SCR_XSIZE*2*LCD_SCR_YSIZE)
#define LCD_ARRAY_SIZE_TFT_8BIT (LCD_XSIZE_TFT/1*LCD_YSIZE_TFT)
#define LCD_ARRAY_SIZE_TFT_16BIT (LCD_XSIZE_TFT*2*LCD_YSIZE_TFT)
//Apollo -
//注销原有定义
//Apollo +
/*
#define LCD_VBPD ((1)&0xff)
#define LCD_VFPD ((2)&0xff)
#define LCD_VSPW ((1)&0x3f)
#define LCD_HBPD ((6)&0x7f)
#define LCD_HFPD ((2)&0xff)
#define LCD_HSPW ((4)&0xff)
*/
//Apollo -
//Apollo +
//#define CLKVAL_TFT (6)
//Apollo -
Src/Kernel/Oal/init.c
//修改lcd屏clkval值
//Apollo +
// clkval_calc = (WORD)((float)(S3C2440A_HCLK)/(2.0*5000000)+0.5)-1;
clkval_calc = (WORD)((float)(S3C2440A_HCLK)/(2.0*9200000)+0.5)-1;
//Apolo -
删除配置TCONSEL寄存器的语句
//Apollo +
// s2440LCD->TCONSEL |= (0x1<<4);
//Apollo -
Src/Drivers/Display/s3c2440disp.cpp
//添加头文件引用
//Apollo +
#include "s3c2440a_lcd.h"
//Apollo -
//修改分辨率设置
//Apollo +
/*
m_nScreenWidth = 240;
m_nScreenHeight = 320;
m_colorDepth = 16;
m_cxPhysicalScreen = 240;
m_cyPhysicalScreen = 320;
*/
m_nScreenWidth = LCD_XSIZE_TFT;
m_nScreenHeight = LCD_YSIZE_TFT;
m_colorDepth = 16;
m_cxPhysicalScreen = LCD_XSIZE_TFT;
m_cyPhysicalScreen = LCD_YSIZE_TFT;
//Apollo -
Src/Kernel/Oal/bitmap.c
使用bmp2c工具,生成新的ScreenBitmap数组,替换原有内容,可设置新的开机画面
6、触摸屏驱动
在DdisTouchPanelGetPoint,函数一开始,添加坐标点调试信息输出
//Apollo +
RETAILMSG(1,(TEXT("DdsiTouchPanelGetPoint:: *pUncalX=%d, *pUncalY=%d/r/n"),*pUncalX,*pUncalY));
//Apollo -
然后想象运行了触摸屏校验程序(如果能够实际启动触摸屏校验程序则更好),按照 中、左上、左下、右下、右上的顺序依次记录5个校验坐标点,写入platform.reg中,即可
;Apollo +
"CalibrationData"="956,536 1688,984 236,976 288,88 1700,92 "
; "CalibrationData"="480,668 127,212 133,1128 838,1120 827,212 "
;Apollo -
7、为CS8900 添加 MAC地址修改功能
Src/drivers/CS8900/cs8900.c
添加读取注册表函数
//Apollo +
WORD iMAC[3]={0x3322,0x5544,0x0F66}; //添加MAC地址的原始数据
void ReadRegsister()
{
HKEY hkMAC = NULL;
DWORD MAC;
DWORD dwStatus, dwType, dwSize;
TCHAR gszBaseInstance[256] = _T("//Comm//CS89001//Parms");
// open the registry key and read our configuration
dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, gszBaseInstance, 0, KEY_ALL_ACCESS, &hkMAC);
dwType = REG_DWORD;
if(dwStatus == ERROR_SUCCESS && dwType == REG_DWORD)
{
dwSize = sizeof(DWORD);
//下面读取失败的话那么就用初始值作为MAC地址
dwStatus = RegQueryValueEx(hkMAC, _T("MAC12"), NULL, &dwType, (LPBYTE) &MAC, &dwSize);
if (dwStatus == ERROR_SUCCESS)
{
iMAC[0]=MAC;
}
dwStatus = RegQueryValueEx(hkMAC, _T("MAC34"), NULL, &dwType, (LPBYTE) &MAC, &dwSize);
if (dwStatus == ERROR_SUCCESS)
{
iMAC[1]=MAC;
}
dwStatus = RegQueryValueEx(hkMAC, _T("MAC56"), NULL, &dwType, (LPBYTE) &MAC, &dwSize);
if (dwStatus == ERROR_SUCCESS)
{
iMAC[2]=MAC;
}
}
}
//Apollo -
initCS()函数
//Apollo +
/*
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR, 0x3322);
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR + 2, 0x5544);
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR + 4, 0x0F66);
*/
ReadRegsister();
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR, iMAC[0]);
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR + 2, iMAC[1]);
CS8900WriteRegister(PKTPG_INDIVISUAL_ADDR + 4, iMAC[2]);
//Apollo -
CS8900ReadEthernetAddress()函数
//Apollo +
/*
Adapter->PermanentAddress[0] = 0x22;
Adapter->PermanentAddress[1] = 0x33;
Adapter->PermanentAddress[2] = 0x44;
Adapter->PermanentAddress[3] = 0x55;
Adapter->PermanentAddress[4] = 0x66;
Adapter->PermanentAddress[5] = 0x0F;
*/
Adapter->PermanentAddress[0] = iMAC[0]& 0x00FF;
Adapter->PermanentAddress[1] = iMAC[0]>>8;
Adapter->PermanentAddress[2] = iMAC[1]& 0x00FF;
Adapter->PermanentAddress[3] = iMAC[1]>>8;
Adapter->PermanentAddress[4] = iMAC[2]& 0x00FF;
Adapter->PermanentAddress[5] = iMAC[2]>>8;
//Apollo -
注册表中添加MAC地址设置
Files/platform.reg
[HKEY_LOCAL_MACHINE/Comm/CS89001/Parms] 项下添加
;Apollo + MAC = 08:00:3E:26:0A:5B
"MAC12"=dword:0008
"MAC34"=dword:263E
"MAC56"=dword:5B0A
;Apollo -
开启cs8900驱动
smdk2440.bat
@REM Apollo +
@REM set BSP_NOCS8900=1
set BSP_NOCS8900=
@REM Apollo -
修改网络参数
Files/platform.reg
;Apollo +
;[HKEY_LOCAL_MACHINE/Comm/CS89001/Parms/TcpIp]
; "EnableDHCP"=dword:1
; "DefaultGateway"="0.0.0.0"
; "LLInterface"=""
; "UseZeroBroadcast"=dword:0
; "IpAddress"="0.0.0.0"
; "Subnetmask"="0.0.0.0"
; "DNS"="0.0.0.0"
[HKEY_LOCAL_MACHINE/Comm/CS89001/Parms/TcpIp]
"EnableDHCP"=dword:0
"DefaultGateway"="192.168.0.1"
"LLInterface"=""
"UseZeroBroadcast"=dword:0
"IpAddress"="192.168.0.11"
"Subnetmask"="255.255.255.0"
"DNS"="61.144.56.100"
;Apollo -
8、添加HIVE注册表保存功能
Files/platform.reg
; HIVE BOOT SECTION
;Apollo +
[HKEY_LOCAL_MACHINE/init/BootVars]
"SYSTEMHIVE"="Documents and Settings//system.hv"
"PROFILEDIR"="Documents and Settings"
"Start DevMgr"=dword:1
;如果是多用户,可以在上述的注册表位置下输入"DefaultUser"="",指定默认的用户名。如果是单用户系统,可以不设置。
; "DefaultUser"="default"
"Flags"=dword:3
"RegistryFlags"=dword:1
;Apollo -
[HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/SMFLASH/FATFS]
"Flags"=dword:14
"FormatTfat"=dword:1
"CheckForFormat"=dword:1
;Apollo +
"MountAsBootable"=dword:1
;Apollo -
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/SMFLASH]
"Prefix"="DSK"
"Dll"="smflash.dll"
"Index"=dword:1
"Order"=dword:0
"Profile"="SMFLASH"
"IClass"="{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
;Apollo +
"Flags"=dword:1000
;Apollo -
9、睡眠功能
能够关LCD屏
Src/Common/Power/off.c
ConfigStopGPIO()函数
//Apollo +
// pIOPort->GPGCON = 0x00000000;
pIOPort->GPGCON = 0x00000300;
//Apollo -
OEMPowerOff()函数(修正 唤醒后usb host 驱动问题)
//Apollo +
S3C2440A_CLKPWR_REG *pClkPwr = (S3C2440A_CLKPWR_REG*)OALPAtoVA(S3C2440A_BASE_REG_PA_CLOCK_POWER, FALSE);
//Apollo -
//Apollo +
pClkPwr->UPLLCON = 0x38022;
//Apollo -
Src/Kernel/Oal/startup.s
;休眠后关LED
;Apollo +
ldr r1, =0x30
str r1, [r0, #oGPFDAT]
;Apollo -
10、唤醒后U盘需要重插bug
修改 C:/WINCE500/PUBLIC/COMMON/OAK/DRIVERS/USB/HCD/COMMON/cdevice.cpp
函数BOOL CRootHub::EnterOperationalState( IN CPipeAbs * const DEBUG_ONLY( pEndpoint0Pipe ) )
BOOL fSuccess = FALSE; //Apollo +
Sleep(50);
//Apollo -
EnterCriticalSection( &m_csDeviceLock );
11、三串口驱动
Files/platform.reg
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial]
;Apollo +
; "ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.
;Apollo -
添加
;Apollo +
IF BSP_KITL != SERIAL_UART1
;=============== UART1 (physical COM2 connector P1) (Serial) ===============
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial2]
"DeviceArrayIndex"=dword:2
"Irq"=dword:17
"MemBase"=dword:50004000
"MemLen"=dword:2C
"InterruptBitsShift"=dword:3 ; UART 1 Interrupt Sub Register shift bit.
; "ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.
"Prefix"="COM"
"Index"=dword:2
"Dll"="serial_smdk2440.dll"
"Order"=dword:0
"Priority"=dword:0
"Port"="COM2:"
"DeviceType"=dword:0
"FriendlyName"=LOC_DISPLAYNAME_COM2
"Tsp"="unimodem.dll"
"IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
"DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
ENDIF
IF BSP_KITL != SERIAL_UART2
;=============== UART2 (physical COM3 connector P1) (Serial) ===============
[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/IRDA2440]
"DeviceArrayIndex"=dword:1
"Irq"=dword:f
"MemBase"=dword:50008000
"MemLen"=dword:2C
"InterruptBitsShift"=dword:6 ; UART 2 Interrupt Sub Register shift bit.
; "ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.
"Prefix"="COM"
"Index"=dword:3
"Dll"="serial_smdk2440.dll"
"Order"=dword:0
"Priority"=dword:0
"Port"="COM3:"
"DeviceType"=dword:0
"FriendlyName"=LOC_DISPLAYNAME_RAWIR
"IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
"DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
ENDIF
;Apollo -
12、将Flash 作为U盘使用
Files/platform.reg
为了使系统将flash识别为DSK1,需注释以下几行
;Apollo +
;[HKEY_LOCAL_MACHINE/System/StorageManager/AutoLoad/SMFLASH]
; "DriverPath"="Drivers//BuiltIn//SMFLASH"
; LoadFlags 0x01 == load synchronously
; "LoadFlags"=dword:1
; "BootPhase"=dword:0
;Apollo -
usb设置为存储模式
;[HKEY_LOCAL_MACHINE/Drivers/USB/FunctionDrivers]
; "DefaultClientDriver"=- ; erase previous default
; "DefaultClientDriver"="RNDIS"
;[HKEY_LOCAL_MACHINE/Drivers/USB/FunctionDrivers]
; "DefaultClientDriver"=- ; erase previous default
; "DefaultClientDriver"="Serial_Class"
[HKEY_LOCAL_MACHINE/Drivers/USB/FunctionDrivers]
"DefaultClientDriver"=- ; erase previous default
"DefaultClientDriver"="Mass_Storage_Class"
[HKEY_LOCAL_MACHINE/Drivers/USB/FunctionDrivers/Mass_Storage_Class]
"Dll"="usbmsfn.dll"
"InterfaceSubClass"=dword:06
"InterfaceProtocol"=dword:50
"DeviceName"="DSK1:" ; for SD/MMC : 3, for SMC : 1
"FriendlyName"="Mass Storage"
"idVendor"=dword:045E
"Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
"idProduct"=dword:FFFF
"Product"="Generic Mass Storage (PROTOTYPE--Remember to change idVendor)"
"bcdDevice"=dword:0
"Removable"=dword:0 ; all partition: 0, only one partition : 1