lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Checksum problem with lwip_chksum()


From: John Taylor
Subject: RE: [lwip-users] Checksum problem with lwip_chksum()
Date: Thu, 2 Sep 2004 07:29:18 -0400

>Has anybody else seen this problem? 
Yes. I also had to modify lwip_chksum() to be byte oriented.

>Is it a particular problem of the H8
It's not H8 specific.  It is problem with all processors that require
16bit words to be aligned on an even boundary.   However, as you
mentioned the problem only show ups when a pbuf is referencing
"externally managed packet contents" AND that content is not aligned -
as your literal string example.

<sidebar>The H8 is particular annoying in that it does *not* throw a
hardware exception when attempting to read words from odd addresses.
You just get garbage for the odd byte and the CPU goes on its merry way.
Makes debugging alignment issues a joy ;-).</sidebar>


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf
Of Chris WIlliams
Sent: Thursday, September 02, 2004 6:33 AM
To: address@hidden
Subject: [lwip-users] Checksum problem with lwip_chksum()

I have had problems with checksums, and traced a problem in
lwip_chksum().

The problem is to do with alignment:

I am using Hitachi H8 which is 2 byte aligned and I have set

#define MEM_ALIGNMENT           2

The problem is that a definition of the kind:

char *text = "This is text";

is BYTE aligned.

If you try to send this with the following call:

tcp_write(port,text,strlen(text),0);

that is without copy, you can fail to get the correct checksum from
lwip_chksum(). This assumes that ALL the data it receives will be 2 byte
aligned. 

This caused one of my applications to always fail. If you change the
call to:

tcp_write(port,terminal,length,1);

then it works OK because it copies the data into a pbuf first which IS
correctly aligned.

I have reworked lwip_chksum() to work in bytes. This is slower, but it
does now work correctly.

Has anybody else seen this problem? Is it a particular problem of the H8
(Paul C, did you have any problem here?). Would anybody like me to post
my new code?

Chris.
-- 
------------------------------------------------------------------------
---
| Chris Williams    EMail address@hidden
|
|                   Tel/Fax  01686 688065
|
| Chrysalis Design. Electronics, Computers, Hardware, Software.
|
|                   Design and development to meet all your needs.
|
------------------------------------------------------------------------
---


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

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