Reprinted please indicate the source
Author: Pony
A project of the company should be implemented based on ce6.0, but the number of boards on hand is 5.0. I wanted to save time and ask the manufacturer for a 6.0 BSP of the Board, I contacted their customer service and said that I was self-reliant because I didn't have the 6.0 BSP on this board.
At the time of writing this article, the oal part has been transplanted successfully. According to the dnw output, the system has started successfully. the rest is the peripheral driver part. I don't want to port all the drivers, because my goal is to do upper-layer applications. This upper-layer application will use some hardware resources, such as serial ports, LCD, etc. Which peripheral is used to transplant the driver. this can be completed quickly.
I didn't port bootloader because I used ads to develop a loader independently. It has eboot and nboot functions and does not use wince eboot. therefore, you can remove the bootloader directory under yourbspname/src, because it is not used. in addition, I would like to thank yashi and gooogleman on csdn for their answers to some of their questions on the Forum, which is very useful.
Let's talk about my method first. clone a 6.0 built-in BSP and use deviceemulator, because it is based on the 2410 cpu bsp, which is the closest to my board. next, compare the BSP of 5.0 and port it a little bit. It should be noted that I did not directly replace the oal-related files and directories of 5.0 with 6.0, instead, modify the source code of oal directly in the BSP of clone 6.0 without changing the original directory structure and file name of 6.0. although tedious, the BSP obtained in this way is more standard. it is recommended that Microsoft retain its original directory structure when porting to 6.0.
The procedure is as follows:
1 clone BSP
Open vs2005-tools-pfatform builder for CE 6.0-clone BSP.
Select deviceemulator for the clone source, and name your BSP my2410.
2. Create an operating system project
Use my2410 bps to create an operating system project. To facilitate oal debugging, you can create a simple system. You can select Custom when customizing the system, and then click Finish. after the LCD driver is transplanted, a shell system can be customized. After all, it is very exciting to see the interface.
3 startup code
Find the startup. s file (my2410/src/oal/oallib/ARM)
Change the value of sleepdata_base_physical to the following:
SLEEPDATA_BASE_PHYSICAL EQU 0x30058000
Find the following two lines
If software Reset
MoV R1, #0
Change
MoV RR1, #0x38000000
To the cpupoweroff. s file (my2410/src/oal/oallib)
Change the value of sleepdata_base_virtual to the following:
Sleepdata_base_virtual equ 0xac058000
Find the cpupowerreset function. Replace it with the function in BSP of 5.0 as follows:
Change leaf_entry cpupowerreset to the following (replace with 5.0 BSP)
Replace the physicalstart function (the implementation of this function is omitted)
ldr r3, =SLEEPDATA_BASE_VIRTUAL ; base of Sleep mode storagemov r2, #0x38000000 ; store Virtual return addressstr r2, [r3], #4; Disable MMUldr r2, = PhysicalStartldr r3, = (0x8C000000 - 0x30000000)sub r2, r2, r3mov r1, #0x0070 ; Disable MMUmcr p15, 0, r1, c1, c0, 0nopmov pc, r2 ; Jump to PStartnop
Find the implementation of the cpupoweroff function and find the following sentence:
Change LDR R6, = 0x88000000:
LDR R6, = 0x92000000
4. debug serial port transplantation.
Clone my2410 BSP uses uart1 as the debugging serial port by default, and changes it to uart0
First, find the oeminitdebugserial function (my2410/src/oal/oallib/debug. c) and run the following code:
CLRREG32(&pIOPortReg->GPHCON, (3 << 8)|(3 << 10));SETREG32(&pIOPortReg->GPHCON, (2 << 8)|(2 << 10));SETREG32(&pIOPortReg->GPHUP, (1 << 4)|(1 << 5));g_pUARTReg = (S3C2410X_UART_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_UART1, FALSE);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);
Changed:
CLRREG32(&pIOPortReg->GPHCON, (3 << 4)|(3 << 6));SETREG32(&pIOPortReg->GPHCON, (2 << 4)|(2 << 6));SETREG32(&pIOPortReg->GPHUP, (1 << 2)|(1 << 3));g_pUARTReg = (S3C2410X_UART_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_UART0, FALSE); 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);
Modify the macro definition in bsp_cfg.h (my2410/src/INC ).
#define BSP_UART1_ULCON 0x03 // 8 bits, 1 stop, no parity#define BSP_UART1_UCON 0x0005 // pool mode, PCLK for UART#define BSP_UART1_UFCON 0x00 // disable FIFO#define BSP_UART1_UMCON 0x00 // disable auto flow control#define BSP_UART1_UBRDIV (S3C2410X_PCLK/(38400*16) - 1)
Modify the values of the preceding five elements as follows:
#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 (S3C2410X_PCLK/(115200*16) - 1)
5 LCD Initialization
OAL's oeminit function will call the initdisplay function, so you need to follow your own LCD (my model is LTV350QV-F04, 320*240 tftscreen)
First, modify s3c2410x_ LCD .h (my2410/src/INC). The changes are as follows:
#define LCD_XSIZE_TFT (320) #define LCD_YSIZE_TFT (240)#define LCD_VBPD ((8)&0xff)#define LCD_VFPD ((4)&0xff)#define LCD_VSPW ((4)&0x3f)#define LCD_HBPD ((13)&0x7f)#define LCD_HFPD ((4)&0xff)#define LCD_HSPW ((18)&0xff)#define CLKVAL_TFT (7)
It should be noted that the LCD is a slow display device and has high timing requirements. Therefore, you must set the equivalent of vbpd (related to the return time, the specific principle and how to set the parameters refer to my other article about LCD.
Http://blog.csdn.net/pony_maggie/archive/2010/01/29/5270147.aspx
In addition, modify it in initdisplay (my2410/src/oal/oallib/init. C:
Change the LCD _mval in s2410lcd-> lcdcon1 to LCD _mval_used.
Change s2410lcd-> lcdcon5 to the following settings.
S2410lcd-> rlcdcon5 = (0 <12) | 1 <11) | (1 <10) | (1 <9) | (1 <8) | (0 <7) | (0 <6) | (0 <5) | (0 <4) | (1 <3) | (0 <2) | (0 <1) | (1 <0 );
6. memory space configuration
The memory configuration includes the following parts:
Open the oemaddrtab_cfg.inc file (my2410/src/INC), and configure the g_oaladdresstable variable according to the following values:
DCD 0x80000000, 0x02000000, 30 ; 30 MB SROM(SRAM/ROM) BANK 0 DCD 0x82000000, 0x08000000, 32 ; 32 MB SROM(SRAM/ROM) BANK 1 DCD 0x84000000, 0x10000000, 32 ; 32 MB SROM(SRAM/ROM) BANK 2 DCD 0x86000000, 0x18000000, 32 ; 32 MB SROM(SRAM/ROM) BANK 3 DCD 0x88000000, 0x20000000, 32 ; 32 MB SROM(SRAM/ROM) BANK 4 DCD 0x8A000000, 0x28000000, 32 ; 32 MB SROM(SRAM/ROM) BANK 5 DCD 0x8C000000, 0x30000000, 64 ; 64 MB DRAM BANK 0,1 DCD 0x90800000, 0x48000000, 1 ; Memory control register DCD 0x90900000, 0x49000000, 1 ; USB Host register DCD 0x90A00000, 0x4A000000, 1 ; Interrupt Control register DCD 0x90B00000, 0x4B000000, 1 ; DMA control register DCD 0x90C00000, 0x4C000000, 1 ; Clock & Power register DCD 0x90D00000, 0x4D000000, 1 ; LCD control register DCD 0x90E00000, 0x4E000000, 1 ; NAND flash control register DCD 0x91000000, 0x50000000, 1 ; UART control register DCD 0x91100000, 0x51000000, 1 ; PWM timer register DCD 0x91200000, 0x52000000, 1 ; USB device register DCD 0x91300000, 0x53000000, 1 ; Watchdog Timer register DCD 0x91400000, 0x54000000, 1 ; IIC control register DCD 0x91500000, 0x55000000, 1 ; IIS control register DCD 0x91600000, 0x56000000, 1 ; I/O Port register DCD 0x91700000, 0x57000000, 1 ; RTC control register DCD 0x91800000, 0x58000000, 1 ; A/D convert register DCD 0x91900000, 0x59000000, 1 ; SPI register DCD 0x91A00000, 0x5A000000, 1 ; SD Interface register DCD 0x92000000, 0x00000000, 2 ; 2 MB SROM(SRAM/ROM) BANK 0 DCD 0x00000000, 0x00000000, 0 ; End of Table (MB MUST BE ZERO!)
This is modified according to the value of oemaddresstable in the original 5.0 BSP.
Then replace config. Big in BSP 5.0 with config. bib (my2410/Files) in BSP 6.0)
Go to the image_cfg.h file (my2410/src/INC) and change the following macro definitions to the following values:
#define IMAGE_SHARE_ARGS_UA_START 0xAC020000#define IMAGE_SHARE_ARGS_CA_START 0x8c020800#define IMAGE_SHARE_ARGS_SIZE 0x00000800 //------------------------------------------------------------------------------#define IMAGE_FRAMEBUFFER_UA_BASE 0xAC100000#define IMAGE_FRAMEBUFFER_DMA_BASE 0x30100000
Find the following four rows:
#define EBOOT_CONFIG_OFFSET 0x000F0000 #define EBOOT_CONFIG_SIZE 0x00010000#define EXTENDED_RAM_BASE 0x94000000 // This must match the "Extended RAM" #define EXTENDED_RAM_MEGS 192 // 192 Megs
These four lines are directly commented out. The first two lines are related to eboot configurations, which will be used in files under my2410/src/bootloader/eboot. as mentioned above, I didn't use the eboot of wince, so do not. the last two rows are used to expand the memory. these two macros are used in the oemgetextensiondram function (my2410/src/oal/oallib/init. c) Yes, because the memory is not extended according to the oemaddresstabel configuration, so this can be avoided, and then the implementation of oemgetextensiondram is cleared, leaving only one row: Return
False. This function will be called in the kernel's kernelfindmemory to set the extended memory.
7. Power Management
Go to the power. c file (src/oal/power), find the cpuclearcs8900 (void) function, and change its implementation to the following:
PRIVATE voidCPUClearCS8900(void){ USHORT temp; do { temp = *((volatile USHORT *)(BSP_BASE_REG_PA_CS8900A_IOBASE + 8)); } while (temp != 0); }
In power. add void configmiscreg and configstopgpio functions in C. these two functions are called by the oempoweroff function, which is used to disable some IO resources when the system is shut down. for their implementation, see the power under the original 5.0 BSP. c file, but note that it can be used without directly copying it, because the methods for obtaining the addresses are different. For example, the original BSP obtains the preferred IP address for the IO port:
Volatile iopreg * s2410iop = (iopreg *) iop_base;
After porting to 6.0, it should be changed to the following form:
Static volatile s3c2410x_ioport_reg * s2410iop = (s3c2410x_ioport_reg *) oalpatova (s3c2410x_base_reg_pa_ioport, false );
All functions in powerstub. C (src/oal/power) have only one implementation, return True, for example:
BOOL OALIoCtlHalPresuspend( UINT32 code, VOID* pInpBuffer, UINT32 inpSize, VOID* pOutBuffer, UINT32 outSize, UINT32 *pOutSize) { return TRUE;}
8. interrupt handling
Find the bspintrinit function (src/oal/oallib/Intr. c). According to the implementation of the oeminitinterrupts function in the original BSP, modify bspintrinit as follows:
BOOL BSPIntrInit(){ S3C2410X_IOPORT_REG *pOalPortRegs; ULONG value; OALMSG(OAL_INTR&&OAL_FUNC, (L"+BSPIntrInit/r/n")); // Then get virtual address for IO port pOalPortRegs = OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE); /***************************************************************************/value = INREG32(&pOalPortRegs->GPGCON);OUTREG32(&pOalPortRegs->GPGCON, (value & ~(3 << 10))|(2 << 10)); //GPG5 == EINT13. value = INREG32(&pOalPortRegs->GPGUP);// Disable pullupOUTREG32(&pOalPortRegs->GPGUP, value | (1 << 5)); value = INREG32(&pOalPortRegs->EXTINT1);// High level interruptOUTREG32(&pOalPortRegs->EXTINT1, (value & ~(0xf << 20))|(0x4 << 20)); /***************************************************************************/ value = INREG32(&pOalPortRegs->GPGCON);// Set GPG1 as EINT9 for CS8900A OUTREG32(&pOalPortRegs->GPGCON, (value & ~(3 << 2))|(2 << 2)); value = INREG32(&pOalPortRegs->GPGUP);// Disable pullup OUTREG32(&pOalPortRegs->GPGUP, value | (1 << 1)); value = INREG32(&pOalPortRegs->EXTINT1);// High level interrupt OUTREG32(&pOalPortRegs->EXTINT1, (value & ~(0xf << 4))|(0x1 << 4)); /***************************************************************************/ value = INREG32(&pOalPortRegs->GPGCON);// Configure EINT14 for dm9000 interrupt.OUTREG32(&pOalPortRegs->GPGCON, (value & ~(3 << 12))|(2 << 12)); value = INREG32(&pOalPortRegs->GPGUP);// Disable pullupOUTREG32(&pOalPortRegs->GPGUP, value | (1 << 6)); value = INREG32(&pOalPortRegs->EXTINT1);// High level interruptOUTREG32(&pOalPortRegs->EXTINT1, (value & ~(0xf << 24))|(0x1 << 24)); /***************************************************************************/ // Configure EINT8 for PD6710 interrupt value = INREG32(&pOalPortRegs->GPGCON); OUTREG32(&pOalPortRegs->GPGCON, (value & ~(3 << 0))|(2 << 0)); // Disable pullup value = INREG32(&pOalPortRegs->GPGUP); OUTREG32(&pOalPortRegs->GPGUP, value | (1 << 0)); // Low level interrupt value = INREG32(&pOalPortRegs->EXTINT1); OUTREG32(&pOalPortRegs->EXTINT1, (value & ~(0xf << 0))|(0x1 << 0)); /***************************************************************************/s // Add static mapping for Built-In OHCI OALIntrStaticTranslate(SYSINTR_OHCI, IRQ_USBH ); OALMSG(OAL_INTR&&OAL_FUNC, (L"-BSPIntrInit(rc = 1)/r/n")); return TRUE;}
9 others
Find the init. C (src/oal/oallib/init. c) function and add two functions. These two functions are called
The implementation of initsdmmc and hzhinitpio functions can be directly copied from the original BSP (in the CFW. c file.
Then, the oeminit function calls these two functions.
The oal part should have some other things to be transplanted, but so far, the system can be started, and the peripheral driver is transplanted below
If you have any problems, go back and modify them.
Now the system can be started. The current startup information is as follows:
Windows CE Kernel for ARM (Thumb Enabled) Built on Sep 25 2009 at 11:06:11ProcessorType=0920 Revision=0OEMAddressTable = 8c205c10INFO:OALLogSetZones: dpCurSettings.ulZoneMask: 0xbDCache: 8 sets, 64 ways, 32 line size, 16384 sizeICache: 8 sets, 64 ways, 32 line size, 16384 sizethis is initDisplay2............SDMMC config current rGPGCON: 26898aSDMMC config set rGPGCON: 26898aSDMMC config Init Done.Setting up softlog at 0x8fffc000 for 0x800 entriesBooting Windows CE version 6.00 for (ARM)&pTOC = 8e00ac1c, pTOC = 8c2d6a44, pTOC->ulRamFree = 8e00f000, MemForPT = 00001000 Old or invalid version stamp in kernel structures - starting clean!Configuring: Primary pages: 8167, Secondary pages: 0, Filesystem pages = 4083 Booting kernel with clean memory configuration:Memory Sections:[0] : start: 8e011000, extension: 00004000, length: 01fe7000NKStartup done, starting up kernel.Windows CE KernelInitReserve VM for kernel XIP DLls, first = c0010000, last = c0260000g_pprcNK == 0x8e008aa0Updated eptr->e32_vsize to = 00013000Initializing Memory Mapped File SupportScheduling the first thread.Detecting VFP... VFP Not Found!LoaderInit: Initialing loaderUpdated eptr->e32_vsize to = 00013000Updated eptr->e32_vsize to = 000a3000PGPOOL: Reserved 768 pages for Loader poolPGPOOL: Reserved 256 pages for File poolOSAXST0: Platform Name = DeviceEmulatorOSAXST1: >>> Loading Module 'kd.dll' (0x8FFDF744) at address 0xC0010000-0xC0045000 in Process 'NK.EXE' (0x8E008AA0)KD: Starting kernel debugger software probe (KdStub) - KD API version 22OSAXST1: >>> Loading Module 'NK.EXE' (0x8E008AA0) at address 0x8C200000-0x8C213000 in Process 'NK.EXE' (0x8E008AA0)Message Queue support initialized, g_hMsgQHeap = d0080010OSAXST1: >>> Loading Module 'filesys.dll' (0x8FFDFE88) at address 0xC0180000-0xC01E7000 in Process 'NK.EXE' (0x8E008AA0)OSAXST1: >>> Loading Module 'fsdmgr.dll' (0x8FFBA574) at address 0xC0210000-0xC0256000 in Process 'NK.EXE' (0x8E008AA0)FSDMGR!DllMain: DLL_PROCESS_ATTACHCertMod.dll not found, using old OEM Trust ModelFileSystem Starting - starting with clean file systemFSDMGR!STOREMGR_InitializeFSDMGR!InitializeStoreAPIFSDMGR!MountTable_t::RegisterVolumeName: Registered "StoreMgr" at index 2FSDMGR!MountTable_t::RegisterVolume: Registered volume at index 2 (Name="StoreMgr", MountFlags=0x1)FSDMGR!InitializeROMFileSystem: File System=ROMOSAXST1: >>> Loading Module 'romfsd.dll' (0x8FF9E3CC) at address 0xC01F0000-0xC01F7000 in Process 'NK.EXE' (0x8E008AA0)FSDMGR!MountTable_t::RegisterVolumeName: Registered "ROM" at index 3FSDMGR!MountTable_t::RegisterVolume: Registered volume at index 3 (Name="ROM", MountFlags=0x71)FSVOL: Opening existing volumeFSVOL: Volume heap already initializedFSREG: Mounted ROM portion of boot registryFSVOL: Creating clean virtual volumeFSVOL: Initializing volume heapFSREG: Mounted RAM portion of boot registryOALIoCtlDeviceEmulatorHalInitRegistry: Set Orientation to 0 pBSPArgs->ScreenOrientation = 205 OALIoCtlDeviceEmulatorHalInitRegistry: FMD reserve size 0x7fffdfff; base addr 0x7fffd7ffFS: HKLM/System/Events not available, no signal events created.FSREG: Unable to read value "Start DevMgr" under HKEY_LOCAL_MACHINE/init/BootVarsFILESYS: Starting boot phase 0.FSDMGR!STOREMGR_StartBootPhase BootPhase=0 (PrevBootPhase=-1)FSDMGR: File security disabled.FSDMGR!AutoLoadFiFSDMGR!PNPThread: Using PNPUnloadDeleSystems: CurrentBootPhase=0, LoadFlags=lay of 4096FSDMGR!PNPThread: PNP1FSDMGR!AutoLoadFileSystem: CuThread starting!rrentBootPhase=0, RootKey=System/StorageManager/AutoLoad, FileSystem_t=ObjectStoreFILESYS: RAM File System FSD_MountDisk registering folder "Object Store"FSDMGR!MountTable_t::RegisterVolumeName: Registered "Object Store" at index 4FSDMGR!MountTable_t::RegisterVolume: Registered volume at index 4 (Name="", MountFlags=0x46)FILESYS: Starting boot phase 1.FSDMGR!STOREMGR_StartBootPhase BootPhase=1 (PrevBootPhase=0)FSDMGR!AutoLoadFileSystems: CurrentBootPhase=1, LoadFlags=1FILESYS: Waiting for bootable file system to be mounted.FILESYS: Device started. Boot file system ready.FSREG: Unable to read value "SystemHiveInitialSize" under HKEY_LOCAL_MACHINE/init/BootVarsFSVOL: Opening existing volumeFSVOL: Volume heap already initializedFSREG: Mounted ROM portion of system hiveFILESYS: Loading system hive from /Documents and Settings/system.hv.FSREG: Mounting clean system hiveBuildPath: Documents and SettingsFSVOL: Creating new volume (size=28672 bytes)FSVOL: Initializing volume heapFSREG: Taking down boot registry. Any open keys will be invalid.FILESYS: Registry in place.FSREG: Unable to read value "RegistryFlags" under HKEY_LOCAL_MACHINE/init/BootVarsFSREG: Unable to read value "RequireCertMod" under HKEY_LOCAL_MACHINE/init/BootVarsFSREG: Unable to read value "NoDefaultUser" under HKEY_LOCAL_MACHINE/init/BootVarsFSREG: Logging in default user.FSREG: Unable to read value "DefaultUser" under HKEY_LOCAL_MACHINE/init/BootVarsSetCurrentUser: Logging out (nobody), logging in defaultBuildPath: Documents and SettingsBuildPath: Documents and Settings/defaultFSREG: Mounting ROM portion of user hiveFSVOL: Opening existing volumeFSVOL: Volume heap already initializedMounting user hive from /Documents and Settings/default/user.hvFSREG: Mounting clean user hiveFSVOL: Creating new volume (size=28672 bytes)FSVOL: Initializing volume heapFSREG: Unable to read value "RegistryFlags" under HKEY_LOCAL_MACHINE/init/BootVarsFSDMGR!STOREMGR_StartBootPhase BootPhase=2 (PrevBootPhase=1)FSDMGR!AutoLoadFileSystems: CurrentBootPhFSDMGR!AutoLoadFileSystems: CurrentBootPhaase=2, LoadFlags=2se=2, LoadFlags=1Filesystem initialized!FILESYS: Waiting for kernel to be ready to launch appsInitMUI: Langs=409 0 0 0 0 0FS: HKLM/System/Events not available, no signal events created.FILESYS: Launching appsFILESYS: Done launching appsThis device has booted 1 times !!!