QMP+RP2 drivers working in all XMM modes!
Rayman
Posts: 14,665
I've been putting HUBDATA and volatile everywhere I can think of, but it still won't work...
I've wittled this test down to just the display driver (no fsrw or any sub objects).
The attached code runs fine in LMM and CMM modes with any optimization.
This was converted with spin2cpp and the original spin file is here too:
QMP_GccTest - Archive [Date 2013.05.08 Time 16.01].zip
But, it doesn't work in xmmc or xmm-single mode with Rampage2X.
In xmmc mode, it appears like it tries to work. It initialized the screen and then fills the screen blue.
But then, it misbehaves badly and sets some random pixels on one horizontal row and then stops.
In xmm-single mode it doesn't even fill the screen.
I've tested ebasic with this setup, so I'm sure xmmc and xmm-single modes can work...
Any ideas?
Update: It now works in -xmmc mode after adding HUBDATA and volatile and HUBTEXT in all the right places
-xmm-single and split modes still don't work though.
Update: All modes now working! A lot of my issues were due to using a prototype version of Rampage2 with pulldown resistors instead of pullup resistors on the memory chip selects. Fortunately, the real boards have the correct pullup resistors.
Also, replaced FSRW with stdio because couldn't make FSRW work in xmm-single or split modes.
I've wittled this test down to just the display driver (no fsrw or any sub objects).
The attached code runs fine in LMM and CMM modes with any optimization.
This was converted with spin2cpp and the original spin file is here too:
QMP_GccTest - Archive [Date 2013.05.08 Time 16.01].zip
But, it doesn't work in xmmc or xmm-single mode with Rampage2X.
In xmmc mode, it appears like it tries to work. It initialized the screen and then fills the screen blue.
But then, it misbehaves badly and sets some random pixels on one horizontal row and then stops.
In xmm-single mode it doesn't even fill the screen.
I've tested ebasic with this setup, so I'm sure xmmc and xmm-single modes can work...
Any ideas?
Update: It now works in -xmmc mode after adding HUBDATA and volatile and HUBTEXT in all the right places
-xmm-single and split modes still don't work though.
Update: All modes now working! A lot of my issues were due to using a prototype version of Rampage2 with pulldown resistors instead of pullup resistors on the memory chip selects. Fortunately, the real boards have the correct pullup resistors.
Also, replaced FSRW with stdio because couldn't make FSRW work in xmm-single or split modes.
Comments
Yes.
This is from the gas_toggle example. It could easily use an array instead of __builtin_alloca().
QMP uses the same data bus (P0..P7) as the Rampage2 board...
Now, I need to figure out if it is possible to share the bus...
BTW: Did you guys invent "Hubdata" and "Hubtext"? Or, did you base it on something else?
Also: If I declare a function "Hubtext" and it calls another function, what happens? Does it remain in hub, or does that break it?
Multithreading would be impossible with a shared memory bus, right?
No, only the functions you declare with HUBTEXT will be located in hub memory. That means you need to restrict that to leaf functions (functions that don't call any other functions) in practice. I've typically only placed the mailbox loop in hub memory and left most of the complex logic in external memory.
However, it doesn't "break" anything to do that. It just doesn't achieve your goal of eliminating the possiblity of cache misses. Yes, of course it is impossible. Now go do it! :-)
No. It's just that we have disallowed multi-threading on xmm for now mainly because of the XMM cache mechanism (full multi-cog, multi-threading is available on LMM with pthreads). David is experimenting with new cache ideas for P2 (and P1) where multiple "cogstart" functions can be run on XMM just like on LMM. A lock will be required for sharing pins between a peripheral and XMM for that case.
Doesn't work in xmm-single mode though. Isn't that strange?
Weird thing is that it almost works... This little test code starts the LCD, then shows random lines, then shows random dots.
In xmm-single mode, it shows the random lines fine and then reboots.
Maybe your problem is the crappy cache driver you're using. You should get someone who knows what they're doing to write one for you! :-)
xmmc mode works, but single and split don't.
Maybe this means that there's some variable that should be in hub that isn't...
Let me try some things before bothering you more...
BTW: I'm kinda amazed the fsrw is working this way with no changes at all.
Just using the raw spin2cpp output and it's reading bitmap images from uSD just fine...
Definitely a caching issue, I think because it crashes when leaving a big loop.
I noticed something interesting though... I had forgotten that this code, in the main Spin routine,
set the flash and sram ce pins high, to keep them from doing anything.
But, somehow, the flash was working anyway! How can this be? I guess the flash cache driver must be running in the same cog as the lmm cog?
I'll post a small example that doesn't work in single mode, in case somebody can see the problem...
PS: I'm still wondering why FSRW works just fine without any volatile or hubdata/hubtext additions...
My Spin code had this:
But, it came out of Spin2Cpp like this:
Isn't that off a bit?
But, if I change it to this:
OUTA |= (3<<9);
DIRA |= (3<<9);
I can keep xmmc from working
Yes, that is a spin2cpp bug. I've checked a fix in to the p2test branch of propgcc. In the meantime, you can change those expressions to I think it's generally safer to use the ranges that way (hi..lo), since an expression like: actually sets the low byte of outa to $80, which may not be what you intended.
Thanks for the bug report!
Eric
This threw me off because I thought I had the same PropGCC installed on both computers.
But, I think I found the difference in the rampage2x.cfg file.
The one that works has this:
cache-param1: 0x00070600
And the one that doesn't has this:
cache-param1: 0
I remember changing these values, but I thought that was for C3F...
Does this help figure out what's going on?
I added some more code to that small example and now it does like before, runs for a while and then messes up...
You probably don't have this hardware setup (QMP+Rampage2), but maybe you can see the problem?
QMP_GccTest8.zip
What I did was plug QMP into the Quickstart's main connector and then plug Rampage2 into the second connector.
But, this is a little tricky because RP2 had to be in at an angle and it's also hard soldered, so it can't be removed.
Maybe it would be better to solder a female header under Quickstart and then solder male header pins to top of RP2 so it can plug in underneath of Quickstart.
Another way would be to use those stacking connectors for Quickstart and plug both boards into the main connector of Quickstart.