I'm trying to get a simple application together using DSPBridge on the beagle board. I'm a relative newb with TI software, so apologies in advance! I wrote a sample application, and have it building fine. I execute it by loading the bridgedriver module, and then use "./cexec.out ddspbase_tiomap3430.dof64P".
I have a function [see figure 1] that executes an FFT. This version of the code takes the x & y buffers, and generates w, then calls on DSPLIB's FFT. The main point here is that the three arrays are dynamically allocated using malloc, and their sizes are computed based on the FFT size parameter. If the size of the FFT is 256 or less, then this example works fine every time. If the size is greater than 256, it begins to fail, progressively faster. Initially, it fails allocating the W array, if the size is greater than 2048, it will fail allocating the X array. From this, I can conclude that the heap that malloc() has available is less than 4KB.
In the second example, [see figure 2], I change the arrays to statically allocated stack arrays. In this case, the symptoms are that the first time the program runs, it is correct and produces correct results. The second time it runs it typically hangs. I believe the stack is getting smashed as a result of growth beyond the configured size.
Can anyone give me any pointers where to start to increase the amount of memory available to the heap (and/or the stack) in a DSPBridge application?
-tom
[figure 1] - dynamic memory allocation
int fft16x16_exec(int szFFT, short *restrict x, short * restrict y)
{
int i,j;
unsigned int szXY, szW;
int size;
short *w_16x16, *fftx, *ffty;
szXY = szFFT * 2;
szW = nextpow2(fft_sizeW(szFFT));
fftx = (short *) malloc(szXY * sizeof(short));
if (fftx == 0) return -100;
ffty = (short *) malloc(szXY * sizeof(short));
if (ffty == 0) {
free(fftx);
return -101;
}
w_16x16 = (short *) malloc(szW * sizeof(short));
if (w_16x16 == 0) {
free(ffty);
free(fftx);
return -102;
}
gen_twiddle_fft16x16( w_16x16, szFFT);
// take real-valued input from x and store into re/im array
for (i = 0; i < szFFT; i++) {
fftx[i * 2] = x[i];
fftx[i * 2 + 1] = 0;
}
// execute fft
DSP_fft16x16(w_16x16, szFFT, fftx, ffty);
// extract even # values from ffty result
for (i = 0; i < szFFT; i++) {
y[i] = ffty[i * 2];
}
[figure 2] - static allocation on stack
int fft16x16_exec(int szFFT, short *restrict x, short * restrict y) {
int i,j;
unsigned int szXY, szW;
int size;
short w_16x16[2100], fftx[2048], ffty[2048];
szXY = szFFT * 2;
szW = nextpow2(fft_sizeW(szFFT));
if (szXY > 2048)
return -1;
if (szW > 2100)
return -2;
gen_twiddle_fft16x16( w_16x16, szFFT);
// take real-valued input from x and store into re/im array
for (i = 0; i < szFFT; i++) {
fftx[i * 2] = x[i];
fftx[i * 2 + 1] = 0;
}
// execute fft
DSP_fft16x16(w_16x16, szFFT, fftx, ffty);
// extract even # values from ffty result
for (i = 0; i < szFFT; i++) {
y[i] = ffty[i * 2];
}