New XMM hardware
Dr_Acula
Posts: 5,484
I'd like to test out GCC with the latest touchscreen schematic. I've read this page http://code.google.com/p/propgcc/wiki/PropGccExternalMemory
The cog pasm routines are already written and so hopefully are easy to integrate. I see some clever person has added the Dracblade. This was built on software originally written by Cluso99 that had a very simple interface format between spin and the cog. Send 4 longs:
1) is a single ascii character instruction eg "A" is move a block from hub to ram, "B" is move a block from ram to hub etc ("I" is reserved for "initialize")
2) is the hub address
3) is the external ram address
4) is the number of bytes.
and then wait for a long to change to say the operation is completed.
The touchscreen external ram driver uses the same interface, so whatever is working on the Dracblade ought to be possible to port over to the touchscreen without too many changes.
Can some kind soul please point me in the direction of the code used for the Dracblade external ram driver - I'm hoping I can just make a few changes and post the new pasm code.
Many thanks in advance.
The cog pasm routines are already written and so hopefully are easy to integrate. I see some clever person has added the Dracblade. This was built on software originally written by Cluso99 that had a very simple interface format between spin and the cog. Send 4 longs:
1) is a single ascii character instruction eg "A" is move a block from hub to ram, "B" is move a block from ram to hub etc ("I" is reserved for "initialize")
2) is the hub address
3) is the external ram address
4) is the number of bytes.
and then wait for a long to change to say the operation is completed.
The touchscreen external ram driver uses the same interface, so whatever is working on the Dracblade ought to be possible to port over to the touchscreen without too many changes.
Can some kind soul please point me in the direction of the code used for the Dracblade external ram driver - I'm hoping I can just make a few changes and post the new pasm code.
Many thanks in advance.
Comments
http://propgcc.googlecode.com/hg/loader/spin/dracblade_cache.spin
Hope you can read it. David will probably be around tomorrow if you have questions.
You can use BSTC -C to compile your new cache driver and put it in the c:\propgcc\propeller-loader path. This can be compiled in a SimpleIDE project, but you have to copy the new driver to the aforementioned path. The resulting file will be something like newdriver_cache.dat assuming your source is newdriver_cache.spin
You might consider a temporary config file name like dractouch.cfg or something, I'll use that here for simplicity.
All you have to do to use newdriver_cache.dat is copy the file in c:\propgcc\propeller-loader\dracblade.cfg to some new file such as c:\propgcc\propeller-loader\dractouch.cfg and then change the "cache-driver: dracblade_cache.dat" line in dractouch.cfg to "cache-driver: newdriver_cache.dat".
Once you have a new dractouch.cfg all setup, just click the jigsaw puzzle piece in SimpleIDE to reload the board config types.
Then you can choose dractouch.cfg before clicking the blue right arrow Run Console button F8 or the green right arrow Run button F10.
There is a tool available for testing a newdriver_cache.spin in the repository.
It's here: http://propgcc.googlecode.com/hg/loader/spin/test_cache.spin
You will also need this: http://propgcc.googlecode.com/hg/loader/spin/cache_interface.spin
In test_cache.spin, you can change the "mdev" object from mdev : "eeprom_cache" to mdev : "newdriver_cache".
As for the program to compile and load, well I can't with that tonight or tomorrow. Busy day ahead for me tomorrow.
Hope this helps some.
Thanks,
--Steve
Forum software is horrible these days
Quick question;
The touchscreen is reading and writing in words rather than bytes. Simple answer is to shift count >>1. Can I assume that "count" is always an even number?
Also, I'm working through the step-by-step instructions in the Quickstart pdf file and there does not seem to be a "demos" folder. In fact, searching through all the files in the propgcc folder, I have lots of .h files but windows could not find a single .c file nor anything with toggle.* Seems a bit odd.
I'm not sure about why you can't find the demos directory. You can find it in Google Code here: http://code.google.com/p/propgcc/source/browse/#hg%2Fdemos
You'll find a 'toggle' directory under 'demos' with lots of versions of the toggle program.
Ok, what I have is a board in front of me doing all sorts of cool icons and touchscreen things. But the design is about to be superseded by a new design (based on a brilliant idea from jazzed) and that board won't be here till next week. Coding the pasm driver can be done on the board I have but the code will end up being changed very soon. So I think I will wait till the new board arrives. It will need some code to drive the 74HC237 (even though that will only be a few lines of code, I put some debugging leds on the board as I've never used this chip before). On the plus side, I've ordered 10 boards so if they work I've got spares I can give away to anyone wanting to help out.
Which brings up the next step - debugging. On the touchscreen I wrote a slow routine that takes the propeller font from inside the propeller and puts it on the touchscreen. This works without an SD card so you can display a message to say there is no SD card.
But for debugging C right at the very start, I wonder if the serial port might be easier as it can be used to get things working before the display is working.
So...
would anyone have a very simple C program that sends "Hello World" back up the P30/P31 serial lines to a terminal program? And if possible, maybe add a 5 second delay so there is time to do a download and then fire up a terminal program to check the data coming back.
I'm thinking of the way I got the current version working, which was to code every pin logic level change in Spin first, and then port each spin routine over to pasm. So I guess that might be one way to do it in C as well. On the other hand, you might look at the pasm and say - hey that is easy to port over. Maybe it is - it does work rather like a cache. The display startup is still in spin though and so would go to C. And so I guess I'll be asking dumb things like how to do dira and outa in C.
SimpleIDE packages come with a hello demo for P30/31. Other demo programs are also included.
Download here: http://propside.googlecode.com/files/Simple-IDE_0-6-7_setup.zip
User guide is here: https://sites.google.com/site/propellergcc/simpleide/user-s-guide
A: YES!
See attached screenshot. Download the program, F10 and open the terminal.
Well, hats off to the GCC team and congratulations. You guys have made C super easy to use on the propeller.
1) Toggle a led in C
2) Toggle a led by calling a pasm routine from C, and the pasm routine toggles the led
3) Write xmm driver primitives in C to send a byte to xmm, and return a byte
4) Port each routine over to cog pasm code
5) Test running this as actual xmm
I'm up to step 2. Use link from post #7 David Betz for the demos
Scroll to the "toggle" program.
Grab both the C code and the Spin code.
From the way these are separate I surmise that GCC is working with "binary blobs", precompiled in a spin compiler.
This is the spin bit
and this is the C bit
Now in Spin, that would be one program, not two. This sort of thing can be glued into one program - I wrote an IDE for Catalina that put some tags around the pasm/spin bit and then wrote a simple program the split it all up, send the pasm bits off to BST and the C bit off to the C compiler.
So here is a question. If there is a "COG" mode in SimpleIDE and also a "LMM" mode, can you combine both in the same program? Have some C code that goes into a cog, and some C code that is the "main" program. Maybe with some sort of tag around the bit of code that goes into the cogs. Then it becomes one program, not two like "toggle" above?
If that is possible, then the whole program can be pure C and you don't have to learn pasm.
I'd have not said such a thing until recently when heater pointed out his FFT was running almost the same speed compiled from C as it was in native pasm.
Meanwhile - thinking about that some more, I think I'll do things in a different order. I have xmm code already working in a spin program. So I think I'll just grab the pasm bit plus the minimal spin so it compiles and turn that into a binary blob. Then translate the Spin driver into C.
Well, the SimpleIDE might be simple to use but it is very clever behind the scenes. A little drop-down menu in the top right corner with all the hardware boards. The Dracblade works for a XMMC program right out of the box. All those hardware configs had be coded and that must have been a lot of work.
Also the text highlighting in the code. I've written code to do that and it is very complicated. Again, it is all there and working and easy to work out without even reading a help file.
Ok, a new driver.
This is the Dracblade driver using latches to talk to an external ram chip
This is the very clever code David Betz wrote http://propgcc.googlecode.com/hg/loader/spin/dracblade_cache.spin
and this is the complete driver code for the touchscreen
I guess the first thing to point out is there are a lot of extra functions in that code that can be ignored. At the core are just two routines - move a block of data from hub to ram, and move a block of data from ram to hub.
In every routine there is one common call, which collects the variables from the calling program
and just to cause myself and others confusion, in the new code this routine has changed names to
It does the same thing though which is this
Next thing is a startup routine. David Betz calls this BSTART
For the dracblade this sets the high latch with address A16-A18.
On the touchscreen, the equivalent code is
which loads up the 161 counters with the starting address.
I'll just note here that in the middle of David's BSTART routine there are some cache lines of code eg
and a couple more at the end. So those will need to be replicated in the load161pasm driver code.
So once that is done, I think the aim is to replace this read loop
with this code
A couple of things to note there. First, all my routines finish with a jmp #init. All David's routine finish with a ret. Whatever happens, ultimately the cog routine must end by tristating all the propeller pins, ie
And the other thing to note is that there are two ram chips so it is reading in a word at a time, not a byte at a time. So hubaddr etc are incremented by 2 rather than by 1 each loop. So somewhere along the line, len will need to be divided by 2 for cache access (but not for access from within C code).
I suppose we have to work out what this board should be called. The easy answer might be a Touchblade, but I don't want to monopolise the "touch" part as I am sure many other touchscreens will end up supported by GCC.
So I think this encapsulates all the code and bits that need to change.
A general question first. The ILI driver code does multiple things in one cog, because each routine is small so lots can be fitted into a cog.
Is it possible to "share" the cache code and the display driver code in one cog?
If so, how do we send commands like Cluso99's single letter commands, and also send a cache command?
OR (and probably easier), split it up and have the cache code run in one cog, and do all the video driver code in another cog.
If we go for option #2, then the code becomes much simpler. Just ram to hub and hub to ram. I might start with that first and then think about combining cogs (to save a cog) later.
Yes. The SD cache driver does just that. It supports the XMM kernels by handling code-memory read cache misses, and it also handles generic block read/write commands for the C library's SD file system interface.
The trick is found in lib/drivers/load_sd_driver.c/file_io.c - in that code, you'll notice code similar to this:
The C library uses this code to send SD sector commands to the underlying cache driver. These are the extended commands that David mentioned. Check out the full source at http://code.google.com/p/propgcc/source/browse/lib/drivers/file_io.c. You might also want to check out the SD cache driver at http://code.google.com/p/propgcc/source/browse/loader/spin/sd_cache.spin.
Note that this code also supports using a separate driver that does just the sector read/writes needed by the library (your "option #2"). This works when you need SD card access in LMM mode and also when you need SD card access and you're using a different caching mechanism (most likely because all the other caching mechanisms are faster than the SD card cache). In these cases, the split driver is necessary because there is no SD cache driver!
To see this, check out http://code.google.com/p/propgcc/source/browse/lib/drivers/sd_driver.s and notice how similar it is to the aforementioned SD cache driver - just the cache code is missing. This file is loaded manually by the library in http://code.google.com/p/propgcc/source/browse/lib/drivers/load_sd_driver.c. (BTW, the sd_driver.spin driver in loader/spin looks almost 100% identical to this driver - but this driver is not used by the C library, it is solely used by the loader.)
Also note that it works 100% fine when both the SD cache driver and the SD library are loaded at the same time (again, your "option #2"). This wastes a cog, but it does work.
Speaking of SD cards, I see there is an option in the dropdown menu "Dracblade-SDXMMC". What does that do?
And are there any xmm models out there where the program is stored on an SD card? Sounds a bit crazy, but with caching, it ought to be no slower than storing a program in serial sram or serial flash.
In SimpleIDE version 0-6-7 the -SDXMMC and -SDLOAD board types don't work. I have fix and will post later today.
The user's guide explains these, but for convenience ....
Program->Run (F10) and Program->Run Console (F8) buttons:
Dracblade-SDLOAD should put your program on SDCard and load it to SRAM and run.
Program->Burn (F11) button:
The AUTORUN.PEX program can be replaced by copying it to SDcard - then you reset the board to run it.
Program->Build (F9) button:
The a.pex file can be copied to SDcard as AUTORUN.PEX for booting after burning the EEPROM.
Tools->Send File to Target SDCard:
By default in XMM modes it will create a new AUTORUN.PEX program.
You can choose to send that or any file serially to the target SDCard.
I often use it to just copy AUTORUN.PEX to the SDCard using the filesystem.
Prof Braino suggested something similar recently too. Thinking of the way a touchscreen OS might work, you have a "main" program that waits for the user to touch a key. Then it loads up an operation, eg a calculator, or a picture viewer, and that would need some cache changes. But while a calculator is running, no cache updates would be needed as it would all fit in a few kilobytes. So maybe SD cache is a "generic" option for many boards?
If so, could one think about a SD cache driver that worked on the dracblade by defining pins 12,13,14,15 and worked on the various demoboards by devining pins 0,1,2,3 and worked on the Touch161 board by defining pins 24,25,26,27.
Maybe you already have this for the demoboards?
Re the 512 byte sector size, all my programs seem to end up with an array "byte sdbuffer[512]" so if you had that and you read in 512 bytes and the next cache read request happened to be already in the buffer, could you detect that and not have to read the sd card again?
Thanks++
If yo have a generic SD XMM version then this might end up a super simple solution for both myself and for others with different boards. Just take the board I have and change the pin numbers. (see post #22. The order of pins on the touch161 is the same order as the dracblade. I'm not sure about gadget ganster boards though).
I've designed boards with multiplexed pins for SD cards but in the end it is simpler to use existing code and just devote 4 propeller pins to SD cards. Which means that a solution for the dracblade will work for the gadget ganster board and the touch161 board. Just change the pin numbers.
This could open up large C programs for a whole lot of people who have boards with SD cards.
I'm really excited about the whole "cache and run from an SD card" concept - it has so many possibilities.
Dr. Acula:
I have adding both a full-size- and a micro-SD to the demo board and it works fine. Just like David said, all you have to do is provide the appropriate loader config file in the propeller-load directory.
To convert an existing config to allow it to be used with SD caching:
1) Add the following parameters - these use the pins I used for my demo board:
sdspi-do: 4
sdspi-clk: 5
sdspi-di: 6
sdspi-cs: 7
Note that there are 4 additional sdspi- parameters that allow you to using address multiplexing on the SPI bus - check the code or ask for an explanation if you want to use them.
2) If you're going to use the IDE, add a line near the top like this:
# IDE:SDXMMC
Note that you do not have to include the "sd-driver: sd_driver.dat" line unless your board provides some caching mechanism and you want to run your program using the alternate SD card execution method (the sd-loader method that reads your entire program and tosses it to the cache before starting).
- Ted
I tired doing that but have run into some problems.
1) Change the file "propboe.cfg" so the pins are correct for my sd card. (same order, just add 2 to each number)
corrected file below
Now compile a program using simpleIDE. PROPBOE in the dropdown menu at the top. I presume that is right. Memory model is XMMC.
I can't copy and paste the build dialog but it says that it verified sending the data to ram, and then verified sending it to flash.
I did a program to eeprom. However, no file has appeared on the SD card. The program does run though so it appears as if it is in eeprom, not on the SD card.
I tried sending it to PROPBOE-SDXMMC but it says it can't find the board configuration.
Any advice here would be most appreciated!
PROPBOE-SDXMMC must be selected for the IDE to use the SDXMMC mode.
As I mentioned though, version 0-6-7 has a bug regarding this board type.
Please read this message: http://forums.parallax.com/showthread.php?137928-PropGCC-SimpleIDE&p=1094377&viewfull=1#post1094377