zynq中mgtx应用_基于ZYNQ的UCOS移植(TCP通讯)

本文介绍了如何在ZYNQ平台上使用SDK创建工程,并详细阐述了在UCOS操作系统中移植LWIP以实现TCP echo通信的过程。主要步骤包括:配置需求、操作流程、LWIP移植、以及调试和测试设置。提供了一个链接供下载LWIP资源库。
摘要由CSDN通过智能技术生成
周五在某小徐处借到了一块Zedboard开发板,平时在公司没有机会做SDK开发的笔记,今天就趁着这块开发板简要记录一些SDK的基本操作。 一、功能简介

    通过第三方库创建SDK工程

    在ZYNQ-UCOS中实现TCP echo通讯

二、配置需求

操作系统Windows 10(64位)
开发环境SDK 2018.3

三、操作流程

1、添加资源库。启动SDK软件,选择Xilinx->Repositories弹出Perferences视图,在Local Repositories中添加ucos资源库(ucos 资源库下载链接 见附件部分 )。

b463c1c9849a6d0f2d42516b0e379431.png

bed0cb95308e6730b1bbfdce0916af48.png

2、创建新工程。选择File->New->Application Project弹出New Project视图,输入工程名称ucos_tcp,选择操作系统平台ucos,点击Next>,在弹出的Templates选项中选择Micrium uc/OS- Ⅱ Hello World,点击Finish完成基础示例工程的创建。

b66b4829218923d54a819b85f5900d5e.png

0c001a6640ed6a166c7f0b1ecdba4870.png

91b89e43f3edd4b05b61806fe03dac17.png

3、配置emac。 在ucos_tcp_bsp文件 夹上单击鼠标右键,选择Board Support Pcakage Settings,在弹出的Board Support Pcakage Settings视图中选择drivers,修改ucos_emacps为emacps,单击OK完成emac的配置。

95a2a5c3a89ce47b7cc9eb1a316a7295.png

4、移植Lwip。将lwip212文件夹及内容拷贝到工程源文件目录下(Lwip资源库下载链接见附件部分)。

e63f423ea5f69d18a858e8520be346a2.png

5、设置 头文件路径 ,在src文件夹上单击鼠标右键,选择Properties,在弹出的Properties for src视图中选择C/C++ Build->Settings->Directories,在Include Paths中依次添加lwip212文件下的contrib、contrib/xilinx/include,lwip-2.1.2/include三个文件夹。单击Apply应用配置变更,单击OK退出 Properties for src视图。

efe6e2a64592813fe7573e9107329d82.png

6、删除报错的头文件。

注释/ucos_tcp/src/lwip212/contrib/xilinx/include/netif/xemacpsif.h中xuartps.h的引用

注释/ucos_tcp/src/lwip212/contrib/xilinx/netif/xemacpsif.c中xuartps.h的引用

注释/ucos_tcp/src/lwip212/contrib/LwipEnter.h中platform_config.h的引用

7、修改入口函数文件。将app.c文件进行如下修改。
/***********************************************************************************************************                                             uCOS XSDK BSP**                      (c) Copyright 2014-2020; Silicon Laboratories Inc.,*                             400 W. Cesar Chavez, Austin, TX 78701**                All rights reserved. Protected by international copyright laws.**               Your use of this software is subject to your acceptance of the terms*               of a Silicon Labs Micrium software license, which can be obtained by*               contacting info@micrium.com. If you do not agree to the terms of this*               license, you may not use this software.**               Please help us continue to provide the Embedded community with the finest*               software available. Your honesty is greatly appreciated.**                 You can find our product's documentation at: doc.micrium.com**                       For more information visit us at: www.micrium.com**********************************************************************************************************//***********************************************************************************************************                                          SETUP INSTRUCTIONS**   This demonstration project illustrate a basic uC/OS-II project with simple "hello world" output.**   By default some configuration steps are required to compile this example :**   1. Include the require Micrium software components*       In the BSP setting dialog in the "overview" section of the left pane the following libraries*       should be added to the BSP :**           ucos_common*           ucos_osii*           ucos_standalone**   2. Kernel tick source - (Not required on the Zynq-7000 PS)*       If a suitable timer is available in your FPGA design it can be used as the kernel tick source.*       To do so, in the "ucos" section select a timer for the "kernel_tick_src" configuration option.**   3. STDOUT configuration*       Output from the print() and UCOS_Print() functions can be redirected to a supported UART. In*       the "ucos_standalone" section the stdout configuration will list the available UARTs.**   Troubleshooting :*       By default the Xilinx SDK may not have selected the Micrium drivers for the timer and UART.*       If that is the case they must be manually selected in the drivers configuration section.**       Finally make sure the FPGA is programmed before debugging.***   Remember that this example is provided for evaluation purposes only. Commercial development requires*   a valid license from Micrium.**********************************************************************************************************//***********************************************************************************************************                                            INCLUDE FILES**********************************************************************************************************/#include  #include  #include  #include "ucos_ii.h"#include "LwipEnter.h"/***********************************************************************************************************                                      LOCAL FUNCTION PROTOTYPES**********************************************************************************************************/OS_STK  Polling_thread_Stk[256u];OS_STK  LwipEnter_thread_Stk[512u];void  MainTask (void *p_arg);void  PollingTask (void *p_arg);/***********************************************************************************************************                                               main()** Description : Entry point for C code.***********************************************************************************************************/int main(){    UCOSStartup(MainTask);    return 0;}/***********************************************************************************************************                                             MainTask()** Description : Startup task example code.** Returns     : none.** Created by  : main().**********************************************************************************************************/void  MainTask (void *p_arg){    OS_CPU_SR cpu_sr;  OS_ENTER_CRITICAL();  // Create Task  OSTaskCreate(PollingTask, (void*)0, (OS_STK*)&Polling_thread_Stk[255u], 20u);  OSTaskCreate(LwipEnter_thread, (void*)0, (OS_STK*)&LwipEnter_thread_Stk[511u], 50);  OS_EXIT_CRITICAL();  // Suspend this Start Task after initialization  OSTaskSuspend(OS_PRIO_SELF);}/***********************************************************************************************************                                             PollingTask()** Description : Polling task example code.** Returns     : none.** Created by  : MainTask().**********************************************************************************************************/void  PollingTask (void *p_arg){    UCOS_Print ("Hello world from the main task\r\n");    while (DEF_TRUE) {        OSTimeDlyHMSM(0, 0, 3, 0);        UCOS_Print("Periodic output every 3 seconds from the main task\r\n");    }}

8、调试配置。调试配置如下图所示。

e410907d7bbc157745bda6894d07c300.png

0415c96ba88fceb775b47578fc24e020.png

9、启动调试。将测试PC机IP设置为192.168.1.99(与Zedboard处于同一网段),子网掩码为255.255.255.0。此时即可通过网口调试助手测试TCP的通讯功能。

f2aca6b38ee45490d0ee49bfe82683e5.png

四、资源链接

链接:https://pan.baidu.com/s/1iVkFfXC964F7cCZVK8URCA

提取码:s5p1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值