LWIP UCOS 移植步骤记录

本文记录了LWIP协议栈移植到UCOS操作系统的过程中遇到的挑战,主要问题是TCP case失败和运行时死机。解决办法在于任务间的同步,将take sem操作放在tcpip_apimsg函数中,在发送消息后等待sem,确保在tcpip_thread执行回调函数时正确给予conn->op_completed信号量,从而避免了运行异常。
摘要由CSDN通过智能技术生成
今年5, 6月份的时候, 将LWIP移植到了ucos平台上, 把之前总结的移植的大致步骤记录在这里. 供参考和回忆.

当时的移植工作是基于ppp new 的branch, 解压后在doc的目录下的sys_arch.txt中, 有一点关于porting的工作的介绍.

1.主要是os相关的一些函数类和类型的处理. 在sys_arch.txt中有比较详细的介绍.
  The general idea is that porting lwIP to new architectures requires only
  small changes to a few header files and a new sys_arch implementation.
  It is also possible to do a sys_arch implementation that does not rely on
  any underlying operating system.

  The sys_arch provides semaphores and mailboxes to lwIP.

  有一些函数是必须实现的.
  The following functions must be implemented by the sys_arch:


- void sys_init(void)
  Is called to initialize the sys_arch layer.
  在实际的实现中就是初始化了lwip_timeouts数组.
  struct sys_timeouts lwip_timeouts[OS_LOWEST_PRIO+1];

- err_t sys_sem_new(sys_sem_t *sem, u8_t count)
  创建sem
  Creates a new semaphore. The semaphore is allocated to the memory that 'sem'
  points to (which can be both a pointer or the actual OS structure).
  The "count" argument specifies the initial state of the semaphore (which is
  either 0 or 1).
  If the semaphore has been created, ERR_OK should be returned. Returning any
  other error will provide a hint what went wrong, but except for assertions,
  no real error handling is implemented.
 
- void sys_sem_free(sys_sem_t *sem)
  释放sem
  Deallocates a semaphore.
 
- void sys_sem_signal(sys_sem_t *sem)
  其实就是sem的count加1
  Signals a semaphore.
 
- u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
  等待其他地方sem的signal, 但是有一些特殊的要求.
  Blocks the thread while waiting for the semaphore to be
  signaled. If the "timeout" argument is non-zero, the thread should
  only be blocked for the specified time (measured in
  milliseconds). If the "timeout" argument is zero, the thread should be
  blocked until the semaphore is signalled.

  If the timeout argument is non-zero, the return value is the number of
  milliseconds spent waiting for the semaphore to be signaled. If the
  semaphore wasn't signaled within the specified time, the return value is
  SYS_ARCH_TIMEOUT. If the thre
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值