lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] LWIP Implementation on PIC32 (no OS)


From: Jérémie CHABOD
Subject: [lwip-users] LWIP Implementation on PIC32 (no OS)
Date: Fri, 31 Aug 2012 12:53:02 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0

Hello,

First, I would like to thank you for you work, which is of great quality.
I am a neebis to both TCP/IP implementation and to PIC32 processors, but implementing LWIP came to be quite easy, thanks to the precise documentation and code.

My configuration is:
- NO_SYS
- 32 Kb of RAM
- TCP/ICMP/ARP/ 1 connect max

I make below a list of remarks. Actually, it's more a list of suggestions (maybe I missed some information, or did not understand things in their global view). Just hope, that might help to ease further users work.

In doc/rawapi.txt

This file could embed some more information, which I found but with some difficulty (I had to parse code and example files)
- tcp_recved and pbuf_free must be called within the callback passed though tcp_recv.
- A reference to netif/ethernetif.c. In fact, There is no link to this file in the documentation, which is regrettable as this file really helps.
o    It is not obvious how to set the output, linkoutput and input callbacks, and what shall be done inside
o    Some necessary field can be forgotten
o    More generally the netif_add input and init parameters are quite opaque -for neewbie :/ -

About the code/options/specific configuration
- (Just for information) Setting ETH_PAD_SIZE = 2 does not seem to work (I saw some topics on that subject but did not invest researches yet). I've not found the bug so far (so that it could be in my code part)  I will detail this in another mail, when I find more valuable information.

- The mem.c /memp_std.h module is not so easy to read... (yet, I understand why it's done this way). I my case, I only have 32 K RAM, and a maximum of 50% is dedicated to LWIP. I think something's missing: to see how an option impacts the RAM usage. I made a Excel sheet that estimates the RAM required given a set of parameters. This allows to check the viability of a project, without requiring to implement and build a project to see actual RAM occupation in a .MAP file. I am aware that this excel sheet is limited (it only shows the example for a ICMP/ARP/TCP/NO_SYS configuration), but, you maybe will find a way to add it somehow.

-    (suggestion?) Adding extra braces into LWIP_ASSERT macro (include/lwip/debug.h) around LWIP_PLATFORM_ASSERT(message); would have saved me time. But I admit I implemented LWIP_PLATFORM_ASSERT dirtily. (LWIP_ERROR does not have the problem)

-    On PIC32 processor, with pic32-gcc.exe, some warnings are raised at compile-time for PACK_STRUCT_FIELD(x) if x is a u8_t or u8_t*. My solution was to add a new macro PACK_STRUCT_FIELD_U8 used for such fields (I did not use all modules so the list is probably uncomplete).
Concretely:

In cc.h:

#define PACK_STRUCT_FIELD(x) __attribute__ ((packed)) x

#define PACK_STRUCT_FIELD_U8(x) x

In Etharp.h

PACK_STRUCT_BEGIN

struct eth_addr {

  PACK_STRUCT_FIELD_U8(u8_t addr[ETHARP_HWADDR_LEN]);

} PACK_STRUCT_STRUCT;

PACK_STRUCT_END

(…)struct eth_hdr {

#if ETH_PAD_SIZE

  PACK_STRUCT_FIELD_U8(u8_t padding[ETH_PAD_SIZE]);

#endif

  PACK_STRUCT_FIELD_U8(struct eth_addr dest);

  PACK_STRUCT_FIELD_U8(struct eth_addr src);

  PACK_STRUCT_FIELD(u16_t type);

} PACK_STRUCT_STRUCT;

(…)

 

PACK_STRUCT_END

PACK_STRUCT_BEGIN

/** the ARP message, see RFC 826 ("Packet format") */

struct etharp_hdr {

  PACK_STRUCT_FIELD(u16_t hwtype);

  PACK_STRUCT_FIELD(u16_t proto);

  PACK_STRUCT_FIELD_U8(u8_t  hwlen);

  PACK_STRUCT_FIELD_U8(u8_t  protolen);

  PACK_STRUCT_FIELD(u16_t opcode);

  PACK_STRUCT_FIELD_U8(struct eth_addr shwaddr);

  PACK_STRUCT_FIELD_U8(struct ip_addr2 sipaddr);

  PACK_STRUCT_FIELD_U8(struct eth_addr dhwaddr);

  PACK_STRUCT_FIELD_U8(struct ip_addr2 dipaddr);

} PACK_STRUCT_STRUCT;

PACK_STRUCT_END

In ipv4/lwip/icmp.h

 

PACK_STRUCT_BEGIN

struct icmp_echo_hdr {

  PACK_STRUCT_FIELD_U8(u8_t type);

  PACK_STRUCT_FIELD_U8(u8_t code);

  PACK_STRUCT_FIELD(u16_t chksum);

  PACK_STRUCT_FIELD(u16_t id);

  PACK_STRUCT_FIELD(u16_t seqno);

} PACK_STRUCT_STRUCT;

PACK_STRUCT_END

In ipv4/lwip/ip.h

PACK_STRUCT_BEGIN

struct ip_hdr {

  /* version / header length / type of service */

  PACK_STRUCT_FIELD(u16_t _v_hl_tos);

  /* total length */

  PACK_STRUCT_FIELD(u16_t _len);

  /* identification */

  PACK_STRUCT_FIELD(u16_t _id);

  /* fragment offset field */

  PACK_STRUCT_FIELD(u16_t _offset);

#define IP_RF 0x8000U        /* reserved fragment flag */

#define IP_DF 0x4000U        /* dont fragment flag */

#define IP_MF 0x2000U        /* more fragments flag */

#define IP_OFFMASK 0x1fffU   /* mask for fragmenting bits */

  /* time to live */

  PACK_STRUCT_FIELD_U8(u8_t _ttl);

  /* protocol*/

  PACK_STRUCT_FIELD_U8(u8_t _proto);

  /* checksum */

  PACK_STRUCT_FIELD(u16_t _chksum);

  /* source and destination IP addresses */

  PACK_STRUCT_FIELD_U8(ip_addr_p_t src);

  PACK_STRUCT_FIELD_U8(ip_addr_p_t dest);

} PACK_STRUCT_STRUCT;

PACK_STRUCT_END



best regards,
-- 
------------------------------------------------------------------------
Jérémie CHABOD               Tél. : (+33)(0)4 42 90 65 64

SYSTEREL
------------------------------------------------------------------------
Standard / Fax : (+33)(0)4 42 90 41 20 / 29     site : www.systerel.fr
------------------------------------------------------------------------

Attachment: RAM_TCP_NO_SYS.xlsx
Description: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet


reply via email to

[Prev in Thread] Current Thread [Next in Thread]