---
title: "SDFileSystem for mbed platfrom"
url: "https://maker.wiznet.io/teju/projects/SDFileSystem-for-mbed-platfrom/"
markdown_url: "https://maker.wiznet.io/teju/projects/SDFileSystem-for-mbed-platfrom/md"
type: "UCC: User Created Content"
author: "teju"
original_author: "teju"
original_url: "https://embeddist.wordpress.com/2015/04/28/sdfilesystem-for-mbed-platrom/"
published: "2022-03-29"
language: "en"
hardware: ["W5500 Ethernet Shield with MicroSD Slot", "LPC824 Xpresso"]
likes: 0
views: 215
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# SDFileSystem for mbed platfrom

> SDFileSystem for mbed platfrom

Original author: teju (source: https://embeddist.wordpress.com/2015/04/28/sdfilesystem-for-mbed-platrom/)

## Components

- **W5500 Ethernet Shield with MicroSD Slot** x 1
- **LPC824 Xpresso** x 1

## Article

This post shows how to use SDfile System on W5500 Ethernet Shield for mbed platfrom.

## SDFile System

> A library to allow SD Cards to be accessed as a filesystem, using a SPI interface

[SDFileSystem @developer.mbed.org/handbook](http://developer.mbed.org/handbook/SDFileSystem)

This library supports: ? Fat12/ FAT16 / FAT32 ? SD / SDHC cards up to 32Gb

## HW ? W5500 Ethernet Shield with MicroSD Slot

![W5500 Ethernet Shield](https://c2.staticflickr.com/8/7714/17092554337_3f7447b9bb.jpg)

[W5500 Ethernet Shield](http://wizwiki.net/wiki/doku.php?id=osh:w5500_ethernet_shield:start)

- ARM mbed compatible operation

- Arduino Pin-compatible

- Ethernet (W5500 Hardwired TCP/IP chip)

- MicroSD Slot

- Ethernet port

- I2C I/F

- UART I/F

### W5500 Ethernet Shiel Pin Map

![W5500 Ethernet Shiel Pin Map](http://wizwiki.net/wiki/lib/exe/fetch.php?media=osh:w5500_ethernet_shield:w5500_ethernet_pin2.png)

- **SPI Bus support Arduino and mbed platfrom**
  | MOSI | MISO | SCK |
  | --- | --- | --- |
  | D11 | D12 | D13 |
  | MOSI(ICSP-4) | MISO(ICSP-1) | SCLK(ICSP-3) |

- **SPI_CS and SD_CS pins are allowed to select as below,**
  - SPI_CS : D8 / D9 / D10
  - SD_CS : D4 / D5 / D6

## SW1 ? SDFile System for LPC824 Xpresso (mbed platform)

- LPC824 Xpresso
  - <http://developer.mbed.org/platforms/LPCXpresso824-MAX/>
  - D6 is used for SD_CS, because D4 and D5 are PWM out. ![CS for LPC824](https://c2.staticflickr.com/8/7683/17298606832_028ea0dfd4.jpg)

| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | `/**? import SDFiles System Library **/` `#include "mbed.h"` `#include "SDFileSystem.h"` `/*for LPC824 Xpresso */` `SDFileSystem sd(D11, D12, D13, D6, ``"SD"``); ``// the pinout on the mbed Cool Components workshop board` `int` `main() {` `????``printf``(``"Hello World!n"``);?? ` `????``mkdir(``"/SD/mydir"``, 0777);` `????``FILE` `*fp = ``fopen``(``"/SD/mydir/sdtest.txt"``, ``"w"``);` `????``if``(fp == NULL) {` `????????``error(``"Could not open file for writen"``);` `????``}` `????``fprintf``(fp, ``"Hello fun SD Card World!"``);` `????``fclose``(fp); ` `????``printf``(``"Goodbye World!n"``);` `}` |
| --- | --- |

## SW2 ? SDFile System for FRDM-KL25Z (mbed platform)

- FRDM-KL25Z
  - <http://developer.mbed.org/platforms/KL25Z/>
  - D4 and D5 are used for SD_CS, because D6 is PWM out. ![CS for FRDM-KL25Z](https://c1.staticflickr.com/9/8751/17300448705_47a266f736.jpg)

| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | `/**? import SDFiles System Library **/` `#include "mbed.h"` `#include "SDFileSystem.h"` `/*for FRDM-KL25Z */` `SDFileSystem sd(D11, D12, D13, D4, ``"SD"``); ``// the pinout on the mbed Cool Components workshop board` `int` `main() {` `????``printf``(``"Hello World!n"``);?? ` `????``mkdir(``"/SD/mydir"``, 0777);` `????``FILE` `*fp = ``fopen``(``"/SD/mydir/sdtest.txt"``, ``"w"``);` `????``if``(fp == NULL) {` `????????``error(``"Could not open file for writen"``);` `????``}` `????``fprintf``(fp, ``"Hello fun SD Card World!"``);` `????``fclose``(fp); ` `????``printf``(``"Goodbye World!n"``);` `}` |
| --- | --- |

## Demo.

Notice:?**SD card name**?shoud be same variable in sd(mosi, miso, clk,?**“SDname”**). * Serial terminal ![minicom](https://c2.staticflickr.com/8/7684/17300020441_28ef8caa19.jpg) * Check SD card by using card reader ![read SD card](https://c1.staticflickr.com/9/8732/17114288049_3dbc5529a8.jpg) * Confirm?stdtest.txt ![read SD card](https://c1.staticflickr.com/9/8783/17093041187_473d80d07a.jpg)

---

Source: https://maker.wiznet.io/teju/projects/SDFileSystem-for-mbed-platfrom/
