KITL从5.0到6.0的移植

今天KITL移植终于通过了,累死我了,让我纠结了好久啊!当然要说完全通过也不一定,毕竟还有一个重要的问题没有解决,就是如何将CS8900A替换为DM9000,不过现在这个问题暂时先不关注了,因为,我想休息一下,毕竟都有近两个星期没有进展了,突然在今天,一个周六,给调试出来了,呵呵,意外,多少有点搞笑,难道我真的适合加班?闲话不说,来看正题。
首先,我们来看一下MSDN是怎么说的:
五、To create and build Kitl.dll
Moving the KITL source code from the OAL into Kitl.dll should be a fairly straightforward process. Kitl.dll must export the following new functions:
OEMKitlStartup
This function is called from the kernel when KITLIoctl(IOCTL_KITL_STARTUP, NULL, 0, NULL, 0, NULL) is invoked by the OAL.
This function is equivalent to the OALKitlStart function, but it has been renamed to follow the convention for public OEM functions. The Windows Embedded CE 6.0 kernel requires that you use the new function name OEMKitlStartup.
OEMKitlIoctl
This function handles all KITL-related IOCTLs when KITL is removed from the OAL. In most cases, you can use the common version of this function, which is implemented in Oal_Kitl.lib.

1.Move all your KITL-related source code from the Src\Oal\OalLib folder into the Src\Kitl folder.

For more information on how to do this, see Removing KITL from the OAL.
To remove KITL from the OAL:
a.Remove any KITL stubs from the Src\Oal\OalExe folder.

b.Move any KITL-related files from the Src\Oal\OalLib folder to the Src\Kitl folder.

c.Remove KITL-related file names and libraries from the Src\Oal\OalLib sources file.

d.Remove the following IOCTLs from your OAL IOCTL table (Oal_IOCTL_Tab.h):

IOCTL_VBRIDGE_ADD_MAC


IOCTL_VBRIDGE_CURRENT_PACKET_FILTER


IOCTL_VBRIDGE_GET_ETHERNET_MAC


IOCTL_VBRIDGE_GET_RX_PACKET


IOCTL_VBRIDGE_GET_RX_PACKET_COMPLETE


IOCTL_VBRIDGE_GET_TX_PACKET


IOCTL_VBRIDGE_GET_TX_PACKET_COMPLETE


IOCTL_VBRIDGE_SHARED_ETHERNET


IOCTL_VBRIDGE_WILD_CARD


IOCTL_VBRIDGE_WILD_CARD_RESET_BUFFER


IOCTL_VBRIDGE_WILD_CARD_VB_INITIALIZED


These IOCTLs are now handled by Kitl.dll (KitlIoCtl).


2.Copy the makefile from the Src\Oal\OalLib folder to the Src\Kitl folder.

3.Create the sources file.

To do this, use the following commands:
TARGETNAME=KITL
TARGETTYPE=DYNLINK
DLLENTRY=KitlDllMain
DEFFILE=
Then, add the following TARGETLIBS: KitlCore.lib, OEMStub.lib, and NkStub.lib.

These libraries are in addition to any other libraries required by your KITL implementation.

4.Rename OALKitlStart to OEMKitlStartup.

5.Initialize two KITL power function pointers in OEMKitlInit.

To do this, use the following code example:
pKitl->pfnPowerOn = OALKitlPowerOn;
pKitl->pfnPowerOff = OALKitlPowerOff;
This step is required only if your OAL is implementing these functions.

6.Run the build command and verify that Kitl.dll builds without any errors.

