Shop OBEX P1 Docs P2 Docs Learn Events
More Memory for Code..? — Parallax Forums

More Memory for Code..?

A while ago I bought the (#32312) Micro SD Card adapter after (I think) reading about how it could be used for data logging and for executing spin programs. But, I can't seem to find it anymore. And there's not a whole lot of info on OBEX. Prop can execute code written on a SD card, right?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2016-06-16 17:52
    The SD card acts just like it would if it were plugged into a PC with an SD card slot. It stores files. You can log data to one or more files and you can store programs on a card. A number of the SD card I/O drivers in the OBEX can load and execute a program from an SD card (like this one). FemtoBasic (here with other versions also in OBEX) is a simple Basic interpreter that includes the ability to read and write files on an SD card and load either other Basic programs or a Spin program from an SD card. Tachyon Forth also has I/O drivers for SD cards. Propeller C has SD card I/O drivers as well and can execute compiled C code from an SD card file ... there's a significant speed penalty to doing so, but it can be done.

    For documentation, look at <learn.parallax.com>. The Propeller Board of Education and the Propeller Activity Board both have micro SD card sockets on the boards and you can wire your adapter to pretty much any set of 4 I/O pins the same way. If you want, just look at the schematic for either board and wire up your adapter the same way.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    One of our former application engineers created an application that goes on an SD card and gives you a menu of programs to run. When you choose one it loads and runs that program. I can look it up if you're interested.
  • When you choose one it loads and runs that program.

    But the programs themselves are limited to the ROM on the propeller, right (32k)?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Jim,

    Correct. PASM code runs within the COG RAM whle SPIN code runs from the shared 32K RAM. The Kiosk application I refer to would bootstrap 32K images from the SD card.
  • HI
    Chris Savage
    One of our former application engineers created an application that goes on an SD card and gives you a menu of programs to run. When you choose one it loads and runs that program. I can look it up if you're interested.

    I'd be interested to see that code thanks

    Dave
  • As I recall, it was written in FemtoBasic. A series of numbered choices was displayed on a screen ... probably video and the user was asked for their choice. The input was used to select a SPIN statement to load and execute the requested program. Each program was just a file containing the .bin output of the Spin compiler.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    I believe Mike is correct. See attached.
  • I haven't been reading the Prop 2 threads, how much memory (to be saved on EEPROM) will it have?
  • jim you are confusing things here.

    First, ROM is Read Only Memory. Filled with content at the time the chip is made. You are not able to change it.

    Program execution uses RAM, Random access memory. the P1 has 32KB shared (Hub)-RAM and each COG has its own 2KB of RAM to execute code.

    As pointed out you can use the SD card to load different spin programs, but a single program still is bound to 32KB in spin.

    PropGCC the C/C++ compiler for the P1 can use virtual memory (either SD card or external spi ram or bigger eeproms) so you are able to run larger programs as will fit into the 32KB of hub memory.

    The upcoming P2 chip will have 512KB of ram, so has way less restrictions on code size - but - is not there yet.

    Enjoy!

    Mike
  • Thanks

    Having a look

    Dave
  • and then there is spin2cpp, converting spin to c/c++.

    that would be also a way to run larger spin programs with propgcc

    Enjoy!

    Mike
  • msrobots wrote: »
    and then there is spin2cpp, converting spin to c/c++.

    that would be also a way to run larger spin programs with propgcc

    Enjoy!

    Mike
    I'm not sure you could run much larger programs unless you used the XMMC memory model which isn't reallly supported by any Parallax boards other than the C3 which is being discontinued.

  • Jim the HermitJim the Hermit Posts: 79
    edited 2016-06-17 17:29
    When I'm talking about memory, I mean how big of a program can it hold with the power off.
    I quickly ran out of space on the BS2. I don't think 32k is enough for what I want to do (I'm trying to build a robot pet), but I plan on using 2 props because I need more I/O pins. 512k is better, but a meg or two would put my mind at ease.

    I was hoping the prop could use the sd card for program memory, but it doesn't work that way.

    BTW
    The prop can play wav's from the card, could it record them to it in the adapter as well? (with additional recording components)
  • When I'm talking about memory, I mean how big of a program can it hold with the power off.
    I quickly ran out of space on the BS2. I don't think 32k is enough for what I want to do (I'm trying to build a robot pet), but I plan on using 2 props because I need more I/O pins. 512k is better, but a meg or two would put my mind at ease.

    I was hoping the prop could use the sd card for program memory, but it doesn't work that way.

    BTW
    The prop can play wav's from the card, could it record them to it in the adapter as well? (with additional recording components)
    You could replace the stock EEPROM with a larger one. I'm pretty sure you can get 1MB EEPROMs. You'd have to verify if the Propeller can boot from them though. Most people use 32K or 64K. I think all current Parallax boards have 64K EEPROMs. And, has already been discussed, you can load programs off of an SD card. The only way I know of to get a single program >32K to run is to use XMM with either PropGCC or Catalina C. Or, if it's Spin code, you could use spin2cpp and run the resulting code in XMM mode.

  • That's interesting, mine goes up to $7FFF, that's 32K
  • That's interesting, mine goes up to $7FFF, that's 32K
    Are you talking about your EEPROM? What board do you have?

  • Even if you use a larger EEPROM than 32K, any single Spin program is limited to 32K. What you can do is store multiple programs in the extra EEPROM and load and execute them as needed. The code needed to load and execute a program from EEPROM is smaller than the code for a program on an SD card.

    If you get much beyond a couple of Spin programs, you're better off using an SD card or serial Flash chip. There is a simple serial Flash driver in the OBEX that can load and execute Spin programs as well as reading and writing named files and there's a simple wear levelling algorithm used (not so good but better than none).
  • msrobotsmsrobots Posts: 3,704
    edited 2016-06-17 22:59
    @Mike Green,

    Large Spin is possible via spin2cpp and XMM. Not very practical but interesting. I just tested XMM on a C3 board successful, never got that Parallax Memory card to work on my other boards I have.

    Since I prefer SPIN over C/C++ I never investigated it further what other external Memories PropGCC supports. But I remember there is support for bigger EEPROMS, SD-Card and SPI Ram.

    Sure it is slower and I guess you are still restricted by Hub space for variables and needed buffers, but there is support for larger C/C++ programs as would fit into 32KB.

    Sadly Parallax has no Board sold with extra RAM to set up some standard to use it except the C3, having that curious SPI select schema.

    So the PropGCC guys did their part of the work, but no HW was provided and interest got lost, I guess.

    Hopefully the P2 will solve the SPIN size restriction, but I still think it would be nice to have native SPIN byte code running in a virtual memory space.

    A couple of people here made custom SPIN interpreters, using some HUB ram to extend the available size for the interpreter. I am sadly to stupid to do things like that or do not have the time to dig deeper into the interpreter source, Chips code is somehow overwhelming.

    But if all (most?) HUB access of the interpreter would be redirected to some memory-cache-driver for external SPI RAM or whatever PropGCC already has, then SPIN could grow quite big.

    Basically all modules are able to be relocated already, sadly @Chip used 16bit(?not sure?) pointers, there are some old threads about this.

    Maybe the HyperRam efforts will bring some approachable way to standardize things.

    Enjoy!

    Mike
  • Jim the HermitJim the Hermit Posts: 79
    edited 2016-06-18 00:32

    David Betz wrote: »
    That's interesting, mine goes up to $7FFF, that's 32K
    Are you talking about your EEPROM? What board do you have?

    Rev A, apparently.
  • Mike Green wrote: »
    Even if you use a larger EEPROM than 32K, any single Spin program is limited to 32K. What you can do is store multiple programs in the extra EEPROM and load and execute them as needed. The code needed to load and execute a program from EEPROM is smaller than the code for a program on an SD card.

    If you get much beyond a couple of Spin programs, you're better off using an SD card or serial Flash chip. There is a simple serial Flash driver in the OBEX that can load and execute Spin programs as well as reading and writing named files and there's a simple wear levelling algorithm used (not so good but better than none).

    Wait a minute, the spin language is built with a limit of 32k??? Running multiple programs is completely useless to me. I would like to experiment with a software based neural network (or at least try)

  • David Betz wrote: »
    That's interesting, mine goes up to $7FFF, that's 32K
    Are you talking about your EEPROM? What board do you have?

    Rev A, apparently.
    Rev A QuickStart? I think only the *very* early ones had only 32k EEPROMs and I'll bet Parallax would exchange his for one with the larger EEPROM since they were advertised as 64k even at the beginning.

  • Heater.Heater. Posts: 21,230
    The Propeller is a micro-controller. You can fit 32K of code and data into it's RAM space if you program in Spin or C using LMM/CMM mode.

    There is 8 cores with space for 512 LONGS (32 bits) of instructions and data each.

    If that is not enough for what you want to do it really is time to look for something else. Like an ST32 F4. Or whatever.

Sign In or Register to comment.