Teensy 4.1 Ethernet


New member
Hi all.

I represent an open source project https://github.com/cesanta/mongoose.
Our library has a built-in TCP/IP stack. We have recently implemented Ethernet driver for RT1061, and have examples working, like

Now, we'd like to make an Arduino example for Teensy 4.1
In order to make it work, the Ethernet pins should be setup to their alternate functions and ENET controller clocked.
For our current examples, we do that using NXP's CMSIS header: https://github.com/cesanta/mongoose...60-evk-make-baremetal-builtin/hal.h#L222-L311

Question: can someone point out the Teensyduino way to do it, specifically:
- set Ethernet pins to alternate (ethernet) functions
- clock and reset the ENET controller
- enable Ethernet interrupt, i.e. NVIC_EnableIRQ(ENET_IRQn)

Or shall we just use mimxrt.h ?
Last edited:
Here’s a link to Paul’s original Ethernet test code:

Side note: I’ve implemented a Mongoose Ethernet driver for the Teensy 4.1.

Thank you! That helps.

Quick question - in order to enable Ethernet interrupt handler, we're using the following code:

extern "C" {
extern void (*volatile _VectorsRam[176])(void);
extern void ENET_IRQHandler(void);


  // Setup IRQ handler
  _VectorsRam[16 + IRQ_ENET] = ENET_IRQHandler;

Is that the right way to setup an IRQ handler "the Teensyduino way" ?
Think you're better off using attachInterruptVector() (from imxrt.h) instead of accessing _VectorsRam[] directly.
Thank you @jmarsh, that was helpful.

I'd like to announce is that now, the implementation of the Mongoose library with a built-in TCP/IP stack on Teensy 4.1 works.
It enables a built-in MAC controller in Teensy, and allows to use Ethernet without an external Wiznet module.

We have an Arduino sketch that implements a Web UI dashboard (screenshot attached).
We'll add an MQTT example shortly.

Steps to reproduce:
1. https://mongoose.ws/documentation/tutorials/tools/ to prep your environment (important: symlink support for git)
2. Clone mongoose repo: git clone https://github.com/cesanta/mongoose
3. Open examples/arduino/teensy41-http/teensy41-http.ino in Arduino , and flash on your Teensy
4. Open serial monitor, it should print the obtained IP address, like this:

189f 1 mongoose.c:4549:onstatechange Link up 189f 3 mongoose.c:4649:tx_dhcp_discov DHCP discover sent. Our MAC: 02:95:c1:4e:92:d2 18d2 3 mongoose.c:4628:tx_dhcp_reques DHCP req sent 18d3 2 mongoose.c:4754:rx_dhcp_client Lease: 86400 sec (86406) 18d3 2 mongoose.c:4544:onstatechange READY, IP: 18d3 2 mongoose.c:4545:onstatechange GW:

5. Point your browser on that IP address.

The ethernet pin init function, borrowed from the Pauls sketch, looks .. complicated and cryptic.
Would it make sense to turn in into the Teensyduino API function?
@Paul , your advice would help !


  • Screenshot 2023-11-15 at 18.44.47.png
    Screenshot 2023-11-15 at 18.44.47.png
    1.3 MB · Views: 35
Last edited: