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

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.
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.
I’ve decided to post on Netduino forum (I’ve not log there since 2 years, I had to reset password

I just hoping that there won’t be question’s flood …

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.
But those experiment were done with the UIPEthernet examples, bot with the one from Serasidis_EtherCard_STM, although there might be some similarities.
Thank you.
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
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.

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();
}
}
}
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…
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”) …

martinayotte wrote:
For the IPAddress.toString(), it has been committed more than 2 months ago, so maybe your installation isn’t up-to-date.
So, you can now enjoy the internet from the BluePill …

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!
can you tell us what did you modify on the UIPEthernet lib?
Maybe is relevant for the original lib as well.
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!
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.
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.
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
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.)
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!
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.
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.)
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.)
Use a different pin on ESP8266 for CS, not GPIO15. Generally any pin can be used as cable select.
Invalid version found: 1.04
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.
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
Thanks!
I added support to MBED/SMeshStudio IDE.
Compiled to STM32F103RB (Nucleo).
You can download from:https://github.com/UIPEthernet/UIPEthernet
Best Regards
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
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
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