Shop OBEX P1 Docs P2 Docs Learn Events
FSRWfemto help!!! Anybody who knows how to work it, please share. — Parallax Forums

FSRWfemto help!!! Anybody who knows how to work it, please share.

RavenkallenRavenkallen Posts: 1,057
edited 2010-07-01 01:24 in Propeller 1
Okay, so i have finally gotten around to playing a little more with sd cards. I modified the SD trainer program(It is powered by FSRWfemto)·so i could test out various functions(Reading single characters, writing single characters, using arrays...ect).... My only few problems so far are, ·1. Can the SD card read and write words/ Longs?, 2. If you are reading a whole file larger than 32 Kilobytes do you need any knowledge of clusters or stuff like that?, 3. How hard is it to boot the prop up from a SD card?..... Thanks again for all the previous help. The people on this forum are as friendly as they are knowledgeable and that is very unusual...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Picaxe = Romeo & Juliet

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-06-23 23:06
    There is no separate routine for words or longs. They're all treated as sequences of bytes and the address of the first byte is what's passed to the routines along with a byte count (2 for words, 4 for longs). "pread" and "pwrite" are the routines. The routines take care of clusters and cluster boundaries.

    Booting from an SD card is a little harder. Kye's routines have a boot method and FemtoBasic's fsrwFemto/sdspiFemto has a boot routine where you have to mount the card first, open the file you want, then call bootSDCard to boot the opened file. The file must be contiguous in the 1st 32K for this to work. The easiest way to insure this is to format the SD card with 32K clusters.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-06-24 01:26
    There are a number of bootloaders, including the one posted today. The simplest in EEPROM is on the RamBlade thread. It only knows about the SD hardware and will boot a file from the SD. There is no need to ever change the code in EEPROM as the running program will be located on the SD. There is a sequence and it will load any OS, such as PropDos, PropCmd, Sphinx, Kyes OS, etc. It is fully descrived in the RamBlade thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-25 03:05
    Sorry it took so long to reply. I had a busy week. Thank you for the quick answers and Cluso99, What is the bootloader you are talking about?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-25 03:05
    Sorry it took so long to reply. I had a busy week. Thank you for the quick answers and Cluso99, What is the bootloader you are talking about?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-25 04:22
    I like fsrw... but Kye's code is better for me because it works with more cards, and can do FAT32 and a bootloader.

    http://forums.parallax.com/showthread.php?p=912403

    My only few problems so far are, 1. Can the SD card read and write words/ Longs?, 2. If you are reading a whole file larger than 32 Kilobytes do you need any knowledge of clusters or stuff like that?, 3. How hard is it to boot the prop up from a SD card?.

    1) Yes you can read and write single bytes to a card - open file, write a byte, close file. Or do it in bigger chunks. Kye's code has all the routines already written and they are easy to use.
    2) No need for knowledge of clusters. Just send the bytes in and out and the OS handles it all behind the scenes.
    3) From about page 5 of that thread I was posting code for the bootloader. Put KyeDOS in the eeprom, and it boots up with a vga screen and a list of all the .BIN files (which are all precompiled spin programs). Choose which one you want. Plus the help menu. You can add one line of code to run one of those programs if you want it to auto run. I also added xmodem file transfer so you can put new files on the sd card without having to unplug it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-06-25 04:36
    Ravenkallen: The bootloader used in RamBlade is on the RamBlade thread (see link in my signature). It is either in the top 2-3 posts, or near the end, so work backwards. It uses the femto driver. There is also PropCmd there which shows the use of the femto driver quite well I believe. Also, the femto driver (sdspixxxx) has been patched to enforce the SD card to release DO. This is a problem with hardware that shares the SD pins, like TriBlade & RamBlade.

    It really boils down to what you are trying to achieve. My objective was to have a minimal EEPROM boot that only knew about the SD card and so could load it's files from there. No need to ever change the EEPROM, just change the SD files. The SD card would know the hardware location and drivers.

    There is another recent thread which deals with updating the EEPROM driver from SD files. It uses a 64KB eeprom (many pcbs have the 64KB version, but not all). This is a more complex bootloader. It is based on the one done by mctrivia.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-26 04:05
    @Cluso99... I just mostly want to do it to say that i can do it. Just another concept under my belt. And thank you again for the help. I have only started learning how to use SD cards a little while ago, so i am not to familiar with the concepts. I did manage to read and write longs from the sd card tonight. I am pretty excited....And thank you Dr_acula for the advice. I guess i will worry about booting from a sd card later when i am more experienced

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-27 02:55
    I have one more question. When you open a new file for a write does the system erase the whole previous file and put only the new info in? Or is there a certain memory threshold that you must attain before the system will not erase the whole previous file? Does that make sense?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-28 18:37
    Anybody?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-06-29 04:14
    I do not think it erases the file. So I think you have to do this first. Remember, some of us rely on files being contiguous, so deleting files may cause problems. To get around this, I rename them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-30 02:35
    Thank you for replying. I though i was all alone for a minute. Well, when i write a new portion of text to the file and then, when i read it, it only outputs the new text and not any of the previous stuff. This is just something that i have noticed from my various testing. I am not sure why this works, perhaps it has something to do with blocks or sectors or something. I mean, i would think that it would not erase it like you said, but it just doesn't for some reason.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-30 02:53
    Ravenkallen said...
    Well, when i write a new portion of text to the file and then, when i read it, it only outputs the new text and not any of the previous stuff.
    Note that when you open a file the read/write location is usually positioned at 0. Meaning when you have existing content in the file and you start writing without repositioning this pointer (e.g. to the end of the file, provided seeking is supported) then you overwrite said content.
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-30 02:57
    That might explain some of it, but i have tried it with way smaller chunks of new content and it still acts like it erases it. I will try another time to see if it does it again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-30 03:02
    Ravenkallen said...
    That might explain some of it, but i have tried it with way smaller chunks of new content and it still acts like it erases it. I will try another time to see if it does it again.
    If you can reproduce it, a small test case may come in helpful (posted here).
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-30 05:05
    Re "Well, when i write a new portion of text to the file and then, when i read it, it only outputs the new text and not any of the previous stuff."

    I have not used fsrw, but I can answer for Kye's Sd card driver. There are three modes you can open in - Read, Write and Append. Write starts a new file. Append adds data to an existing file.

    If you opened a new file for write, you could try erasing it first. If it exists - then it is definitely gone. If it does not exist, then it won't matter. Obviously you are not going to try erasing it if the file is being appended. The steps are;

    Try erasing file
    Open for write
    Write bytes
    Close file

    or

    Open for append
    Write bytes
    Close file

    If you get a chance, download the zip at the bottom of the first post http://forums.parallax.com/showthread.php?p=912403 and unzip it and open up the file 'SD2.0_FATEngine' and quickly scroll down the list of PUB functions. Each is well commented (sometimes the comments are longer than the code) and very quickly you can get a feel for what it can do. eg
    PUB openFile(fileName, mode) '' 33 Stack Longs
    
    '' ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    '' │ Opens a file in the current directory for reading, writing, or appending.                                                │
    '' │                                                                                                                          │
    '' │ All files opened for writing or appending must be closed or they will become corrupted and must be fixed with scandisk.  │ 
    '' │                                                                                                                          │
    '' │ If the partition is not mounted or an error occurs this function will abort and return a string describing that error.   │
    '' │                                                                                                                          │
    '' │ The "." and ".." entries are ignored by this function.                                                                   │                                                                   
    '' │                                                                                                                          │
    '' │ Returns a pointer to the name of the opened file.                                                                        │ 
    '' │                                                                                                                          │
    '' │ FileName - The name of the file to open for reading, writing or appending.                                               │
    '' │ Mode - A character specifing the mode to use. R-Read, W-Write, A-Append. By default the file is opened for reading.     │                                                                                      
    '' └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-30 19:05
    @Dr.Acula..... Is this Sd2.0_fatengine very hard to understand?
    @Kuroneko... I will try to post some test code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-06-30 22:32
    Okay, here is the demo that i was using. You will need FSRWfemto and sdspifemto, plus parallax serial terminal... Anyway, when you write the test text it

    Will read off just fine, but when you omit one or more lines of text and then proceed to write it again, it will only read off the new data.... Maybe somebody

    can shed some light on this strange thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-30 22:53
    I think I understand the problem but I'm not sure. Ok, you write a file
    line1
    line2
    line3

    and then read it back and that works?

    then you write it again with
    line1
    line3

    and do you get back
    line1
    line2
    line3
    line1
    line3

    or do you get back
    line1
    line3


    and what do you want to get back?

    I am wondering if you want 'append' mode? This is where you can add text to an existing file. From frswFemto;
    pub popen(s, mode) | i, sentinel, dirptr, freeentry
    {{
    '   Close any currently open file, and open a new one with the given
    '   file name and mode.  Mode can be "r" "w" "a" or "d" (delete).
    '   If the file is opened successfully, 0 will be returned.  If the
    '   file did not exist, and the mode was not "w" or "a", -1 will be
    '   returned.  Otherwise abort will be called with a negative error
    '   code.
    }}
    
    



    and you are current using 'write' mode which erases the previous file of the same name.
      sd.popen(string("alpha.txt"),"w")  '' Open alpha.txt for write
    
    


    So presuming alpha.txt already exists, try changing that to;
    sd.popen(string("alpha.txt"),"a")  '' Open alpha.txt for append
    
    



    and see if the text is now longer. Every time you call this the text should get longer and longer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-07-01 01:24
    I get back only line one and line three. So you said that when you use the "write" method, that it will erase the previous file of the same name? I will try the append method and see if
    that helps any. Mainly, i don't really care either way, i just want to know which one works. Thanks again for the assistance

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller + Picaxe = Romeo & Juliet
Sign In or Register to comment.