Hi Fabi, have you followed this guide
http://lwip.wikia.com/wiki/Porting_for_an_OS ? In particular:
"Packet headers data is stored in network byte order
<http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking> which is
the the big-endian mode <http://en.wikipedia.org/wiki/Endianness#Big-endian>.
If your processor architure is little-endian
<http://en.wikipedia.org/wiki/Endianness#Little-endian>, then we need to
convert data using htons()/htonl()/ntohs()/ntohl()
<http://www.opengroup.org/onlinepubs/007908799/xns/htonl.html> functions."
Here an example (the following code use CMSIS, so you must be sure to have
it enabled)
---------------------------
u16_t
lwip_le_htons(u16_t n)
{
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
}
/**
* Convert an u16_t from network- to host byte order.
*
* @param n u16_t in network byte order
* @return n in host byte order
*/
u16_t
lwip_le_ntohs(u16_t n)
{
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
}
/**
* Convert an u32_t from host- to network byte order.
*
* @param n u32_t in host byte order
* @return n in network byte order
*/
u32_t
lwip_le_htonl(u32_t n)
{
return __REV(n);
}
/**
* Convert an u32_t from network- to host byte order.
*
* @param n u32_t in network byte order
* @return n in host byte order
*/
u32_t
lwip_le_ntohl(u32_t n)
{
return __REV(n);
}
-------------------------------------------
you must insert these functions in /core/def.c and check the #define chain
Bye Adriano
2014-06-26 11:14 GMT+02:00 Fabian Cenedese <[email protected]>:
> Hi
>
> I'm using lwip 1.4.1 on big endian targets and it works. Now I
> want to use the same software on little endian targets (ARM)
> and have problems. Should that work from the lwip part? The
> Ethernet frame of course is always big endian why it works
> without problems on big endian targets. However I'm not sure
> that all places do the correct conversion between host and
> network order.
>
> E.g. the IP address for the interface:
>
> IP4_ADDR(ipaddr, 192, 168, 1, 197)
> netif_add(&m_Netif, &ipaddr...
>
> gives a debug trace
>
> ... set to 197.1.168.192
>
> Is the trace wrong or did I give a wrong address?
>
>
> Sending (e.g. ARP reply):
> ip_output_if_opt
>
> The ip address is copied directly into the frame:
> ip_addr_copy(iphdr->src, *src);
>
> Shouldn't that be
> ip_addr_set_hton(&iphdr->src, src);
>
> if the runnig hardware is little endian?
>
> And yes, I do have
> #define BYTE_ORDER LITTLE_ENDIAN
>
> Thanks
>
> bye Fabi
>
>
> _______________________________________________
> lwip-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
--
Adriano Pallavicino
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users