看着挺多内容,实际理解起来不难,网上可以参开的内容也很多,但是有一个地方始终调试不通。就是第四条:4.Rename OALKitlStart to OEMKitlStartup.
这个函数到底在那里改呢?于是翻书,搜索等等,终于发现是在init.c这个文件下,于是在oeminit()函数下将OALKitlStart()注释,并添加OEMKitlStartup()这个函数,然后 编译,奇怪怎么还是有错啊!真是头疼!错误始终还是那两个,现在记不清了到底是哪个了?等我晚上回来重新再做一次。
要么是:
BUILD: [Thrd:Sequence:Type  ] Message
BUILD: [01:0000000021:ERRORE] D:\WINCE600\PLATFORM\mini2440\src\KITL\ETHERNET\DLL\sources(15) :  U1033: syntax error : 'kitl.c' unexpected
BUILD: [01:0000000023:ERRORE] NMAKE.EXE TargetCompilePass  -i -c BUILDMSG=Stop.  BUILDROOT=D:\WINCE600\PLATFORM\mini2440 CLEANBUILD=1 NOLINK=1 NOPASS0=1 failed - rc = 2
要么是:
BUILD: [Thrd:Sequence:Type  ] Message
BUILD: [01:0000000113:ERRORE] kitl.obj : error LNK2019: unresolved external symbol OALArgsQuery referenced in function OEMKitlStartup
BUILD: [01:0000000114:ERRORE] D:\WINCE600\platform\Micro2440\target\ARMV4I\debug\kitl.dll : fatal error LNK1120: 1 unresolved externals
要么是:
这个错误和OEMKITLSTART()有关,具体原因因为刚才调试过程中没有保存,所以被覆盖掉了,等晚上回来再整,肯定还会出现的。
哎,说起来也不难,就这么几步,想到了就很简单,想不到就难了,一开始我把方向搞错了,一直以为是CS8900A和DM9000之间没有转换好,确切的说是老以为是应该是DM9000而不是CS8900A,其实KITL只是用到了以太网口而已,不管你是DM9000还是CS8900A,先调通KITL再说嘛。抱着这个心思,我就不纠结到底是CS8900A还是DM900了,在翻阅书籍以后,直觉告诉我ARGS.C这个文件很可能是问题的所在。为了进一步验证我的观点,我首先没有添加这个文件,直接把朋友给我的一份移植好的BSP6.0下的KITLO移植过来,毕竟都是samsung2440,cpu是一样的,外部只是有那么一点不同而已,内核应该相差不大。于是,完全复制过来以后,,REBUILD,好像是无法编译 $(_TARGETPLATROOT)\lib\$(_CPUINDPATH)\s3c2440a_args.lib \这个库,于是我直接删除,接下来继续编译错误又换成无法编译 $(_TARGETPLATROOT)\lib\$(_CPUDEPPATH)\nandflash_lib.lib  \,继续删除,我就不信一直让我删除下去,接着继续编译,这次错误换成上述的OALKitlStart()相关的了,于是我在OALLIB文件下修改init.c文件,添加OALKitlStart()这个函数,生成解决方案,这下四个错误:除了OALKitlStart()这个错误继续存在以外,一看oal.exe也出现问题了,那就否定了我刚才的做法,KITL是基于OAL进行的调试,也就是在不损害OAL的前提下进行移植的。所以,还是不对,于是我回复到之前的操作,即把OALKitlStart()给注释掉,又把5.0的BSP里面的args.c文件复制到kitl目录下,在source文件下添加kitl.c\,接着看了下INC下面的args.c文件,觉得不大对劲,和李大为书上讲的出入很大,少了一些东西,应该是这个结构体吧BSP_ARGS, *PBSP_ARGS;当然李大为介绍的是基于模拟器的,这个地方我先把朋友给的BSP包里的直接复制过来并进行覆盖,重新编译,啊!终于成功了!
太难了!
呵呵!
多少有点成就感了!
现在的问题依然存在:
1,$(_TARGETPLATROOT)\lib\$(_CPUDEPPATH)\nandflash_lib.lib  \和$(_TARGETPLATROOT)\lib\$(_CPUINDPATH)\s3c2440a_args.lib \为什么要删除了,不删除是否可以,尤其是$(_TARGETPLATROOT)\lib\$(_CPUINDPATH)\s3c2440a_args.lib \这个静态库,显然和ARGS.C这个文件有关,我却删除了,回头逐一添加,看看什么情况。
2,如果INC里面的args.c文件换成是DEVICEEMULATOR是会是什么样子呢,毕竟朋友给的BSP包和模拟器的多少有点出入,也是进行了一定的修改的。这个回来可以一试。
3.最重要的是KITL可以基于serial也可以基于以太网口,听gooogleman说还可以基于USB,到底基于哪个呢?如何进行选择呢?而微软实现的全代码是基于serial和以太网口的。以太网口又是选择DM9000还是CS8900A呢?这个问题有点纠结。
当然了,有点进步还是好的,毕竟每天要进步一点点嘛,和自己比才有进步,和高手比才有动力!
好了今天先备份,晚上接着搞!

 

你可能感兴趣的:(it)