ENC28J60 on Netduino2Plus

martinayotte
Wed Jul 01, 2015 12:12 am
Hi !

If your seen the other thread, I was stuck with a hangs on readOp(ENC28J60_READ_CTRL_REG, ESTAT) during ENC28J60 initialize().
After spending hours, I’ve narrow the problem. First, I wasn’t sure about SPI init() since the ENC28J60 is hookup with several pins differences against normal SPI(1), but it was still not working. Opening again the Netduino2Plus schematic, I’ve got the light coming to me : the 25MHz oscillator is shared between STM32F405 and the ENC28J60, but not a direct connection, the STM32 provide the derivative Clock thru GPIO PA8 as and MCO1 alternate. So, I’ve struggled to have that init code added in rrcF2.c. Bingo ! The ENC28J60 is now having its clock !!! :)
So, the initialize() doesn’t hang any more on readOp(ENC28J60_READ_CTRL_REG, ESTAT) !!! And I’m now been able to ping my Netduino2Plus board ! ;)

@Roger, I will clean my code and send you a PR soon.


martinayotte
Wed Jul 01, 2015 9:10 pm
Some more success !
Since the Serasidis_EtherCard_STM library didn’t provide a TCPServer yet, I’ve decide to continue my work already started on the “arduino_uip” library by porting the changes done in Serasidis_EtherCard_STM/src/enc28j60.cpp file into the arduino_uip/utility/Enc28J60Network.cpp file that was having AVR direct register access to AVR SPI. After few hours, I’ve got the merge done and I have now a TcpServer example working on my Netduino2Plus !
Hourra !!! :D

Vassilis
Thu Jul 02, 2015 6:19 am
Well done martinayotte!

The Arduino_UIP (UIPEthernet) library is a 100% compatible with the standard arduino Ethernet library. So, that are all sketches that are written for arduino Ethernet, will work on your ported library.


martinayotte
Thu Jul 02, 2015 1:42 pm
Thanks !

At first, I started to merge your Ethernet_STM library into your Serasidis_EtherCard_STM library, but I’ve quickly figured out that was a tedious task.

So, I will do some clean up on Arduino_UIP codes and push it into my branch and send a PR to Roger soon.


martinayotte
Wed Jul 15, 2015 2:20 am
Since all basics components seems to works nicely on Netduino2Plus,
I’ve decided to post on Netduino forum (I’ve not log there since 2 years, I had to reset password :) ) to invite people to come on our stm32duino forum.
I just hoping that there won’t be question’s flood … :)

Valery
Mon Apr 18, 2016 4:38 pm
Hello!
Vassilis wrote:Well done martinayotte!

The Arduino_UIP (UIPEthernet) library is a 100% compatible with the standard arduino Ethernet library. So, that are all sketches that are written for arduino Ethernet, will work on your ported library.


martinayotte
Mon Apr 18, 2016 4:49 pm
From what I remember from last summer, after I’ve achieved it on F405, I’ve gave it a try with MapleMini and it was working.
But those experiment were done with the UIPEthernet examples, bot with the one from Serasidis_EtherCard_STM, although there might be some similarities.

Valery
Mon Apr 18, 2016 8:55 pm
I’ll try,
Thank you.

Quintessence
Wed May 11, 2016 10:46 am
Hey stm32duino community,

I’m new here and I got started with a blue Pill, which was really full of bugs at the beginning (locked chip, too long name of the FTDI board on OSX, at least I programmed it via a CH340 board…).
I installed the ported UIP Library on my Arduino 1.6.7 IDE and it was compiled and uploaded to the chip succesfully, other Test Sketches ran quite good (Blink and Serial Sketches).

I wanted to test the AdvancedChatServer Sketch, which did not work. I checked the wiring often (SPI Interface number one PinA4-7), checked it on the other SPI interface etc but it did not work…

I got just one hint, which maybe helps here: After bootup the Board tells you via Serial on what IP adress it is available. In my sketch it is: 192.168.0.6
So I had a look at the serial output of the Board after bootup and it said: Chat server address:100706496
So there is something wrong.

