W5500 Ethernet and Soft Reboot

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
thestumbler
Posts: 11
Joined: Tue Mar 16, 2021 4:19 am

W5500 Ethernet and Soft Reboot

Post by thestumbler » Fri Dec 10, 2021 7:48 am

I'm using Adafruit Ethernet Feather with a Pyboard v1.1.
I successfully compiled the firmware and am able to establish UDP and TCP connections.
The problem I'm having is how to resume from a "soft reboot", or ctrl-D, from the REPL.
I've seen several discussions on this issue regarding the ESP boards and WiFi, but nothing that helps me.

After a power-on reset or machine.reset(), I can initialize the LAN module and proceed to use networking.
But after a ctrl-D soft reset, the network card appears to be still up and running. For example, I can skip initializing the network card and jump right in to socket calls. But if I blindly try to re-initialize the network card, it freezes the program. Sometimes it just freezes until I press ctrl-C, sometimes I get

Code: Select all

wiznet5k_poll: fatal error len=32896 ret=-5
More frustrating, I can't see any way to check this from the code. The return value of machine.reset_cause() is zero, whether I do a soft reset or hard power-on reset. Since the NIC object gets deleted by the soft reset, there's no way to query the NIC status. I've tried doing a hardware reset of the NIC module, no joy. I've tried making a new instance of the NIC object, no joy.

What is the intended method of using a NIC across soft reboots of the Pyboard? Or are you supposed to always to a hard reset when working with ethernet?

thestumbler
Posts: 11
Joined: Tue Mar 16, 2021 4:19 am

Re: W5500 Ethernet and Soft Reboot

Post by thestumbler » Sat Dec 11, 2021 6:18 am

Not quite solved yet, but I found out why I'm always getting soft reset as the cause.
I have been using rshell and figured out that it does a bunch of reboots. Apparently,
  • On machine reset, there is one hard reset followed by 10 or so soft resets
  • On a single press of ctrl-D soft reset, I get about 5 actual soft resets.
  • Just exiting the rshell REPL and listing files appears to generate a couple of soft resets
Trying similar tests in Thonny:
  • ctrl-D soft reset just makes one soft reset.
  • machine reset generates one hard reset and one soft reset.
Just using a raw serial port terminal emulator, the reset cause works as expected.

thestumbler
Posts: 11
Joined: Tue Mar 16, 2021 4:19 am

Re: W5500 Ethernet and Soft Reboot

Post by thestumbler » Sun Dec 12, 2021 2:33 am

Well, I figured out a work-around, although it doesn't solve the basic problem that the Nic can't be re-initialized, de-initialized, or queried on soft reboots.

Seeing all the resets going on in my previous reply, I decided to ditch the USB REPL and switch it to UART 6 on my PyBoard. Thankfully, I had left one set of UART pins free on my PCB, on the off-chance that I might need a spare serial port. I've tested this now with a bare serial terminal emulator, rshell, and Thonny. In all cases, machine.reset_cause() returns the expected result corresponding to either soft reboot or hard reset / machine.reset().

I'm fortunate that this is an acceptable solution for me, since the REPL is only used for development (see the squirrelly cable I patched together from an old FTDI C232HD cable I had laying around).
IMG_6339.jpeg
IMG_6339.jpeg (95.47 KiB) Viewed 16572 times

skylin008
Posts: 88
Joined: Wed Mar 11, 2015 6:21 am

Re: W5500 Ethernet and Soft Reboot

Post by skylin008 » Sat May 07, 2022 3:20 am

Hello thestumbler, Had Did it this issue yet ? I had same this issue when Soft Reset the pyboard.

Post Reply