ENC28J60 Ethernet library is ported (Completed !)

Vassilis
Mon May 25, 2015 2:28 pm
I have ported the basic functions of EtherCard Arduino library to STM32F103 MCU.

-= EDIT =-
The new library can be found on github

https://github.com/Serasidis/STM32duino … erCard_STM

Roger, if you want you can add it to your repository.


Vassilis
Mon May 25, 2015 7:56 pm
I have tested successfully on STM32F103 the following EtherCard examples:

– backSoon
– getStatic
– multiPacket
– noipClient
– rbbb_server
– stashTest
– webClient
– xively


RogerClark
Wed May 27, 2015 7:22 am
OK.
Let me know when the new lib is in your repo and I can pull it

Thanks

Roger


Vassilis
Thu May 28, 2015 11:15 am
The EtherCard_STM library can be found on github (See the first post)

https://github.com/Serasidis/STM32duino … erCard_STM


RogerClark
Thu May 28, 2015 11:40 am
Vasillis,

Can you copy those files to your Fork of my repo and do a “pull request”

Its getting too late to “pull” today (for me), but I will do it first thing tomorrow.

Thanks

Roger


Vassilis
Thu May 28, 2015 11:45 am
RogerClark wrote:Vasillis,

Can you copy those files to your Fork of my repo and do a “pull request”

Its getting too late to “pull” today (for me), but I will do it first thing tomorrow.

Thanks

Roger


Vassilis
Thu May 28, 2015 1:55 pm
@Roger: After a lot of hours, finally I managed to upload and “pull request” the library to Github.

The Github is very powerful tool but at the same time it’s very complicated.


martinayotte
Thu May 28, 2015 2:10 pm
Hi Vassilis,
In the list of examples, I don’t see any servers, such as TCPServer. Do you think we can get some ?

Vassilis
Thu May 28, 2015 2:24 pm
martinayotte wrote:Hi Vassilis,
In the list of examples, I don’t see any servers, such as TCPServer. Do you think we can get some ?

martinayotte
Thu May 28, 2015 3:05 pm
Vassilis wrote:If you mean Telnet Server … there is not example code for that.

RogerClark
Thu May 28, 2015 10:07 pm
How can you have a telnet server?

Do you mean it would link Serial over TCP ?


RogerClark
Thu May 28, 2015 10:09 pm
Vasillis

Yes. Git is complicated

I sometimes get my local Git very confused and have to delete it and get a new copy from the server ;-)


martinayotte
Thu May 28, 2015 10:27 pm
RogerClark wrote:How can you have a telnet server?

Do you mean it would link Serial over TCP ?


Vassilis
Fri May 29, 2015 7:02 am
RogerClark wrote:How can you have a telnet server?

Do you mean it would link Serial over TCP ?


hackstage
Fri May 29, 2015 12:35 pm
NICE!!! Thanks alot! :)

martinayotte
Tue Jun 23, 2015 9:42 pm
I’ve started to look into the ENC28J60 library and I’m trying to make it works under Netduino2Plus.
The wiring of Netduino2Plus is a bit different :

ENC_SCK = PA5
ENC_MOSI = PA7
ENC_MISO = PB4
ENC_CS = PC8

I change those accordingly, but in the ENC28J60::begin(), it is hanging in infinite loop writePhy(PHCON2, PHCON2_HDLDIS), which is in fact the loop with no timeout handling in wrtiePhy() is while (readRegByte(MISTAT) & MISTAT_BUSY);

since I don’t know much about ENC28J60, other than having used it on Arduino, I don’t know what I should do.
Probably, since I have a seperate ENC28J60 module, I can try to connect it to my MapleMini and figure out the differences in bytes received.

Any other clues ?


stuartw
Tue Jun 23, 2015 11:16 pm
Its probably not the most helpful suggestion, but doing SPI and I2C interfacing I find an external logic analyser to be GOLD.

http://www.aliexpress.com/item/USB-24M- … 88263.html

this one gives a bit more info:
http://www.aliexpress.com/item/USB-24M- … 54825.html

One of these, with the software that does decode of the serial protocols for you, so you can compare what is actually on the wire with
what you expect, etc just makes life SO much easier. There are a whole lot of options at different prices but these are so cheap they dont
have to save you much time to be useful.

NOTE: These are clones of better devices, so I will leave the opinions of if using cloned hardware is ok to the individual.
If you do want the real deal then: https://www.saleae.com/ these guys are great.


martinayotte
Wed Jun 24, 2015 12:10 am
Hi Stuartw,

I have already 2 logic analysers, 1 is like the link your provided,a Saleae clone, and 1 is a FX2 Cypress board from LC-Soft.
I’m using sigrok/pulseview with them on Linux.
It was really helpful recently to debug SPI in MapleMini, and also on ESP8266, even those past days.

But for Netduino2Plus, with all hardware embedded on a 4 layers PCB, it is a bit more difficult, unless I solder thiny wires directly on ENC28J60.
So, I think my only way to debug is thru software and compared it with a working setup, maybe an external ENC28J60 module hookup on an external SPI where I can hook also one of those logic-capture board more easily.

