Micro SD-card support

The logging subsystem of the Crazyflie 2.0 is fairly flexible and easy to use, but despite its nice properties it may still be limiting in some scenarios. Two areas where it is lacking are offline- and high-speed logging. As a step towards solving these problems we are happy to announce support for micro SD-cards in the Crazyflie 2.0 firmware.


We have had a prototype for a micro SD-card expansion deck lying around in the office for a long time but have not had time to write any code for it. Finally we decided to go ahead an fix it and now there is a first basic version in the master branch of the firmware. What we have added so far is a driver for communicating with the deck and support for the FAT file system and that means that it is possible to read or write files to/from a SD-card. We have not yet implemented any means for configuring parameter logging to file but that is something we would like to do in the near future.


The hardware design for the expansion deck is very simple.


If you are eagerly waiting for this functionality it should not be too hard to create your own deck, otherwise we plan to release one sometime in the near future. We can not promise when, but if you need it please let us know as it might change our priorities when deciding what to do.

When the deck is installed all you have to do is build the firmware with 


in the tools/make/config.mk file to enable the SD-card functionality and add your own code in src/deck/drivers/src/usddeck.c to read or write to your SD-card.

3 comments on “Micro SD-card support

    • I actually just got it right by simply removing the “FIL fil” declaration.
      Here a test code working if anybody needs it:

      static void usdInit(DeckInfo *info)
      isInit = true;

      FATFS_AddDriver(&fatDrv, 0);

      DEBUG_PRINT(“mount returned %d\n”, f_mount(&FatFs, “”, 1));

      //Mount drive
      if (f_mount(&FatFs, “”, 1) == FR_OK) {
      DEBUG_PRINT(“mount successfully done\n”);

      //Try to open file
      if (f_open(&logFile, “1stfile.txt”, FA_OPEN_ALWAYS | FA_READ | FA_WRITE) == FR_OK) {
      //File opened, turn off RED and turn on GREEN led
      DEBUG_PRINT(“File opened successfuly\n”);
      //If we put more than 0 characters (everything OK)
      if (f_puts(“First string in my file\n”, &logFile) > 0) {
      DEBUG_PRINT(“String written in file\n”);

      //Close file, don’t forget this!

      //Unmount drive, don’t forget this!
      f_mount(0, “”, 1);

      timer = xTimerCreate( “usdTimer”, M2T(SD_DISK_TIMER_PERIOD_MS), pdTRUE, NULL, usdTimer);
      xTimerStart(timer, 0);

Leave a Reply

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