GP2X Dualcpu & Rlyeh's-minimal-lib


tuskenraider2k

Certified Guru
Joined
Nov 1, 2002
Messages
117
Hello,
The "using-subprograms" testprogram seems to work. I've been playing around a bit and I am confused. In the first frame the data is available in the non cached area. But from that moment it disappears. I tried also in the our_shared_data.h 0x2000 instead of 0x1000. I disabled the second cpu, there it is the same situations.


#include "minimal.h"
#include "our_shared_data.h"


gp2x_dualcore_declare_subprogram(940t); //declare our first subprogram

void output_data(unsigned char *pData, int nCountCols, int nCountRows)
{
int i,j;
for (i = 0;i<nCountCols;i++)
{
gp2x_printf(NULL,10,-1,": ");
for (j = 0;j<nCountRows;j++)
{
gp2x_printf(NULL,-1,-1,"%03d ", *pData);
pData++;
}
gp2x_printf(NULL,-1,-1,"\n");
}
}

int main(int argc, char *argv[])
{
char szBuffer[260];
int szBufferLength;
int nLoopCounter=0;
gp2x_init(1000, 16, 11025,16,1,60, 1);

strcpy(szBuffer,"Hello World");
szBufferLength = strlen(szBuffer);
memcpy(((unsigned char*)&VARIABLE_STR),szBuffer,szBufferLength);
VARIABLE_STR_LENGTH = szBufferLength;
VARIABLE_A = 123;


//gp2x_dualcore_launch_subprogram(940t);

while (!(gp2x_joystick_read() & GP2X_A))
{
//memset(gp2x_video_RGB[0].screen8,3,320*240*2);
gp2x_printf(NULL,0,0,"Dual CPU test (compiled "__DATE__" " __TIME__")\n\n");
gp2x_printf(NULL,-1,-1,"Run %d\n",nLoopCounter++);

gp2x_printf(NULL,-1,-1,"cnt=%lu\n",VARIABLE_TESTS);
output_data( (unsigned char *)&gp2x_dualcore_data(0x1000),8,8);
gp2x_printf(NULL,-1,-1,"---\n");
gp2x_video_RGB_flip(0);
gp2x_timer_delay(1000);

}

}

void gp2x_sound_frame(void *blah, void *buff, int samples) {}

---
our_shared_data.h:
---

#define VARIABLE_A gp2x_dualcore_data(0x1000)
#define VARIABLE_B gp2x_dualcore_data(0x1004)
#define VARIABLE_TESTS gp2x_dualcore_data(0x1008)
#define VARIABLE_STR_LENGTH gp2x_dualcore_data(0x1010)
#define VARIABLE_STR gp2x_dualcore_data(0x1014)

/*
Let's define two messages for our communication system.
These numbers have no special meaning here, they're just for identification purposes.
*/

#define MESSAGE_INVERT 0
#define MESSAGE_SUBTRACT 1
#define MESSAGE_ADD_LOOP 2
#define MESSAGE_INC_STR 3
 
Aehm, would be so nice if somebody tests this. I got quite frustrated and I have no idea where the problem is. Perhaps somebody has a clue
 
I haven't got into using the 2nd CPU yet, so I wouldn't be able to help.

From the small amount of multi-threaded programming I have done before, this sounds like just the start of all the fun with two CPUs on this thing. :)
 
I tried to use the second cpu and that seems to work.. But...

In this code I don't use it at all. The problem is the 'shared memory' which I should use disappears?

1.
At the line
-> memcpy(((unsigned char*)&VARIABLE_STR),szBuffer,szBufferLength);
I copy a string to the memory.

If you run the code it displays the memory. At the first frame it is there. But 1 second later there are only zeros in the memory. But in the do-while loop I don't modify the memory.

I don't see the problem :-/
 
Hi, here is the code. But actually I don't start it? and it doesn't do anything meaningful :)

( If I define a normal char-array the memory doesn't disappear, that really would be strange :) )



#include "minimal_940t.h" /*this must be your first line*/

#include "our_shared_data.h"

int gp2x_2ndcore_try(void)
{
static int a=0;
return ++a;
}

void pmemcpy(void *_dest, void *_source,int nLength)
{
unsigned char *dest = _dest;
unsigned char *source = _source;
while (nLength-->0)
{
*dest = *source;
}
}

void main(unsigned long command)
{
//VARIABLE_TESTS=gp2x_2ndcore_try();

if(command==MESSAGE_INVERT) VARIABLE_A^=1;
if(command==MESSAGE_SUBTRACT) VARIABLE_B--;
if (command==MESSAGE_INC_STR)
{
unsigned char *pBuffer = (unsigned char*)(&VARIABLE_STR);
int i;
int nLength = VARIABLE_STR_LENGTH;
VARIABLE_B = nLength;
nLength = 15;
VARIABLE_A = 123;
VARIABLE_TESTS=gp2x_2ndcore_try();
}
}

gp2x_dualcore_name_subprogram(940t); /*this must be your last line*/
 
Back
Top