Does anyone have an idea what this can be?

@Martinayotte: You said, it worked on your MapleMini last year, what can be the difference here?

Thanks a lot for your comments and I’m sorry for this newbie questions! I think the UIP Lib is really important for the STM32duino, because it takes so much RAM of the Arduino UNO to run larger sketches than the example, so I think it is really worth to make it work on the BluePill ;)


martinayotte
Wed May 11, 2016 12:51 pm
Quintessence wrote:In my sketch it is: 192.168.0.6
So I had a look at the serial output of the Board after bootup and it said: Chat server address:100706496
So there is something wrong.

Quintessence
Wed May 11, 2016 1:10 pm
Thank you a lot for your help and the quick answer ! :)

The Serial print works well on the arduino board, it is the standard Example sketch from the UIPEthernet Library :


#include <UIPEthernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,6);

// telnet defaults to port 23
EthernetServer server(23);

EthernetClient clients[4];

void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());
}

void loop() {
// wait for a new client:
EthernetClient client = server.available();

if (client) {

boolean newClient = true;
for (byte i=0;i<4;i++) {
//check whether this client refers to the same socket as one of the existing instances:
if (clients[i]==client) {
newClient = false;
break;
}
}

if (newClient) {
//check which of the existing clients can be overridden:
for (byte i=0;i<4;i++) {
if (!clients[i] && clients[i]!=client) {
clients[i] = client;
// clead out the input buffer:
client.flush();
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
client.print("my IP: ");
client.println(Ethernet.localIP());
break;
}
}
}

if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to all other connected clients:
for (byte i=0;i<4;i++) {
if (clients[i] && clients[i]!=client) {
clients[i].write(thisChar);
}
}
// echo the bytes to the server as well:
Serial.write(thisChar);
}
}
for (byte i=0;i<4;i++) {
if (!(clients[i].connected())) {
// client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false;
clients[i].stop();
}
}
}


martinayotte
Wed May 11, 2016 2:46 pm
For the Serial.println(Ethernet.localIP());, I’m surprised that it is working fine on Arduino boards, because Ethernet.localIP() is returning an IPAddress, not a string. In fact, in STM32, I’ve added a method to be print friendly : so, Serial.println(Ethernet.localIP().toString()); should print it correctly.

If I remember, yes, I’ve simply copied the STM32F4/libraries/arduino_uip into STM32F1/libraries/arduino_uip, (or probably created a symbolic link).

I would need to setup my MapleMini and try the above sketch again to see how it is reacting on my side, but unfortunately, I’m currently lacking of the “time ingredient”, so it can take awhile…


Quintessence
Thu May 12, 2016 7:12 pm
martinayotte wrote:For the Serial.println(Ethernet.localIP());, I’m surprised that it is working fine on Arduino boards, because Ethernet.localIP() is returning an IPAddress, not a string. In fact, in STM32, I’ve added a method to be print friendly : so, Serial.println(Ethernet.localIP().toString()); should print it correctly.

martinayotte
Thu May 12, 2016 10:53 pm
Hi Quintessence,

For the IPAddress.toString(), it has been committed more than 2 months ago, so maybe your installation isn’t up-to-date.

https://github.com/rogerclarkmelbourne/ … cba714aa01

Of course, I wish to give it a try again, but I can’t commit when (“time is the missing ingredient”) … ;)


Quintessence
Sun May 15, 2016 10:59 am
Finally it worked !! :)

martinayotte wrote:
For the IPAddress.toString(), it has been committed more than 2 months ago, so maybe your installation isn’t up-to-date.


martinayotte
Sun May 15, 2016 1:11 pm
Good !
So, you can now enjoy the internet from the BluePill … ;)

cassyarduino
Tue Nov 08, 2016 1:04 pm
Hi all!

