andysworkshop / stm32plus

The C++ library for the STM32 F0, F100, F103, F107 and F4 microcontrollers
http://www.andybrown.me.uk
Other
745 stars 224 forks source link

Initializing network stack resets #170

Closed mikeodr closed 8 years ago

mikeodr commented 8 years ago

We're running into an issue where our networking stack is successfully initializing without a network cable/other endpoint being powered on, but upon attempting to send a ping we get a reset.

Has anyone else run into this issue? This is reproducible either with:

Our use case is that our board is what switches power to the other endpoint. We are trying to use ping to detect it is ready for network communications for us to tx/rx with it. Unfortunately this is leading to a bit of a reset loop of our board.

Any thoughts or workarounds appreciated.

mikeodr commented 8 years ago

We're using net/physical/lan8710a/LAN8710A.h

To expand our stack setup:

  typedef stm32plus::net::PhysicalLayer<stm32plus::net::LAN8710A> PhysicalLayer;
  typedef stm32plus::net::DatalinkLayer <
  PhysicalLayer,
  stm32plus::net::DefaultRmiiInterface,
  stm32plus::net::Mac > DatalinkLayer;
  typedef stm32plus::net::NetworkLayer <
  DatalinkLayer,
  stm32plus::net::DefaultIp,
  stm32plus::net::Arp
  > NetworkLayer;
  typedef stm32plus::net::TransportLayer <
  NetworkLayer,
  stm32plus::net::Udp,
  stm32plus::net::Icmp
  > TransportLayer;
  typedef stm32plus::net::ApplicationLayer <
  TransportLayer,
  stm32plus::net::StaticIpClient,
  stm32plus::net::Ping
  > ApplicationLayer;
  typedef stm32plus::net::NetworkStack<ApplicationLayer> NetworkStack;
mikepurvis commented 8 years ago

I wonder if phyIsLinked() could help here? I was unable to use it for this purpose on a previous project because the connection was through a switch (which was always powered on), but it should do the trick if the connection is direct.

Maybe there's some more graceful way for stm32plus::net to recover from this scenario, though?

mikeodr commented 8 years ago

Apologies for the issue. This appeared to be our own watchdog.

For other peoples benefit the default ARP timeout is 5seconds with 5 retires in a wait loop.

Loop here

And timeout settings here

andysworkshop commented 8 years ago

Let me know if I can be any help here, i.e. please log a feature request if there's something else that you think the stack can provide.