[En-Nut-Discussion] Nut/OS application run problem

MichalKrakora michal.krakora at centrum.cz
Fri Oct 24 10:09:48 CEST 2003


Hi all,
i have problem with compilation of my project.
I have this Makefile:
PRG = simple
 OBJ = $(PRG).o
 HEX = $(PRG).hex
 OUT = $(PRG).out
 MCU = atmega128
 OPTIMIZE = -O2
 NUT_DIR = c:\ethernut\nut
 LIBDIR = $(NUT_DIR)\lib\gcc\$(MCU)
 INCDIR = $(NUT_DIR)\include
 MODDIR= $(NUT_DIR)\mod
 MODINC = $(MODDIR)\include
 FLAGS = -g $(OPTIMIZE) -Wall -mmcu=$(MCU)
 CFLAGS = -mmcu=$(MCU) -Os -Wall -Wstrict-prototypes
-Wa,-ahlms=simple.lst 
 LIB = $(LIBDIR)\nutinit.o -lnutpro -lnutfs -lnutos -lnutdev
-lnutos
 -lnutnet -lnutcrt
 LDFLAGS = -mmcu=$(MCU) -Wl,--defsym=main=0, -L $(LIBDIR)
 #override LDFLAGS = -Wl, -Map, $(PRG).map
 CC = avr-gcc
 OBJCOPY = avr-objcopy
 all: $(OBJ) $(PRG).out text eeprom
 $(OBJ): $(PRG).c
 	$(CC) -c $(CFLAGS) -I$(MODINC) -I$(INCDIR)  $(PRG).c -o $(OBJ)
 $(PRG).out : $(OBJ)
 	$(CC) $(OBJ) $(LDFLAGS) $(LIB) -o $(PRG).out
 # rom
 text: hex
 hex:$(PRG).hex
 %.hex: %.out
 	$(OBJCOPY) -j .text -O ihex $(OUT) $(PRG).hex
 # eeprom
 eeprom: ehex
 ehex: $(PRG)_eeprom.hex
 %_eeprom.hex:%.out
 	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex
$(OUT)
 $(PRG)_eeprom.hex 
 
 
 
 and my source code simple.c looks like this:
 
 #include <compiler.h>
 #include <stdio.h>
 #include <io.h>
 #include <sys/thread.h>
 #include <sys/timer.h>
 #include <dev/uartavr.h>
 #define my_PORTD (*((volatile unsigned char *) 0x12))
 #define my_DDRD (*((volatile unsigned char *) 0x11))
 #define UCSRA UCSR0A
 #define UCSRB UCSR0B
 #define UBRR UBRR0L
 #define UDR UDR0
 #define NULL 0
 #define SYSCLK 7372800 
 
 void ioinit(void)
 {
   UCSRB = _BV(TXEN);		/* tx enable */
  UBRR = (SYSCLK / (16 * 9600UL)) - 1; /* 9600 Bd */
 }
 
 int uart_putchar(char c)
 {
   if (c == '\n') 
     uart_putchar('\r');
   loop_until_bit_is_set(UCSRA, UDRE);
   UDR = c;
   return 0;
 }
 
 int main(void){ 
 	u_long baud = 9600;
	FILE *uart;
 	NutRegisterDevice(&devUart0,0,0); 	// registruje UART0 
 	uart=fopen("uart0","r+");			// otevreme 
 	_ioctl(_fileno(uart),UART_SETSPEED,&baud); // nastavime
 	my_DDRD =0xFF;
 	my_PORTD |= 0xFF;
 	fprintf(uart,"Ahoj.\n");
 	DDRB |= 0xFF;
 	while(1){
 		PORTB ++;
 		NutSleep(125);
 		//fprintf(uart,"A %d\n",my_PORTD);
 	}  
 	return(0);          
 } 
 
My program should blink LED on port D. 
 
Compilation with avr-gcc is OK, but my ATmega128 embedded board
(i'm  not using Ethernut Board !!!) after avrdude burn does live
 I tried to use simulavr with avr-gdb and whe i use "break main" it
 sets breakpoint "main" position to 0x00 and write
somethig about wrong  memory access (access to memory 0x7FFF and 0x7FFe).
  
 Any ideas ehre Am I wrong? 
 Is it possible to run Nut/OS on different HW than on
Ethernut-board?
 Where is possible to set memory constraints?
 Thanks for answers.
 Michal
 PS: i'm using WinAVR - i'm sorry, but there is no other way...
:o#
 


--------------------
Nové telefony a originální príslušenství, datová podpora - Cell Net s.r.o. http://adarbo2.bbmedia.cz/please/redirect/53/18/9/10/?param=6039/9931_1 






More information about the En-Nut-Discussion mailing list