I working with leaflab ‘maple mini’ (STM32F103CBT6) and ENC28j60.
I compiled project with my modified UIPEthernet library with arduino IDE 1.6.9.
Original UIPEthernet writed by Norbert Truchsess.
You can download from https://github.com/ntruchsess/arduino_uip
You can download my modified version UIPEthernet from:http://www.zalaszam.hu/~cassy/devel/avr/UIPEthernet.zip
The wiring for ‘maple mini’ and ENC28j60:http://www.zalaszam.hu/~cassy/devel/ard … wiring.PNG

Best Regards!


stevestrong
Tue Nov 08, 2016 3:19 pm
@cassyarduino,
can you tell us what did you modify on the UIPEthernet lib?
Maybe is relevant for the original lib as well.

cassyarduino
Wed Nov 09, 2016 8:31 am
Hi All!

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.

Compililation tested: ATMEGA328P,ArduinoDue,Maple Mini,ESP8266.

Best Regards!


zoomx
Wed Nov 09, 2016 9:46 am
Well done!

I didn’t know this library, I know only the ethercard library but reading here
http://www.tweaking4all.com/hardware/ar … -ethernet/
where libraries are compared, it seem that UIPEthernet is better.


stevestrong
Wed Nov 09, 2016 9:49 am
I used to use this site (also on github) as information source before switching to W5500 (which is much faster and easier to handle).

danieleff
Wed Nov 09, 2016 10:34 am
zoomx wrote:Well done!

I didn’t know this library, I know only the ethercard library but reading here
http://www.tweaking4all.com/hardware/ar … -ethernet/
where libraries are compared, it seem that UIPEthernet is better.


cassyarduino
Wed Nov 09, 2016 11:12 am
Hi!

Right:
“Except Ethercard is active, while UIPEthernet is not (I do not know about forks).”

But:
– 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/

Best Regards


stevestrong
Wed Nov 09, 2016 12:47 pm
Well, looking at the examples, Ethercard supports a lot of features, including DHCP, TCP, and so on.

cassyarduino
Wed Nov 09, 2016 1:51 pm
The ethercard’s readme.md say:”Hardware: Non-AVR boards are NOT currently supported (101/Zero/Due) #211″

The UIPEthernet supports: DHCP,DNS,UDP,TCP,ARP,ICMP.

My modified UIPEthernet supported more MCUs:AVR arduinos, STM32F MCU-s, ESP8266 MCU.
I already tested (modified UIPEthernet) on arduino nano, and maple mini (STM32F103CBT),
i will wiring ESP8266 with ENC28j60, and i will test it. (You can compile UIPEthernet to ESP8266 now, but i not tested yet on this hardware.)


danieleff
Wed Nov 09, 2016 4:45 pm
cassyarduino wrote:Hi all!

I working with leaflab ‘maple mini’ (STM32F103CBT6) and ENC28j60.
I compiled project with my modified UIPEthernet library with arduino IDE 1.6.9.
Original UIPEthernet writed by Norbert Truchsess.
You can download from https://github.com/ntruchsess/arduino_uip
You can download my modified version UIPEthernet from:http://www.zalaszam.hu/~cassy/devel/avr/UIPEthernet.zip
The wiring for ‘maple mini’ and ENC28j60:http://www.zalaszam.hu/~cassy/devel/ard … wiring.PNG

Best Regards!


cassyarduino
Wed Nov 09, 2016 10:35 pm
danieleff wrote:

I was able to make the library work, but could you put somewhere more permanent and visible place like github, because buried in a forum thread is pretty hidden.

stevestrong
Thu Nov 10, 2016 1:24 pm
I would recommend to anyway fork the UIP repo, and work in your changes.

cassyarduino
Thu Nov 10, 2016 2:58 pm
stevestrong wrote:I would recommend to anyway fork the UIP repo, and work in your changes.

cassyarduino
Thu Nov 24, 2016 1:21 pm
cassyarduino wrote:The ethercard’s readme.md say:”Hardware: Non-AVR boards are NOT currently supported (101/Zero/Due) #211″

The UIPEthernet supports: DHCP,DNS,UDP,TCP,ARP,ICMP.

