Pages: 1 ... 3 4 [5] 6 7   Go Down
Author Topic: Connecting an Ethernet PHY to Arduino Due  (Read 38983 times)
0 Members and 1 Guest are viewing this topic.
Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul,
Thank you again for your questions and notes. It's glad to know you can take time to help here.

Here my answers,

Quote
I have some further questions, and I would first like to confirm a few things with you if I may.
You were able to get 'good communication' with a Davicom AM-DM-9161 module connected to the SAM3X-EK development board using the sample code provided by Amtel, correct?
Yes. Correct.

Quote
With the above test, the Davicom module was wired in place of the existing on-board DM-9161 PHY, yes?
Yes. Correct.

Quote
And so far, this has been the only success with use of a PHY in any way, other than the on-board PHY of the SAM3X-EK, correct?
Yes. Correct.

Quote
Thus, there has been no success as yet with a PHY connected to a Taijiuino or a Due, is this correct?
Yes. Correct.

Quote
I believe the SAM3X-EK, the development board you have is using the 'beRTOS', is that correct?
No. For this EMAC example, I am using some CMSIS thirdparty sources and SAM compiler drivers.
There is a couple of other EMAC samples that use FreeRTOS, a thirdparty API, but again, not for this current application.


Quote
I know nothing of this OS, other than to assume it is a Real Time multi thread capable Operating System?
Yes. More specifically a mini Real-Time Kernel.


Quote
That being the case, any porting from an OS based system to a no OS based system such as used on Arduino is going to need some careful attention to detail for a successful porting.
It is not the current case.

ODwyerPW,
Thanks for your generous offer, I can understand your keenness also, though I'm not sure that having the PHY chips right at this moment will help us.
What would help would be if I had my hands on a Taijiuino and a PHY module.
I would then be in a better position to assist Palliser with the porting and testing, more hands or brains on deck would certainly help.
I might need to go out and buy those things, but am hesitant as I would have little use for them afterwards, and it will just be another board collecting dust. If anyone wants to donate one on a temporary basis, that would be great, I'll pay postage   

Yes ODwyerPW. Thank you also for you interest and offering. So far, I am covered with my Taijiuino and PHY. If I need something, I will let you know.

Quote
There is no way to get any communication between them. I have double-checked the wiring, pull-up/down resistors, and I even ran a simple code that blinked all the Ethernet pins in the SAM3X8E
I take it you meant there was no indication of any communication between them, rather than 'there is no way to get..'   
Right, no indication of any communication between them.

Quote
When you did the test to toggle the EMAC IO lines on the chip, did that succeed?
Yes. I made all the EMAC pins to blink accordingly.


Quote
If you were able to do that, then my first suggestion to you is that you would appear to have those IO lines set for GPIO use rather than having them set to what I believe should be, to use peripheral 'A', the EMAC function.
For that test, maybe you configured those pins for GPIO use?
Interesting. Yes. For that specific ‘blink’ test I did set the Emac I/O lines for GPIO use.

Quote
Did you then configure those pins for peripheral use to continue with EMAC?
Not sure now. I will verify that.

Quote
I think it will be important for you to make sure you are setting up the peripheral the correct way and to confirm that you can read and write various EMAC registers initially. Check section 42.6 of the main SAM3X pdf for Ethernet MAC 10/100 (EMAC) User Interface Register Mapping at table 42-6.
I will do that as soon as possible. Thanks.

Quote
Make a test code that goes ahead and configures the EMAC and then have it read back those registers and display them in a way you can see the values, maybe even a Serial.print might be good.
I will do that also as soon as possible. Thanks.

Quote
Also, from you photo at reply #43 it appears to me you are attempting the test in MII mode rather than what I would assume to be an easier mode of RMII. In your software I see you have mii.h, do you also have a rmii.h to work with for RMII later?
No. Remember that for MII you need: carrier sense (ECRS), collision detect (ECOL), receive clock (ERXCK) and transmit error (ETXER) pins. I have not use any of those phys pins in my tests. For a better understanding, please, see my schematics on reply #29 and read page 2 of doc11153. Regarding rmii.h, even though I am not using it, I wanted to keep it for further use.


Quote
Wilfredo, with a 25Mhz MII or 50Mhz RMII clock, all wires need to be very short, otherwise I expect you'll have a lot of problems getting it to work. See if it is possible for you to mount the PHY module directly on top of the Taijiuino with wires no longer than 50mm.
I will consider that in my next tests. Thanks.
Later on I would suggest using RMII as it uses fewer of IO pins of the SAM3X and that the interface to the PHY should be simpler, in terms of both hardware and also PHY register configuration.
Again, so far I have been using RMII, with less pins as you said.


