Is there any Ethernet Library working on STM32F4 Discovery (F407) board?

stmfunk
Mon Dec 12, 2016 2:43 pm
Hi,

All the Ethernet libraries (UIPEthernet, Ethernet_STM, arduino_uip, Serasidis_EtherCard_STM) can be compiled with the STM32F103.
But none of them compiles with the F4 Discovery (F407).

When i saw “arduino_uip” library in the STM32F4 library folder, i thought that i could use it with the F4 board. But unfortunately it did not compile. Upon my research on the forum, i discovered that it was included in the library only for Netduino. Is this correct?

I definitely need Ethernet on the F4 Discovery, but it looks like there is no available library yet. Is there any chance to get Ethernet on this board?
Are there any modifications needed to do in the library to get it work? If so where can i find information for that ?


martinayotte
Mon Dec 12, 2016 2:47 pm
Yes, the arduino_uip in the STM32F4 folder was added awhile ago for the Netduino2Plus, but it should work for any F4.
What are the compile errors you’ve got ? (maybe some other changes make such errors come to surface)

stmfunk
Mon Dec 12, 2016 2:52 pm
Thank you Martin for the quick reply.
Last night i have been going trough nearly all your posts regarding Ethernet :) Maybe i missed something…
I also tried your repo. But still no luck.
please hang on, i will send the error messages in a couple of minutes..

stmfunk
Mon Dec 12, 2016 3:02 pm
Running latest Arduino_STM32-master on Arduino IDE 1.6.13

You mentioned SPI error a lot of ime. I get the same SPI class errors but no clue how to solve it.

I also replaced the SPI library from F1 to F4 but still no luck.

Maybe you already found the solution for that which i missed in this forum…

Arduino: 1.6.13 (Windows 7), Board: "STM32 Discovery F407"

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility\Enc28J60Network.cpp:40:8: error: 'SPIClass' does not name a type

extern SPIClass SPI;

^

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility\Enc28J60Network.cpp: In static member function 'static void Enc28J60Network::init(uint8_t*)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility\Enc28J60Network.cpp:72:7: error: 'class HardwareSPI' has no member named 'setBitOrder'

SPI.setBitOrder(MSBFIRST);

^

Using library arduino_uip at version 1.04 in folder: C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip
exit status 1
Error compiling for board STM32 Discovery F407.


stevestrong
Tue Dec 13, 2016 12:01 am
silly question, but have you included <SPI.h>?

stmfunk
Tue Dec 13, 2016 12:31 am
Btw, i am trying to compile UdpClient.ino from the included arduino_uip library in the STM32F4/libraries folder.
(did not edit anything ; except included now the SPI.h in the header.)

Unforunately when i include SPI.h i get the same error posted above.


stevestrong
Tue Dec 13, 2016 8:30 am
And what if you remove the line:
extern SPIClass SPI;

stmfunk
Tue Dec 13, 2016 12:17 pm
When i remove extern SPIClass SPI;

stevestrong
Tue Dec 13, 2016 1:02 pm
Do you use SPI.begin(…)?
Can you show us your sketch?

stmfunk
Tue Dec 13, 2016 2:01 pm
As i mentioned before, the sketch what i am trying to compile is not a custom sketch. It is already in the latest Arduino_STM32 repo :

/Arduino_STM32-master/STM32F4/libraries/arduino_uip/examples/UdpClient/UdpClient.ino

I simply can not understand that it is in the repo but it is not compiling.

I did a fresh Arduino IDE 1.6.12 & SAM 1.6.9 install with no other libraries anywhere installed. Just the Arduino_STM32….


stevestrong
Tue Dec 13, 2016 3:17 pm
As far as I can see, @martinayotte has committed the lib to the repo, so he should be able to support you.
Beside on that, it would be helpful to activate verbose output for compiling to see whether some other warnings/errors are affecting this, too.
So please post here all the warnings, if any, during compilation.

stmfunk
Tue Dec 13, 2016 3:41 pm
Thanks for your time & effort Steve.
The verbose output is the same.

I was hoping that Martin could lead me to some directions but i guess he is busy.


