Shop OBEX P1 Docs P2 Docs Learn Events
SD Card Socket for P2 Community — Parallax Forums

SD Card Socket for P2 Community

Ken GraceyKen Gracey Posts: 7,392
edited 2021-02-26 03:01 in Propeller 2

Hey all,

We've got this pretty microSD card adapter in production today, which means it'll be in stock shortly. First production run is about 350 units. You can get a half dozen of these type of adapters from Amazon for $7 with free shipping, but our parts/labor cost is at least 3x the Chinese imports (which we all "pay" for through USPS e-packet losses). Plus, those Amazon versions are only "Arduino compatible" haha; they won't work with the P2.

Would you pay, say, $5.95 for an authentic Parallax version? That's a Starbucks coffee and half of a cookie or banana nut bread.

It'll plug right into your JonnyMac or P2 Eval Board. It's much more beautiful than the Amazon cheapies.

When we start shipping these, I'm hoping we can formalize the SD card code for data storage, bootup, wav file storage, etc. Kinda like we have done with other efforts: VGA, motors, HUB75, games, and serial - we'll take an inventory of what's out there and try to find the best code for use in Quick Bytes. I think @Cluso99 has some favorable code, as does @ersmith for FlexProp.

Ken Gracey

Comments

  • Ken,

    Will these have the uSD slot already soldered on? ALso, will it allow 4-Bit mode? I'm guessing yes on both accounts, but want to make sure.

    And yes, I'd pay that. Having good code examples is a plus. You don't get anything with the cheap ones.

  • Jim,

    Yes on the socket and connector. I'm sure we designed it for the most access possible.

    Fully agreed about the code examples. The minute these come off the production line I'll be hounding the SD card wizards for drivers. We're going to get this done!

    @VonSzarvas will verify shortly the question about the I/O interface.

    Ken Gracey

  • hinvhinv Posts: 1,255

    @JimFouch2 said:
    Ken,

    Will these have the uSD slot already soldered on? ALso, will it allow 4-Bit mode? I'm guessing yes on both accounts, but want to make sure.

    And yes, I'd pay that. Having good code examples is a plus. You don't get anything with the cheap ones.

    Yeah, 4-Bit mode is important, especially if it taking up a whole 8-bit connector. Having them supplied from parallax in large quantity as a 4-Bit socket will mean way faster SDcard transfer rates for those projects that need it. If will do 4-bit mode, I'll take 3. I'll take 10 if you'll take Bitcoin Cash.

  • Cluso99Cluso99 Posts: 18,069

    Ken,
    The SD pasm cog driver is done and complete. It's a totally self contained object using a very simple 4 long hub mailbox interface usable by spin/pasm or anything else that can access the hub ram mailbox. The driver can also locate and load a file from the FAT32 on the SD card. Currently it doesn't support multi-sector read or writes, nor the streamer, nor the 4-bit interface. However it is
    otehrwise FAST because it uses unravelled code and rep to advantage.

    My conversion of Kye's FAT32 still has bug(s) working with spin and the serial driver. It's fine using the ROM serial driver tho. This doesn't make sense.
    Once this works, the P2 OS will follow along quickly.

    As you know, I've been on something else this past week ;)

  • roglohrogloh Posts: 5,786
    edited 2021-02-26 06:10

    Currently it doesn't support multi-sector read or writes, nor the streamer, nor the 4-bit interface. However it is otehrwise FAST because it uses unravelled code and rep to advantage.

    So how fast is it currently Cluso? Without multi-sector reads, streaming application performance might be limited. Is there a plan to add multi-sector stuff? Also is there a limit to how fast the P2 can run when using it? Has that been tested out?

    It would be very good if this or a future Parallax breakout board supported 4 contiguous SD data bits for (the possibility of a future) 4 bit SD mode on an 8 bit boundary which would then allow use of the streamer. I know it somewhat messes up the P2 pin order for regular SPI based SD leaving gaps in the 8 bit port due to the SD pin mapping, but given nothing else can be plugged into the same 8 pins, it's probably less of a big deal to burn a couple of extra pins there.

  • Cluso99Cluso99 Posts: 18,069

    @rogloh said:

    Currently it doesn't support multi-sector read or writes, nor the streamer, nor the 4-bit interface. However it is otehrwise FAST because it uses unravelled code and rep to advantage.

    So how fast is it currently Cluso? Without multi-sector reads, streaming application performance might be limited. Is there a plan to add multi-sector stuff? Also is there a limit to how fast the P2 can run when using it? Has that been tested out?

    It would be very good if this or a future Parallax breakout board supported 4 contiguous SD data bits for (the possibility of a future) 4 bit SD mode on an 8 bit boundary which would then allow use of the streamer. I know it somewhat messes up the P2 pin order for regular SPI based SD leaving gaps in the 8 bit port due to the SD pin mapping, but given nothing else can be plugged into the same 8 pins, it's probably less of a big deal to burn a couple of extra pins there.

    Not a straight forward answer, but...
    SD cards are slow to get going. So, when you issue a command, the majority of the time is wasted in waiting for the SD card to say it's ready to read/write a sector. Once we get to that point, and IIRC it's anywhere from 10's to 100's of ms to get going, then it is a few additional clocks plus 4 instructions per bit, so 512 * 8 * 4 * 2 = 32,768 clocks plus a handful for the crc plus 512 *2 =1024 clocks to read/write from/to hub (it uses RFbyte/WFbyte so it's via the cache). So 32,768 + 1024 = 33,768 clocks so maybe 35,000 clocks to be safe, which at 200MHz = 175 us. If my maths is correct, then 512 / 175 MHz = 2.9 MB/s but remember, this is after the SD card is ready for data transfer.

    The SD driver reads/writes direct from/to hub so there is no cog/lut buffering going on.

    Yes, if the driver gets use then I'll add multi-sector read/writes. It's not too difficult to add this, but currently I'm busy with other P2 projects, and of course the FAT32 spin code that goes with it for additional features.

  • Here's the schematic.

    We've gone SPI mode and included the series R for P2 Boot compatibility. So no to the 4-bit support here.

    I suppose P56 and P57 could have been used for DAT1 and 2, but that 240R is still going to be a hinderance, right ? And the pin order is not good anyway given that the board is configured to allow Boot from SD. (It would be: P56=DAT2, P57=DAT1, P58=DAT0, P59=CMD, P60=DAT3, P61=CLK)

    Almost feels like 4-bit mode needs another P2 header on the opposite side of the board, instead of the single SIP header. Have that wired with direct connections to the SD pins in a nice consecutive way. Then you just plug the board onto the P2 Accessory Header whichever way round you need (4-bit mode or SPI/Boot mode).

    Maybe this works for all use cases, and continues to allow breadboard / FLiP / P1 uses too:

    4 bit connector:
    P basepin +0=DAT0, +1=DAT1, +2=DAT2, +3=DAT3, +4=CMD, +5=N/C, +6=CLK, +7=DET (DAT0 through 3 pinout could be reversed without disturbing all use cases)

    SPI/Boot connector (as in schematic):
    P basepin +0=N/C, +1=DET, +2=240R to MISO, +3=MOSI, +4=CS, +5=CLK, +6=N/C, +7=N/C

    With any luck, for breadboard users, they will still be able to use two male pin header to grab the desired signals to breadboard. That assumes the 2nd P2 header could be configured in a way to allow a single row on each side of the board to provide all the signals.

    Maybe we could do that later, once the 4-bit drivers become reality.

  • VonSzarvasVonSzarvas Posts: 3,449
    edited 2021-02-26 09:49

    The pin order shown here is not quite perfect, as I was mainly curious about overall dims. Now it's drawn, figured sharing might help explain the prior post!!

    Although.... Feels like that got overly complicated with supporting all options. Pumps up the price too.

    I'm thinking 4-bit mode SD is best as another simple (and smaller) product. 2x6 connector, SD socket. No other breakouts
    Yep- that seems neater ! :)

  • roglohrogloh Posts: 5,786
    edited 2021-02-27 01:47

    @VonSzarvas With your 1 spare pin left on your 4-bit mode SD breakout variant/end, maybe you could add in an LED to be optionally flashed in SW during card access or card detection because the CS pin, which is also useful for doing that, is lost in the SD mode. That would consume the 8 pins nicely.

    I quite like the double ended version too by the way. Neat idea. :smile:

    Also for breadboard use, you could always try to drill holes up one side of the board for external connections to these signals.

  • Ken: I sent you some samples of using the SD card from FlexProp earlier, so this is quite timely. Did you get those?

    The next version of FlexProp will allow you to specify the pins for the SD card file system. Looks like I should probably add a feature to support multiple cards for P2 eval board users who have one of these breakouts as well.

  • VonSzarvasVonSzarvas Posts: 3,449
    edited 2021-02-26 14:38

    @rogloh said:
    Also for breadboard use, you could always try to drill holes up one side of the board for external connections to these signals.

    Yeah, that would be the way to handle that behemoth !

  • @"Ken Gracey" said:
    Would you pay, say, $5.95 for an authentic Parallax version? That's a Starbucks coffee and half of a cookie or banana nut bread.

    It'll plug right into your JonnyMac or P2 Eval Board. It's much more beautiful than the Amazon cheapies.

    Six bucks? Heck yes! At these prices the shipping will probably be more than the board. :)

    Amazon is what I use for getting past the disposable (read “purple smoke”) phase of the learning curve. Long term quality is usually shoddy and any money I saved initially tends to be spent on ibuprofen later when things work unexpectedly.

    Parallax can take my money. It is well-spent IMHO. And the Parallax support is priceless. TAKE MY MONEY KEN!!

  • @JRoark said:

    @"Ken Gracey" said:
    Would you pay, say, $5.95 for an authentic Parallax version? That's a Starbucks coffee and half of a cookie or banana nut bread.

    It'll plug right into your JonnyMac or P2 Eval Board. It's much more beautiful than the Amazon cheapies.

    Six bucks? Heck yes! At these prices the shipping will probably be more than the board. :)

    Amazon is what I use for getting past the disposable (read “purple smoke”) phase of the learning curve. Long term quality is usually shoddy and any money I saved initially tends to be spent on ibuprofen later when things work unexpectedly.

    Parallax can take my money. It is well-spent IMHO. And the Parallax support is priceless. TAKE MY MONEY KEN!!

    @JRoark thank you for the support. We will prepare our bankers in Switzerland for the wire transfer! I'll be sure we post objects that work, exercising them myself like an absolute newbie.

    Ken Gracey

  • Yes, $5.95 is a good price. As soon as the modules become available, I will probably have to order a P2 Mini Starter bundle with that. My robot project has to be upgraded to a P2 system.

    Ray

  • hinvhinv Posts: 1,255

    @VonSzarvas said:
    The pin order shown here is not quite perfect, as I was mainly curious about overall dims. Now it's drawn, figured sharing might help explain the prior post!!

    Although.... Feels like that got overly complicated with supporting all options. Pumps up the price too.

    I'm thinking 4-bit mode SD is best as another simple (and smaller) product. 2x6 connector, SD socket. No other breakouts
    Yep- that seems neater ! :)

    I'm no signals expert, but could the unterminated connector on the other side send back reflections back on the lines and interfere with signaling at high rates?
    I don't know what the top performance will be on the P2, but odroids drive microSD's in excess of 70MB/s, which is over 140MHz signalling at a minimum.
    I'm thinking you are right that there should be 2 versions, or maybe just the 4bit version pinouts as it seems there is already going to be a microSD card on the P2Edge w/memory.
    For breadboarding, wouldn't bother creating a parallax product as there are already many options out there cheaply on ebay, and it looks to me like the best breadboarding option out there is the Jonny Mac board.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-02-27 02:21

    The TAQOZ in ROM can be redirected to another SD card socket which you can mount and DIR to and even explore the hex dump of a file etc. Just change the sdpins variable to match your configuration in the order of CS.MISO,MOSI,CLK using the & prefix to encode decimal bytes.
    TAQOZ# sdpins .L --- $3C3A_3B3D ok
    Which to set in the first place is &60.58.59.61 sdpins ! where 60 is encoded to a byte $3C, and 58 as $3A etc. Of course you can enter it as a hex number too.
    (edit: I forgot that sdpins is a constant which can still be changed like this: &60.58.59.61 ' sdpins 2+ !

    It's even easier in TAQOZ RELOADED btw.

    Here's a short terminal capture talking to the SD.

    -------------------------------------------------------------------------------
      Parallax P2  .:.:--TAQOZ--:.:.  V1.1--v33h         190219-1900
    -------------------------------------------------------------------------------
    TAQOZ#  ---  ok
    TAQOZ# MOUNT --- .SDSL08G 6269_0201 P2 CARD    64k 7,576M ok
    TAQOZ# DIR --- 
    .SDSL08G 6269_0201 P2 CARD    64k 7,576M
    ROOTDIR      $0000_2686   1980.00.00.00.00   0
    _BOOT_P2.BAK $0000_2806   2021.02.08.14.58   131,072
    CONFIG       $0000_2906   2021.02.24.11.34   65,536
    MINION  .BMP $0000_2986   2021.01.24.13.08   231,478
    TAQOZUP .WAV $0000_2B86   2021.01.26.22.05   899,834
    _BOOT_P2.BIY $0000_3286   2021.01.25.19.11   131,072
    DESKTOP .BMP $0000_3386   2021.01.26.22.04   231,478
    SED     .BLK $0000_3506   2021.02.04.19.58   65,536
    SED     .FTH $0000_3586   2021.02.02.11.31   6,141
    EXTEND  .FTH $0000_3606   2021.02.02.11.18   67,591
    MEDIA   .FTH $0000_3706   2021.01.29.13.51   53,047
    FILE    .FTH $0000_3786   2021.01.27.22.30   46,022
    P2ASM   .FTH $0000_3806   2021.01.24.04.59   34,647
    EXTEND  .BLK $001B_C206   2021.02.05.16.09   131,072
    AF O N T. 8  $2100_2686   1980.02.14.00.02   4,294,901,760
    FONT8X8 .BIN $001B_C306   2021.02.21.22.51   2,048
    WAV          $0000_3886   2021.02.02.12.11   0
     ok
    TAQOZ# 0 FOPEN ---  ok
    TAQOZ# 0 $80 SD DUMP --- 
    00000: 14 15 80 FD  50 32 20 20  20 20 20 20  03 00 00 00     '....P2      ....'
    00010: 00 2D 31 01  00 C2 EB 0B  F8 09 00 01  00 10 0E 00     '.-1.............'
    00020: 00 01 02 03  04 00 00 00  CC 0C 00 00  00 AC 1C 10     '................'
    00030: 35 36 00 00  BC 05 00 00  20 31 00 00  3A 00 00 00     '56...... 1..:...'
    00040: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00050: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00060: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00070: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................' ok
    TAQOZ# 
    TAQOZ# @ROOT FOPEN 0 $80 SD DUMP --- 
    00000: 52 4F 4F 54  44 49 52 20  20 20 20 08  00 00 00 00     'ROOTDIR    .....'
    00010: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00     '................'
    00020: 5F 42 4F 4F  54 5F 50 32  42 41 4B 20  00 2D 8B 21     '_BOOT_P2BAK .-.!'
    00030: 39 52 44 52  00 00 57 77  48 52 03 00  00 00 02 00     '9RDR..WwHR......'
    00040: 43 4F 4E 46  49 47 20 20  20 20 20 20  00 48 8D 21     'CONFIG      .H.!'
    00050: 39 52 39 52  00 00 40 5C  58 52 05 00  00 00 01 00     '9R9R..@\XR......'
    00060: 4D 49 4E 49  4F 4E 20 20  42 4D 50 20  00 53 8D 21     'MINION  BMP .S.!'
    00070: 39 52 39 52  00 00 1C 69  38 52 06 00  36 88 03 00     '9R9R...i8R..6...' ok
    
  • jmgjmg Posts: 15,173

    @VonSzarvas said:
    I'm thinking 4-bit mode SD is best as another simple (and smaller) product. 2x6 connector, SD socket. No other breakouts!

    I'm a bit lost, is the card shown in #1, this 4 bit one ? The Eval boards already have 1-bit microSD card sockets, so it seems a 4 bit alternative would be sensible ?

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-02-27 02:18

    SPI mode or 4-bit SD mode is totally up to software as long as you have all 6 I/O connected and arranged favorably for 4-bit mode.

    But it seems to me that if you need a card detect switch for 4-bit mode that will make 7 I/O, that you should at least use the other I/O for a 20 cent supply enable to ensure the card resets to the default mode.

  • roglohrogloh Posts: 5,786
    edited 2021-02-27 03:12

    Yeah makes sense Peter to have full control. I think the card detect and optional LED function could be combined anyway. P2 could sense the switch being pulled low (potentially via the LED, depending on voltage drop) and disconnect it to be able to flash it. An activity LED doesn't need to be able to light up when the card is not even inserted.

Sign In or Register to comment.