SD-Card FileSystem on Nucleo L476RG (mbed)

Hello,

I’m totaly stuck, spend the hole day trying to use a SD-Card on my STM32F4. The Hello world example on ARM-mbed works. So no Hardware Problem.

This works on the mbed web compiler

But when I try to compile it on platformIO:

Compiling .pioenvs\nucleo_l476rg\lib\filesystem\FileSystem.o
Compiling .pioenvs\nucleo_l476rg\lib\filesystem\bd\HeapBlockDevice.o
Compiling .pioenvs\nucleo_l476rg\lib\filesystem\bd\MBRBlockDevice.o
Compiling .pioenvs\nucleo_l476rg\lib\filesystem\bd\ProfilingBlockDevice.o
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp: In instantiation of 'class Managed<mbed::File>':
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp:139:19:   required from here
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp:128:7: error: invalid use of incomplete type 'class mbed::File'
class Managed : public F {
^~~~~~~
In file included from C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp:18:0:
C:\Users\cmeinert\.platformio\packages\framework-mbed\features/filesystem/FileSystem.h:39:7: note: forward declaration of 'class mbed::File'
class File;
^~~~
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp: In member function 'virtual int mbed::FileSystem::open(mbed::FileHandle**, const char
*, int)':
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp:139:19: error: cannot convert 'Managed<mbed::File>*' to 'mbed::File*' in initializatio
n
File *f = new Managed<File>;
^~~~~~~~~~~~~
C:\Users\cmeinert\.platformio\packages\framework-mbed\features\filesystem\FileSystem.cpp:140:16: error: invalid use of incomplete type 'class mbed::File'
int err = f->open(this, path, flags);
^~

I already tried this:

build_flags = -DPIO_FRAMEWORK_MBED_FILESYSTEM_PRESENT

But the the compiler do not find mbed-filesystem …

Sorry, I’m more the hardware guy and not compiler issues

Every Help appreciated!

Chris

Hi @HarpieC! Can you upload your project as a zip archive somewhere?

Thank you for your help, here it is…

https://www.dropbox.com/s/c4g3gyiy0x2o64b/SD-Card.zip?dl=0

Hope you can download it. It is basically a copy of the Hello World Example form the mbed cookbook. Only chaged the PINs to match with SPI3 on the Nucleo Board.

Where did you get that SDFileSystem library? Looks like it’s a bit outdated because FATFileSystem is already a part of the mbed framework. Anyway, could you please try to remove the FATFileSystem folder from the SDFileSystem library and uncomment build_flags = -DPIO_FRAMEWORK_MBED_FILESYSTEM_PRESENT line in your platformio.ini and try again?

Hello,
thank you for your help … when I removed the files the hello work compiles (not tested, because I’m currently traveling and do not have access to my development board.

But when I use the SDFileSystem lib in my main project (with many other libraries) with the build flag I get two errors:

in file mbed.h “filesystem/FileSystem.h” not found. I fond it under Features. So I copied the complete folder one level down to Framework_mbed

Then in file FileSystem.h it can’t find #include “BlockDevice.h” so I changed this line to #include “filesystem/bd/BlockDevice.h”

Now It compiles, Yeah! , but not tested … I know that this is a crude hack but that is everything I can do. Can only do real tests on the board over the weekend.

The reason perhaps is that I use a TFT Display Lib which uses the File System Library to for loading bitmaps (#include “SPI_TFT_ILI9341.h”)

Thank you for your help so far.

Regards Christian

Nope … not working.

Can’t access the SD-Card even when its compiles. So moving the FileSystem Folder and so on do not work!
On my main Project the TFT is not worrking too. When I changed everything back to normal TFT is working again.

So lost again.