Jump to content

[Energia Library] Jaffl: Just another FatFs library

Recommended Posts

I have been searching for a FatFs Energia library for the FR5969 a while and haven't come across anything that worked, so I decided to try make one. If there is one out there.... ahhhhhhhhhhghhghgh.


The library is called Jaffl: Just another FatFs library  :)   


It is located at:  https://github.com/geometrikal/Jaffl



  • It is written for the MSP430FR5969, mainly because transmit and receive SPI bytes routines hard coded to USCB0. If someone can make this more generic it would be welcome.
  • The Jaffl wrapper is based on the FatFs wrapper by David Sirkin.
  • The latest FatFs version (ff11) is used, but not all functions may have made it to the wrapper.
  • The diskio.c MMC interface comes from the TI example code for the MSP430F5529 LaunchPad with a few changes: 1. there were extra functions added to attach the SPI init / change speed / cs routines. 2. Class 6 and 10 cards weren't initialising, so instead of sending CMD0 once before failing (during disk_initialization()) it keeps sending every 1ms until it gets the right response, or one second has passed.
  • f_printf was changed to f_vprintf in ff.c and modified to accept va_list instead of the normal variable argument designator (the dots: ...) . This is because Jaffl.printf wraps it, and needs to pass the variable arguments as va_list.

A quick test example:

#include "SPI.h"
#include "Jaffl.h"

int counter = 0;

void setup()
  Serial.print("Begin, return code: ");
  Serial.print("Open file, return code: ");
  Serial.println(Jaffl.open("test.txt", FA_WRITE | FA_CREATE_ALWAYS));

void loop()
  Serial.print("Print file, return code: ");
  Serial.println(Jaffl.printf("Hello world: %d\r\n", counter++));
  Serial.print("Sync, return code: ");

The code isn't polished, but seems to work. I will be doing on going testing as this will be used in another project, but I've put it up now to get feedback and help spot bugs. 99% of the code came from other sources so thanks to those people. Its all on github so if you have changes do a pull request.


2015-03-18 - Added MISO internal pull up to get some cards to work.

Link to post
Share on other sites
  • 2 years later...
  • 8 months later...
  • 1 year later...


The weekend is coming soon and I'm very tired.

I downloaded your nice library and I tried to use it with the Launchpad MSPFR5994. Your example displays






Then nothing more.

Maybe (and probably) the guilty is me. I'd think about it next Monday morning. But if you have any advice for me to avoid any trap, I'll be happy to read you.

Thanks and have a nice week-end.

Link to post
Share on other sites


I haven't working on the Launchpad for a very long time sorry. However, I would recommend the SdFat library -> https://github.com/greiman/SdFat to see if it works. That is what I'm currently using with an ATmega1248

What I really recommend is to develop in Visual Studio Code with the PlatformIO plug in (https://platformio.org/platformio-ide). So much better than the Energia or Arduino IDEs

I searched for the SdFat library in there and found this page: https://platformio.org/lib/show/322/SdFat which says it has MSP430 support so I would hope that it would work fairly seemlessly with  the FRs.

Good luck!


Link to post
Share on other sites


Thank you for your reply.

The SdFat library seems to be very interesting.   Unhappily I can't compile the code and obtain the message :


In file included from /opt/energia/libraries/SdFat/src/SdFat.h:31:0,
                 from /opt/energia/libraries/SdFat/examples/dataLogger/dataLogger.ino:5:
/opt/energia/libraries/SdFat/src/SysCall.h: In static member function 'static void SysCall::yield()':
/opt/energia/libraries/SdFat/src/SysCall.h:79:3: error: '::yield' has not been declared
In file included from /opt/energia/libraries/SdFat/src/sdios.h:32:0,
                 from /opt/energia/libraries/SdFat/src/SdFat.h:36,
                 from /opt/energia/libraries/SdFat/examples/dataLogger/dataLogger.ino:5:
/opt/energia/libraries/SdFat/src/FatLib/ArduinoStream.h: In member function 'void ArduinoInStream::readline()':
/opt/energia/libraries/SdFat/src/FatLib/ArduinoStream.h:58:13: error: 'yield' was not declared in this scope
exit status 1
Erreur de compilation pour la carte MSP-EXP430FR5994LP

I think know what does the function yield() but I'm not really sure. And for the moment I don't know how to fix the problem.

Any idea welcome.


Link to post
Share on other sites

Hi Geometrikal, Hi TL

The portage works perfectly, it is only necessary to put the good chip select for the Launchpad as well as to specify the good bus SPI in the file Jaffl.cpp in the routine SPI_INIT. For the applications which I use I tested at the same time the competition between the SPI bus (0) which manages the SD card and the SPI bus (1) which manages another device.
I enclose all the necessary sources to test on a Launchpad MSP430FR5994.

For my work I use Visual Studio 2019 with the Visual Micro plugin.
I can compile for Arduino (Arduino,ESP8266,ESP32,ST) and Energia families in an efficient way.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...