messani / pico-lan8720

Creative Commons Zero v1.0 Universal
15 stars 1 forks source link

Suddenly stops receiving #4

Open MicroKoder opened 2 years ago

MicroKoder commented 2 years ago

Sometimes it stops receiving. Usually when I'm trying to access web page. I added a LED flashing when RX PIO is working (on instruction address changing), and turned on all debug output. I started a ping task in background and tried to access to web page, after this pico stops answering for ping requests. I see in the serial output that pico is working, but PIO RX not flashing. I found the rx pio not always in work, sometimes there is commands to start or stop pio (I added in those places output to the log messages like "START PIO", "STOP PIO") I see the last time the PIO is stopped but not restarted, after that it doesn't receive any packages. I've tried to add restarting PIO ("PIO RESET" in log) but it doesn't help me. putty_1.log

messani commented 2 years ago

Hi, try to increase MEMP_NUM_SYS_TIMEOUT. Not tested, by you can add: #define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 1) to your lwipopts.h

MicroKoder commented 2 years ago

unfortunately it didn't help me. Looks like the lan8720_free_framedata didn't called, so RX PIO didn't start. As I see lan8720_free_pbuf should be called after every pbuf_free call, but it not always happen.

Also I see infinite loop: etharp_timer tcp_slowtmr: processing active pcb tcp_slowtmr: polling application tcp_slowtmr: processing active pcb tcp_slowtmr: polling application etharp_timer tcp_slowtmr: processing active pcb tcp_slowtmr: polling application tcp_slowtmr: processing active pcb tcp_slowtmr: polling application etharp_timer tcp_slowtmr: processing active pcb tcp_slowtmr: polling application tcp_slowtmr: processing active pcb tcp_slowtmr: polling application etharp_timer

what does it mean

messani commented 2 years ago

Unfortunatelly I do not have time to debug it. Try increase LAN8720_RX_FRAME_COUNT. Maybe it is necessary to receive more that two (current value) packets at one time.

MicroKoder commented 2 years ago

Hi, I've added 1 ms timeout in line 210 lan8720.c (changed from 0 to 1). After that it's working stable

messani commented 2 years ago

If you added sleep() function there, it is not good idea, because it is called in the interrupt handler. Does the changing value of LAN8720_RX_FRAME_COUNT work?

MicroKoder commented 2 years ago

LAN8720_RX_FRAME_COUNT didn't give the result, but I left it =6 and also changed line 210 sys_timeout(0, lan8720_rx_process_frame.. changed from 0 to 1, hmm, here is line 194.

Now I've rewrited it so the "trystart" called before "process_frame"