Quote
Can you check that none of the additional lines used for MII over RMII are not used by other functions of the DUE or Taijiuino as they will need to be free for EMAC?
I checked them and all the Taijiuino EMAC lines are free for EMAC.

Quote
But for now, make sure you configure the EMAC interface to match your PHY, whether that be MII or RMII.
I will consider that in my next tests. Thanks.

Quote
At this point my suggestion would be to focus on using the Taijiuino and to know that you are accessing the internal EMAC interface correctly. Once this has been achieved and proven, we can connect up a PHY.
I will consider that also in my next tests. Thanks.

Quote
As stated in the Atmel 11153.pdf, 'How to connect an Ethernet PHY to SAM3X' documentation;
Quote
'Due to standardization, the connection between a MAC controller and a PHY is straightforward and simple. Even, any PHY can work with any MAC'
I would hope that to be the case, and with that I am pretty keen to develop with Micrel's KSZ8081RNA, though let's get what we have now going first, in terms of PHY chip.
Like you, I hope and believe that any RMII PHY transceiver should make it with SAM3X8E/EMAC.

Quote
Micrel's KSZ8081RNA is a purely RMII unit, so no extra lines for MII.
It uses a 25Mzh crystal to produce the required 50Mhz clock for both EMAC and PHY timing.
It supports standard IEEE 802.3 MII management interface.
My thoughts are that it would be quite a simple and preferable PHY to use, once we get EMAC proven.
Link to PHY info http://www.micrel.com/index.php/en/products/lan-solutions/phys/article/3-ksz8081rna.html

Yes. I believe Micrel should be my next phy choice.

Again, thank you Paul and Rob for your interest. I will keep you posted about my progress here.

Regards and Happy Easter!
Wilfredo
Logged

Alamos, Sonora, Mexico
Offline Offline
Full Member
***
Karma: 5
Posts: 132
learning never stops.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul,
Let's get a Taiji-uino and it's programmer over to you. I'm all for dividing the workload and splitting expenses.
email me at odwyerpw@sonoratechnical.com with shipping info.
Peter

At some point, when you're ready just send it over my way. A sort of rob Paul to pay back Peter.
« Last Edit: March 29, 2013, 05:10:33 pm by ODwyerPW » Logged

Quiero una vida simple en Mexico...nada mas.

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 14
Posts: 306
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wilfredo,
Thank you for your detailed answers, I appreciate your time in explaining them.

I would like to spend some time looking over the software as you have it in the zip file at your first post, just getting my head around it. Can you update it as you make changes so I keep updated as well?

Could I also suggest we set up a off site file location for the library files, say for example Github, as I believe you already have one set up for the CAN bus library. That way we can share the code changes.

Peter, I have sent an email to you, which I guess you will have seen already before reading this.

_____
Paul
Logged


Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello rockwallaby,

I have good news. I just got GOOD communication between Taijiuino's EMAC and the DM9161 PHY!

I just did two things:
1. I re-built from very scratch the EMAC library and sample sketch but using the prior CAN library as a base.
   (For the current non-working EMAC library I used the new Arduino IDE 1.5.2). 
3. I connected the Ethernet error pin (I never connected it before for my prior tests considering it was not necessary).

I will be running some tests before publishing this working EMAC library/Arduino sample sketch in github.

I am so happy that after two months, finally I can see positive results.

Logged

Alamos, Sonora, Mexico
Offline Offline
Full Member
***
Karma: 5
Posts: 132
learning never stops.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good news Wilfredo.

Two Taijiuinos have been sent to Oz, so that Paul & Rob can continue validation with other PHYs... as they develop their DUE work alike.

However, I do not know how to source the Ethernet PHYs that you folks are developing with.  I still have three Taijiuinos in my possession and I'd like to give it a try too.

I have one PHY in my possession,
LCTech ENC28J60 Network Module
here is the info:
http://www.lctech-inc.com/Hardware/Detail.aspx?id=588fbc2e-ecc1-4013-ac35-69bc83bda1fb
On-board ENC28J60-I/SO chip.
On-board 25MHZ crystal.
On-board HR91105A network interface.
3.3V power supply pin.
Size: 56(mm) x34(mm).

Is anyone doing any work with this one?
« Last Edit: April 02, 2013, 04:56:02 pm by ODwyerPW » Logged

Quiero una vida simple en Mexico...nada mas.

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 14
Posts: 306
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wilfredo, that is good news so far.

As you have read in the post above, Peter has kindly organised for two Taijiuino's for us to assist in the testing phase.
I have been in contact with the Russian supplier of the Davicom AS-DM9161 PHY module and am organising two of these modules to be sent to me as well.