My modified UIPEthernet supported more MCUs:AVR arduinos, STM32F MCU-s, ESP8266 MCU.
I already tested (modified UIPEthernet) on arduino nano, and maple mini (STM32F103CBT),
i will wiring ESP8266 with ENC28j60, and i will test it. (You can compile UIPEthernet to ESP8266 now, but i not tested yet on this hardware.)


danieleff
Thu Nov 24, 2016 1:30 pm
cassyarduino wrote:cassyarduino wrote:The ethercard’s readme.md say:”Hardware: Non-AVR boards are NOT currently supported (101/Zero/Due) #211″

The UIPEthernet supports: DHCP,DNS,UDP,TCP,ARP,ICMP.

My modified UIPEthernet supported more MCUs:AVR arduinos, STM32F MCU-s, ESP8266 MCU.
I already tested (modified UIPEthernet) on arduino nano, and maple mini (STM32F103CBT),
i will wiring ESP8266 with ENC28j60, and i will test it. (You can compile UIPEthernet to ESP8266 now, but i not tested yet on this hardware.)


cassyarduino
Thu Nov 24, 2016 3:57 pm
danieleff wrote:

Use a different pin on ESP8266 for CS, not GPIO15. Generally any pin can be used as cable select.

zoomx
Sun Dec 04, 2016 6:45 pm
After installing the UIPEthernet library I get this error on Arduino IDE
Invalid version found: 1.04

cassyarduino
Mon Dec 05, 2016 2:23 pm
ESP8266 wiring with ENC28j60 completed.
I uploaded to:https://github.com/UIPEthernet/UIPEther … wiring.PNG

The code doesn’t full tested yet.
I will correct this “version bug” also.
Coming soon I commit the code changes.


cassyarduino
Thu Dec 08, 2016 2:51 pm
Hi All!

I uploaded modified UIPEthernet library to https://github.com/UIPEthernet/UIPEthernet
I modified the following:
– Set the version to 1.1.0
(This version tested on ESP8266 too. Working properly. Without watchdog resets.)
– Correct ESP8266 exception(28).
– Add watchdog reset calls in functions for stable running on ESP8266.
– Add geterevid function to get ENC28j60 chip erevid (revision information).
– Change linkStatus to static for outside call.
– Add functions bypass, if can’t communicate with ethernet device.
– Add SPI bus instabil communication detection.
– Change debuging/logging. Remove individual debuging. Add global and scalable debuging feature.
You can setup debuging/logging level in utility/logging.h
You can use this header file in Your scetch too.
Add “LogObject” define for serial logging/debuging with board specific default setting.

Best Regards


zoomx
Fri Dec 09, 2016 9:18 am
I hope that I wil find time to check it!

Thanks!


cassyarduino
Thu Dec 15, 2016 3:40 pm
Hi All!

I added support to MBED/SMeshStudio IDE.
Compiled to STM32F103RB (Nucleo).
You can download from:https://github.com/UIPEthernet/UIPEthernet

Best Regards


anass
Thu Mar 02, 2017 9:04 am
hi everyone
sorry for bothring you all. i’m trying to connect my STM32L152 to a network using enc28j60, i can get the MAC address, but can’t get the IP address.
i used the ARP_req but i didn’t see it in Wireshark. i’m using the EtherSield library. pleas help me

cassyarduino
Thu Mar 02, 2017 10:05 am
Hi!

Can You try this library: https://github.com/UIPEthernet/UIPEthernet ?

Best Regards

anass wrote:hi everyone
sorry for bothring you all. i’m trying to connect my STM32L152 to a network using enc28j60, i can get the MAC address, but can’t get the IP address.
i used the ARP_req but i didn’t see it in Wireshark. i’m using the EtherSield library. pleas help me


anass
Thu Mar 02, 2017 10:46 am
[quote=”cassyarduino”]Hi!

Can You try this library: https://github.com/UIPEthernet/UIPEthernet ?

Best Regards

hi
thanks for your quick reply
i’m using a library i think it’s completed. i got my MAC address, but i don’t know how to use the library to get my ip adress.
thanks


Leave a Reply

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