STM32 Ethernet Demo

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32 Ethernet Demo

Post by rubenswerk »

Hello,

I spent several evenings with testing. It needs some time and good luck (or bad luck?) to cause the problem. Finally the problem also occured on the original lwip Demo. I only did the minimum changes to make the Olimex P407 demo run on the Discovery with Chinese DP83848 board (using Jacon's board.h).

Up to now, I was not able to reproduce the problem on the old ChibiOS Olimex P107 lwip demo with ST wrapper. Also the original lwip demo from ST works stable up to now. There is a port of the ST demo for the discovery board:
http://www.mikrocontroller.net/topic/237223#2491080

There is an obvious difference between ChibiOS and the ST demo:
With ChibiOS I loose ~40% of packets.
With ST demo I only loose ~2% of packets (it uses lwip 1.3.2)

I changed MEM_SIZE from 1600bytes to 10k as done in the ST demo, but no impact.


Edit:
Once the problem occurs, the lwipthread fails in low_level_input with
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);

The MAC itself still receives the packets. This explains why a ping with smaller packets still works - there seems to be a memory leak.

In my point of view, this pbuf could be allocated statically, because the lwipthread is not re-entrant. But the lwip architecture frees this buffer in different places.

In the lwipthread main loop, is it ensured that the buffer is always freed by the input handler when the switch/case runs into the break?

Code: Select all

    if (mask & FRAME_RECEIVED_ID) {
      struct pbuf *p;
      while ((p = low_level_input(&thisif)) != NULL) {
        struct eth_hdr *ethhdr = p->payload;
//  GPIOD->ODR = GPIOD->ODR ^ (1<<15); // toggle LED unten
        switch (htons(ethhdr->type)) {
        /* IP or ARP packet? */
        case ETHTYPE_IP:
        case ETHTYPE_ARP:
#if PPPOE_SUPPORT
        /* PPPoE packet? */
        case ETHTYPE_PPPOEDISC:
        case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
          /* full packet send to tcpip_thread to process */
          if (thisif.input(p, &thisif) == ERR_OK)
            break;
          LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
        default:
          pbuf_free(p);
        }
      }
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 Ethernet Demo

Post by Giovanni »

Interesting, so this seems lwIP related, I think I did read something about a leak fixed in 1.4.1, it would be a good idea to go check the bugs fixed in 1.4.1 so far and if they have an idea about the release date.

Giovanni
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32 Ethernet Demo

Post by rubenswerk »

Maybe the leak is also in the ST demo, but it does not appear because the timing is different.
The difference in lost packets is really huge. Don't know why ST has a nearly perfect ping rate, and the Chibi demo loses 40% in my tests.

I wonder why you have 0% loss with 10 ping processes, and 100% loss with 14 processes.
I only use a single instance of hrping, but always have some lost packages. But it's important to reach the maximum media speed. The console output causes enough delay the make everything look fine, because the ping speed decreases.

Giovanni, is your MAC driver based on the ST code and should work similar, or is it completely different?

Bye, RuWe
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 Ethernet Demo

Post by Giovanni »

It is similar but not the same, it uses the same scheme for frame buffers, it is possible there is a problem but so far I failed to trigger it.

It is possible that the packet loss you see has an HW origin, the one I verified was caused by saturation, I never saw a single packet lost using both the F107 and the F407.

Giovanni
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32 Ethernet Demo

Post by rubenswerk »

To avoid misunderstandings:
A single ping always succeeds. Problems come up when I flood the STM32 with pings.
In that case, I think it's quite normal that some packets get lost, because an embedded system is not always able to handle the full traffic. Also, if you drive the 100mbit cable at its maximum with pings, all other packets (Windows broadcasts...) will cause problems.

I would agree in a HW problem when I look at the long cables connecting the Discovery with the Chinese PHY. But I have the same behaviour on my own PCB where STM32 is close to PHY.

And I also loose packets with other network devices:
If I do ping flooding with my printer or router, I also have a loss of 20-50%
I think the performance of the ST demo with only 2% loss is really outstanding.

Are you sure your tool sends at maximum speed? Maybe it adds 1-2ms delay between the packets. In that case, I never had problems. You should have a throughput of several thousand 1472byte pings per second.

Anyway, there seems to be a mem leak in high load situations with lwip. I think it's not worth deeper analysis, as long as there's no need for maximum bandwidth. I think I'm the only bored guy who attacks his board with a ping flood, just to know how fast it goes.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 Ethernet Demo

Post by Giovanni »

Good point about the tool, what are you using for ping flooding?

Giovanni
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32 Ethernet Demo

Post by rubenswerk »

I use hrping, which can be found here:
http://www.cfos.de/de/ping/ping.htm

I posted the usage somewhere in this thread. Typically I call it like that:
hrping -l 1472 -n 100000 -s 0 -q 192.168.0.222

There is a bug which causes some error messages when the time between packets is zero (-s 0), but it works nevertheless.
I minimize the console window after starting the command, otherwise the error messages slow down ping performance noticeably.

Regards, RuWe
botdream
Posts: 4
Joined: Mon May 21, 2012 12:41 am

Re: STM32 Ethernet Demo

Post by botdream »

Hi guys,

FYI: Olimex just released a new STM32F4 based board with Ethernet included:
http://olimex.wordpress.com/2012/05/30/ ... are-ready/

since you guys already made some previous work with some Olimex Dev boards, will you be supporting this new stm32-e407?

The STM32F4 Discovery board does have a nice price, but it could be nice to have a more "professional" platform available if one requires for a non-hobbyist project (that's just my 2 cents).

Regards,
Nelson.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 Ethernet Demo

Post by Giovanni »

Hi,

I plan to support this new board, not a big effort.

Giovanni.
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: STM32 Ethernet Demo

Post by mabl »

Hey Nelson,

I know, I've also just seen the release. I've been really looking forward for this board because I want to base a low quantity product on it. If Olimex where to update the git repository one could even add the missing board files right now. I think Giovanni is going to get one prototype, I've tried to convince Tristan from Olimex to also give me one - but I guess I was not persuasive enough.... Might bug him again :mrgreen:
Post Reply