Skip to content

Hard fault occasionally on Pico W ping loop #10255

Open
@b-blake

Description

@b-blake

CircuitPython version and board name

Adafruit CircuitPython 9.2.7 on 2025-04-01; Raspberry Pi Pico W with rp2040
Board ID:raspberry_pi_pico_w
UID:E6614103E7356B37
MAC:28:CD:C1:01:1C:6A

Code/REPL

#######################################
# Diagnostics
#######################################
import ipaddress
import supervisor
import microcontroller
addr = os.getenv("PING_ADDRESS")
ip1 = ipaddress.ip_address(addr)
print("pinging", ip1, 'from', IP)#, end=' ')
t = time.time()
while True:
    try:
        GreenLED.value = not GreenLED.value
        if (wifi.radio.connected and ((t+25) > time.time())):
            #print('  Ping round trip time: %1.3f  Are we good!' % (wifi.radio.ping(ip1)), end='\r')
            #               R  G  B
            Neo_Pixel[0] = (0, 0, 50)
            time.sleep(0.03125)
            Neo_Pixel[0] = (25, 0, 0)
            _ = wifi.radio.ping(ip1) # ping DNS CRASH HAPPENNS HERE!
            #                R  G  B
            Neo_Pixel[0] = (0, 25, 0)
            #print(('   %3.1f' % (_)), end='')
            u = time.time()-t + 1
            if u < 10: print(' ', end='')
            print(u, end='')
            print('   ', _, '   \t\b\b\b\bWe are Bad:-( ') if _ == None else print(('   %3.0f' % (_*1000))+'ms\t\b\b\b\bWe are Good:-)')
            time.sleep(1) # 1 second
        else:
            print('\n\t\aTimeout/Lost Connection\a')
            time.sleep(1) # 1 second
            supervisor.reload()     # Like Ctrl-C, Ctrl-D
            microcontroller.reset() # Like RESET button or remove/connect power, REPL will disconnect
    except:
        supervisor.reload()
        microcontroller.reset()
print('')

Behavior

The crash happens after it has run for a while. One to 12+ hours after start.
REPL stops and disconnects from Putty without comment.
The board has crashed.
Minutes to hours later I then close Putty and then reopen Putty to get the crash notification.
It is like it just waits for me to reconnect Putty to give me the bad news.

Auto-reload is off.
Running in safe mode! Not running saved code.

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.

Description

REPL output:

Connected if True
pinging 8.8.8.8 from 192.168.1.88
1 64ms We are Good:-)
2 58ms We are Good:-)
3 59ms We are Good:-)
4 None We are Bad:-(
6 142ms We are Good:-)
7 139ms We are Good:-)
8 58ms We are Good:-)
9 64ms We are Good:-)

It just stops. No response in REPL/

Additional information

https://forums.adafruit.com/viewtopic.php?p=1052990#p1052990

From AdaFruit Forum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions