Connecting an Ethernet PHY to Arduino Due

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.

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.

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.

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.

You may consider TaijiDUE on which The ethernet terminal was supplied.

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!

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

Frenki_:
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.

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.

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

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.

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.

Today I have ordered some DM9161 from ebay so I'll be able to contribute to the progress on arduino due ethernet port. :wink:

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)

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.

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

Hi all,

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

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 !

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.

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.

Datasheets:
http://sva.ti.com/assets/en/other/phyter_prodbrief.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...



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.

Tnx :slight_smile:

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...

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?

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.