[En-Nut-Discussion] IP Checksum calculation broken. Reenabled old algorithm for the meantime.
Bernard Fouché
bernard.fouche at kuantic.com
Mon Jun 18 15:33:48 CEST 2012
Le 18/06/2012 14:28, Ole Reinhardt a écrit :
> Hi Harald,
>
>>> What's about the ICMP checksum thing where we calculate the checksum
>>> just over a part of the ICMP packet data?
>> That should make any difference. However, in sys/types.h we have
>>
>> #ifndef NUTMEM_ALIGNMENT
>> #if defined(__avr__)
>> #define NUTMEM_ALIGNMENT 1
>> #elif defined(__CORTEX__)
>> #define NUTMEM_ALIGNMENT 1
>> #elif defined(__ARM__)
>> #define NUTMEM_ALIGNMENT 4
>> #elif defined(__AVR32__)
>> #define NUTMEM_ALIGNMENT 4
>> #else
>> #define NUTMEM_ALIGNMENT sizeof(int)
>> #endif
>> #endif
>>
>> This means, that malloc() will use 1 byte alignment for the Cortex. In
>> this case forget everything I told you about NETBUF alignment.
> Would it really hurd to set the alignment to 4 for Cortex M?
>
> Just ask because several peripherals of the LPC need 4 byte aligned
> buffers (e.g. the iap flash driver). If malloc does not guarantee 4 byte
> aligned buffers we would have to check and / or modify alignment just
> before passing a buffer to such a peripheral!
IMHO word alignment for malloc() must be setup with the biggest value
that can be returned by __alignof()__. For Cortex-M that is 4 AFAIK
since there is no biggest data type in the core itself. Besides
peripherals the compiler will take decisions according to the type of
the data it processes, and can use LDM/STM anytime it is convinced that
__alignof(data)__ is 4.
Bernard
Bernard
More information about the En-Nut-Discussion
mailing list