How to use XMM memory models for SD Card + small SPI SRAM layout?
matrixsmaster
Posts: 17
in Propeller 1
Hello!
I'm new to Propeller chip, but have a lot of background in other microcontrollers. I've searched through a lot of propeller and propgcc documentation, but I still can't answer a few simple questions:
1) What is a "cache"? I know that word, and know it well, but I have a strange impression, that this particular word serving multiple definitions in propeller context, like "bootstrap temporary storage" or "RAM-like device to hold all the Data (not Code, though)" or "cache" (as we know it). I'm not right, I know, but I want to read something explains the different situation or use-cases of this "cache".
2) Can I use SD card space to hold the Data? I've done it many times before with AVR chips, and this solutions are working great (but slow, of course).
3) I can use SD card to hold the Code (XMMC), I know, but can I use it as RAM as well (I thought that is xmm-single is for, besides its main purpose to serve RAM)?
4) Can I use cache with "SD card RAM" solution? It's very attractive solution, I've used it for one of my projects on AVR, and its working surprisingly fast!
5) What propeller-load options can be (and should be) used for:
6) Where can I find documentation on cache drivers?
I know this questions are obvious to answer for you, who are using propeller for years, but for me it's a total darkness. I totally confused by bits and parts of information here and there, googling for three days and two nights...
Please, if someone can, help me to understand these memory models and layouts!
I'm new to Propeller chip, but have a lot of background in other microcontrollers. I've searched through a lot of propeller and propgcc documentation, but I still can't answer a few simple questions:
1) What is a "cache"? I know that word, and know it well, but I have a strange impression, that this particular word serving multiple definitions in propeller context, like "bootstrap temporary storage" or "RAM-like device to hold all the Data (not Code, though)" or "cache" (as we know it). I'm not right, I know, but I want to read something explains the different situation or use-cases of this "cache".
2) Can I use SD card space to hold the Data? I've done it many times before with AVR chips, and this solutions are working great (but slow, of course).
3) I can use SD card to hold the Code (XMMC), I know, but can I use it as RAM as well (I thought that is xmm-single is for, besides its main purpose to serve RAM)?
4) Can I use cache with "SD card RAM" solution? It's very attractive solution, I've used it for one of my projects on AVR, and its working surprisingly fast!
5) What propeller-load options can be (and should be) used for:
a) XMM-SINGLE with some SRAM chip
b) XMM-SINGLE with some Flash memory (is it possible?)
c) XMM-SPLIT with SD card as Code storage and some SPI SRAM as Data storage
and the last question,b) XMM-SINGLE with some Flash memory (is it possible?)
c) XMM-SPLIT with SD card as Code storage and some SPI SRAM as Data storage
6) Where can I find documentation on cache drivers?
I know this questions are obvious to answer for you, who are using propeller for years, but for me it's a total darkness. I totally confused by bits and parts of information here and there, googling for three days and two nights...
Please, if someone can, help me to understand these memory models and layouts!
Comments
Spin was designed specifically for the Propeller, while C had to be shoehorned in (via XMM, LMM, and CMM). Spin bytecode is only slightly slower than CMM and is probably faster than XMM, and it's very compact so you don't need to worry about XMM or caches or anything like that, unless you try really pushing the limit. You write code, feed it to the compiler, and it just works... No linker errors, no obscure compiler flags, no need to worry about XMM/LMM/CMM, no massive libraries that eat up a large part of hub ram and force you to use XMM or CMM, and less overhead since the Spin interpreter is in ROM.
If you read the Spin tutorials, you'll be up and running in hours. Or, since you already are experienced with microcontrollers, a good way to learn Spin is just by reading other peoples' Spin programs.
http://learn.parallax.com/propeller-spin-tutorials
There's the older Propeller Tool and the newer PropellerIDE for Spin. Propeller Tool is Chip Gracey's original compiler and IDE, while PropellerIDE has more powerful IDE features and uses the OpenSpin compiler which is based off of Chip Gracey's compiler but has some optimizations and other nice features. There's also BST, which works great but hasn't been maintained in years.
Thanks, David! I suspected something like that. But what about SINGLE and SPLIT modes? (If we temporarily forget about SD card)
Thank you! But I rely on a huge amount of already written C code. For this option I had to reinvent the wheel with this strange configuration of "SD card RAM" with other microcontrollers. And for both MSP430 and AVR this method worked perfectly!
So, Spin isn't an option.
I still want to hear at least something about XMM-SPLIT and XMM-SINGLE modes with SPI SRAM, SDRAM, SPI Flash and SPI EEPROM configurations.
OK. I've got it. Have looked through C3 schematics. My last (stupid) question: is it possible to use "spi_sram_cache" driver with SDXMMC solution to buffer code transactions from SD card? SPI SRAM chip is well-known 23K256 and I've tested it already (program loaded to RAM, like in quickplayer board).
Oh, I'm sorry, until today I haven't noticed the sd_cache is a automatically enabled part of whole SDXMMC scenario. So no, I don't want slow things down.
By now I think I know what I need to know. The one question remaining. Is it possible to actively use SD filesystem driver while using SDXMMC? I've tested it today and it seems to work fine. Both debugging output and file system check results and even llogic analyzer diagrams looks surprisingly right! Is it intended to be so, or just a good luck?
1) it's slow by design (stack architecture)
2) it's an emulator in this case, so overhead is enormous.
As I figured out, XMM uses another approach: just grab the native code from outside and use it. In this case overhead consists of fetching code (or data, doesn't matter) only. Like a RAM proxy layer.
ZPU has to not only fetch the code and data, but do a bunch of actions: decode instruction, increment/decrement stack pointer, etc...
BTW, I heard about ZOG, but didn't realized that it is ZPU emu. My own PZPU emulator works on different platforms (i386, avr, pic, msp430, and now P1, although only avr and i386 are "officially" supported). It works even on 8-pin ATtiny chips, driving LCD screen terminal with keyboard.
Is it faster than XMM?
UPD: last but not least: I need to use megabytes of data space, and access to it as fast as I can. Yes, I can just grab my STM32F4 Discovery with native SDRAM support via FMC, but there's other considerations.
UPD: ZPU uses fixed 1-byte opcodes. PZPU instruction cache uses simplest possible cache strategy and have a 32-byte line. It speeds up code execution, yes, but not so much. So I implemented SCache (stack cache), which uses bidirected loading of current stack context. And SCache provides sufficient speed up.
The alternative linker script is just a minor inconvenience.
P.S. I noticed many things changed between release_1_0 branch and master. I stick for now with release branch for one thing: the loader. I haven't managed to run new propeller-load to upload SDXMMC code, but the old one (in release branch) does the job done. Maybe I missed something? My current Makefile that works with release branch propeller-load is here: https://github.com/matrixsmaster/PZPU/blob/propeller/pzpu/Makefile.prop
UPD: That's a great feature! I think I'll use it to allow user to run multiple programs without preemptive multitasking. Moreover, GUI code can run on its own pthread, am I right?
So it seems I have to port sd cache to a new propgcc in addition to write my own ram driver.
Yes and no. I need SD card and I certainly need to run my program from it. There's definitely no way to make whole OS with all modules fit into HUB ram. So at first, I need a space for code. Hundreds of kilobytes of compiled propeller code.
The next thing I need is threads. Now I'm completely sure I will not use preemptive multitasking. I've used pthreads on Linux and have some skill in multithread programming. So I would love to use pthreads on propeller.
Next, I need to access my file storage, which is located on the same SD card, as OS itself (for ease of OS upgrades, making nice little hacks, etc).
And at last, there's some big data storage inside my runtime library. This data is highly volatile. I mean, this isn't a static const table or something similar. It's a live image, like a screen buffer.
That's a setup I need to implement.
Rewriting or porting the driver seems like a simple puzzle. But what you said about XMM? Isn't it supported at all nowadays?
UPD: re-reading this thread I noticed So XMM is still alive, and all what I need - is to write the new C3-like driver. Am I right? If so, it'll be wonderful!