MCUXpresso SDK Documentation

sdcard_fatfs_freertos

sdcard_fatfs_freertos#

Overview#

The SDCARD FATFS FREERTOS project is a demonstration program that uses the SDK software. The purpose of this example is to show how to use SDCARD with fatfs and freertos.

Supported Boards#

EVKB-IMXRT1050
Hardware requirements
  • Mini/micro USB cable

  • EVKB-IMXRT1050 board

  • Personal Computer

  • SD card

Board settings

Please insert the SDCARD into card slot(J20) Note: If you want to use a SD3.0 card with SD3.0 protocol, just insert a SD3.0 card into the card slot will be ok.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1060-EVKB
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1060 board

  • Personal Computer

  • SD card

Board settings

Make sure resistors R368/R347/R349/R365/R363 are removed.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1170-EVKB
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1170 board

  • Personal Computer

  • SD card

Board settings

Please make sure R136 is weld for GPIO card detect.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1060-EVKC
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1060 board

  • Personal Computer

  • SD card

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


FRDM-IMXRT1152
Hardware requirements
  • Type-C USB cable

  • FRDM-IMXRT1152 board

  • Personal Computer

  • SD card

Board settings

Please make sure R23 is weld for GPIO card detect.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


EVK-MIMXRT1020
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1020 board

  • Personal Computer

  • SD card

Board settings

Please insert the SDCARD into card slot(J20) Note: If you want to use a SD3.0 card with SD3.0 protocol, just insert a SD3.0 card into the card slot will be ok.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1024-EVK
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1024 board

  • Personal Computer

  • SD card

Board settings

Please insert the SDCARD into card slot(J15) Note: If you want to use a SD3.0 card with SD3.0 protocol, just insert a SD3.0 card into the card slot will be ok.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1040-EVK
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1040 board

  • Personal Computer

  • SD card

Board settings

Please insert the SDCARD into card slot(J20) Note: If you want to use a SD3.0 card with SD3.0 protocol, just insert a SD3.0 card into the card slot will be ok. As the EVK board limitaion, there is eletronic mux added for switch between M.2 and sdcard which will affect the sdcard SDR104 timing. So the maximum sd card timing frequency been decreased to 100MHZ to improve the stability. User can remove the limitation by change the macro BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ in sdmmc_config.h from (100000000U) to (200000000U).

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


EVK-MIMXRT1064
Hardware requirements
  • Mini/micro USB cable

  • EVKM-IMXRT1064 board

  • Personal Computer

  • SD card

Board settings

Please insert the SDCARD into card slot(J20) Note: If you want to use a SD3.0 card with SD3.0 protocol, just insert a SD3.0 card into the card slot will be ok.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


MIMXRT1160-EVK
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1160 board

  • Personal Computer

  • SD card

Board settings

Please make sure R136 is weld for GPIO card detect.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK1: file access is blocking.
TASK1: file access is blocking.
TASK2: write file successed.
TASK2: file access is blocking.
TASK2: file access is blocking.
TASK1: finsied.
TASK2: finsied.

MIMXRT1180-EVK
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1180-EVK board

  • Personal Computer

  • SD card

Board settings

1.Please make sure R257/R140 is weld for GPIO card detect. 2.Please make sure J76 1-2 and J57 2-3 are installed for sdcard socket. Note: As the EVK board limitaion, there is eletronic mux added for switch between M.2 and sdcard which will affect the sdcard SDR104 timing. So the maximum sd card timing frequency been decreased to 100MHZ to improve the stability. User can remove the limitation by change the macro BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ in sdmmc_config.h from (200000000U / 2U) to (200000000U).

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Insert SD card to card slot

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


EVK-MIMXRT595
Hardware requirements
  • Micro USB cable

  • EVK-MIMXRT595 board

  • Personal Computer

  • SD Card

Board settings

Make sure resistors R691~R697 are populated and resistors R611~R620,R660, R661 are removed.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J40) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Please insert the SDCARD into card slot(J32)

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:

SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FRDM-K32L3A6
Hardware requirements
  • Micro USB cable

  • FRDM-K32L3A6 board

  • Personal Computer

  • micro SD card

Board settings

