From b3dd424e105f5b7e927ee040fcd627d609b92745 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 17 Feb 2015 16:57:15 -0600 Subject: [PATCH] mkfatfs: use DMA memory for mkfatfs when needed this makes mkfatfs use fat_dma_alloc() when CONFIG_FAT_DMAMEMORY is set. This is needed to ensure mkfatfs operates with boards that use DMA for microSD From Andrew Tridgell via the PX4/NuttX repository --- fs/fat/fs_mkfatfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/fat/fs_mkfatfs.c b/fs/fat/fs_mkfatfs.c index 88d1859118..e4fd147549 100644 --- a/fs/fat/fs_mkfatfs.c +++ b/fs/fat/fs_mkfatfs.c @@ -298,7 +298,12 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt) /* Allocate a buffer that will be working sector memory */ +#ifdef CONFIG_FAT_DMAMEMORY + var.fv_sect = (uint8_t*)fat_dma_alloc(var.fv_sectorsize); ++#else var.fv_sect = (uint8_t*)kmm_malloc(var.fv_sectorsize); +#endif + if (!var.fv_sect) { fdbg("ERROR: Failed to allocate working buffers\n"); @@ -319,7 +324,11 @@ errout: if (var.fv_sect) { +#ifdef CONFIG_FAT_DMAMEMORY + fat_dma_free(var.fv_sect, var.fv_sectorsize); +#else kmm_free(var.fv_sect); +#endif } /* Return any reported errors */