messani / pico-lan8720

Creative Commons Zero v1.0 Universal
15 stars 1 forks source link

Wiring #1

Open igrowagarden opened 3 years ago

igrowagarden commented 3 years ago

Your approach is awesome! How did you wire it compared to the other 10mbps approach? Did you remove the crystal from the lan8720 board and then generate a clock from the pico directly? If so, what frequency? If you could clarify your approach that would be great. I'm looking forward to testing your implementation. Thanks!

messani commented 3 years ago

Hi, there is no need to do any changes to wiring. LAN8720 is running at 50MHz and Pico is overclocked at 250MHz. Pico is able to safely process 4 instructions per single LAN8720 cycle. So it is asynchronous compared to 10MBit approach (in 10MBit approach they underclock Pico to 50MHz so it is synchronous with LAN8720)

I think that this information is written in README.md.

But this is only example implementation. It is neccessarry to tune it and fix possible bugs. I know that for example using function sys_timeout in lan8720.c is not correct because I did not increased timer count in LWIP configuration (I figured it out later after this project).

This project is only way, how to solve 100MBit ethernet with pico. It has not been used anywhere so there can be a lot of bugs.

It is good that you are going to test it. If there are some problems, let me know. I can fix it in this repo so other people will be able to run it.

dave-online commented 2 years ago

we need a version for the new Zero 2 W working with generic pikvm as their image doesn't know the new radio & so cant ever connect wirelessly to actually use it... local 172.0.0.2 comes up so there's that for LAN8720/pico to pin passthrough to a z2w header

PaulskPt commented 2 years ago

Hi, first of all thank you for publishing this repo! Two remarks : a) I cloned it and tried to build it, but the make step revealed line-ending (CRLF) errors in both the .pio files. I changed them to LF line-endings only. Then the build process proceeded without error;

b) in the CMakeLists.txt was missing activation for USB output (or UART). I added the following lines: pico_enable_stdio_usb(${name} 1) pico_enable_stdio_uart(${name} 0) It built and flashed successfully. In both MS Windows 10 as in a Raspberry Pi O.S. there were respectively a COM-port device and a /dev/ttyACM0 device visual. Using minicom in the Raspberry Pi OS but no output from the RPi Pico. Visual observations: the Amber LED of the LAN8720 is steady ON. The green LED is blinking in an irregular rhythm. In file lan8720.c line 32, I un-commented "#define ENABLE_LOG". This had a positive effect. In minicom I now see output as "netif status changed 192.168.1.89", "sending packet", "valid packet received".

The central router of the LAN in this house is reporting the new IPv4 wired device as 192.168.1.89. The device has no HOSTNAME (yet).

Greetings, Paulus

messani commented 2 years ago

@dave-online: But I do not know what to do with this information. This code is probably useless for you.

Hi @PaulskPt. Please, do a pull request for a). ad b) This is your setting. I used RX and TX pins for debugging so current state is good for me. Are you telling me that it is not working when debug messages are disabled?

PaulskPt commented 2 years ago

Hi @messani, created a branch put in that branch the changes mentioned under a) and b) and created a PR. OK about using the RX and TX pins for debugging. I own a Segger BASE compact which I can connect to the SWO pins of the Pico (did not do that yet with this setup. As for your last question: I don't know. I will put the ENABLE_LOG 'out of service' again and see what happen, then I'll report back to you. --

There are two more things that I noticed. The setup received an IP address from the router; then the router reports the device being connected (see image in other answer below) but shortly after the router reports that the device is disconnected.

Using WireShark I see packets from a device with IP-address 0.0.0.0, sometimes shown with a resolved name "Raspberr_85:74:33" and a MAC of b8:27:eb:85:74:33. See the screenshot below from WireShark.

2021-11-16_12h24_RPiPico_Lan8720_packets_monitored_by_WireShark

PaulskPt commented 2 years ago

You wrote: "Are you telling me that it is not working when debug messages are disabled?". My answer: "Yes". When ENABLE_LOG is commented-out, there is no serial output. Below an image of my test setup.

IMG_3167

PaulskPt commented 2 years ago

Below a screenshot of the serial output after boot:

2021-11-16_12h46PT_RPi_Pico_w_LAN8720_serial_output_at_boot

Next image: the RPi Pico listed by the router (edited screenshot) (texts in Portuguese, but you'll understand): RPi_Pico_w_LAN8720_module_listed_in_router

messani commented 2 years ago

Ok, lets make it clear. Purpose of this project is not to write anything to serial port. Purpose of this project is to transmit and receive packets. So I will ask you again. Can you see packets when ENALBE_LOG is disabled? (You wrote "When ENABLE_LOG is commented-out, there is no serial output.")

Wireshark shows DHCP discover and DHCP offer packets. This is IMHO correct because DHCP client is enabled. You can try to ping it: ping 192.168.1.89

or you can try to open example page in web browser: http://192.168.1.89

It is long time ago when i commited this project. But I remember that ICMP PING and HTTP server worked.

If it really does not work, can you send me packets of communication which does not work (eg. wireshark screenshot)?

PaulskPt commented 2 years ago

Yes, the RPi Pico with the LAN8720 module are sending and receiving packets. See the attached screenshot showing the ping challenge and reply in Wireshark and the ping command in a Windows Terminal / bash (WSL1) session. Also the router showed, for less than a minute, that the RPi Pico was connected. The ping command worked 15 times in a row then hang because the RPi was not anymore connected. Because of this the browser test failed. OK Messani, thank you again for this repo and your responses. I am now able to go on with it. Greetings, Paulus.

2021-11-16_16h26PT_RPi_Pico_w_LAN8720_ping_challenge_and_reply