I've just been able to get my GNU Toolchain working fully in the last few days and now confirming that my working code from VDSP works out of the GNU Toolchain as well on my target. I'm seeing an issue in code while debugging now though that I don't understand. I'm certain its a disparity between coding in VDSP and GNU which I'm not aware of.
Here is some code:
/* Enumerations */
typedef enum {
red,
blue,
green
}Colors;
/* Structures */
typedef struct {
unsigned int color[3];//sizeof(Colors)];
}Bulb;
typedef struct {
Bulb bulb[BULBS_ON_STRAND];
}Strand;
/* Declaration of global variable */
/* From VDSP these were just declared as: unsigned int without any attributes and resided in SDRAM */
/* I also tried without the __attribute__ from GNU with same results, they resided in SDRAM */
volatile Strand lightStrand __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned char FrameState __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned char DataState __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int BulbDataBuffer[NUM_OF_STRANDS] __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int BitCount __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int BitShift __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int BulbCount __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int StrandCount __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int BitPhase __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int IdleLine __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int StaleFrameFlag __attribute__((section("MEM_L1_DATA_B")));
volatile unsigned int RefreshFlag __attribute__((section("MEM_L1_DATA_B")));
int main(void)
{
Init();
}
void Init(void)
{
// u32 fcclk, fsclk, fvco;
unsigned int i;
/*
ADI_PWR_COMMAND_PAIR rgb514_init[] =
{
{ ADI_PWR_CMD_SET_PROC_VARIANT, (void *)ADI_PWR_PROC_BF514SBBC1400 },
{ ADI_PWR_CMD_SET_PACKAGE, (void *)ADI_PWR_PACKAGE_LQFP },
{ ADI_PWR_CMD_SET_VDDEXT, (void *)ADI_PWR_VDDEXT_330 },
{ ADI_PWR_CMD_SET_VDDINT, (void *)ADI_PWR_VLEV_140 },
{ ADI_PWR_CMD_SET_CLKIN, (void *)24 // MHz // },
{ ADI_PWR_CMD_END, 0 }
};
adi_pwr_Init(rgb514_init);
adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);
adi_pwr_SetFreq(398000000, 99500000, ADI_PWR_DF_NONE);
adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);
*/
Init_Clocks();
/* Initialize global variables */
FrameState = IDLE_STATE; // <-- Starts in IDLE_STATE
DataState = RED_DATA_STATE;
BulbCount = 0;//NUM_OF_BULBS;
StrandCount = NUM_OF_STRANDS;
BitCount = 0;
BitPhase = 0;
BitShift = 8;
IdleLine = TRUE;
StaleFrameFlag = FALSE;
RefreshFlag = FALSE;
/* Temporary Initialization for Test */
BulbDataBuffer[0] = 0x11000000;
BulbDataBuffer[1] = 0x22000000;
BulbDataBuffer[2] = 0x33000000;
BulbDataBuffer[3] = 0x44000000;
BulbDataBuffer[4] = 0x55000000;
/* Setup IO flags */
//flagResult = adi_flag_Init(FlagServiceData, sizeof(FlagServiceData), &ResponseCount, NULL);
//flagResult = adi_flag_Open(ADI_FLAG_PG2);
//flagResult = adi_flag_SetDirection(ADI_FLAG_PG2, ADI_FLAG_DIRECTION_OUTPUT);
//flagResult = adi_flag_Clear(ADI_FLAG_PG2);
/* Initialize light strand buffer */
i = (unsigned int)red;
i = (unsigned int)blue;
i = (unsigned int)green;
for(i = 0; i < sizeof(lightStrand.bulb); i++)
{
lightStrand.bulb[i].color[red] = 0x00000000;
lightStrand.bulb[i].color[blue] = 0x3FF80000;
lightStrand.bulb[i].color[green] = 0;
}
/* Initialize RGB Outputs */
Init_RGBIO();
/* Initialize timers */
//timersInit();
Init_RGBTimer();
Init_FrameTimer();
}
Having a breakpoint on Init_RGBIO() several global variables which were initialized are now 0x3FF80000. In particular, BulbDataBuffer[0], [3] and [6], BitPhase, BitShift and RefreshFlag. This only occurs after the lightStrand structure initialization. It looks like an alignment problem but not sure why that would be. This is a bare-metal project in C using Eclipse Indigo and Blackfin Toolchain 2011R1_45. I'm using gdb for debug through Eclipse. I'm also using the basiccrt that came with the toolchain and the linker script. I tried my own linker script with same results as well. Anybody know what is happening here?