martinayotte
Tue Dec 13, 2016 4:55 pm
Yes, unfortunately I’m really busy these days.

In short, I’ve never used the arduino_uip examples by themselves, (maybe they need to be tweaked), I was using my own sketch, which is including SPI.h before arduino_uip.h.

For the second error, “error: ‘class HardwareSPI’ has no member named ‘setBitOrder'”, it seems that the wrong SPI is included, because it should not be HardwareSPI class, in STM32F5/libraries/SPI/src/SPI.h the setBitOrder() method is defined there.
Maybe the reason is that you’ve explicitly included HardwareSPI.h, but I think that file is a LeafLab legacy, since SPI class take care of using hardware anyway by including <libmaple/spi.h>


stmfunk
Tue Dec 13, 2016 10:18 pm
Thank you Martin for taking time.

For testing, i replaced the SPI.cpp & SPI.h content which has the ‘setbitorder’ with the HardwareSPI.cpp & HardwareSPI.h cotents.
It does not give SPI errors but alot of DMA converting errors. :(

So how did you overcome the LeafLab legacy to prevent access to the HardwareSPI?

It would be great if you could share your sketch for understanding how things work.


martinayotte
Wed Dec 14, 2016 3:56 pm
Why did you replaced the original SPI.cpp/SPI.h ?
Those are the ones that already take care of talking with the real hardware.
(The HardwareSPI.cpp/HardwareSPI.h are left over of legacy code, and probably could be deleted completely)

stmfunk
Wed Dec 14, 2016 4:04 pm
Sorry typing error.

I did not replace the content of original SPI.cpp & SPI.h. I did replace the content of the HardwareSPI ones with the original SPI ones. Just for testing, to see if it compiles, because if it looks to the legacy HardwareSPI files while compiling, i thought to put the original SPI content into the HardwareSPI content would work and maybe somehow can recognise the setbitorder and extern SPI class.
As i said, by replacing, it bypasses the extern SPI class errors and setbitorder errors but can not convert to DMA.


martinayotte
Wed Dec 14, 2016 7:07 pm
I’m still confused : why did you need to replace the content of HardwareSPI ?
You don’t need those, simply include SPI.h directly.
For the DMA stuff, if I remember, I’ve simply commented out.
It is there simply because F4 SPI is some kind of copy of the F1, and I didn’t ported it.
Maybe you can do the same since the arduino_uip is not using DMA anyway.

stmfunk
Mon Dec 19, 2016 11:06 pm
hi Martin thanks for the advices.

I commented the DMA stuff out.

Now it compiles but with the following errors. ( Also , I can not Ping the F4 yet)

libraries\arduino_uip\utility\Enc28J60Network.cpp.o: In function `Enc28J60Network::readOp(unsigned char, unsigned char)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:476: warning: undefined reference to `SPI'

libraries\arduino_uip\utility\Enc28J60Network.cpp.o: In function `Enc28J60Network::writeOp(unsigned char, unsigned char, unsigned char)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:485: warning: undefined reference to `SPI'

libraries\arduino_uip\utility\Enc28J60Network.cpp.o: In function `Enc28J60Network::readBuffer(unsigned short, unsigned char*)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:497: warning: undefined reference to `SPI'

libraries\arduino_uip\utility\Enc28J60Network.cpp.o: In function `Enc28J60Network::writeBuffer(unsigned short, unsigned char*)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:509: warning: undefined reference to `SPI'

libraries\arduino_uip\utility\Enc28J60Network.cpp.o: In function `Enc28J60Network::readByte(unsigned short)':

C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:383: warning: undefined reference to `SPI'

libraries\arduino_uip\utility\Enc28J60Network.cpp.o:C:\Users\sly-VM\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\arduino_uip\utility/Enc28J60Network.cpp:392: warning: more undefined references to `SPI' follow


martinayotte
Tue Dec 20, 2016 5:59 pm
Since arduino_uip can be used with any SPI, the library is referencing the port as “extern SPIClass SPI;” in arduino_uip/utility/Enc28J60Network.cpp.
So, you have to instantiate it yourself in your main sketch as “SPIClass SPI(1);”, where 1 is the port number.

Leave a Reply

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