JAndrassy / WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
GNU Lesser General Public License v2.1
271 stars 44 forks source link

Not working with SD on STM32F4 BLACKPILL #65

Closed bobemoe closed 2 years ago

bobemoe commented 2 years ago

As soon as I add #include <WiFiEspAT.h> to my project, not even create a client or call any functions, the SD card starts failing to initialize.

To reproduce, I can take one of the SD lib examples, compile and confirm the SD is working. Then add #include <WiFiEspAT.h>, compile and then see SD fails to initialize.

I'm compiling using arduino-cli and the stm32duino core for the STM32F4 BlackPill. WiFiEspAT 1.3.1

Setup

arduino-cli config add board_manager.additional_urls https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
arduino-cli core update-index
arduino-cli core install STMicroelectronics:stm32
arduino-cli lib install WiFiEspAT

Compile

arduino-cli compile -e -b STMicroelectronics:stm32:GenF4:pnum=BLACKPILL_F411CE,rtlib=nanofps,xserial=none,usb=CDCgen

Even the SDWebServer example in this repo fails for me. If I comment out all the WiFi code and the include, then SD starts to work. So I guess its my environment!?

Can anyone confirm this working on STM32F4. I'm using the AdaFruit SD (and TFT) module, with core SD libs.

Tomorrow I will try installing the Arduino IDE and compiling there. But for now, any ideas?

bobemoe commented 2 years ago

A couple of things to note:

  1. The WiFiEspAT actually works fine. Even in my big project with many other libs and extensive code, I'm able to communicate with the ESP8266, connect to WiFi and communicate to servers etc. It's just SD functionality that is lost.

  2. When I remove #include <WiFiEspAT.h> and return the sketch to a working code base, upon compiling and uploading it isn't actually working!! I have to pass --clean to the arduino-cli compile command to bypass the cache. What is being cached I wonder?

JAndrassy commented 2 years ago

I tested the speed of the WiFiEspAT library with the SDWebServer sketch on many platforms including the stm32duino with a Blue Pill. One problem on the Blue Pill was the combined power consumption of SD and the esp8266.

bobemoe commented 2 years ago

Same issue in the IDE, but things are getting even weirder....

I now have a working binary of the SDWebServer example, but to compile it, it must be initially compiled without the WiFiEspAT include and related code, which compiles and shows the SD initialize ok. THEN add the WiFi code back to it, compile and everything works. I can make changes, compile, still working, nice! UNTIL I close that IDE window, reopen it exactly the same code, compile and the SD does not initialize. Even when I strip out the WiFi code again it still fails, UNTIL I close and reopen that window, then its working again!! WTF?

I'm guessing closing and reopening the IDE window is the same as providing --clean to the cli.

So its seems to be fairly consistent, it is the state of the first compile that determines successive results:

I have saved out the working and not working binaries, compiled from the exact same code but a different IDE session, they are slightly different size. I've done a hexdiff but it doesn't mean much to me!

49580 Oct 24 12:27 SDWebServer.FAIL.bin 49568 Oct 24 12:25 SDWebServer.WORKING.bin

Puzzled :/ Feels like its some sort of compiler caching issue but what is causing the problem initially I'm not sure. Maybe multiple things at play here.

@jandrassy thanks for the suggestion, the TFT is also running off 3.3v and I do see it flicker suggesting the PSU is struggling. I'm expecting this to be an issue soon, but for the sake of testing I'm seeing the scenario above even with the TFT and ESP8266 unplugged, that SD will or wont initialize depending on the compile sequence.

bobemoe commented 2 years ago

I tested the speed of the WiFiEspAT library with the SDWebServer sketch on many platforms including the stm32duino with a Blue Pill. -- @jandrassy

What was the max transfer speed you found during these tests? Do you have results online somewhere?

JAndrassy commented 2 years ago

I tested the speed of the WiFiEspAT library with the SDWebServer sketch on many platforms including the stm32duino with a Blue Pill. -- @jandrassy

What was the max transfer speed you found during these tests? Do you have results online somewhere?

500000 baud on Mega hw Serial