1.Please insert the SDCARD into card slot(J9) 2.Make sure R153. R154, R156, R157 is switch to 1-2. Note: Due to FRDM board do not provide 1.8V IO voltage for SD part, so cannot switch to DDR50 mode. And the CARD detect PIN level is high when card is inserted.

Prepare the Demo
  1. Connect a USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:

SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finished.
TASK2: finished.
LPCXpresso54628
Hardware requirements
  • Micro USB cable

  • LPCXpresso54628 board

  • Personal Computer

  • SD card

Board settings

Insert the card into the card slot

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Insert sdcard into sdcard.

  5. Reset the SoC and run the project. Note:Do not try to use DATA3 to detect card, the demo board pull up the DATA3 pin, but DATA3 should be pull down when used as card detect pin.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


LPCXpresso54S018
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018 board

  • Personal Computer

  • SD card

Board settings

Insert the card into the card slot

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Insert sdcard into sdcard.

  5. Reset the SoC and run the project. Note:Do not try to use DATA3 to detect card, the demo board pull up the DATA3 pin, but DATA3 should be pull down when used as card detect pin.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


LPCXpresso54S018M
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018M board

  • Personal Computer

  • SD card

Board settings

Insert the card into the card slot

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Insert sdcard into sdcard.

  5. Reset the SoC and run the project. Note:Do not try to use DATA3 to detect card, the demo board pull up the DATA3 pin, but DATA3 should be pull down when used as card detect pin.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


LPCXpresso55S28
Hardware requirements
  • Micro USB cable

  • LPCXpresso55S28 board

  • Personal Computer

  • SD card

Board settings

Insert the card into the card slot

Prepare the Demo

Note: MCUXpresso IDE project default debug console is semihost

  1. Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Insert sdcard into sdcard.

  5. Reset the SoC and run the project. Note:Do not try to use DATA3 to detect card, the demo board pull up the DATA3 pin, but DATA3 should be pull down when used as card detect pin.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


LPCXpresso55S69
Hardware requirements
  • Mini USB cable

  • LPCXpresso55S69 board

  • Personal Computer

Board settings

Insert the card into the card slot

Prepare the Example
  1. Connect a micro USB cable between the PC host and the LPC-Link USB port (P6) on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Reset the SoC and run the project.

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:


FATFS example to demonstrate how to use FATFS with SD card.

Please insert a card into board.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......

Create a file in that directory......

Create a directory in that directory......

List the file in that directory......
General file : F_1.DAT.
Directory file : DIR_2.

Write/read file until encounters error......

Write to above created file.
Read from above created file.
Compare the read/write content......
The read/write content is consistent.

Input 'q' to quit read/write.
Input other char to read/write file again.

​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MIMXRT700-EVK
Hardware requirements
  • Micro USB cable

  • MIMXRT700-EVK board

  • Personal Computer

  • SD Card

Board settings

Make sure JP65 1-2 connected. Recommend SD Cards used to run the example

Brand

Mode

Size

Speed Class

Video Speed Class

UHS

A1

A2

SanDisk

Ultra

16GB

10

-

-

YES

-

SanDisk

Extreme

64GB

-

V30

3

-

YES

SanDisk

Ultra Plus

32GB

10

V10

-

YES

-

SanDisk

ImageMate PRO

32GB

-

V30

3

YES

-

Kingston

-

16GB

10

-

1

-

-

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the Debug port on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Please insert the SDCARD into card slot(J47)

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:

SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FRDM-IMXRT700
Hardware requirements
  • Type-C USB cable

  • FRDM-IMXRT700 board

  • Personal Computer

  • SD Card

Board settings

Recommend SD Cards used to run the example

Brand

Mode

Size

Speed Class

Video Speed Class

UHS

A1

A2

SanDisk

Ultra

16GB

10

-

-

YES

-

SanDisk

Extreme

64GB

-

V30

3

-

YES

SanDisk

Ultra Plus

32GB

10

V10

-

YES

-

SanDisk

ImageMate PRO

32GB

-

V30

3

YES

-

Kingston

-

16GB

10

-

1

-

-

Prepare the Demo
  1. Connect a USB cable between the PC host and the Debug port on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Please insert the SDCARD into card slot(J47)

Running the demo

When the demo runs successfully, the log would be seen on the terminal like:

SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.

Create directory......
TASK1: write file successed.
TASK2: write file successed.
TASK1: finsied.
TASK2: finsied.


​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~