本帖最后由 littler 于 2016-12-24 21:39 编辑
尽管已经MicroZed下运行ucos调试ucos_tcpip日志中,已经将网口程序调试通过,但在实际使用时发现ucos没有公开这部分源码,不易扩展,下面将我移植的过程记录下来。
在ucos中configuration for OS的ethernet设置保持默认设置;
在driver中设置ethernet的驱动为emacps。

在ucos 1.30版的ucos_standalone的src中xil_types.h与vivado2015.1中的emacps中数据类型定义不同。所以生成emacps的时候会出现LONG找不到定义的错误。解决办法将ucos库(不是BSP)中的xil_types.h文件用2015.1版standalone中xil_types.h替换。文件所在路径如下ucos_v1_30\ucos\components\ucos_standalone\src\common
由于修改的lwip的OS支持中使用的sem、mutex、mbox等与ucos系统相关的模块,采用KAL进行创建,所以需要使用从堆上分配空间,ucos默认的HEAP_SIZE为512,不够使用(原因参见ZYNQ ucos KAL_LockCreate创建互斥信号量失败),所以这里设置为10K。

将lwip在standalone BSP中生成源代码拷贝到ucos的应用程序工程目录下。设置include文件目录
修改sys_arch.h文件,定义ucos相关的系统变量类型,如下所示

修改sys_arch.c中具体的函数实现。注:在创建任务、信号量、消息队列时增加一些调试信息,便于调试。
更改完成后,需要修改opt.h中的,TCPIP_THREAD_STACKSIZE的大小8182。
优先级默认为1,倒可以不用修改,修改的优先级不能低于创建tcpip任务的优先级,不然会造成任务创建不成功,而出现死锁。
由于mbox使用了ucos的中msgq实现,而ucos不支持0个消息的消息队列,所以TCPIP_MBOX_SIZE需要修改。

由于使用zynq自带emac连接phy,所以不需要axiemac等网络连接,所以可以将axiemac相关内容删除,不然编译出错。
使用简单的IPV4,所以也将IPV6的支持删除。
emacps中的中断采用的standalone中sugic的方式,与ucos就是在中断handle的类型不同,ucos为两个参数,而standalone为一个参数,可能直接混用也可以,为了避免不安全的,作了一个转换,通过ucos的inthandle调用standalone的inthandle,处理掉ucos多余的一个参数。
下面为在xemacpsif_dma.c的XStatus init_dma(struct xemac_s *xemac)函数中注册中断。

ucos中断转换为standalone中断处理

到此ucos BSP与lwip库程序的修改与编译完成。
|