Hi,
We are developing firmware for Cypress EZUSB processor. At beginning, our program only had 1 source C file and it worked fine. Now we have 2 source C file which share 2 common header files, and it suddenly gave this link error, Error L107: ADDRESS SPACE OVERFLOW.
linking... *** ERROR L107: ADDRESS SPACE OVERFLOW SPACE: XDATA SEGMENT: ?XD?TIMER0 LENGTH: 0654H *** WARNING L6: XDATA SPACE MEMORY OVERLAP FROM: 8000H TO: 8010H *** WARNING L6: XDATA SPACE MEMORY OVERLAP FROM: 8020H TO: 803FH Program Size: data=13.0 xdata=3338 code=283 Target not created
We have simplified the program as below(giving the same error msg):
1. main C file
#pragma NOIV // Do not generate interrupt vectors //-------------------------------------------------- #include <ezusb.h> #include <ezregs.h> #include <fx.h> #include "lcb.h" #include "head.h" //------------------------------------------- // Code //------------------------------------------- void main(void) { // Initialize endpoints, interrupts, and ports init(); } void init(void) { } //------------------------------------------------------ // USB Interrupt Handlers // The following functions are called by the USB interrupt jump table. //----------------------------------------------------------------------------- void ISR_IBN(void) interrupt 0 { } void ISR_Ep0in(void) interrupt 0 { } void ISR_Ep0out(void) interrupt 0 { } void ISR_Ep1in(void) interrupt 0 { } void ISR_Ep1out(void) interrupt 0 { } void ISR_Ep2in(void) interrupt 0 { } void ISR_Ep2out(void) interrupt 0 { } void ISR_Ep3in(void) interrupt 0 { } void ISR_Ep3out(void) interrupt 0 { } void ISR_Ep4in(void) interrupt 0 { } void ISR_Ep4out(void) interrupt 0 { } void ISR_Ep5in(void) interrupt 0 { } void ISR_Ep5out(void) interrupt 0 { } void ISR_Ep6in(void) interrupt 0 { } void ISR_Ep6out(void) interrupt 0 { } void ISR_Ep7in(void) interrupt 0 { } void ISR_Ep7out(void) interrupt 0 { } //----------------------------------------------------------------------------- // Interrups used when RENUM = 1. Not used for this code. //----------------------------------------------------------------------------- void ISR_Ures(void) interrupt 0 { } void ISR_Sudav(void) interrupt 0 { } void ISR_Sutok(void) interrupt 0 { } void ISR_Sof(void) interrupt 0 { } void ISR_Susp(void) interrupt 0 { }
2. timer0.c, this is the timer0 ISR
#include <ezusb.h> #include <ezregs.h> #include <fx.h> #include "head.h" #include "lcb.h" void timer0 (void) interrupt 1 using 1 { }
3. header1.h
#ifndef LCB_H #define LCB_H #define FPGABASE 0x8000 static xdata volatile BYTE lcb[17] _at_ FPGABASE; static xdata volatile BYTE VME_DATA[32] _at_ (FPGABASE+32); // WRITE ADDRESSES #define WR_INIT_PCP_CNT lcb[0] #define WR_READ_PCP_CNT lcb[1] #define WR_INC_PCP_CNT lcb[2] #define WR_BACK_PMB_CARD lcb[4] #define WR_BACK_PMB_ADDR lcb[5] #define WR_BACK_PMB_WRITE lcb[6] #define WR_BACK_PMB_READ lcb[7] #define WR_LATCH_VME_CMD lcb[15] #define WR_CLR_VME_CMD lcb[16] // READ ADDRESSES #define RD_55 lcb[0] #define RD_AA lcb[1] #define LCB_RD_STAT lcb[2] #define bmPCP_RDY bmBIT0 #define bmPMB_NOT_RDY bmBIT1 #define RD_PCP_DATA lcb[3] #define RD_BACK_PMB_DATA lcb[4] #define RD_FORE_PMB_DATA lcb[5] #define RD_VME_CMD lcb[7] #endif
4. header2.h
#ifndef HEAD_H #define HEAD_H //----------------------------------------------------------------------------- // Global Variables //----------------------------------------------------------------------------- static BYTE g_ssv_run; static BYTE g_bCard; static xdata float g_cal[6][6][7]; static xdata WORD g_dac_M[6][6][4]; static xdata short g_acssv_buffer[6][6]; static xdata short g_dcssv_buffer[6][6]; static xdata char g_mezz_id[6][6]; static xdata short g_temperature[6][6]; static xdata short g_squelch[6][6]; //----------------------------------------------------------------------------- // Prototypes //----------------------------------------------------------------------------- extern void bootload(void); void init(void); #endif
Is there anything wrong with the program structure? Because the program now is almost empty and it's still giving the overflow error.
Thanks for any hint.
It is very important to recognize the difference between a declaration and a definition.
Exactly. For starters, follow these rules-of-thumb:
1) never use the "static" keyword in a header file 2) never use the "extern" keyword outside header files
That set aside, I consider the usage of @ in the original posting a sign of trouble. Too many people believe that they know better than the tools where variables should be placed.
That set aside, I consider the usage of @ in the original posting a sign of trouble. after a quick glance I get the strong impression that the _at_ s are MMIO where YOU, not the compiler, place the 'variables'
Erik