Shop OBEX P1 Docs P2 Docs Learn Events
Reading files written on SDmicro on PC? — Parallax Forums

Reading files written on SDmicro on PC?

Hi,
I have a SDMicro card and formatted it on the PC, I can write to it and read from it fine using cgsm_flash_file_demo.spin2 .

When I open it on the PC, I see no files on the card.

Is it possible to read those files on the PC, or just format incompatible?

Thanks,
MH

Comments

  • JonnyMacJonnyMac Posts: 9,157
    edited 2023-10-14 22:30

    You need a uSD driver to read or write files with a card that will work with a PC. Chip's driver just allows you to treat the Propeller 2 flash as a file system. It is all internal.

    Have a look at what Ray Allen has done with porting FSRW (what I use on the P1) to the P2. I have started to play with it a bit, and transferred a largish file from my PC to the uSD, then from the uSD to flash using Ray's P2 version of FSRW to read the the uSD, and Chip's driver to write to the flash. Note that you need a separate uSD socket -- the uSD socket on the P2 Eval and Edge boards won't work when using Chip's flash driver.

    I've attacked one of my test programs so you don't have to go looking for the pieces.

  • Thanks Jon, I'll look it over, but probably more than I want to attack right now.

    I do have another question, when using cgsm_flash_file_demo.spin2, it appears I can write to multiple blocks of data (simply from file size), but I can only 'type' or 'cat' a single block.

    Any easy fix for this or I missing something already in there? I'm working up an example to store large amounts of data then "dump" it to the PC for Wednesday's Propeller Live Forum. Ken says I'll get 'bonus points' for using the uSD lol. You've done 90% of the work for me already with serial, itoa, flash, etc, etc!

    Thanks much.

  • In that demo, yes, because I'm reading into a block-sized buffer and then displaying it. Please understand that the purpose of my demo is to show basic usage of the of the object. By buffering the contents the file can be "typed" to anything -- not just the screen. If you want to dump the contents of a multi-block file to the screen, remove the buffer.

    Once you have the flash file system mounted you can do it like this:

    pub type_flash_file(p_filename) | handle, b
    
      handle := ffs.open(p_filename, "r")
    
      if (ffs.error() <> ffs.OKAY)
        term.fstr1(@"Error opening %s\r", p_filename)
        return
    
      repeat
        b := ffs.rd_byte(handle)
        if (ffs.error() == ffs.OKAY)
          term.tx(b)
        else
          quit
    
      ffs.close(handle)
    

    I suppose you could use a terminal program like PuTTY to catch the output and write it to a file on the PC side.

    Ken says I'll get 'bonus points' for using the uSD lol

    This is a laugh because Parallax doesn't have a uSD driver -- though many of us asked them for one years ago.

  • I just meant a microSD card, as I'm using for your/Chip's FFS code. Ken really said if I use Chip's Flash code, pointing me the GitHub with your examples. I've modified so I can keep the file open and perform multiple writes for a MakerPlot-J formatted line - which is where I'll be dumping it to. It's really a live forum on MPJ, this is one example for storing/dumping to plot/log data..

    Thanks for the code update, I'll try it out!
    -MH

  • @"Martin Hebel" : if your goal is to copy data to the host PC, then you may want to consider using the 9P file system built into loadp2 (and in my version of proploader). This lets you read/write files directly on the PC from the P2. The P2 side currently works only under FlexProp (since it's written in C), but I have a preliminary version that will build with PNut and which I hope to release soon.

    In general FlexProp has built in support for 9P, Fat file systems on uSD, Parallax's flash file system, and ARM's littlefs flash file system. These are all easiest to use from BASIC or C, but you can get at them from Spin as well.

  • Thanks, but my goal is not create files on the PC but to send data to MakerPlot-J software on the PC. Creating files is a by-product and possibly could be used to import data..

Sign In or Register to comment.