lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Bare Metal / Memory Alignment


From: Jens Breuer
Subject: [lwip-users] Bare Metal / Memory Alignment
Date: Tue, 6 Sep 2011 22:18:59 +0200

Hi,

I am implementing lwIP on a MCBSTM32C
( http://www.keil.com/arm/mcbstm32c/ )
without OS (Bare Metal).

I made no changes to the sources of lwIP.

I am using lwIP 1.4.0.

As IDE I am using Keil uVision:
===3<===
IDE-Version:
µVision V4.21.0.0

Tool Version Numbers:
Toolchain:        MDK-ARM Standard  Version: 4.21
Toolchain Path:    BIN40\
C Compiler:         Armcc.Exe       V4.1.0.713
Assembler:          Armasm.Exe       V4.1.0.713
Linker/Locator:     ArmLink.Exe       V4.1.0.713
Librarian:             ArmAr.Exe       V4.1.0.713
Hex Converter:      FromElf.Exe       V4.1.0.713
CPU DLL:               SARMCM3.DLL       V4.21
Dialog DLL:         DARMSTM.DLL       V1.62
Target DLL:             BIN\UL2CM3.DLL       V1.90
Dialog DLL:         TARMSTM.DLL       V1.60
===3<===

As a remote station for testing I am using Ubuntu 10.10 (Kernel
2.6.35-30 i386).

I am developing according to the instructions given on
http://lwip.wikia.com/wiki/LwIP_Wiki
as well as any information I can get from the sources and examples.

Currently I am just working on getting the stack to respond to ICMP Echo
Messages. The underlying driver I wrote seems to work pretty stable.

I have MEM_ALIGNMENT set to 4 in my lwipopts.h.

The first thing I ran into was in file etharp.c line 636.
===3<===
:636 ip_addr_copy(iphdr_src, iphdr->src);
===3<===

If i issue a echo request
===3<===
$ ping -c 1 $LWIP_IP
===3<===
towards the stack I get a IRQ_UsgFault because of an unaligned WORD
(32bit) access in the line mentioned above.
Please tell me if I potentially left out some configuration detail.

The Cortex-M3 is able to accomplish unaligned WORD access, so I
configured it to do so and worked around that issue.

The next thing I tried out was fragmentation.
So I set the MTU of the lwIP netif to 500 and the MTU of eth0 of my
remote station to 500 and issued
===3<===
$ ping -c 1 -s 600 $LWIP_IP
===3<===
This resulted in "Unknown ICMP (obsolete or malformed?)" messages from
lwIP.
Please find the attached wireshark capture as proof.
"192.168.23.1" is the lwIP host, "192.168.23.23" is the Ubuntu remote
station.

According to my research there are exactly two bytes at the beginning of
the ICMP header missing at every reply from lwIP.

After days of trial and error I set MEM_ALIGNMENT to 1 and the
fragmentation problem was cured. I get correct replies by now.

Since I am doing embedded development (this is my bachelor thesis) I
would like to get rid of unaligned memory access and have an alignment
on WORD boundaries. Performance is pretty crucial.

Do you think that the above mentioned is a bug of lwIP or just a matter
of misconfiguration of mine?

I would be glad for any input even if it is voodoo... I'd even sacrifice
chickens for getting the stack to behave properly. ;)

If I left out something you need to reproduce the problem or you need
additional information please tell me and I will supply the information
ASAP.

Thanks in advance & Kind regards
Jens

Attachment: bad_frag_ping.pcap
Description: application/cap


reply via email to

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