• AVR Freaks

Hot!Cannot Mount File System on SD Card

Author
jdtaylor7
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/01/22 15:42:40
  • Location: 0
  • Status: offline
2019/01/30 00:04:34 (permalink)
0

Cannot Mount File System on SD Card

Hello! I have been trying to mount a file system onto an SD card for the past few weeks, to no avail.

My hardware setup is comprised of a Mikroelektronika Clicker 2 development board connected to a Velleman VMA304 SD card breakout board via SPI. The SD card is a base 2GB standard SanDisk SD card. It's not an SDHC, SDXC, etc. My software environment is MPLAB X IDE v5.10. I am using a PICkit3 to connect the development board to my computer. I have attached a picture of my hardware.

I know the PICkit and development board work correctly since I have been using them for the other parts of a larger project. I also know the SD card breakout board and the card itself both work, as I can write to them with an Arduino.

As I understand it from reading the relevant portions of the “Driver Libraries_v111.pdf” and “System Service Libraries_v111.pdf” documents, the file system service library is an abstraction layer for the SD card driver library, which in turn is an abstraction layer for the SPI library. This seems to be the case when looking at the “sdcard_fat_single_disk” example project bundled with MPLAB X. Based on that example project, it appears that neither a SPI nor an SD card driver needs to be opened before mounting the file system. Simply mounting a file system without opening the other two drivers did not work for me, so I tried opening either just the SD card driver or both the SPI and SD card drivers before attempting to mount the file system, which also did not work. Pictures included below. The SPI driver is able to open successfully, though the SD card driver is not, regardless of whether the SPI driver has been opened first.

I have attempted to replicate the Harmony configuration settings of the aforementioned example project as closely as possible, which did not work. I have attached screenshots of my current configuration settings, which are as similar to those of the example project as possible. The only differences are the following:

“SPI Module ID” of “SPI Driver Instance 0”, which is “SPI_ID_2” since that is the only available SPI interface on the development board

In the first group of SPI check boxes, I use “Standard Buffer Mode” instead of “Enhanced Buffer (FIFO) Mode”, since that option isn’t available to me

 Screenshots of my pin configuration are also included. It is the following:

    CS: G13, gray

    SCK: G6, orange

    MISO: G7, blue

    MOSI: G8, purple

    3.3 V logic level

I have checked with a logic analyzer that the chip select pin is brought low for the duration of the write and data is being written to the clock and master data out lines. I’ve tried using a write protect pin and using the file system driver’s auto mount feature, neither of which have solved the problem.

I have tried the solutions mentioned in these posts as well, none of which have worked for me:

    SD Card Cannot Mount (No MISO): https://www.microchip.com/forums/m935672.aspx

    i can't mount a device for file system service with SD card: https://www.microchip.com/forums/m858833.aspx

    Actual Working SD Card Project?: https://www.microchip.com/forums/m1025637.aspx

Two additional strange quirks are 1. The SD card driver opens successfully when I uncheck “Register with File System?” in the SD card driver options menu in Harmony, and 2. The SPI driver stops working when I remove SPI driver instance 1 in the Harmony menu, even though driver instance 0 uses the correct SPI module ID.

All of the pictures mentioned above are located in this album: https://imgur.com/a/QnoASoU

Any guidance would be greatly appreciated, thank you so much!
#1
Paul PortSol
Super Member
  • Total Posts : 534
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: online
Re: Cannot Mount File System on SD Card 2019/01/30 09:19:49 (permalink)
0
Haven't used SD Card, but with USB Stick there were issues if not big enough capacitor on the USB power. You could try adding a 150uF 6V cap on the SD card power.
#2
jdtaylor7
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/01/22 15:42:40
  • Location: 0
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/01/30 16:12:43 (permalink)
0
Hi Paul, thanks for the suggestion. There is at least one capacitor tied to the 3.3V rail on the SD card board, but I tried throwing some electrolytics into the mix anyway. I tried 100uF @ 25V, 147uF @ 25V, and 220uF @ 10V. Unfortunately none of those combinations helped.
#3
muellernick
Super Member
  • Total Posts : 475
  • Reward points : 0
  • Joined: 2015/01/06 23:58:23
  • Location: Germany
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/01/31 04:55:39 (permalink)
0
Oh wow! Throwing even bigger capacitors at problems! They are so cheap, so where small helps, huge can't hurt?!
A 1 uF ceramic is good enough. And a scope helps to verify that.
 
