[En-Nut-Discussion] gcc, large programs, corrupted variable or memory space? :(
Brett Abbott
Brett.Abbott at digital-telemetry.com
Fri Mar 28 12:04:59 CET 2003
Hello, a stange one here. Any help greatfully appreciated, even
sympathy would be appreciated at this point!
Has anyone experienced the situation where the program variable space
appears to be being corrupted, apparently based on program size?
I am using v3 nutos, make files like those in the https.c demo and gcc
version gcc version 3.3 20030113 (prerelease) (as from the ethernut
starter kit CD)
When the code is small, no corruption, runs well. Large code size,
doesnt boot. When I experiment by adding and subtracting lines of code,
I get to a point where it runs for a bit but then strings start to get
corrupted, eventually rebooting. It doesnt appear to be code specific
as I can run both halves of the code separately without issue. The
specific symptoms are text messages (using fprintf) get scrambled with
random characters
I include the 1st section of the code declaring libraries and globals if
you have a moment to review it.
A Theory: (To which I dont know the solution) Is it possible, that the
variable space extends past the stack pointer, which perhaps is still in
internal RAM. Do I have to move the stack to high memory myself, do I
have to alter the make files?
Any suggestions, pointers or advice on what to try next would be great,
Thank you in advance
Brett
--
#define MY_MAC {0x00,0x06,0x98,0x20,0x00,0x00} // MY_MAC: 00-06-98-20-00-00
#define MY_IP "169.254.152.202" // IP address used by Invisibridge
#define MY_MASK "255.255.0.0" //
#define FALSE 1
#define TRUE 0
#define NUMBER_OF_HTTPD 1
#include <string.h>
#include <io.h>
#include <dev/nicrtl.h>
#include <dev/uartavr.h>
#include <dev/urom.h>
#include <avr/eeprom.h>
#include <sys/version.h>
#include <sys/thread.h>
#include <sys/timer.h>
#include <sys/confnet.h>
#include <sys/heap.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pro/httpd.h>
volatile u_char connected = 0;
static char inbuff[128];
static char my_ip[32];
static char my_mask[32];
static char my_gate[32];
static u_char my_mac[] = MY_MAC;
TCPSOCKET *sock;
FILE *uart;
#define CONN_NOCONTACT 0
#define CONN_INCONTACT 1
#define CONN_CONNECTED 2
struct DIALDATA {
int dc_status; // Current Status of link
char dc_number[32]; // Number registered
char dc_ip_address[32]; // IP Address to call
int dc_ip_port; // IP Port to connect on
long int dc_bytes_xfer; // Total Bytes Xferred to/from remote unit
};
#define MAXREMOTEUNITS 5
struct CONNDATA dial_list[MAXREMOTEUNITS];
static int numberOfRemoteUnits = 0;
//default 1st remote units
char def_num[]="1234";
char def_ip_addr[]="169.254.152.203";
int def_ip_port = 23;
u_char rxbuff[256];
u_char txbuff[256];
// --- Is this unit an controller or a remote unit?
#define DEMOTYPE_REMOTE 'R'
#define DEMOTYPE_LOCAL 'I'
char demo_type = DEMOTYPE_REMOTE;
#define EE_demo_type 0x200
//----- What mode is the unit in?
#define MODE_A 'A'
#define MODE_D 'D'
char command_mode = MODE_A;
//---------------------------------------------------------------------------------------------
// cgi demo
static char *states[] = { "TRM", "<FONT COLOR=#CC0000>RUN</FONT>", "<FONT COLOR=#339966>RDY</FONT>", "SLP" };
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: Brett.Abbott at digital-telemetry.com
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860 Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------
More information about the En-Nut-Discussion
mailing list