Jump to content

[Version 1] Sd Card Development


Recommended Posts

Hey Fellow hak5 members!

I've gone ahead and bought the teensy 2.0 , as well as the sd card adapter.

Ive successfully been able to write scripts to the teensy itself and run them.

I purchased the teensy with bread board pins, and in doing so I have gone ahead and attached the sd card read to the underside of my teensy directly into the pins, (Im not using a breadboard at this point) my question is once I use the teensyduino / teensy loader, how do I actually go about getting the teensy to mount the sd card? Within arduino I set my board to the teensy 2.0 and i set the usb type to SDcard + keyboard.

Any help is greatly appreciated!

Link to comment
Share on other sites

Okay, so after a couple system reboots and re-running teensy, finally got it to mount the drive, thing is, on my system running windows 7, it adds a drive to the list of drives on my system "Removable disk H:" but when I go to view the contents of that drive, it says theres no disk inserted, my device is inserted though o_0

Link to comment
Share on other sites

Okay, so after a couple system reboots and re-running teensy, finally got it to mount the drive, thing is, on my system running windows 7, it adds a drive to the list of drives on my system "Removable disk H:" but when I go to view the contents of that drive, it says theres no disk inserted, my device is inserted though o_0

I've been working on this too,

You need to download a library to allow the Teensy to use the card, something like sdfatlib: http://code.google.com/p/sdfatlib/

Link to comment
Share on other sites

Ahh nice find there, I went ahead and downloaded the latest version, copied the library into my arduino folder, and then imported it, went to verify it and got

F:\Data\Teensy\yeah\arduino-0018\arduino-0018\libraries\SdFat/FatStructs.h:345: error: 'uint8_t' does not name a type

F:\Data\Teensy\yeah\arduino-0018\arduino-0018\libraries\SdFat/FatStructs.h:347: error: 'uint16_t' does not name a type

F:\Data\Teensy\yeah\arduino-0018\arduino-0018\libraries\SdFat/FatStructs.h:349: error: 'uint32_t' does not name a type

Gonna start playing around with the source code I guess, let me know if you find anything else! :)

Link to comment
Share on other sites

So status update on my side:

I've finally been able toget that sdfatlib to compile successfully onto my teensy, also. I've tried hooking up the teensy to Windows 7 (x64), windows XP, gentoo linux, ubuntu linux and OSX, in each of these systems It sees a drive when plugged in, and the teensy operates just as Id like it to, but you are still not able to access the sdcard itself, can't read, cant write, says that none is inserted. Ive attempted to load using a SanDisk 8 GB, a Sandisk 2GB, a Kingston "HC" 4Gb and none of these disks are readable when plugged into the SD slot on the teensy, althoguh all operate just fine read / write on my previously stated operating systems. So at this point Im sitting at a standstill with getting the SD card to work, althoguh I was able to get the use of internal memory on the teensy to work, woo that nice whopping 25kb :P If anyone has any tips / suggestions / ideas, please let me know!

<3

Link to comment
Share on other sites

Don't everyone go replying at once...

Hi!

I am currently working with the Teensy and its SD card as well. You could get the Teensy to read files on the SD card and print its contents onto the Serial Monitor, the SDFatRead Example really helps when you try to see if that certain file exist, else you can change the mode and write instead...:) All this is done when the Teensy is in Serial Mode.

Have you tried the SD card+keyboard? that one, you can get the keyboard to open up the command line and possibly execute a bash file and have the result file saved onto the SD card...

How's your project doing?

Bits1

Link to comment
Share on other sites

I purchased a teensy 2.0, and a sd card adapter from the company provided, I use the teensyduino software to flash the teensy with the sd + keyboard, my computers all then see a "drive" but they never actually recognize or mount an sd card within that drive. Any idea why?

Link to comment
Share on other sites

but they never actually recognize or mount an sd card within that drive. Any idea why?

This is very likely a missing or incorrect connection betweeen the SD card adaptor and the Teensy. There are 10 pins, and only 6 actually are needed.

I really need to publish a diagnostic program and procedure. The very first step is to use a multimeter to measure the voltage on the MISO pin (the B3 on Teensy, or the lower right corner of the SD adaptor when held with the SD card opening on the left). Connect the negative probe to ground and the positive to MISO. Remove any card, so the slow it empty. Load the LED blink program onto your Teensy, so that nothing is attempting to communicate with the card. Under these conditions, you should measure 3.3 volts on MISO.

