Shop OBEX P1 Docs P2 Docs Learn Events
Code Size of Various SD Card/FAT32 Drivers — Parallax Forums

Code Size of Various SD Card/FAT32 Drivers

What kind of code sizes are folks looking at for write-capable SD card drivers on the Propeller? I'm only interested in ones running FAT32 drivers because the output needs to be (easily) legible on a computer, so no raw SD drivers. I'd like to log a bunch of data to an SD card in my balance bot software, but it's costing 12k to add PropWare's FatFileWriter and related classes.

My app is in C++, but I'm not at all opposed to converting Spin drivers via spin2cpp, so throw 'em all at me. Please tell me where the driver can be found, how much space it requires, and what model (Spin, PropGCC LMM, PropGCC CMM) gave that memory footprint.

Comments

  • Just to give you some idea from my side of the fence I have EASYFILE which includes the SD card drivers, the virtual memory card and file layer, FAT32 and utilities to handle multiple open files including random access and it's really fast. I can treat a card or a file as virtual memory and just "fetch" or "store" raw data if I want etc.
    Code bytes used = 4246
    
    ..  MOUNT 
    Mounted 1F35.313A-676E.3A3A mkfs.fat VSR         FAT32   7,947MB (4,096/cluster) ok
    ..  ls -l 
    -rwxrwxrwx 1 502     500      1442886 Feb 22  12:57 P8X32A.PDF
    -rwxrwxrwx 1 502     500      3242394 Nov  7  13:26 POPCORN.WAV
    -rwxrwxrwx 1 502     500      3226652 Aug 30  07:27 WARPEACE.TXT
    -rwxrwxrwx 1 502     500              Jul 20  07:56 [code]
    -rwxrwxrwx 1 502     500              Jul 20  07:56 [HELP]
     .  cd CODE
    ..  ls -l 
    -rwxrwxrwx 1 502     500              Jul 26  05:20 [.]
    -rwxrwxrwx 1 502     500              Jul 26  05:20 [..]
    -rwxrwxrwx 1 502     500        47346 Jul 18  13:32 EXTEND.FTH
    -rwxrwxrwx 1 502     500         4146 Jul 12  09:21 FLASH.FTH
    -rwxrwxrwx 1 502     500        42871 Jul 12  09:16 EASYNET.FTH
    -rwxrwxrwx 1 502     500        44012 Jul 12  09:16 EASYFILE.FTH
    -rwxrwxrwx 1 502     500         3520 Jul  6  09:17 COMPACT.FTH
    ..  fopen FLASH.FTH ...opened at 0000.BB2A for 4146
    ..  0 $80 FS DUMP 
    0000.0000:   54 41 43 48  59 4F 4E 20  56 34 20 28  20 56 34 2E    TACHYON V4 ( V4.
    0000.0010:   35 20 29 0A  0A 49 46 44  45 46 20 46  4C 41 53 48    5 )..IFDEF FLASH
    0000.0020:   2E 66 74 68  0A 46 4F 52  47 45 54 20  46 4C 41 53    .fth.FORGET FLAS
    0000.0030:   48 2E 66 74  68 0A 7D 0A  0A 70 75 62  20 46 4C 41    H.fth.}..pub FLA
    0000.0040:   53 48 2E 66  74 68 09 09  09 50 52 49  4E 54 22 20    SH.fth...PRINT" 
    0000.0050:   53 65 72 69  61 6C 20 46  6C 61 73 68  20 64 72 69    Serial Flash dri
    0000.0060:   76 65 72 20  31 37 30 36  32 30 2D 30  30 30 30 20    ver 170620-0000 
    0000.0070:   22 20 3B 0A  0A 0A 7B 0A  53 65 72 69  61 6C 20 46    " ;...{.Serial F
    
  • the smallest (and fastest) is FSRW, but not sure about support for sub directories.

    It has a very fast PASM block diver with read ahead and write behind support.

    Kye's Fat_engine is the completest FAT32 driver, but is also quite big,

    That are the two choices in Spin.

    Mike
  • Cluso99Cluso99 Posts: 18,066
    Using Kye's FAT engine & his string handler plus FullDuplexSerial and some message strings, but read only.
    Searches for a filename, opens and loads into hub ram, and restarts/reboots this code.
    Compiled with homespun (think this removes unused routines) results in a 10KB file/hub.
  • Just to give you some idea from my side of the fence I have EASYFILE which includes the SD card drivers, the virtual memory card and file layer, FAT32 and utilities to handle multiple open files including random access and it's really fast. I can treat a card or a file as virtual memory and just "fetch" or "store" raw data if I want etc.
    Code bytes used = 4246
    

    That is certainly darned impressive.
  • msrobots wrote: »
    the smallest (and fastest) is FSRW, but not sure about support for sub directories.

    It has a very fast PASM block diver with read ahead and write behind support.

    Kye's Fat_engine is the completest FAT32 driver, but is also quite big,

    That are the two choices in Spin.

    Mike

    Any idea on code size for fsrw?

    Sounds like Kye's engine is on the same order of magnitude as mine. Maybe +/- 10 or 20%. @Cluso99, did I understand correctly that your 10kB test did not include file write?
  • PropellerIDE reports 5324 bytes for fsrw.spin, v2.6. That includes the pasm block level driver, safespi.spin, at 2208 bytes.

  • Hm... turns out fsrw is written in C... I wonder what it would take to get the original fsrw code running on the Propeller...

    https://sourceforge.net/p/fsrw/code/ci/default/tree/csource/fsrw.c
  • p2gcc uses the original fsrw.c C code for it's file I/O. I modified fsrw.c to support directories and multiple opened files. The modified version is located in the Can't Wait for PropGCC on the P2? thread.
  • Dave Hein wrote: »
    p2gcc uses the original fsrw.c C code for it's file I/O. I modified fsrw.c to support directories and multiple opened files. The modified version is located in the Can't Wait for PropGCC on the P2? thread.

    That's awesome! well done :) I will definitely take a look.
  • Cluso99Cluso99 Posts: 18,066
    Yes, I don't do any writes with that.

    Last night I was looking in avrfreaks and they have boot code that is much smaller. IIRC about 2KB.

    FWIW I have never tried to make a small boot code.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-08-01 03:18
    DavidZemon wrote: »
    Just to give you some idea from my side of the fence I have EASYFILE which includes the SD card drivers, the virtual memory card and file layer, FAT32 and utilities to handle multiple open files including random access and it's really fast. I can treat a card or a file as virtual memory and just "fetch" or "store" raw data if I want etc.
    Code bytes used = 4246
    

    That is certainly darned impressive.

    I decided to list the breakdown of the size of each routine and wrote a quick bit of code to list all the relevant routines and their code sizes. One of the largest routines is MOUNT at 138 code bytes but that also includes system messages. Some functions can be inferred from their names, certainly FOPEN RENAME etc and some other functions are simply runtime utilities such as setting the pins to be used for the SD card such as SDPSIN for configuring a Spinneret for instance since there is no need to specify any of this at compile time.
       14 QV           8 SDSPIN       8 SDPAB        8 SDQS         8 SD1419       8 SD1144       8 SD1372       8 SD1656    
       8 SD8          8 SD1377      28 LF>CR        6 FL         104 SAVETEXT    20 FRUN        14 .FILES      18 .FX       
       2 .FILE        8 lss         32 VOLNAME!    58 ls           4 .LIST       60 (.LIST)     98 (ls)        14 .UTIME    
      84 .FNAME      30 (SLIST)     10 (DIR)        2 DIR         56 lsdirs       2 udir       130 .DIR         4 (.DIR)    
      86 .SIZE       26 .FTIME       6 .FTIMES     44 .FDATES     16 .FDATE      48 .ATR        44 cd$          2 cd        
       4 pwd          6 cat         42 (cat)        4 FPRINT$      8 FLOAD       72 FCOPY       68 _FCOPY      22 FCOPY$    
      36 RENAME      18 RENAME$     46 APPEND      84 APPEND.BLK   38 -FERASE     18 FMAKE$      58 FOPEN       72 FOPEN$    
      16 RW           8 RO          38 FOPEN#       4 mk          68 FCREATE$    24 FCLOSE      16 >FILE       20 FILEIN    
      80 FPUTB        4 FPUT        44 FGET        10 FABORT      10 FREM         4 fwrite       4 fread       16 CLUST?    
      98 CLUSTERS?    8 endcl        4 CLUSTER@    14 @CLUSTER    36 FreeDir?    54 .ASMONTH    12 FSTAMP      26 FTIME!    
       8 @DIRBUF!    28 FDATE!       8 HMS         82 DIR?        16 UpdateDir   12 OpenDir     88 >F83        12 FILE$     
      36 ?SDCARD     60 ?MOUNT     138 MOUNT       10 cd!          6 ROOT        12 FMAX@      110 .FAT        76 READFAT32 
      18 CLUST>SECT   18 @FAT         6 @BOOT        6 @ROOT        8 FS           6 FS@          6 FSW@         6 FSC@      
       6 FS!          6 FSC!        22 ~!          14 FSADR        6 FSADR!       8 SD           6 XW@          6 XC!       
       6 XC@          6 X!           6 X@          10 XADR         6 XADR!        8 FSECT@       6 FSIZE@       8 FSIZE     
      12 dirbuf       4 dirfsa       8 @FILE       12 FILE#       56 FILE        62 SDRD        24 SECTOR      80 RDSECT    
      12 FLUSH       12 WRSECT      76 SDWR        16 !SD        136 _!SD        42 RDOCR       30 SDDAT!      30 MARKER?   
      16 ?SDTO       14 STAT@       10 ACMD        40 CMD         34 RES@        86 !SDIO       10 SDPINS       4 SDERR     
       4 SDBUSY      10 SDCLK        8 SD@         22 CARD?        4 scrc         4 sdbuf        4 wrflg        4 sector    
       6 *SDCS       12 OVER+       80 EASYFILE.fth
    

Sign In or Register to comment.