I've implemented bit-banged 100 Mbit/s Ethernet UDP transmission on the RP2040/RP2350. That is sufficient to transfer the data of the internal ADC overclocked to 5 MSPS and digitize some IF signal...
GitHub - steve-m/Pico-100BASE-TX: Bit-banged 100 MBit/s Fast Ethernet transmitter and UDP framer for Raspberry Pi RP2040/RP2350

Bit-banged 100 MBit/s Fast Ethernet transmitter and UDP framer for Raspberry Pi RP2040/RP2350 - steve-m/Pico-100BASE-TX

GitHub
@steve_m what does this mean 

@cyb3rm0shp1t @steve_m

They're toggling a GPIO pin fast enough to simulate Ethernet without an Ethernet chip. Basically doing:

set pin HIGH
sleep x cycles, ms, or ns
set pin LOW
....

To form the network packages. It is cursed but it is also genius.

(And you're basically doing 100% CPU load most of the time to get the timing right for this)

Edit: Imagine you'd be flipping a light switch to send network packages. It's basically that.

@agowa338 @cyb3rm0shp1t Although the output is performed by a PIO state machine, which is fed with a 32 bit DMA. So the second CPU core, which I reserved for all the encoding, is not used 100% of the time, and the first core is available for the main 'user' application.

@steve_m @cyb3rm0shp1t

Yea, I kinda glanced over the PIO part that makes the Raspberry PI more suited for this as I haven't worked with it myself yet.

But you'd have 100% CPU load without it on "regular" GPIO pins.

@steve_m I guess without a cooler it'll be wiser to do #10BaseT instead for longterm stability...
@kkarhan What do you mean? The MCU is running at 250 MHz (double the Ethernet bit rate), with normal core voltage. It doesn't even get warm.

@steve_m really?

Huh...

Next thing you gonna tell me you're OpenSourcing it as a.general-pirpose Ethernet adaptor to DIY with pinout and firmware to fladh and add a socket to...

@kkarhan Yeah, I'll release it as OSS in the next weeks after ironing out some things and doing some proper host-side receive code.
@steve_m Cool, cuz that'll certainly make it a nifty choice for many projects...
@kkarhan @steve_m "Nifty" as in "Hackish as hell but actually cool" 😅
@steve_m wow that's amazing

i thought you'd need to level shift to do ethernet, but i don't know much about the physical layer of ethernet
@jiub Fast Ethernet (100BASE-TX) is MLT-3 encoded, so there are 3 signal levels: -1, 0, +1. If you take the voltage between two digital GPIOs, you can emulate this by using 0b10, 0b00, 0b01.
@steve_m TIL! that's really clever

the 2040/2350 are such cool chips, it kind of boggles my mind that they can bitbang protocols that operate at hundreds of megahertz
@steve_m minecraft server when :D (/s)

@steve_m I’m impressed that this works and at the same time scared for signal integrity

like, what if someone deploys this en masse

„my sensor only works with this specific cable“

@uint8_t @steve_m

It's not that bad actually. The signal integrity isn't the issue. The issue here is that ANY interrupt occurring will mess up your timing and you also basically can't do anything else on that CPU core as it needs to "busy-wait" to toggle the pin at the correct time.

a RP2040 is technically even better suited for this than e.g. ESP8266 that I've seen others do this with in the past as it has special hardware for bit-banging but even though less severe still same issues apply

@agowa338 @uint8_t So far it works with all devices and switches I've tested. Of course your could add a matching network and proper magnetics to get close to a 'real' 100Base-TX transmitter, but unless you're using tens of meters of cable it's not required. EMI might be a different issue, though. As for the interrupts, this is not a problem - the PIO does clock-accurate output of the bits supplied by the DMA.

@steve_m @uint8_t

Just adding a properly* twisted and shielded cable should already allow you to get longer distances to work. After that also moving RX and TX to more "distant" pins could also help to reduce the near end interferences.
But besides that there shouldn't really be much more required to get a clean (but limited by the PIO/CPU of the microcontroller's speed) signal across.

* don't undo the twisting and shielding until the very end, like with patch panels

@agowa338 @steve_m won’t you be limited by the total capacitance, necessary slew rate, and the drive strength of the rp2040 GPIO?

@uint8_t @steve_m

Can't tell anything specific about the RP2040, but from similar projects I've seen with ESP8266 that's not the main issue as you won't get to GBit/s speeds and such anyway...

@steve_m I never dreamed I would live to see a day it was possible to bit-bang 100Mhz anything.
@steve_m I appreciate the artisanal hand-crafted twisted pair

@steve_m

Should you be able to get energy harvesting via the Ethernet port working as well then I'd be interested in c'n'p-ing your project 😅 (you basically beat me to it then. Wanted to build something like that to read data from the HAN-Port of the smartmeter and send it over wifi/lora/bluetooth/zigbee/... towards a server for charting)

https://doi.org/10.1587/elex.16.20190220

Feasibility study of Ethernet energy harvesting in an IoT beacon system

Beacon systems for Internet of Things (IoT) services require frequent battery replacement and costly maintenance. To resolve these issues, we develope …

J-STAGE
@steve_m kinda funny that it's faster that way than like, implementing USB this way

@steve_m wow! That's super impressive! I wouldn't have thought it would be possible to bit-bang ethernet!

Super cool hack!

@steve_m hell yeah. Always frustrating to see how expensive adding networking to "cheap microcontroller project" would be with of the shelf modules.

@steve_m

how do you write gpio that fast?? isnt that ~2cycles/symbol?

@__luna Using the PIO and DMA
@steve_m you can overclock the ADC by an order of magnitude?????
@steve_m this is one of the coolest things I've seen recently
@steve_m I'm a huge fan of bit banging protocols and this is AMAZING