Did you verify that card detect and write protect do work as expected? Trace into the source with the debugger to be sure.
 
Nick
#4
Paul PortSol
Super Member
  • Total Posts : 534
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: online
Re: Cannot Mount File System on SD Card 2019/01/31 05:18:03 (permalink)
0
HEAP - Some of the demos have a tiny heap (<=500) that gave erratic performance with USB MSD, 
increasing heap to 10000 removed the issues. 
(USB & SD both use filesystem which needs heap)
Suggest adding code to monitor heap usage (till Microchip publishes heap requirements for various Harmony modules).
 
1uF definitely not sufficient for USB MSD, even 50uF~100uF was erratic with some USB sticks. 150uF 6V works fine in our stuff.
Careful on Cap Voltage ratings. A 50uF 50V cap may be way less uF at 3.3V. More voltage isn't always good. 
 
Paul
 
 
post edited by Paul PortSol - 2019/01/31 12:15:20
#5
muellernick
Super Member
  • Total Posts : 475
  • Reward points : 0
  • Joined: 2015/01/06 23:58:23
  • Location: Germany
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/01/31 07:43:04 (permalink)
0
1uF definitely not sufficient for USB MSD

 
USB doesn't help for a SD-card, right?
 
Nick
#6
jdtaylor7
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/01/22 15:42:40
  • Location: 0
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/01/31 23:37:16 (permalink)
0
muellernick
Did you verify that card detect and write protect do work as expected? Trace into the source with the debugger to be sure.
 

 
What do you mean by card detect? Write protect does not work. I don't think the SD card shield I'm using allows me to even even connect write protect: https://www.velleman.eu/d...ds/29/vma304_a4v01.pdf. And since I cannot successfully get the handle of the SD card, I am not able to run functions such as DRV_SDCARD_IsAttached or DRV_SDCARD_IsWriteProtected either.
 
Paul PortSol
HEAP - Some of the demos have a tiny heap (<=500) that gave erratic performance with USB MSD, 
increasing heap to 10000 removed the issues.




I'm not finding any information on SD card heaps in either the driver library user guide (SPI/SD card documentation) or the system service library user guide (file system documentation). Where would I go to read more about this?
#7
jdtaylor7
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/01/22 15:42:40
  • Location: 0
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/01/31 23:49:01 (permalink)
0
Could it have something to do with the SD card speed or the SPI clock/baud rate? I tried lowering the SD card speed from 10,000,000 Hz to 400,000 Hz and the SPI clock/baud rate from 1,000,000 Hz to 400,000 Hz, but that did not affect anything.
 
#8
Paul PortSol
Super Member
  • Total Posts : 534
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: online
Re: Cannot Mount File System on SD Card 2019/02/01 06:32:57 (permalink)
0
I found nothing in the docs about required heap for different modules I use, and no one else on this forum has answered about finding anything either.
 
a) I chose to Set heap Large (10K) and wait for Microchip support ticket reply (Nothing on year+).
 
b) ToDo: I should write a bit of code to periodically alloc/dealloc a tiny block (a uint_32), and record the min/max addresses returned to track heap usage, print that out and log it somehow (Start and deepest heap vs linker allocated heap addresses).
 
There is also option to print out diagnostics from the linker which can give you a hint of whats happening with heap allocation (so you can tell when your heap has crossed the line).
- Project properties - XC32 - xc32-ld - Options=Diagnostics - Select checkboxes (Memory Usage, Crossref, Warn)
 
Paul
#9
LostInSpace
Super Member
  • Total Posts : 276
  • Reward points : 0
  • Joined: 2016/03/11 22:47:59
  • Location: 0
  • Status: offline
Re: Cannot Mount File System on SD Card 2019/02/16 15:38:47 (permalink)
5 (1)
I would suggest that you take this one step at a time.
1) Get the SD Card interface working, by itself.
When that is done,
2) Add the file system layer.
 
Trying to get two things working at the same time in an embedded project is a sure way to loose ones sanity.
 
Here is some info on how I got the SD Card interface working, and I did it with Click Board also,
 
https://www.microchip.com/forums/FindPost/1066632
#10
Jump to:
© 2019 APG vNext Commercial Version 4.5