Shop OBEX P1 Docs P2 Docs Learn Events
How would I read raw data from SD Card not formatted as FAT? — Parallax Forums

How would I read raw data from SD Card not formatted as FAT?

ryfitzger227ryfitzger227 Posts: 99
edited 2022-05-04 01:22 in Propeller 2

I'm trying to read raw data from an SD card that is not formatted with the file system used in the example (flexprop).

I've tried many things. I formatted the sd card as FAT, wrote a file, and listed the directory with the shell.c example provided with flexprop. This worked fine. Trying using SPI with a reformatted SD card, however, isn't working. Using the spin2 library jm_ez_spi and flexc, I'm trying to initialize the SD Card with the CMD0 (0x40, 0x00, 0x00, 0x00, 0x00, 0x95). But when using shiftin, I always get #FF as the first 8 bits (supposed to be 00) both when the sd card is inserted and is not.

This is the first step to sending commands (and ultimately reading data) to the SD card and I'm stuck. I'm new to working with SPI without using an external library to assist.

I'm using the P2 Eval Board REV B.

Any tips or help is appreciated!

Comments

  • VonSzarvasVonSzarvas Posts: 3,491
    edited 2022-05-04 03:49

    There's a P1 PropBasic code library for raw level SD read/write logging without all the FAT overhead.

    Maybe that will give some ideas.

    https://forums.parallax.com/discussion/122615/propbasic-sd-card/p1

  • pik33pik33 Posts: 2,388

    There is a Cluso's SD driver which has procedures for initialize the card, read and write sector, but then, we have a good and fast SD code in FlexProp so there is no need to write your own or use external libraries. You have only to find and use low level initialize/read/write

    This is the starting point:

    flexprop5.9.10\flexprop\include\filesys\fatfs\sdmm.cc

  • ryfitzger227ryfitzger227 Posts: 99
    edited 2022-05-04 23:31

    Thank you guys for your help.

    I've downloaded the P1 PropBasic code in case I need to use it.

    I tried to find the low level functions for initialize/read/write in FlexProp yesterday without any luck. Thank you for that; a huge help!

  • The current flexprop code now uses smartpin code and is hard to understand.

    Here is my original code that just uses bit bashing to read and write the data from the SD card. Way easier to understand.

    Mike

  • evanhevanh Posts: 16,040
    edited 2022-05-05 02:52

    Mike,
    Eric still has your code in the master branch. Just comment out the #define _smartpins_mode_eh

  • @evanh ,

    Eric never used my code. That's all his original code.

    Mike

  • evanhevanh Posts: 16,040

    Ah, okay. :)

Sign In or Register to comment.