Ironic
Posts: 7
Joined: Fri Nov 29, 2013 11:14 pm

Using board with or without USB attached - freezes when USB not attached

Wed Feb 21, 2024 9:33 pm

Hello all
I have an RP2040 board (Wiznet) with my custom firmware running a webserver.
I use USB to upload new firmware and also to have a debug serial port.

However, it seems that when USB cable is not attached the board becomes mostly unresponsive.
I can still ping the IP and the status LEDs are working, but when I try to open the webpage it timeouts.

Is this caused because I have prints to USB that are not being read?
Ideally, I would like to maintain the debug prints and they would just get ignored when USB is not attached.
Could a solution be to detect if USB cable is attached and disable prints if that is the case?
This would take some time to do because I am using libraries that have their own prints so would like some confirmation before proceeding.

Thank You

hippy
Posts: 16100
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using board with or without USB attached - freezes when USB not attached

Thu Feb 22, 2024 2:26 am

Ironic wrote:
Wed Feb 21, 2024 9:33 pm
Is this caused because I have prints to USB that are not being read?
Not in my experience but I haven't actually tried it with a WIZnet board.

To disable 'print' en masse you can often do that as simply as ...

Code: Select all

def print(*args):
  pass

hippy
Posts: 16100
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using board with or without USB attached - freezes when USB not attached

Thu Feb 22, 2024 7:51 pm

Ironic wrote:
Wed Feb 21, 2024 9:33 pm
Ideally, I would like to maintain the debug prints and they would just get ignored when USB is not attached.
From saying "print" rather than "printf" I pressume you are running MicroPython on your WIZnet board ?

Your issue prompted me to get my WIZnet W5500-EVB-Pico up and running - And that delivered good news for me, perhaps not such good news for you.

The MicroPython-based Web Server I developed for my Pico W works just as well using the WIZnet after a change in network initialisation. It allows me to view and download files, plus upload new ones. It does this whether tethered to my Pi with a serial connection or powered from a dumb PSU, and that throws out plenty of 'print' diagnostics even though they are going nowhere.

So "works for me" in initial testing, and we can discount 'print' and disconnected USB.

But, after some time, I did encounter some "Not responding" issues though it did then recover. This might be the same issue of Jumbled TCP requests as I am seeing with my Pico W - viewtopic.php?t=365960 - but perhaps not. I will have to investigate that further.

But as to why you are not seeing anything served when USB serial is disconnected I am not sure.

I don't have any delay at the start of my code but it might be worth adding a 'time.sleep()' at the start to ensure the hardware is up and running before it is accessed.

I am running recent MicroPython firmware I built from source myself but I wouldn't have thought that would be an issue if already using MicroPython sourced firmware rather than what WIZnet may have provided.

I also had an issue when I first connected to its REPL, issued 'import network' and it hung solid, had to be power-cycled, but has been fine since. So I can't say it's perfect' but wouldn't say "doesn't work".

How big is your code; if you can zip it up and post it I am happy to give it a go and see how it behaves for me.

Ironic
Posts: 7
Joined: Fri Nov 29, 2013 11:14 pm

Re: Using board with or without USB attached - freezes when USB not attached

Fri Feb 23, 2024 5:05 am

Hi hippy

Thank you for your reply.

After further testing I found this to be a non-issue.
I was running this test on several boards at once.
By coincidence, the issues occurred in the ones I did not have a USB connected to, but in reality, they seemed to be caused by a mismatch in length on TX+/TX- and RX+/RX- lines.
There were reversed in the board so I had to cross them over using enamelled wire but I guess there was too much mismatch in length in some of them, which just happened to be the ones without USB.
Redid the fix taking more care to avoid mismatch in length and the problem stopped occurring.

I wrote print but am using C.
Thank You

Return to “Other RP2040 boards”