As well, I am currently researching the preferred Micrel KSZ8081RNA PHY chip and organising the components to make up a test board of this PHY. I am thinking of mounting the Micrel PHY and its required components using a xQFP Protoboard from http://dangerousprototypes.com/docs/Dangerous_Proto_boards.

Peter, the ENC28J60 module is much like the Wiznet 5100 Ethernet shield commonly used with Arduino 8 bitters.
The chip used on that board is a Ethernet and PHY in one, and communicates with the micro-controller via SPI and as such it has rather limited capability in compassion.

Using the EMAC on-board the SAM3X together with the PHY's we are looking at will provide far greater performance.
I would go so far as to say, Ethernet performance and capability like we have not seen on the standard Arduino platform as yet.

With the SAM3X EMAC located internally on the processor AHB Bus via a DMA controller, we should have the opportunity to support sustained fast Ethernet data transfers with quite low CPU overhead.

In contrast, the existing Arduino Ethernet shields need the processor to move each byte of data in and out of SPI which is connected to the Ethernet shield, thus preventing a lot of anything else happening at that time for the cpu.

Wilfredo, can you elaborate more with details of what tests you have been successful with so far please.
Are you ready to set up the git for it so we can start to look at a testing program and documentation.

_____
Paul
Logged


Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Paul,

Quote
As you have read in the post above, Peter has kindly organised for two Taijiuino's for us to assist in the testing phase.

One of my karmas to Peter was very little for his pro-activity. Thank you Paul!

Quote
I have been in contact with the Russian supplier of the Davicom AS-DM9161 PHY module and am organising two of these modules to be sent to me as well.

By the way, I was drawing today a schematic of my current Taijiuino/DM9161 system showing the wiring. It is working OK 'as is'. Here a picture:



You can download my pdf file with better definition in the link below.

Quote
As well, I am currently researching the preferred Micrel KSZ8081RNA PHY chip and organising the components to make up a test board of this PHY. I am thinking of mounting the Micrel PHY and its required components using a xQFP Protoboard from http://dangerousprototypes.com/docs/Dangerous_Proto_boards.

I found an evaluation board literature based on the KSZ8081RNA that can help you. Here the link:

http://www.micrel.com/_PDF/Ethernet/hw_designkit/KSZ8081RNA_RND/

And other link to the KSZ8081RNA datasheet that I assumed you already got.

http://www.micrel.com/_PDF/Ethernet/datasheets/KSZ8081RNA-RND.pdf

Quote
Peter, the ENC28J60 module is much like the Wiznet 5100 Ethernet shield commonly used with Arduino 8 bitters.
The chip used on that board is a Ethernet and PHY in one, and communicates with the micro-controller via SPI and as such it has rather limited capability in compassion.

Using the EMAC on-board the SAM3X together with the PHY's we are looking at will provide far greater performance.
I would go so far as to say, Ethernet performance and capability like we have not seen on the standard Arduino platform as yet.

With the SAM3X EMAC located internally on the processor AHB Bus via a DMA controller, we should have the opportunity to support sustained fast Ethernet data transfers with quite low CPU overhead.

In contrast, the existing Arduino Ethernet shields need the processor to move each byte of data in and out of SPI which is connected to the Ethernet shield, thus preventing a lot of anything else happening at that time for the cpu.


I am happy you can see the meaning of this small 'cornerstone' as the beginning of a huge building.

Quote
Wilfredo, can you elaborate more with details of what tests you have been successful with so far please.

I am pretty much done with the tests. There is not much to test because the sketch is very simple as you may have noticed for the previous
non-working EMAC library. Basically, the sample demonstrates how to configure ans use the EMAC peripheral enabling the Taijiuino to respond to a ping
command send by the host computer.

Software:
Packet tests:
- Send ICMP ECHO requests to get response from Due/PHY system after being PING'ed.
- Send ARP requests to get reply with MAC address.
- Error detection by simulating lost of communication.

Hardware:
- Direct connection computer <-> Due/PHY system using cross-over cat cable.
- Connection via network computer <-> switch <-> Due/PHY system

All the tests have run OK with few data reading inconsistencies related to the IP Dest Address. This may be caused because my wires are not short.
But again, in general, the library is doing the job.
 
Quote
Are you ready to set up the git for it so we can start to look at a testing program and documentation.

The EMAC library is very raw now. I didn't want to touch it waiting for communication. No that that has been solved,
I have planned to build at least the EMAC class before released it (I am trying to get support from Atmel to gain some time).
Bottom line, I should be publishing the Emac library by the end of this week.

