Arduino Forum

Products => Arduino Due => Topic started by: Palliser on Jan 15, 2013, 07:14 pm

Title: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 15, 2013, 07:14 pm
I thought that it would be a good idea to open this post regarding the connection of an Ethernet PHY to Arduino Due, given that I still revising a couple of approaches I have on hand. The first one belongs to Atmel (doc11153). The second one is my own idea. Let's start talking about the first one which looks realizable and later on, my own approach.

As most of you may know, the core inside Arduino Due (SAM3X8E) integrates an EMAC module to implement a 10/100 MAC compatible with the IEEE 802.3 standard. The approach of Atmel evolves around to the idea of connect an external Physical layer transceiver (or Ethernet PHY) by Media Independent Interface (MII) or Reduced Media Independent Interface (RMII). Then, they made a comparison between both considering frequency, cost and manufacturers. Finally, they present the implementation using a 10/100 Mbps fast ethernet physical layer TX/FX single chip transceiver (DM9161) set in RMII mode with a 50MHZ crystal connected to the development kit SAM3X-EK using a HTTP demo under BeRTOS.

I have planned, as I did with the CAN bus approach, to run the demo to familiarize with their approach.

OK. Now my approach: I'd been thinking to wire directly the Ethernet MAC embedded inside Arduino Due with an off-chip Ethernet PHY (built-in can apply also) and add the correspondent coupler and an Ethernet connector. Then, as I did with the CAN, I will start to port part of the SAM3X-EK 32-b  Ethernet libraries to Arduino Due. I haven't made up my mind yet for the phy but it could be like DP83848C.

As you may have noticed, my approach is not original. I did read similar approaches in this forum but I have no heard of anyone working on one yet (ArgusTech? Markus_L811?). So here we go. Any comments and more ideas are very welcome.


April 03, 2013, 10:49:00 PM - I just removed the attachment with a non-working EMAC library (I will publish in github the new working EMAC library very soon).

EDIT [05-15-2016]:

Here a link for the EMAC demo library:

https://github.com/elechouse/EMAC-DEMO (https://github.com/elechouse/EMAC-DEMO)

I f someone want to try it, I'd recommend to do it with the TAIJIUINO Due Pro R3 w/ Programmer and Ethernet PHY module.

http://www.elechouse.com/elechouse/index.php?main_page=product_info&products_id=2230 (http://www.elechouse.com/elechouse/index.php?main_page=product_info&products_id=2230)

-p
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 15, 2013, 10:03 pm
By the way, for those who are asking to themselves how in the world the 8 Ethernet FPGA pins can be reached/connected, the answer is: a customized micro 16-pin clamp that I am designing.  8)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Jan 16, 2013, 12:34 am
I like the idea of 'native' Arduinoe Due Ethernet. How will you be installing the RJ45 header? Shield? Some sort of Side Car?
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 16, 2013, 02:21 am
Hello ODwyerPW. It will be a side car shield board as follows:

Pins 113,114,115,118,119,120,121 of SAM3X8E of Arduino Due connected via a wedge clip wired to a PHY like DM9161AEP soldered to an Arduino proto-shield board. The board will contain the crystal and necessary circuitry (caps, resistors). The PHY will be wired to a coupler and a RJ45 connector, both also soldered to the shield.

The optimal approach should be a pure shield but the problem lies in the fact that there is not direct access to the Ethernet pins in the SAM3X8E.

My goal here is to develop in a real and practical way an Ethernet interface exploiting the MAC. I believe that in future generations of Due, an embedded PHY should be considered.
 
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 16, 2013, 02:43 am
I think that for reasons of space, the embedded PHY has no place, thus, at least a mini Ethernet terminal should be re-considered (remember the eagles).
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 17, 2013, 03:24 am
To address the Ethernet PHY, instead of begin to look for a chip transceiver or to cannibalize one of my Foscam ip cameras, I preferred to equip my interface with a Russian mini PHY module (AS-DM9161) as an expedite solution. This module doesn't come with the 50 MHz crystal and not sure if the RJ45 jack has the embedded magnetic coupling but all that should be easy to tinkerer. In the meantime, I have planned to start running these following nights the Atmel Studio demo 'EMAC_EMAC_EXAMPLE1' in my SAM3X-EK. This example enables the SAM3X8H to respond to a ping command sent by a host computer.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 23, 2013, 09:23 pm
I ran the Atmel Studio Ethernet sample (EMAC_EMAC_EXAMPLE1) in SAM3X-EK and worked OK. I still waiting for my AS-DM9161 module from as-kit.ru (Moscow) and half-way done with my wedge.
I will now show a simplified drawing of the Ethernet shield (wedge+PHY) for Due. The wedge will work as a bridge between SAM3X8E's Ethernet pins and the Ethernet PHY.
As I explained before, my goal is to develop an Ethernet API for a future Due version with Ethernet connector.
My next step is to start porting the Atmel code to Arduino IDE.

(http://img59.imageshack.us/img59/4099/wedge4.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Frenki_ on Jan 23, 2013, 10:48 pm
Do you think we could use this cheap Enc28j60 boards, which are on ebay for 4$ instead of using AS-DM9161?

(http://images7.okr.ro/auctions.v3/700_700/2012/05/19/0/f/607138974861101208220947-116318-700_700.jpg)

For connection to SAM3X8E ethernet pins I would go with pogo-pins mounted on the bottom of DIY shield for DUE.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 23, 2013, 11:50 pm
Hello Frenki_. Thank you for your contribution.
I think the PHY board you mentioned and the pogo-ping should also make it.
During my research, I wanted to use DP83848C. Also, somebody recommended me to use the chip KSZ8041NLI TR.
What really counts here is the concept: Due->Bridge->PHY->API.
I am experimenting with something that is already proven: an Atmel Ethernet API that works with a SAM3X8H through an Ethernet PHY based on the DM9161.
Once the Atmel Ethernet class is ported to Arduino IDE, we will have here in the forum a main parent Ethernet class to start as a base for further discussion and improvement.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: gaplee on Jan 24, 2013, 03:10 am
You may consider TaijiDUE (http://www.ebay.com/itm/TAIJIUINO-Due-Pro-Board-completely-compatible-with-Arduino-Due-/130825173003?pt=LH_DefaultDomain_0&hash=item1e75c9b80b) on which The ethernet terminal was supplied.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 24, 2013, 03:42 am
Hello gaplee and good catch with the TaijiDUE.
Can anybody post a picture showing the Eth terminal? Thanks.

OK. I have good news!. I just ported the Atmel Ethernet API to Arduino IDE. At least the 'EMAC_EMAC_EXAMPLE1' now called 'Arduino_Due_EMAC_Sample_1.ino' is compiling with no errors. My next step now is try to simplify as much as possible the library (34 files) and then wait for my shield to be ready for preliminary tests before upload it to github. Yes!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 25, 2013, 04:30 pm
I want to clarify something regarding this Ethernet PHY development:

The Ethernet API and EMAC sample I am working with, it has emerged from the simplest of three SAM3X-EK Ethernet examples contained in Atmel Studio 6 and it is called "EMAC_EMAC_EXAMPLE1". This example only demonstrates how to configure and use the EMAC peripheral and does not uses Adam Dunkels' lwIP stack.

The other two examples are more elaborated: "LWIP_EXAMPLE1" which is a basic web server and basic TFTP server application with DHCP enabled through the lwIP TCP/IP stack and FreeRTOS of Sam port and finally "THIRDPARTY_FREERTOS_SAM_LWIP_DHCP_EXAMPLE1" which is a basic HTTP web server using also the lwIP TCP/IP stack standalone SAM port (i.e. no OS).
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: bobcousins on Jan 25, 2013, 04:59 pm

Do you think we could use this cheap Enc28j60 boards, which are on ebay for 4$ instead of using AS-DM9161?

For connection to SAM3X8E ethernet pins I would go with pogo-pins mounted on the bottom of DIY shield for DUE.


The ENC28J60 is an SPI connected MAC/PHY chip. It would work, if you have a driver for it, but would be a lot slower than a PHY connected to the ETH  interface on the SAM3X. If you are doing occasional requests like HTTP, it would probably be OK, if you want to transfer a lot of data I think it would be lacking performance.

It is a cheap and relatively simple way to add Ethernet though.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 25, 2013, 05:44 pm
Don't ask but even though DM9161 is obsolete, expensive and difficult to purchase it, it has been Atmel's workhorse for the SAM family all these years. No "TX underrun" messages under heavy loads with 100M link. I still believe is the best option for now.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: kcore on Jan 26, 2013, 12:07 am
Palliser,

Thanks for all your awesome work you are doing on the Arduino Due - Your idea on the wedge is nothing short of awesome!  I will be super impressed to see it in action.  I'm quite frustrated with the slowness of all of the WIZnet (W5100, W5200) options for Arduino Ethernet capability and I'm down to help test a faster and more reliable solution for the Due.

I just ordered a couple of the TaijiDUE boards and I'll open up both of my Arduino Due's to sacrifice for this project in the meantime since it should take a couple weeks to get them in the USA from where they ship in China.

I also noticed there were several PHY options listed in the following document:
http://www.atmel.com/Images/doc11153.pdf (http://www.atmel.com/Images/doc11153.pdf)

Are you choosing the Davicom PHY due to it being part of the SAM3X-EK evaluation board from Atmel?

If so, I'll be ordering some of the Davicom PHY as well as a couple of the others just in case we need them on hand for testing.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 26, 2013, 04:57 am
Hello kcore,

Above all, I am very happy for your willingness to join this project. I am also very pleased with your words of recognition for my work with Arduino Due but sorry that you are facing 'Dum Roma deliberat Saguntum perit Lat' with the other Ethernet solution. I hope you can make more progress very soon.

Now I will get to the point. At this time, I cannot do too much in the shield side. I expect to get the Davicom PHY by the end of next week (the vendor can't ship it directly to America). My wedge will be ready a little before then. Thus, I hope to start tests by the first week of February.

I chose the Davicom PHY because Atmel already developed the API driver for DM9161A (ethernet_phy.c, ethernet_phy.h) and it is proven with SAM3X-EK. In reference to the other PHY options, I do not have enough knowledge or references with which to form a judgement about them but as Atmel states "Due to standardization, the connection between a MAC controller and a PHY is straightforward and simple. Even, any PHY can work with any MAC." It sounds like, "Just do few changes on the DM9161 driver". Regarding the wedge idea....Do you remember the TV series 'The Six Million Dollar man?...I always think of the Arduino Due as Col. Steve Austin. Due looks like another Arduino board but inside contains a lot of power. An unknown power. For me, those Ethernet and CAN shields are like binoculars or hydraulic pliers if compared with the CAN and EMAC controllers embedded inside Due. We need to take advantages of these capacities. This thought made me figure any possible way to reach them...but let's leave my wedge design in mystery for now. So, I will be working these next few days with the Ethernet API. As I mentioned before, it is compiling good but it is not relevant yet in the Arduino context.

Bottom line: Get ready with you Dues and I would recommend you to get the Davicom PHYs. I believe we can start doing official tests, God willing, in about two weeks.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Frenki_ on Jan 26, 2013, 03:41 pm
Today I have ordered some DM9161 from ebay so I'll be able to contribute to the progress on arduino due ethernet port. ;)

Some time ago I wrote tutorial on: arduino + ethenet shield + node.js for udp streaming http://frenki.net/2012/10/remote-logging-with-arduino-and-node-js/
I would like to use the same technique (but faster) to convert DUE into simple oscilloscope and logic analyser. (But this time without W5100 ethernet shield)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 26, 2013, 05:58 pm
Frenki_, I am happy you also embark in this journey. Welcome aboard!
In reference to your arduino + ethenet shield + node.js, shrewd and amazing! You should submit it to the Arduino blog if you have not already done so.

By the way, I just noticed something in the Taijiuino.

The pin 10 (RESET) of its Ethernet terminal is connected to the pin 47 (NRSTB) of the SAM3X8E instead of pin 69 (NRST).
Pin 47 is input only and enables asynchronous reset of the SAM3X8E when asserted low, unlike pin 69 which is bidirectional and can provide a reset signal from SAM3X8E to the external components.

In the SAM3X-EK, pin 69 is connected between SAM3X8E and DM9161.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: cowasaki on Jan 26, 2013, 10:51 pm

Can anybody post a picture showing the Eth terminal? Thanks.


(http://www.cowasaki.co.uk/TPimages/eth_taij.png)

(http://www.elechouse.com/elechouse/images/product/Taijiuino/Taijiuino-3.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: dammien on Jan 27, 2013, 11:13 pm
Hi all,

First I would like to thank you for all the energy you put is this project , which seems very interesting :) !

Then I have one simple (maybe stupid) question :

On one hand, we have Arduino Uno which comes with ethernet shield (with W5100) and is able to do some client/server application with ethernet.
On the other hand, we have Arduino Due which indeed has a SAM3X and thus some ethernet capabilities, but no access to these ethernet pins and it also needs another PHYceiver, which means alse another kind of shield (Am I right?)

So my question is... what is wrong with the existing ethernet shield ? Is it a matter of speed ? In what case would we need to use this new extra shield rather the W5100 existing one ?

You may answer with "it depends on your application, the amount of data you want to transfer, etc.", so here is what I would like to do:
Just one client, one server, ethernet connection. The arduino is the server. The client makes requests, which mean "I want information number X". The servers makes the answer, which is just a few characters for each answer. So it's a lot of small requests - answer, maybe a hundred per seconds. It must be able to run for hours without "bugging or overloading"

=> Is this good with the standard "ethernet W5100 shield" ? Or should I follow in more details your developments which aim at using the SAM3X ethernet hardware with a specific PHYceiver?

Thanks for your answer !


Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 28, 2013, 01:17 am
Hello dammien,

Yes, speed. What moved me with this Ethernet interface, besides the exercise of help building a future Ethernet API for Due, was the ability of SAM3X8E's EMAC controller to work with RMII at 50MHz, thanks to the fact that all transfers between the EMAC and the core through the DMA interface are 32 bit words (FIFO 128-byte). 100 Mbit/s pure. There are of course more embedded characteristics you can find in page 1267 of the SAM3X specs (Atmel doc11057). We can implement also lwip network stack, or NUT/OS or even the venerable ┬ÁC/IP (now 6LoWPAN). I don't remember now but I think W5100 only has inbuilt IP stack, but without any doubt, W5100 remains to be a phenomenal Ethernet controller. Indeed, It should work for what you want.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Frenki_ on Jan 30, 2013, 08:54 am
I have found this DP83848 PHY ethernet board which should be very simple to set up, because it's kind of all in one. On the header are all the signals neded for RMII.
http://www.wvshare.com/product/DP83848-Ethernet-Board.htm

Datasheets:
http://sva.ti.com/assets/en/other/phyter_prodbrief.pdf
http://www.ti.com/lit/an/snla076/snla076.pdf

Tutorial:
http://blog.tkjelectronics.dk/2012/08/ethernet-on-stm32f4discovery-using-external-phy/

The cheapest price that I have found is on ebay for 15.99$:
http://goo.gl/7GhMC

Since I'm not really experienced in pcb design I'll go with this for a start and perhaps later make my own pcb design...

(http://www.wvshare.com/img/preview/DP83848-Ethernet-Board_l.jpg)
(http://www.wvshare.com/img/devkit/accBoard/DP83848-Ethernet-Board/DP83848-Ethernet-Board-2.jpg)
(http://www.wvshare.com/img/devkit/accBoard/DP83848-Ethernet-Board/DP83848-Ethernet-Board-4.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jan 30, 2013, 03:43 pm
At the beginning, I was tempted to use DP83848, but once I realized that the Atmel guys already have the driver for the DM9161, I decided to save some time. May be you are aware of, but, a better but more expensive option is to use a Micrel PHY, pretty much because, according to Atmel, it has better hardware integration and documentation.
Indeed, it is in my list To-Do to purchase one of the series KSZ80. Anyway, if you choose the TI, likewise I will help you with it.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Frenki_ on Jan 30, 2013, 06:00 pm
Tnx :)

I'm not familiar with (this or) other PHY modules, I just liked this one because It has everything soldered so there is only the software part to do.
I'm a developer so software is easier to me than pcb design...
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: kcore on Feb 06, 2013, 04:39 am
I received a couple of the TAIJI-UINO Due models from Elechouse.  The build quality is pretty good overall but one of them had a bit of metal in the USB mini-b connector that I had to bend out with a precision screwdriver.

Let me know if you want any up close pictures of it, I'll be happy to post them up.

I don't have any pins small enough to solder into the holes for the ethernet terminal area so I'll have to figure out what size they are and order some.  They look to be the same size as the small pins next to the Due 4 pin debug post.  Anybody know what size those are?

(http://i.imgur.com/XFE1c1m.jpg)

I'm still waiting on some of the Davicom phy chips to arrive along with some 50 mhz oscillators and some extra magjacks.  I figure I'll just re-create the AS-DM9161 schematic on a breadboard since ordering them from the Russian site wasn't very apparent.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 06, 2013, 05:34 am
Hello kcore and thank you for the update.
Regarding the Davicom, I'll be posting tomorrow night an electric schematic with connections to Arduino Due. Like you, I still waiting for my Davicom module (AS-DM9161) from Moscow and hope to get it by early next week. I also ordered one Taijiuino as a second front (in case my wedge doesn't make it with the original Due. By the way, the wedge is almost done. I just need to sold the wire connectors to it). In reference to the Taijiuino connector specs., it is a 12-pin 2-row, 1.27mm (50mil) pitch. In my case, to avoid the soldering, I asked the vendor provide connectors for me and they did it for free!(I don't know exactly what they did it. I have to wait to see it). I hope to be ready to start tests in one week with the original Arduino Due and the Taijiuino (one at a time). Regards! 
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: tsaG on Feb 06, 2013, 10:26 am
It would be nice if you could achieve this with a DP83848 PHY as I have some laying around here :D


As the pitch is 1mm, this would fit
http://de.farnell.com/global-connector-technology/bc035-06-a-0380-0300-l/board-board-connector-header-6way/dp/1798738

Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Feb 06, 2013, 06:31 pm

Hello gaplee and good catch with the TaijiDUE.
Can anybody post a picture showing the Eth terminal? Thanks.

OK. I have good news!. I just ported the Atmel Ethernet API to Arduino IDE. At least the 'EMAC_EMAC_EXAMPLE1' now called 'Arduino_Due_EMAC_Sample_1.ino' is compiling with no errors. My next step now is try to simplify as much as possible the library (34 files) and then wait for my shield to be ready for preliminary tests before upload it to github. Yes!


Hey Palliser - any chance you can share the code for example you have - I am working with a KSZ8051RNL which I had working on LPC1789 and want to port to the SAM3X8E.

Cheers
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: kcore on Feb 06, 2013, 06:33 pm
Looks like I found a header that will work for the TaijiDUE, It's 1.27 mm pitch dual row:
http://www.mouser.com/ProductDetail/Harwin/M50-3500642/?qs=%2fha2pyFadui%252brfDKGlTD5x3r%252bOuj8VQay4ssRX%2feMEHuxFtsxzviVg%3d%3d (http://www.mouser.com/ProductDetail/Harwin/M50-3500642/?qs=%2fha2pyFadui%252brfDKGlTD5x3r%252bOuj8VQay4ssRX%2feMEHuxFtsxzviVg%3d%3d)

I've been getting a little better at using Eagle recently and looking at the schematic for the AS-DM9161 it looks fairly simple and possible to build at home:
http://as-kit.ru/hardware/AS-DM9161/AS-DM9161_sch.pdf (http://as-kit.ru/hardware/AS-DM9161/AS-DM9161_sch.pdf)

I think I might be able to recreate this in Eagle as long as the schematic is correct.  I may need you to verify Palliser.  It's basically a Ethernet magjack, the DM9161, some resistors, capacitors, an oscillator and a header for breadboard.  Anyone interested?

Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 07, 2013, 05:01 pm
Here a couple of schematics:
1- Original Arduino Due and Taijiuino Ethernet pins connection reference with DM9161 PHY.

http://img853.imageshack.us/img853/3558/ethernetdue2.jpg (http://img853.imageshack.us/img853/3558/ethernetdue2.jpg)

2- Original Arduino Due and Taijiuino Ethernet pin location reference.

http://img827.imageshack.us/img827/9944/ethernetdue3.jpg (http://img827.imageshack.us/img827/9944/ethernetdue3.jpg)

The PHY can be simplified like the one posted by kcore (reply #28).
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 08, 2013, 09:07 pm
Hello TonyT3P3,
I would rather prefer if you can wait a couple of weeks for the code. Few tests have to be done before release this Ethernet MAC API. I am moving from ~40 ported files to about just 4 (MAC and PHY classes). Thanks for your patience.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: kcore on Feb 09, 2013, 02:00 am
Thanks for the update Palliser, I should get some of the DM9161 chips on Monday and hopefully have a home brew version of the AS-DM9161 within a week or two.  Just in time to run your API against it!

I'll post up my Eagle files here when I got them ready.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: kcore on Feb 11, 2013, 07:27 am
I couldn't find an Eagle library for the DM9161 Ethernet PHY chip so I made my own library.  Hopefully this is a start to a PCB.

This is actually my second Eagle library I have ever created so hopefully I didn't screw it up.

Symbol
(http://i.imgur.com/x9rqQYO.png)
Package
(http://i.imgur.com/nKz0iQo.png)
Device
(http://i.imgur.com/x23sJvH.png)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 11, 2013, 11:34 pm
Hello kcore!
Thank you for sharing your design. It looks professional. I am glad you are moving on with this project. I hope to receive this week my Taijiuino and the PHY module. China and Russia are too far from here!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Feb 12, 2013, 08:26 am
I too have the Taijuino on order (2 of them). I asked them to include the smaller pins as well.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: cowasaki on Feb 12, 2013, 10:30 am
I have the Taijuino board with it's extra header here.  What difference is there in using this "PHY module" over using one of the already available modules that don't rely on the built it interface?  Speed? Cost? ??
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 12, 2013, 04:17 pm
ODwyerPW / cowasaki

I am pleased to know you are interested on this project.
In reference to the PHY module, I made a quick review on the phy driver component and class' functions and I believe that 'any' Ethernet PHY module should work with the EMAC. Indeed, I am considering to use a couple of other PHYs different from DM9161. Remember, I chose DM9161 trying to build this interface as close as possible to the original from Atmel.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 13, 2013, 11:23 pm
To support the Ethernet PHY DP83848 (in addition to the AS-DM9161), I ordered one and just got it today. I also built a breadboard adapter for better access of the pins.

(http://img42.imageshack.us/img42/570/dp83848.jpg)

(http://img694.imageshack.us/img694/498/emacdp83848base.jpg)

My wedge is having false contacts, so I've decided to start tests using the Taijiuino which should arrive this week. Also waiting for the AS-DM9161.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 14, 2013, 01:20 pm
Pin interconnection between Taijiuino and Ethernet PHY DP83848C

(http://img41.imageshack.us/img41/516/taidp8.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 19, 2013, 04:13 pm
Since last weekend, I have a compiling (OK) Ethernet MAC API for Arduino Due. It contains the following files:

- emac sample sketch
- emac.h
- emac.cpp
- ethernet_phy.h
- ethernet_phy.c
- mii.h
- mini_ip.h
- conf_eth.h

All these files come from Atmel and are the only necessary to run the sample. I did rid off the rest (about 40 files) from the original ASF library.

I have planned to start tests tonight with a Taijiuino and a DP83848 PHY module. (I still waiting for the Russian AS_DM9161. The last snowstorm have caused mail delays). I hope to show tomorrow results of the tests and some pictures.

I am conscious that some people are eager to get the library but it doesn't make much sense to publish it without previous basic tests. Thus, thank you for your patience!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 20, 2013, 08:14 pm
I connected Taijiuino with EPHY DP83848 but no communication. I will be revising the phy files, pin configuration and wires. I hope to bring good news soon. Here a picture of my mess!.

(http://img547.imageshack.us/img547/1934/taijiuinodp83848test1.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Feb 24, 2013, 07:03 am
This is one thread I am really interested in.  Ethernet on the DUE without sacrificing so many i/o pins or fitting a shield.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: simplygraham on Feb 24, 2013, 11:58 pm
Hi Palliser

I'm also interested in this, I'll likely go and make my own board (not a shield )to add onto a TAIJIUINO so I can pick up the additional pads, I'll design this board with 802.3af POE hence why I'll design my board around components that have been proved to work 1st ;)
I wish you luck...  I did wonder if the breadboard wiring may be causing an issue with its failure; have you tried to shorten the wiring at all ??

BR
Graham
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 25, 2013, 01:12 am
Hello Graham,

I am happy you are interested in this project. I still working on the modified Ethernet MAC library. As you mentioned, I had to get rid off the breadboard to avoid wiring issues. Here a picture of what I have so far with less connections between the external Ethernet PHY DP83848 and a Taijiuino, although I am planning to use a DM9161 Phy when coming in from Russia next week. It could be also great to see your POE one of these days. One of my future goals is the implementation of a Webserver example, but for that, I have to wait a little longer. Regards!

(http://img42.imageshack.us/img42/4640/taijiuinodp83848test2.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: simplygraham on Feb 25, 2013, 09:24 pm
Hello Palliser

My; that looks a lot neater, and hopefully stop any gremlins with wire lengths.
It will be interesting when you receive the DM9161, is this mounted on a carrier with the jack/magnetic's similar to the DP83848 board ?

The POE is very easy to achieve with suitable Jack socket, as similar to the Arduino Ethernet, and a ready built POE module can then be soldered in
these can range in voltage from 3.3V upwards so can be selected to give the voltage that's required and additional Voltage regulators used for lower voltages if needed.
some such as the silverline range can have there outputs modified, the usual 12V from the 9012-S POE module is reprogrammed with a shorting link to only supply 9V so not to overheat the fixed 5V regulator on most of the Arduino boards.

I'll keep and eye open for developments and wish you success

BR
Graham
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 27, 2013, 12:04 am
Hello Graham,

Yes. The DM9161 board is similar to the DP83848. I chose it as my first option, given that the hardware (pull-up, pull-down PHY address resistors, filter/noise capacitors, Crystal, timing, etc.) is more than proven by Atmel for the most of their development kits. Thank you for the good wishes.

here a picture of AS-DM9161

(http://img96.imageshack.us/img96/1087/asdm9161angle.jpg)

Regards!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 07, 2013, 04:37 pm
After a long wait, I just received yesterday my AS-DM9161 board. I really hope to have better luck with it. I have been trying to modify the EMAC library to make the DP83848 work with the Taijiuino but only communication errors. I will keep you posted once I start getting communication between Taijiuino EMAC and Ethernet PHY DM9161. regards!
Here a picture of the Russian board!

(http://img560.imageshack.us/img560/7683/dm9161.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Mar 13, 2013, 08:13 pm
Hey Palliser, how are you getting on with interfacing your phy to the Due? I don't mean to chase you but I am keen to see the library/ethernet files as I would like to add support for a different PHY.
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 14, 2013, 05:20 pm
Hello TonyT3P3,

Following is a summary of my progress with the EMAC/PHY interface.

Firstly, I got good Ethernet communication between my new Russian PHY board (AS-DM9161) with the SAM3X-EK board. I performed this with the purpouse of verify the functionality of this PHY board because is slightly different from the one embedded in the SAM3X-EK.

Here a log excerpt of the EMAC/external EPHY communication between SAM3X-EK board and AS-DM9161 Ethernet PHY board:

Code: [Select]
-- MAC 0:4:25:1c:a0:2
-- IP  192.168.0.2
Link detected.
-- IP  255.255.255.255
-- IP  20.254.181.156
======= IP   60 bytes, HEADER ==========
IP Version        = v.4
Header Length     = 5
Type of service   = 0x0
Total IP Length   = 0x22
ID                = 0x4B8E
Header Checksum   = 0x2E92  Protocol          =
UDP

IP Src Address    = 192:168:0:3
IP Dest Address   = 255:255:255:255
----------------------------------------
-- IP  255.255.255.255
-- IP  20.254.181.156
======= IP   60 bytes, HEADER ==========
IP Version        = v.4
Header Length     = 5
Type of service   = 0x0
Total IP Length   = 0x2C
ID                = 0x4B91
Header Checksum   = 0xAF94  Protocol          =
ICMP

IP Src Address    = 192:168:0:3
IP Dest Address   = 255:255:255:255
----------------------------------------
...


So far so good.

Then, I started tests between the Taijiuino board and the AS-DM9161,but hitherto, I have not managed to get communication between them. The EMAC sample sketch compiles OK in the Arduino IDE but I believe
I am overlooking something, specially in the Pio/pin configuration (in the variant files).

Here a log excerpt of the Taijiuino DUE EMAC/external EPHY:

Code: [Select]

-- MAC 0:4:25:1c:a0:2
-- IP  192.168.0.2
Link detected.


I can see leds activity (FD/100/LINK) in the DM9161 but I am getting the same log even with the Taijiuino disconnected from the PHY.

Thus and unlike my CAN project, I have decided to publish and keep updates of the EMAC library files here (see my very first post in this thread). This files are the ones I am using now. The purpose of this is to obtain help from you guys.

Because the sketch compiles OK, I think that the only way to help testing the code, is to do it with the Taijiuino board and a DM9161 based board. Anyway, any comment/revision of the code is very welcome.

Other exercise I am going to do this week, is to run the same test SAM3X-EK/DM9161 but with the DP83848 to confirm that it works also, thus, using this second PHY as another option.

For your information, I am also trying to get direct support from Atmel. Thank you.
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 18, 2013, 10:21 pm
Whoever ventures to help me with the Ethernet MAC library, here what I have done regarding the EMAC pin configuration:

-I added in the variant.cpp the EMAC pin definition (lines 291 to 301) and the initialization of the EMAC Pio configuration (lines 431 to 485).
-I added in the variant.h the defines of the EMAC pins (lines 187 to 202).

Here a picture of my test of the DM9161 board. My test with the DP83848 still pending. I also still trying to get help from Atmel technical support team.
But don't worry, I will solve it.

(http://img542.imageshack.us/img542/792/sam3xekexternalphy.jpg)

Regards!


Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Mar 20, 2013, 02:36 am
Hi Palliser,

I'm currently designing a SAM3X8E Arduino "work-alike" system and was planning to use a W5200 but this thread has convinced me to at least break out all the EMAC signals so I can add the PHY at a later date.

Thanks for you work in this (and other) areas, I also have both CAN interfaces on my backplane so will presumably be looking to your work there as well.

______
Rob
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 20, 2013, 02:47 pm
Hello Graynomad,

I am delighted to know about your Due-oriented system! Please, remember to include also the pin 69 (NRST) which adds the capability of the SAM to reset external components. Keep us posted about your progress and count on me if you need any assistance.

Palliser
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Mar 20, 2013, 04:15 pm
Quote
remember to include also the pin 69 (NRST)

Already done.

I'm trying to provide full access to all peripherals like HSMCI, SSC, SMC, EMAC etc. Unfortunately the chip MUXs many signals and provides no optional pins so there will always be trade-offs of the "If you use X you can't use Y" type.

Do you know what frequencies I can expect on the EMAC signals? The full 100MHz or only 50 because there are two data lines. I plan to run these signals across a backplane to an Ethernet card and am a bit worried about the speeds.

______
Rob
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 20, 2013, 04:50 pm
Quote
Unfortunately the chip MUXs many signals and provides no optional pins


Yep. Multiplexing scheme (to reduce I/O) is our eternal karma with micro-controllers.

Quote
Do you know what frequencies I can expect on the EMAC signals?


The frequency depends on the interface supported by the external PHY. Most PHYs support both.

-25 MHz for MII
-50 MHz for RMII.

I am using RMII (higher speed and saves me 4 pins).

-Palliser
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: anon10500 on Mar 24, 2013, 11:01 am
Is there any progress with DP83848 with sam3x-ek?
Later I would like to contribute LAN8720A PHY once I understand how you port it.
Thanks for your work.

Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 27, 2013, 08:41 pm
Hello anon10500,

I haven't started my tests with DP83848 but I am almost certain that it will work in a similar way to the DM9161. I also checked some specs and schems of the LAN8720A PHY you mentioned and it should also work. What I do not understand is why the people from MikroElectronika didn't connect the reset pin?...though I'm mostly centered now trying to communicate the Due with the PHY. As you may have noticed, I am working together with Atmel tech support to achieve this. And I also published in the forum my library asking for help. Even though what separates me to begin to see result is too little, I cannot be precise about the 'when'. Just keep in touch.
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Mar 28, 2013, 04:16 am
Hello Palliser,

I am working together with Graynomad (Rob) in the design of a new modular Due 'work-a-like' system, in which we intend to use the EMAC together with a PHY such as the DM9161 chip from Davicom or maybe something better still.

Firstly, I wish to say that we appreciate your willingness and openness in wanting to have a working SAM3X EMAC/PHY Ethernet library for the Due family.

I would like clarification as to the current progress of your library to allow the SAM3X EMAC interface to connect to a PHY.

In your first post you write:
Quote
See the attachment with the latest EMAC library (compiles OK but not working)

You say it compiles ok but that it does not work, can you give us some details as to what you have been able to get working and what is not working please?

In your post #10 you wrote:
Quote
I just ported the Atmel Ethernet API to Arduino IDE. At least the 'EMAC_EMAC_EXAMPLE1' now called 'Arduino_Due_EMAC_Sample_1.ino' is compiling with no errors

When you say you ported the Amtel Ethernet API to Arduino IDE, can you elaborate a little for us, in terms of what functionality does this port provide in the Arduino IDE, for example, does it allow full configuration of and use of the EMAC interface?

In your post #13 your wrote:
Quote
Don't ask but even though DM9161 is obsolete, expensive and difficult to purchase it, it has been Atmel's workhorse for the SAM family all these years. No "TX underrun" messages under heavy loads with 100M link. I still believe is the best option for now.

I understand Davicom have a newer DM-9162 now, in your opinion, is this any better?
If not, what other PHY would you suggest for best design for a better system?

In your reply #22 you mention:
Quote
better but more expensive option is to use a Micrel PHY, pretty much because, according to Atmel, it has better hardware integration and documentation.
Indeed, it is in my list To-Do to purchase one of the series KSZ80.

Looking at the Micrel list for PHY chips, I found this one, a KSZ8081RNA, http://www.micrel.com/index.php/en/products/lan-solutions/phys/article/3-ksz8081rna.html (http://www.micrel.com/index.php/en/products/lan-solutions/phys/article/3-ksz8081rna.html). It looks to be a modern PHY that offers a few more niceties such as termination resistors on chip as well as being able to use a 25Mhz crystal which generates the 50Mhz clock for RMII.
When you say 'more expensive', I checked the cost of these chips and I found them to be one of the cheapest, at around US$1.00 each as compared to the TI DP83848 which sells at around US$3.00 to US$5.00. Why did you find this option 'more expensive' ?

In post #27 on February  TonyT3P3 wrote:
Quote
I am working with a KSZ8051RNL which I had working on LPC1789 and want to port to the SAM3X8E.

I believe the KSZ8051 to which he refers is a model before KSZ8081, and with my limited research, both appear to be a very suitable PHY to use, especially since the DM-9161, as you say is 'obsolete', or at least quite a number of years old now.

In your reply #46 you wrote:
Quote
I have been trying to modify the EMAC library to make the DP83848 work with the Taijiuino but only communication errors.

Can you tell us if you have since been able to understand and rectify those errors or have you made further progress with this?

In reply #48 you wrote:
Quote
I got good Ethernet communication between my new Russian PHY board (AS-DM9161) with the SAM3X-EK board. I performed this with the purpose of verify the functionality of this PHY board because is slightly different from the one embedded in the SAM3X-EK.


Can you tell us in more detail what you mean exactly by 'good Ethernet communication'?
My understanding from looking at the schematic of the SAM3X-EK where the DM-9161 is located looks to be the same as the AM-DM-9161 module, is this not correct?

In reply #48 you wrote:
Quote
The EMAC sample sketch compiles OK in the Arduino IDE but I believe
I am overlooking something, specially in the Pio/pin configuration (in the variant files).

I wonder if you can elaborate on this?
Do you believe the problems are in the initial PHY configuration or are you getting past that point and the problem lies in the actual implementation of Ethernet communication?

Lastly, I noticed that in your first post, the last edit states 'Last Edit: 15 March 2013, 02:18:35 by Palliser'.
But I notice in your reply #49, dated March 19 it appears you have made further improvements to your library as follows;
Quote
I added in the variant.cpp the EMAC pin definition (lines 291 to 301) and the initialization of the EMAC Pio configuration (lines 431 to 485).
added in the variant.h the defines of the EMAC pins (lines 187 to 202).

Can I confirm with you that you are keeping the first post the location of the latest code?

Palliser, I realise this is a long list of questions, but we are very keen to use the SAM3X EMAC in our design.
I like what you say when I read 'But don't worry, I will solve it'. Please keep at it Palliser, it will be a major step forward to have it functional.

I would also like to say we would invite any others who might have 'tinkered' with this interface who may have something to add to please step up to the podium.

_____
Paul
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Mar 28, 2013, 04:55 pm
We are experimenting with 5 Due's (Arduino y TAIJIUINO varieties) at the moment. While I am enjoying the freedom of multiple UARTs and Allot of I/O... well, I'm growing frustrated getting LCD touch screens, SDfat and I2C working acceptably. (I bet we have 9 different LCD panels ranging from 2.4" to 7").  I haven't even begun with Ethernet...nor do I have the technical expertise and capabilities you all have. It's frustrating because I want to stop messing around with getting the prototyping platform (DUE) operational and just move on to designing and building my proof of concepts. Admittedly the stuff I am trying with DUE is magnitudes more difficult than what I've done with Uno and Mini. I need local user interface (lcd/sdfat), remote user interface (web/Ethernet), local I/O (done! finding hardware debounce was awesome) and remote I/O (I2C) operational.

That said..if you all (GreyNomad, Wallaby and Pallisar) identify a number of PHYs you want to try.... just direct me to where they can be purchased in quantity and at good prices...and I will donate them to the cause... I'll gather a mess of them together and then get them shipped to Oz and Venezuela. (I live in Mexico but I get up to Arizona, USA allot). I'll send you multiples so that you can burn a few of them up at will. Sorry, guys, that is the best I can do stepping up to the plate to help you guys with the effort.
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 28, 2013, 05:03 pm
Hello Wallaby and GreyNomad,

I just stopped 'Round Midnight in my cassette player. Sometimes the Monk helps to put some ideas in order! I am glad to know that you and Rob are taking seriously the challenge of building your own Due-oriented system. Godspeed.
Thank you very much also for your words regarding this initiative to exploit the full potential inside SAM3X8E. That is the minimum we can do in favor of Arduino in return for their amazing contribution.

Here my answers:

Post#1:
What is working: If you test the EMAC sample sketch with Arduino IDE 1.5.2 using the EMAC library, it compiles OK (No errors. No warnings).
 
What is not working: When you test it on real hardware (DM9161 phy/Taijiuino), it doesn't work. 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. Furthermore, I connected the DM9161 to the SAM3X-EK and I got communication between them. Thus, all the hardware is OK but the something in the software is wrong.

Post#10:
This EMAC library is the result of the same porting approach I did to the CAN library (which is workable and available here in the forum). Let me just recap that: I took the Atmel ASF EMAC library that actually permits, through a couple of samples, the perfect communication between the SAM3X8H and DM9161 embedded in the SAM3X-EK board. Thus, SAM3X8H and PHY DM9161 work OK. That's why I decided to 'port' the library to the Arduino environment. To achieve this, I had to get rid of a lot (and I mean 'a lot') of unneeded references that ASF uses. Of course, CAN was easier because involved only two pins unlike Ethernet that uses ten pins. I can post later the details of how to port ASF libraries but I have a warning, it is not very Arduino-style, lot of pointers, structures, and low-level stuff, written for engineers, not for beginners.

Post#13:
I don't know if the new DM-9162 is better or not. I need to read about it. Because of SAM3X8E, all my design consideration are derived from Atmel's literature, I know from them that the DM9161 was the best option (you can read other phy suggestions of Atmel in their document 11153) but recently I knew that Atmel just turned to Micrel for the reasons I mentioned in my reply #22.

Post#22:
I was making reference to some phy boards based on KSZ80 series (KSZ8001,KSZ80
51MNL) I did read after Google it. I believe (may be I am wrong), most people in the forum does not build stuff from scratch, like you, but get/purchase parts ready to go. $1 for a KSZ8081RNA sounds like a good deal.

Post#27:
I don't know how old is KSZ8051RNL but Atmel recommended it in their doc 11153.   
I can ask Atmel about Micrel and let you guys know.

Post#46:
I am prompted to test again DP83848 but with SAM3X-EK. In the past, I made some mistakes synchronizing the reset pin of the phy. PHY reset pin should be disable for few milliseconds before start handshake. The good of the EMAC library is that lets SAM3X8E to take control over this.

Reply#48:
First quote: The log excerpt that I did read in the serial monitor it means to me that I have good communication.
Second quote: The problem should be in the actual implementation of Ethernet communication.
(Working on it with Atmel technical support. Nothing clear yet).
Both statements make reference to the same library. With my last quote, I wanted to point the user to where (in the files/lines) the attention has to be focused.

I hope I have enlightened you a bit more with my answers. Please, feel free to ask more questions if needed. Regards!

-Wilfredo
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Mar 29, 2013, 05:19 am
Wilfredo,
Thank you for your prompt and detailed reply, it helps me to better understand where you are at with your progress.

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?
With the above test, the Davicom module was wired in place of the existing on-board DM-9161 PHY, yes?
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?

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

I believe the SAM3X-EK, the development board you have is using the 'beRTOS', is that correct?
I know nothing of this OS, other than to assume it is a Real Time multi thread capable Operating System?
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.

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  :)

Wilfredo (Palliser) wrote:
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..'  :)

When you did the test to toggle the EMAC IO lines on the chip, did that succeed?
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?
Did you then configure those pins for peripheral use to continue with EMAC?

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.

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.

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?

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.

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.

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?

But for now, make sure you configure the EMAC interface to match your PHY, whether that be MII or RMII.

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.

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.

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 (http://www.micrel.com/index.php/en/products/lan-solutions/phys/article/3-ksz8081rna.html)

_____
Paul
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Mar 29, 2013, 05:23 pm
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
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Mar 29, 2013, 11:00 pm
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.
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Mar 30, 2013, 03:24 pm
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
Title: Re: [Attached nonworking EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 02, 2013, 07:03 pm
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.

Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Apr 02, 2013, 11:50 pm
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?
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Apr 03, 2013, 02:51 pm
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 (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
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 04, 2013, 04:35 am
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:

(http://img545.imageshack.us/img545/5792/taijiuinophy1.jpg)

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/ (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 (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
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 04, 2013, 05:42 am
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.

(http://img577.imageshack.us/img577/1016/emactaijiuinophy3.jpg)

(http://img37.imageshack.us/img37/3651/emactaijiuinophy2.jpg)

-Wilfredo
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 05, 2013, 09:31 pm
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.

(http://img12.imageshack.us/img12/6613/taijiuinophy5.jpg)

Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Apr 06, 2013, 05:52 pm
Looks a bit better than the rat's nest :)

_____
Rob
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Apr 09, 2013, 01:04 pm
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
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Apr 14, 2013, 04:37 pm
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
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Apr 15, 2013, 02:14 am
An update

I had set the debug output on and defined in cc.h:
Code: [Select]
#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: [Select]
#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.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Apr 15, 2013, 03:38 am
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  :)

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
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 15, 2013, 05:03 pm
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!
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: swseansw on Apr 15, 2013, 05:28 pm
(http://s20.postimg.org/txubluu89/IMG_0371.jpg)
Hope it could make things easy
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Apr 15, 2013, 05:43 pm
Hasn't helped me any.

_____
Rob
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Apr 15, 2013, 05:48 pm
swseansw,

Do you provide a magnifying glass.
Or some details about what you are suggesting could hopefully make what easy?

_____
Paul
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Markus_L811 on Apr 15, 2013, 06:15 pm

(http://s20.postimg.org/txubluu89/IMG_0371.jpg)
Hope it could make things easy

An little bit barely an explanation.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: gaplee on Apr 16, 2013, 03:32 pm
(http://s20.postimg.org/txubluu89/IMG_0371.jpg)

This module is designed with reference to the Atmel SAM3X-EK board,  and has a microSD card slot on it. The PHY chip is DM9161.

This module is in testing now.  Detail information will be delivered when the testing is finished.

The testing process is not going well.
I compiled the beRTOS SAM3X-EK examples to test this DUE Ethernet module with Taijiuino DUE.  Unfortunately, something was wrong, the module didn't preform as expected. Now i want to open the beRtos's DEBUG option to see what happened. But i don't find the correct way.

I want to find out whether the DM9161 is working, does anyone know which SAM3X8E's register should i check.
How can i open the tcpip function's debug option.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Apr 16, 2013, 04:22 pm
Hello,

I want to clarify that the emac class files (emac.c, emac.h) ARE NOT contained in the current Arduino IDE version 1.5.2.
For those interested to get these files, please refer to the following link:

For the emac.h ----> https://github.com/cmaglie/Arduino/tree/ide-1.5.x/hardware/arduino/sam/system/libsam/include (https://github.com/cmaglie/Arduino/tree/ide-1.5.x/hardware/arduino/sam/system/libsam/include)
For the emac.c ----> https://github.com/cmaglie/Arduino/tree/ide-1.5.x/hardware/arduino/sam/system/libsam/source (https://github.com/cmaglie/Arduino/tree/ide-1.5.x/hardware/arduino/sam/system/libsam/source)

Regards,
Wilfredo 
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Apr 16, 2013, 08:49 pm
I agree that we will end up having a number of different Phy drivers to incorporate within an overall "Due Ethernet" library. The SAM3X-EK example that I modified has ARM(CMSIS), ATMEL(ASF) and LwIP code. It might be better to look at a LwIP or another stack without all the rest and see if its possible to add Due support, we would then benefit from further developments of the LwIP stack, rather than a Arduino specific library that once working may not be further developed.

Thoughts?
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: komby on May 09, 2013, 08:51 am
I have been lurking, watching this thread from the start, now its time for me to try with due-ethernet!   I have been working on a custom diy board which has onboard micrel 8051 phy and magjack.    Finally got one built up and it passed the blink test.  Now on to try and follow the leader with the lwip example.

Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on May 09, 2013, 05:02 pm
Hello komby,

Wow, I am amazed with what you have pulled off. Nice work!

This is getting really good. So far, you are the fourth developer with a Due DIY board-oriented that includes the Ethernet phy interface (floating or embedded).

Here the list (with no order of preference but chronological for me):

1- as-kit.ru new AS-SAM3X board (also includes the CAN bus embedded interface)

2- elechouse.com new Taijiuino R2 version.

3- Graynomad's Black Diamond (also includes CAN bus and other communication interfaces).

4- komby (web site?)

I am happy that this initiative has already gained a great deal of software/hardware support.

Thank you,
Wilfredo
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: komby on May 09, 2013, 08:04 pm

Hello komby,

Wow, I am amazed with what you have pulled off. Nice work!

This is getting really good. So far, you are the fourth developer with a Due DIY board-oriented that includes the Ethernet phy interface (floating or embedded).

Here the list (with no order of preference but chronological for me):

1- as-kit.ru new AS-SAM3X board (also includes the CAN bus embedded interface)

2- elechouse.com new Taijiuino R2 version.

3- Graynomad's Black Diamond (also includes CAN bus and other communication interfaces).

4- komby (web site?)

I am happy that this initiative has already gained a great deal of software/hardware support.

Thank you,
Wilfredo


Thanks Wilfredo.  To be fair I'm still unsure if its pulled off yet!...I just soldered the first one together yesterday :)... That said I am working on making sure it does work.    I do have a little bit of information about it on komby.com but I was planning on verifying the board is working before publishing the eagle files.   If any of the people on the thread who are working on the Ethernet Library and are interested in one of the prototype boards PM me.   I made a lot of sacrifices on the board to get the ethernet onboard as well as some nRF24L01 headers so it may be a bit specialized for common use...

Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: swseansw on May 30, 2013, 10:59 am
Please allow me to tell everybody who might be interested in Due-Ethernet. You could find a hardware kit for developing this libaray here:
On ebay click here (http://www.ebay.com/itm/TAIJIUINO-Due-R2-w-Programmer-and-Ethernet-PHY-Module-Arduino-DUE-compatible-/140981886057)
On official web click here (http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=72_73&products_id=2230)
We hope this kits could help those software guys who are less patient and sick of handing wires.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on May 31, 2013, 12:41 am
Took a look at it.  This hardware kit can't be used simultaneously with your CTE LCD shields. Bummer.  Split decision... lots of wires for the LCD or lots of wires for the Ethernet.  Oh well. The DUE platform will get there eventually.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: swseansw on May 31, 2013, 04:00 am
We know it is not perfect. While designing it, we didn't consider its compatibility with other modules in hardware. The best choice would be a Due shield which contains PHY chips. But we think we should do that later. As this library is not finished yet, a small and cheap PHY module would be better. That's how it comes. Sure later there will be a shield for Due to have all on it.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Jun 05, 2013, 08:40 pm
Yes, you are correct, I didn't mean it as a criticism.  DUE is such a work in progress... I appreciate you providing this module which eliminates all of the wiring for folks trying to develop the Ethernet libraries.  

Somewhere down the road, we will all figure out how to make the UI, Comms, and I/O portions all play nice together on DUE. Which will give us feature parity with UNO, but higher performance and greater capabilities.

I've looking forward to seeing what the folks down under will have when they release Black Diamond.
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Jun 06, 2013, 05:49 am
Quote
I've looking forward to seeing what the folks down under will have when they release Black Diamond.

Me to :)

The project is alive and well, there has been a lot of changes in the last 2-3 weeks, often due to input from interested parties. We froze the design about 3 days ago then had another bright idea, oh well better to try and get it as right as possible.

When implementing various comms, EMAC, SD, and external memory interfaces there are not many pins left for GPIO so don't expect a huge IO pin count. That said what we do have should be quite robust, not just raw pins connected to the big bad world.

I'll post more details on the Black Diamond thread soon.

______
Rob

Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Jun 08, 2013, 06:32 am
New thread started about the successor to the Black Diamond.

http://forum.arduino.cc/index.php?topic=170901.new#new (http://forum.arduino.cc/index.php?topic=170901.new#new)

______
Rob
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: jake1981 on Jul 25, 2013, 08:44 pm

Took a look at it.  This hardware kit can't be used simultaneously with your CTE LCD shields. Bummer.  Split decision... lots of wires for the LCD or lots of wires for the Ethernet.  Oh well. The DUE platform will get there eventually.


Ehm.. What does this mean? Arduino Due cannot have SD+TFT+Touch+ethernet - or does this just mean that shields are incompatible if they are not being wired? I am interested in a project that has a tft with touch.. And Sd.. And would be connected with ethernet.. Currently I have a shield from aqualed source for 5.0" tft - and was thinking I could use a ribbon cable to take ethernet connection "outside" - but does this then work or not?
Title: Re: [Finally a working EMAC library] Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jul 29, 2013, 12:56 am
Small web server example using Taijiuino.

As some of the followers of this thread know, I have been working porting the EMAC library and example from AS6 ASF SAM3X-EK to the Arduino Due environment. Even though I tried to put the Due in action, it is very hard under its actual design. Thus, I migrated to Taijiunio and AS-Sam3x (third parties Due based boards). So far, we have a very raw workable library but also we have been very busy to finish it. We have some plan to continue next month (Paul, Thibaut and me).    
In the meantime of our EMAC library development and taking advantage that the raw EMAC library is working decently, I have decided to explore, what is, our next frontier: to use the potential EMAC cababilities of Arduino Due (now available in the Taijiuino board) an convert it in a small web server. Thus, I made a raw porting of the AS6 ASF lwIP Atmel example. This example features a basic HTTP web server using lwIP TCP/IP stack and the EMAC driver of the Taijiuino in mode standalone (without OS).

Plugging directly the Ethernet cable into the Taijiuino EMAC kit to my laptop and configuring the network to local mode setting up a 'point-to-point' network, now I can launch my Google Chrome web browser and typing the IP address assigned automatically to the Taijiuno (DHCP mode) and see an index.html page that comes with the example (converted into a static C struct, with HEX codes, with the help of a small Perl script).

Here attached a couple of pictures of the Taijiuino in action and the serial output. I have planned (of course) to polish and finish this raw code of the web server (it is messy and big now) into the Arduino IDE environment and create some input/output functions like turn on/off digital outputs using buttons in the web page, or change analog signals using a painted potentiometer or show status of some parameters in the board (temperature, voltage, etc.) but...that will take some weeks. Regards!

(http://i1314.photobucket.com/albums/t570/Wilfredo_A_Molina/Taijiuino_lwIP_stack_DHCP2_zps5f477489.jpg)

(http://i1314.photobucket.com/albums/t570/Wilfredo_A_Molina/Taijiuino_lwIP_stack_serial_zps9e0cc941.jpg)
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: greghol on Sep 12, 2013, 08:19 am
Missed out on this thread while it was active but read through it all. Nice work all.

What is the status on the demo code? I do see that the emac.h and emac.c files are in as of 1.5.3 now.

Tnx,
Greg
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Sep 13, 2013, 04:14 pm
Hello Greg,

Thank you for asking about the EMAC code. Here a brief dossier about its status:

EMAC demo sample code is running OK using Arduino IDE 1.5.2 and a third-party Due-based board, enabling it to respond to a ping command sent by a computer. See reply #67:
http://forum.arduino.cc/index.php?PHPSESSID=5i6p7elee9gv585u7626tb7mn7&topic=142908.60 (http://forum.arduino.cc/index.php?PHPSESSID=5i6p7elee9gv585u7626tb7mn7&topic=142908.60)

So far, I have a ported EMAC library (from AS6 ASF) with the Media Independent Interface (mii),  mini IP structure (mini_ip) and the phy driver (conf_eth) files. I also had to modify the emac files (.c, .h) that you mentioned, and the variant files (.c, .h) from the IDE152. Notice that IDEs 1.53 and 1.54 do not have the emac pin definition/configuration. The next step is to create the EMAC class and overload some functions under the Arduino style. Regards!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Markus_L811 on Sep 15, 2013, 06:05 pm

Hello Greg,

Thank you for asking about the EMAC code. Here a brief dossier about its status:

EMAC demo sample code is running OK using Arduino IDE 1.5.2 and a third-party Due-based board, enabling it to respond to a ping command sent by a computer. See reply #67:
http://forum.arduino.cc/index.php?PHPSESSID=5i6p7elee9gv585u7626tb7mn7&topic=142908.60 (http://forum.arduino.cc/index.php?PHPSESSID=5i6p7elee9gv585u7626tb7mn7&topic=142908.60)

So far, I have a ported EMAC library (from AS6 ASF) with the Media Independent Interface (mii),  mini IP structure (mini_ip) and the phy driver (conf_eth) files. I also had to modify the emac files (.c, .h) that you mentioned, and the variant files (.c, .h) from the IDE152. Notice that IDEs 1.53 and 1.54 do not have the emac pin definition/configuration. The next step is to create the EMAC class and overload some functions under the Arduino style. Regards!


Impressiv as usually what you did, cool stuff
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Dec 02, 2013, 11:19 pm
Hi Palliser and all the rest interested in utilising the EMAC built in to the SAM3X8E

Let me introduce the Duet:

(http://www.think3dprint3d.com/image/cache/data/Shiny%20product%20pictures/Think3DPrint3D_DUET_Arduino_DUE_Compatible_3DPrinter_Controller1-600x600.jpg)

Its a 3D Printer (or other stepper driven robot) controller board that uses the SAM3X8E, along with its onboard EMAC,  HSMCI SD 2.0 interface and other peripherals. Alot more info is available on this blog post:

http://blog.think3dprint3d.com/2013/12/Duet-Arduino-Due-compatible-3DPrinter-controller.html

It uses the KSZ8051RNL PHY, I wrote about this initial work back in post #72: (http://forum.arduino.cc/index.php?topic=142908.msg1201468#msg1201468). The firmware is linked from the blog and runs a web server to control the 3D Printer. Thanks for all the work by Pallister and all the other contributors to this forum  - it was useful to see the other implementations.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Dec 02, 2013, 11:39 pm
Nice-looking board.

______
Rob
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: TonyT3P3 on Dec 02, 2013, 11:43 pm
Cheers! your pin out diagrams feature on my wall art!
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: graynomad on Dec 03, 2013, 12:25 am
:), thanks, I do like that diagram.

_______
Rob
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Dec 03, 2013, 10:25 pm
Hi Tony,
I am very happy and surprised with your Duet. Also anxious to watch the video. It reassures me that every grain of sand distilled from the forum can inspire people like you. I take my hat off to you guys. Best regard! Palliser
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: ODwyerPW on Dec 04, 2013, 08:35 pm
That's just an incredible piece of work! Thanks for sharing.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: dlloyd on Jan 19, 2014, 07:10 pm
EDITED:

While investigating ways to interface (at high speed) two sam3x8e mcu's, I've discovered this thread. What fantastic work many have accomplished here!

When development of the Ethernet PHY Due driver resumes, I'm curious if it would be easy to implement a "direct connect mode" that couples 2 due compatibles together for diagnostic or communication purpose (no external PHY boards required - just a jumper cable).

Here is the link to the TI paper:
http://e2e.ti.com/cfs-file.ashx/__key/CommunityServer-Discussions-Components-Files/717/2480.Inter_2D00_DM6467-Communications-Using-Direct-GMII-Connections-E2E-.pdf (http://e2e.ti.com/cfs-file.ashx/__key/CommunityServer-Discussions-Components-Files/717/2480.Inter_2D00_DM6467-Communications-Using-Direct-GMII-Connections-E2E-.pdf)

Due compatible to Due compatible jumper cable connection (incomplete):
(http://www.testcor.ca/pdf/Sam3X%20Emac.JPG)

Also, I've recently found a similar driver for reference that might be of interest: "The internal Ethernet Controller consists of a fully integrated media access controller (MAC) and network physical (PHY) interface (Stellaris M3 family only). The Ethernet Controller conforms to IEEE 802.3 specifications and fully supports 10BASE-T and 100BASE-TX standards."

At the following link, scroll down and click the "Libraries" tab, then click "ETHERNET LIBRARY":
http://www.mikroe.com/mikroc/arm/ (http://www.mikroe.com/mikroc/arm/)

Regards - dlloyd

Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: An00bIS on Jul 30, 2014, 07:55 pm
Hi all,

First of all thank you very much for investing so much time in writing and testing this library!
I just wanted to ask, what is the status of your library? Are you still developing/testing? Have you already uploaded your library to github?
I am planning to use an ethernet plug with a digistump digix board (this is a due clone where the ports are available on the board)
I have read the whole thread and also the infos on the taijidue site. but the site links to this thread...

Thank you!
An00bIS
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jul 30, 2014, 09:50 pm
Hello An00bIS,

The EMAC library for Due remains very raw. You can download it with an sample sketch here:

https://github.com/elechouse/EMAC-DEMO/tree/master/EMAC (https://github.com/elechouse/EMAC-DEMO/tree/master/EMAC)

I tried to conform a work team about a year ago but this has not really been possible for a number of reasons. I also corroborated the library with a sample of a basic HTTP web server using lwIP TCP/IP stack (see reply#92) but that is not on github yet. Feel free to use the library 'as is' but again, it is raw and will work as a base for more developments. Regards,

p




 
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: An00bIS on Jul 31, 2014, 12:45 am
Hi Palliser

thank you for your quick reply! i will check it out!

thanks :)
An00bIS
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Kellermaaan on Sep 18, 2014, 01:29 pm
Hello everybody,

At the beginning, sorry for my bad english but i try my best...

And now i need some help. I have an adruino taijiuino and the DM9161 PHY and i want to use UDP. Can I use the existing libraries or do I have to write a new one???

Kellermaaan
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: the_sensor on Feb 17, 2015, 05:21 am
Hi all,

TAIJIUINO Due seems out-of-stock on the ElecHouse website.
It just says a new revision "R3 will come soon".

Furthermore, did anyone read this: ?
http://www.hwmakers.eu/arduino/arduino-due-the-missing-ethernet/

Any ideas if any new board Arduino due with ethernet phy might be arriving soon ?

Thanks,
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Feb 17, 2015, 09:29 pm
Hi all,

TAIJIUINO Due seems out-of-stock on the ElecHouse website.
It just says a new revision "R3 will come soon".

I'd recommend you to look at ebay. So far, Taijiuino and its Ethernet PHY module have been my best option.

p
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Kellermaaan on Mar 10, 2015, 04:13 pm
Hi all,

How do I get to die current time in milliseconds since power up?

Thanks Kellermaaan
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: rockwallaby on Mar 11, 2015, 02:06 am
Kellermaaan wrote:
Quote
How do I get to die current time in milliseconds since power up?
What on Earth has your question got to do with this post title 'Connecting an Ethernet PHY to Arduino Due'?

First, start your own thread, secondly state clearly your question, as when you write 'current time' specify the format, do you mean as a long or as human readable. New thread please.
____
Paul
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: nitrof on Feb 26, 2016, 11:37 am
Hi.

Is there been any developpement in de EMAC library. Is there will be any day ?

Nitrof.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jun 20, 2016, 03:29 pm
Hi.

Is there been any developpement in de EMAC library. Is there will be any day ?

Nitrof.
Hello nitrof,

As you probably know, Arduino Due was launched in 2012 with some features not supported by Arduino APIs like the CAN and EMAC peripherals.

Regarding CAN and EMAC, Atmel's ASF developed their libraries and examples for their SAM3X development/evaluation boards.

A couple of years ago, with the help of Atmel, I ported the CAN library but very raw. Collin from this forum, polished the library with extra examples. I could say that now, the CAN library is very decent but not official.

Similarly, I ported the EMAC library (also very raw) from Atmel's ASF but I was only able to make it run OK in a third-party board (Taijiuino by Elechouse) given that Due doesn't have its EMAC pins broken out.

Unlike the CAN communication, my EMAC ported library still waiting for someone to finish it. I could do it but I am busy nowadays.

If you look at my first post in this thread, you'll find the library with the example.

In reference to a future development on the part of the Arduino team, it is difficult to know. Regards,

-p
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: pjrc on Jun 21, 2016, 03:04 am
FWIW, I'm just now starting to look at native ethernet with Teensy.  Last week I created a PCB for the LAN8720A chip (http://www.microchip.com/wwwproducts/en/LAN8720A) and sent it to OSH Park.  I also just placed an order for the Elechouse DM9161 module.  So far I have not yet written even a single line of code... and I only have a small pile of parts which arrived from Digikey, but I'm still waiting for the bare PCB from OSH Park.

Eventually I hope to write a great ethernet library capable of full 100 Mbit/sec speed, but perhaps that's a distant pipe dream?
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: westfw on Jun 21, 2016, 11:12 am
Quote
I hope to write a great ethernet library capable of full 100 Mbit/sec speed,
Raw ethernet speed, or whole TCP/IP stack?
The MK20 Kinetis chips don't have ethernet MACs, do they?  It's pretty tough to push 100Mbps through an external interface...

Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: pjrc on Jun 21, 2016, 11:55 am
Of course with a TCP/IP stack, and probably Arduino API extensions for asynchronous network event notifications, and libraries of networking middleware built on top of those APIs.  What's the point of dreaming if you can't dream big?  ;)

Yeah, the K20 Kinetis series lacks ethernet macs, but the very similar K60 series chips have them.  You can probably guess where I'm heading....

Performance-wise, the K60 ethernet mac does have some really nice-looking features, like TCP checksum offload in hardware and automatic segmenting of large packets across multiple buffers.  Reports of people achieving the sustained 10 Mbyte/sec speeds with the MQX RTOS system have been posted occasionally, so at least there's some indication such performance can be achieved.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: nitrof on Jun 23, 2016, 11:11 am
HI Allz.

Thanks for the answers.


Quote
Eventually I hope to write a great ethernet library capable of full 100 Mbit/sec speed, but perhaps that's a distant pipe dream?
I hope that this day come soon ! :)

In the same way, from this forum tread, 've learn about the arduino DUET https://www.think3dprint3d.com/Duet (https://www.think3dprint3d.com/Duet)

This board is connected use KSZ8051RNLU chip and lWip stack. Is that could be a good idea as well ?

Regars Nitrof
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jun 23, 2016, 06:31 pm
HI Allz.

Thanks for the answers.


I hope that this day come soon ! :)

In the same way, from this forum tread, 've learn about the arduino DUET https://www.think3dprint3d.com/Duet (https://www.think3dprint3d.com/Duet)

This board is connected use KSZ8051RNLU chip and lWip stack. Is that could be a good idea as well ?

Regars Nitrof

The PHY with LwIP stack  has been already implemented by Atmel (now Microchip) in the SAM4E-EK. Here an application note:

http://www.atmel.com/Images/Atmel-42134-Use-of-Ethernet-on-SAM4E-EK_AT02971_Application-Note.pdf (http://www.atmel.com/Images/Atmel-42134-Use-of-Ethernet-on-SAM4E-EK_AT02971_Application-Note.pdf)

-p
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: pjrc on Jun 24, 2016, 12:14 am
Well sure, lots of semiconductor vendor eval boards not supported by Arduino have implemented LwIP, which isn't anything like the simplicity and ease of learning on Arduino.
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: Palliser on Jun 24, 2016, 02:43 am
Well sure, lots of semiconductor vendor eval boards not supported by Arduino have implemented LwIP, which isn't anything like the simplicity and ease of learning on Arduino.
I mentioned on purpose the lwip on SAM4-EK because it has identical EMAC controller as the one inside SAM3X (Due's core). Thinking on lwip as open source network stack, you could put it in two steps: one first using IP over Serial using the serial ports of the Due in order to be sure the porting (lwip configuration) is good. Second, move on the EMAC driver with whole Ethernet, thus validating the EMAC and PHY drivers and the lwip porting later. Indeed, I made this using Taijuino (Due clone) and external PHY module and I was able the run a basic HTTP web server example using lwIP TCP/IP stack in mode standalone. See my post #92 in my thread.

http://forum.arduino.cc/index.php?topic=142908.90 (http://forum.arduino.cc/index.php?topic=142908.90)

-p
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: pjrc on Jul 04, 2016, 02:02 am
Today I got the LAN8720 PHY chip working with a Kinetis K66.  So far, only very basic ARP & Ping working.  Here's the code (https://github.com/PaulStoffregen/k66_ethernet/blob/master/k66_ethernet.ino), if anyone's interested.

The Elechouse DM9161 board I ordered weeks ago arrived just hours after I got ping replies working with the LAN8720 on a custom board.   :smiley-confuse:

Still so much software work to do.....
Title: Re: Connecting an Ethernet PHY to Arduino Due
Post by: nitrof on Jul 05, 2016, 11:09 pm
I wish I could help but I'm to newbie :P But when it come good for road test, I will be please to buy a shield and try it.

talking about that, it will be good that the shield pins on taijiuno does'nt interfeare with standar pin header on arduino due for other shield compatibility.. just a sugestion.

And thank again for the hard work!