If you do see 3.3 volts, that verifies the SD adaptor is getting power and correctly converting it to 3.3 volts, and the pullup resistor on the board is connecting 3.3 volts to the MISO pin. These circuits are tested on every board at PJRC using a bed-of-nails test fixture, so if something is wrong, most likely the board isn't getting power.

Next make sure you can see 3.3 volts actually on the B3 pin on the Teensy. That verifies the connection is good all the way from the SD adaptor down to the Teensy.

There's only 3 more signals to check. I should really write a tiny program than drives them with different duty cycle waveforms, so you'll see something like 1 volt, 1.5 volt and 2 volts on each. Its pretty simple to do this, if anyone wants to take a shot at the coding. Obviously, such code should be run only when a SD card is not inserted. The test with a multimeter involves checking the voltage on the Teensy side, and then checking for the same voltage on the SD adaptor side. If there's a bad connection, you'll discover it by seeing different voltage when they should be identical.

The final diagnostic would just probe the SD card and print lots of verbose info about it to the serial monitor window. This won't probably help you much, since by the time this works, everything else will too. Then again, perhaps there's a slim chance you have some very strange card? If you did, I'd offer to swap it for a normal one of equal or greater capacity. But I already have a pretty good collection of cards covering version 1 and version 2 of the spec, and both standard and high capacity on v2 (but i don't have any SDXC cards......)

As for actually using the card, well, via USB you should be able to read and write the card using Windows, Mac or Linux.

The tricky part is access to the card for code running on the Teensy. The SdFat library is the best option today. Unfortunately, it knows nothing about the USB, so using it while the USB is connected is very risky.

Eventually, I'm going to implement either a full replacement for SdFat, or a partial one that replaces the low-level drivers for ones that integrate with a locking mechanism together with the USB. That will at least prevent horrible collisions at the SD card protocol level. Additional management will be needed at the filesystem level, and the bad news is there's really no way to inform Windows, Mac or Linux about filesystem operations on the device. So it will be limited to simulating a card removal (giving you completely exclusive access), and controlling if the operating system sees the media as writable. None of those media sharing and management functions exist yet. (it's called "experimental" afterall.... the other known problem is the USB disk activity hogs the Teensy CPU time very badly.... I have a plan there too, but it will take a lot of work too).

Anyway, the diagnostic programs should be quite a bit easier to write, so please do remind me if you're still struggling to get it to work. Those and some step-by-step instructions should provide some relief (if this message didn't do the trick).

Link to comment
Share on other sites

I purchased a teensy 2.0, and a sd card adapter from the company provided, I use the teensyduino software to flash the teensy with the sd + keyboard, my computers all then see a "drive" but they never actually recognize or mount an sd card within that drive. Any idea why?

Hi,

Have you made sure you connected the SD card adapter and the teensy with the correct pins? I have provided a picture of what I did with the Teensy and the SD card. I just soldered pins onto the Teensy and the SDAdapter and installed them onto the breadboard. And like Paul says, its probably the connection that was causing you problems. Also, the SDcard type also does somewhat affect the read and write ability too. I read that Sandisk and MicroDisk are good brands you could use.

*Note: the red wires are for providing voltage and blue are grounding the Teensy and the Sdcard Adapter.

I hope it helps.

Bits1

post-19954-1279289672_thumb.jpg

Edited by BITS1
Link to comment
Share on other sites

  • 8 months later...

I recently bought my Teensy++ after seeing a presentation on it. As part of some of my tinkering I have been getting it to work with the SDFat Libraries. I thought I would share what I have learned and put together a simple tutorial on connecting the SD Card reader to the Teensy and reading/writing to it from the Teensy using SDFat.

The tutorial is here: http://dabermania.blogspot.com/2011/04/teensy-sd-card-access-with-sdfat.html

I hope this is helpful for some that are getting started with SDFat and their Teensy.

Link to comment
Share on other sites

  • 1 month later...

Hi DaberMania and everyone,

Regarding SdFat library, is there a code that I can use to delete a file? The most recent SdFat library that I downloaded had the option of deleting a directory if only that it is empty.

The old code:

if ((!file.remove())) error("remove error");

didn't seem to work.

I hope to hear from you guys soon! Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...