BTW, on a side note, I was forgetting another GPIO, ENC_POWER that allows to turn on the VCC of the ENC28J60. I’ve added it, but now it is hanging even earlier, during readOp(ENC28J60_READ_CTRL_REG, ESTAT) … :(


stuartw
Thu Jun 25, 2015 3:46 am
Stupid questions I know, but have you tried scoping or monitoring the MOSI/MISO, CS, etc pins to make sure data really is flowing? slew
rates look ok, etc?

I find sewing machine needles make nice fine probes for smaller SMD work, as an accupuncture needles if you need longer ones.
more difficult if you need to monitor several at the same time.

I often keep a ‘check code’ routing that does the minimum needed to get a chip ID or similar from the device, and which can run looped
which makes checking the basic bus interface a lot easier.

I know its all the basics, but the number of times I catch myself missing something simple.


martinayotte
Fri Jun 26, 2015 2:43 am
I’ve put aside my trials on Netduino2Plus and have hook up an ENC28J60 on another MapleMini. I’ve got testDHCP example running from Vassilis’s library. But I wish to get it further with a TCPServer (especially a Telnet Server that will let me have a shell to do miracles within :) ).
Since Vassilias’s library doesn’t have any TCPServer yet, I’ve look at the “arduino_uip” library that I’ve play with about 10 months ago on ATM328, at that time, it was working nicely. I’ve try to merge enc28j60.cpp from Vassilias’s library into Enc28J60Network.cpp of the “arduino_uip” library. I’ve got some success, I’ve been able to have DHCP there too. Although a Telnet client can succeed getting a connection to port 23, the MapleMini manage it partially : the server.available() always responding False. I’ve enabled that PACKET_DEBUG, I see them coming in (I’ve didn’t look their contents), even “ping” is working, but the arduino loop() where server.available() is located is simply looping.
I will dig more … :(

stuartw
Fri Jun 26, 2015 5:02 am
Probably we are stretching this thread a LOT way from its starting point, but:

By a telnet server, do you mean a custom server on tcp, or do you mean a shell?
If you are looking for a shell, then wont you be wanting something like busybox? thats not a small lump.

If you just want custom commands over TCP, something like:
http://blog.bouni.de/blog/2012/06/25/a- … et-server/
Is quite simply, however that looks like it is W5100 (ethernet lib) based.. which I admit is my personal perference
anyway.

Personally I do much more UDP, but as you say, having TCP servers can be used for a bunch of good purposes.


martinayotte
Fri Jun 26, 2015 3:07 pm
Hi stuartw,

Yes, that is exactly what I wish to have. (no, busybox needed, simply my own commands, a mini-shell thru IP instead of Serial)
Unfortunately, the Server and Client classes are not there yet, so that’s why I was trying to merge it with “arduino_uip”.
I have W5100 too, I will look at it later, but since my end goal is to port that to Netduino2Plus equipped with an ENC28J60, I prefer continuing in the current path. I will dig a bit more in finding how packets are not parsed properly in the upper level of Server.available(), etc.


martinayotte
Wed Jul 01, 2015 12:31 am
Hi !
I’ve finally got the isuue with readOp(ENC28J60_READ_CTRL_REG, ESTAT) fixed :

viewtopic.php?f=39&t=388

Now, I’m getting back on my main goal, a TCPServer …

Telnet server/client examples are in my future plans.

Vassilis ? Did you got chance to look about that part ? Maybe I can help there too. Is it simple to merge socket.* files from the Ethernet_STM into Serasidis_EtherCard_STM libs ?


cassyarduino
Thu Nov 17, 2016 2:29 pm
Hi All!

You can use a alternative library (UIPEthernet) for ENC28j60.

– The UIPEthernet library uses the same API as the official Arduino Ethernet (compatible with WizNet W5100 ethernet library.).
In code only must change #include <Ethernet.h> to #include <UIPEthernet.h>.
– The UIPEthernet full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack.
http://www.homautomation.org/2014/10/27 … r-arduino/

Original UIPEthernet library is written by Norbert Truchsess <[email protected]>
You can access on github:https://github.com/ntruchsess/arduino_uip

I modified the code:
– Replaced import to include, because gcc say ‘import is deprecated’.
– I merged martinayotte’s modification (Correct s_dhcp ~40K more memory usage with STM32F MCU-s.)
– Add support for STM32F, and ESP8266 MCU-s.
– Moved htons,ntohs,htonl,ntohl definitions to uip.h.
– Correct infinite loops.

My modified UIPEthernet supported more MCUs:AVR arduinos, STM32F MCU-s, ESP8266 MCU.
Compililation tested: ATMEGA328P,ArduinoDue,Maple Mini,ESP8266.

I already tested (modified UIPEthernet) on arduino nano, and maple mini (STM32F103CBT).

You can download my modified UIPEthernet repo from github:https://github.com/UIPEthernet/UIPEthernet

Best Regards!


nikosx
Fri Aug 31, 2018 4:10 pm
Hi.

Managed to port & test both Vasillis & cassyarduino Libs in an F091 nucleo board… They both run OK !!!

Well done and thanks !


electrocoder
Fri Dec 07, 2018 10:38 pm
I’ve also tried ping codes at STM32F103VB. I set the CS pin to PA4. ether.begin (sizeof Ethernet :: buffer, mymac, cs). Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *