Use spiffs library with own SPI flash routines?

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Use spiffs library with own SPI flash routines?

Postby vonnieda » Tue Jan 09, 2018 10:58 pm

Hi all,

My project has an external flash chip for which I've written read, write, and erase functions. I'd now like to lay spiffs on top of that. Unfortunately, it looks like the spiffs library bundled with esp-idf does not expose spiffs.h publicly, so I can't call the underlying functions. I copied spiffs.h into my project, and that gets me further, but then I run into locking issues since the included spiffs library defines a couple locking functions in SPIFFS_LOCK and SPIFFS_UNLOCK.

So my question is: Is there a straightforward method of using this library without the ESP specific stuff? And if not, is there a good way for me to include my own copy of it that won't clash with the namespace of the existing one? I have no need for the ESP specific spiffs stuff.

Thanks,
Jason

wobblyboots
Posts: 19
Joined: Mon Sep 18, 2017 4:48 pm

Re: Use spiffs library with own SPI flash routines?

Postby wobblyboots » Wed Jan 10, 2018 12:26 am

Check out the library on github: https://github.com/pellepl/spiffs

kind regards
Ian.

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Use spiffs library with own SPI flash routines?

Postby vonnieda » Wed Jan 10, 2018 2:23 am

wobblyboots wrote:Check out the library on github: https://github.com/pellepl/spiffs

kind regards
Ian.
Thanks for your response Ian. I have indeed attempted to use the Github library directly, by creating a component for it, but when I try to include "spiffs.h" I get conflicts with the one that comes with esp-idf. That's the reason for the second part of my question regarding a clean way to bring it in myself without conflicting with the built in one.

Thanks,
Jason

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Use spiffs library with own SPI flash routines?

Postby ESP_igrr » Wed Jan 10, 2018 3:08 am

Hi Jason,

I think you can use one feature of ESP-IDF build system, namely that you can override one of ESP-IDF components by creating a component with the same name in your project: http://esp-idf.readthedocs.io/en/latest ... -same-name.
This way, if you create 'spiffs' component in your project, IDF build system will disregard the contents of the bundled "spiffs" component: it will not be added to the list of include paths and will not be built. You can then provide your own implementation inside "spiffs" component of your project.

If you have already done that, and seeing build issues, please post a gist of the build log (with make V=1).

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Use spiffs library with own SPI flash routines?

Postby vonnieda » Wed Jan 10, 2018 3:15 pm

ESP_igrr wrote:
If you have already done that, and seeing build issues, please post a gist of the build log (with make V=1).
Thanks ESP_igrr. I did already try that and I still got conflicts when including spiffs.h, but I didn't investigate very deeply. I will try that again today and report back.

Thanks,
Jason

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Use spiffs library with own SPI flash routines?

Postby vonnieda » Wed Jan 10, 2018 4:13 pm

ESP_igrr wrote:Hi Jason,

I think you can use one feature of ESP-IDF build system, namely that you can override one of ESP-IDF components by creating a component with the same name in your project: http://esp-idf.readthedocs.io/en/latest ... -same-name.
This way, if you create 'spiffs' component in your project, IDF build system will disregard the contents of the bundled "spiffs" component: it will not be added to the list of include paths and will not be built. You can then provide your own implementation inside "spiffs" component of your project.

If you have already done that, and seeing build issues, please post a gist of the build log (with make V=1).
Thanks ESP_igrr, that did the trick! The problem I saw when I tried this before was just that I needed to add a config header. I didn't look close enough at the errors to see that it was almost working.

For future readers, here is what I did:

1. Create components/spiffs.
2. Clone spiffs from https://github.com/pellepl/spiffs to components/spiffs/spiffs.
3. Create components/spiffs/component.mk:

Code: Select all

COMPONENT_SRCDIRS := spiffs/src
COMPONENT_ADD_INCLUDEDIRS := spiffs/src .
4. Copy components/spiffs/spiffs/src/default/spiffs_config.h to components/spiffs.
5. Edit components/spiffs/spiffs_config.h:
* Remove the params_test.h include.
* Add #include <stdint.h>
* Add the following lines near the top:

Code: Select all

////////////////////////////////////////////////////////////////////////
#ifndef s64_t
#define s64_t int64_t
#endif

#ifndef u64_t
#define u64_t uint64_t
#endif

#ifndef s32_t
#define s32_t int32_t
#endif

#ifndef u32_t
#define u32_t uint32_t
#endif

#ifndef s16_t
#define s16_t int16_t
#endif

#ifndef u16_t
#define u16_t uint16_t
#endif

#ifndef s8_t
#define s8_t int8_t
#endif

#ifndef u8_t
#define u8_t uint8_t
#endif
////////////////////////////////////////////////////////////////////////
Then it should build clean!

Thanks,
Jason

Who is online

Users browsing this forum: Dennie and 128 guests