Let's continue braking a leg!

-Wilfredo

* EMAC_PHY1_wo_rst.PDF (120.93 KB - downloaded 35 times.)
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted to share a couple of pictures of the Taijiuino/DM9161 in action. Sorry for the wiring mess (I will replace and bundle better the wires).
Most resistors underneath the PHY.



 

-Wilfredo
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I got rid of the breadboard and replaced it for a Schmartboard.
I'm still working on the EMAC library and hoping to have it available as soon as possible.



Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks a bit better than the rat's nest smiley

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 14
Posts: 306
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to keep things updated here, I have a couple of AS-DM9161 PHY boards from Russia being shipped.
Oddly, they will take the 'long way round', going from Russia to the States and then to me in Australia.

Once arrived, we will see if some progress can be made with the EMAC/PHY library of Palliser to have a little bit of Ethernet spiciness.
_____
Paul
Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey All

Having finally received a custom prototype board and I am working though getting a SAM3X8E interfaced with the KSZ8051RNL PHY (similar but slightly older to the KSZ8081 mentioned above). I am using the LWIP example with the Atmel ASF for the SAM3X-EK board and have rewritten the PHY driver for the KSZ8051RNL from the original DM9161A PHY.

So far I have managed to get the MDIO interface up and I can read and write to the PHY registers. Auto Negotiation works as does disabling and enabling various PHY features. However I cannot get any further - I have enabled debug (output to UART) and stats (no output from them yet) but I can't find out why the stack is not responding to ICMP, let alone any other protocols. Actually it does not even respond to an ARP request (I have wireshark monitoring the interface).

As you (especially Palliser) have seen the implementation within the SAM3X-EK ASF example is rather large - running to 200+ files. Any chance I could get a copy of the "working so far" code you have written Palliser? I know it was posted but you have taken it down and I did not get a copy.

I will keep plugging away in the meantime.

Cheers Tony
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

An update

I had set the debug output on and defined in cc.h:
Code:
#define LWIP_PLATFORM_DIAG(x)   do { printf x; } while(0)
#define LWIP_PLATFORM_ASSERT(x) do { printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); \
                                 fflush(NULL); abort(); }while(0)

From here: http://lwip.wikia.com/wiki/Porting_For_Bare_Metal
This did not compile so (due to three incorrectly defined debug lines in ethernetif.h, but i did not realise that at the time) so I changed the line above by adding a bracket:
Code:
#define LWIP_PLATFORM_DIAG(x)   do { printf (x); } while(0)
fatal mistake!

Now everything compiled so I wrote the PHY driver but could not make anything work - it was hanging on loads of debugs. Remove the brackets and fix the faulty lines in ethernetif.h and voila - LwIP working with the KSZ8051RNL

I have attached the phy driver files for reference, they are not fully tested but should help if you have one of these PHYs.

* KSZ8051RNL.zip (9.25 KB - downloaded 35 times.)
Logged

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 14
Posts: 306
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Tony,

Good to hear of your success with the Micrel KSZ8051RNL PHY chip.
I had a quick scan of the files, all looks good.
Missing brackets, easy to miss  smiley

I'm still putting together what I hope to be a basic shield for the Due / Taijiuino which will have as you know the KSZ8081RNA PHY.
It's been years since I last did PCB design work, so a bit of re-learning on my part.

I guess what you have done should also help me with the KSZ8081 board.
What I am thinking is, it would appear we may end up with a number of PHY boards and we really need to pull theses various boards with their PHY register definitions into a PHY boards type file. This would then be a simple matter for a user to select their PHY board from a list.

The Russian PHY boards are being posted April 17/18 to me. I guess they will take a week or two to get to me still.
_____
Paul
Logged


Venezuela
Offline Offline
Sr. Member
****
Karma: 16
Posts: 495
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello TonyT3P3,

Above all, I am admired of the progress you made in such a short period of time with the Micrel class files for your lwIP sample. Indeed, I have always considered as a part of my actions plans, that implementation of Atmel ASF examples including the basic HTTP web server and RFTP solutions with DHCP enabled through the lwIP TCP/IP stack; but prior to this, a solid EMAC library must be created. As you may have noticed, rockwallaby is now involved to achieve this. So far, we have a workable EMAC library but full of pointers, structures, and low-level stuff that must be replaced. In other words, it is in the alpha-stage and we are in the process to build a CPP Ethernet API that will provide an easy use to the people here in the forum. Having said that, it is only a matter of a short period of time. Regards!
Logged

Pages: 1 ... 3 4 [5] 6 7   Go Up
Jump to: