Skip to content

mimxrt/eth: Sleep while waiting for ETH link to come up.#19411

Open
dpgeorge wants to merge 1 commit into
micropython:masterfrom
dpgeorge:mimxrt-eth-sleep-while-waiting-for-link
Open

mimxrt/eth: Sleep while waiting for ETH link to come up.#19411
dpgeorge wants to merge 1 commit into
micropython:masterfrom
dpgeorge:mimxrt-eth-sleep-while-waiting-for-link

Conversation

@dpgeorge

@dpgeorge dpgeorge commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Waiting for the link has a 5 second timeout, and the system should sleep efficiently and poll/process other events while waiting.

Fixes issue #19410.

Testing

Built TEENS41 to verify that it builds.

I did not test on hardware. I need to see if I can find a mimxrt board with ETH...

Trade-offs and Alternatives

The 2ms delay between subsequent polling of the PHY was copied from how the stm32 port works. That should be fast enough for minimal latency, but not too fast.

Generative AI

Not used.

Waiting for the link has a 5 second timeout, and the system should sleep
efficiently and poll/process other events while waiting.

Fixes issue micropython#19410.

Signed-off-by: Damien George <damien@micropython.org>
@kwagyeman

Copy link
Copy Markdown
Contributor

@dpgeorge - Thanks, should be fine without a test.

Also, it might be good to search the code base for tight loops like that which don't wait.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code size report:

Reference:  rp2: Run vm/gc/parse from SRAM by fixing linker object suffix. [f452dab]
Comparison: mimxrt/eth: Sleep while waiting for ETH link to come up. [merge of 54157b7]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@robert-hh

Copy link
Copy Markdown
Contributor

I compiled it for a Seeed Arch Mix, and ETH both times out if not connected and gets a connection if yes. Any suggestion what to test for polling being active? The wait period can be interrupted with Ctrl-C.

P.S.: For Teensy 4.1 you just need the RJ45 plug: https://www.pjrc.com/store/ethernet_kit.html for ETH.

@dpgeorge

dpgeorge commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

I compiled it for a Seeed Arch Mix, and ETH both times out if not connected and gets a connection if yes.

Thanks for testing! That sound good, that both those cases work.

Any suggestion what to test for polling being active? The wait period can be interrupted with Ctrl-C.

If the wait can be interrupted, then the polling is working. To double check that, you can try interrupting the wait with ctrl-C prior to this patch.

For Teensy 4.1 you just need the RJ45 plug

I have a lot of boards (as you can imagine), but I don't actually have a Teensy 4.1...!

@robert-hh

Copy link
Copy Markdown
Contributor

To double check that, you can try interrupting the wait with ctrl-C prior to this patch.

Check! Without this path the wait cannot be interrupted.

@dpgeorge

dpgeorge commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Check! Without this path the wait cannot be interrupted.

Excellent! Thanks for that, now I don't need to find the right hardware :)

I guess this is OK to merge now. At least it fixes this case.

@octoprobe-bot

Copy link
Copy Markdown

Octoprobe PR report

Test Tests
passed
Tests
skipped
Tests
xfailed
Tests
failed
format flash 1
run-tests.py 922 97
run-tests.py --via-mpy --emit native 909 110
run-tests.py --via-mpy 922 97
run-perfbench.py 24
run-natmodtests.py 37 4
run-tests.py --test-dirs=extmod_hardware 18 9 3
run-tests.py --test-dirs=extmod_hardware --emit-native 18 9 3
Total 2850 327 6
Failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants