[En-Nut-Discussion] Problem with Ethernut Startup

ing. Radek BENEDIKT benedikt at hw.cz
Mon Jul 7 23:42:08 CEST 2003


On Monday 07 July 2003 22:59, Hugo Simon wrote:

> I again have this problem, but don't know how to reduce the data segment. Do
> you think there is a possibility to fix this bug. I only have a very few
> initialized variables, I don't know what eats up the data. Maybe the
> threads? What about static non initialized array defined inside functions?
> Or text constants like puts("Hallo");

Don't cry over spilt milk.
If not other way, change GCC startup code:

1)  - change RAMEND

avr/include/avr/iom128.h
==================

/* Constants */
#define    RAMEND   0x20FF     /* Ethernut stack - SRAM Location */
//#define    RAMEND   0x10FF     /* Last On-Chip SRAM Location */

2)  - add MCUCR init code

avr/lib/avr5/crtm128.o (from source avr-libc/crt1/gcrt1.S)
=========================================

#ifndef __AVR_ASM_ONLY__
	.weak	__stack
	.set	__stack, RAMEND

	/* By default, malloc() uses the current value of the stack pointer
	   minus __malloc_margin as the highest available address.

	   In some applications with external SRAM, the stack can be below
	   the data section (in the internal SRAM - faster), and __heap_end
	   should be set to the highest address available for malloc().  */
	.weak	__heap_end
	.set	__heap_end, 0

	.section .init2,"ax", at progbits
#ifdef MCUCR
    .weak	__init_mcucr_
    .set	__init_mcucr_, 0x00C0
	ldi	r28,lo8(__init_mcucr_)
	out	_SFR_IO_ADDR(MCUCR), r28
#endif
	clr	__zero_reg__
	out	_SFR_IO_ADDR(SREG), __zero_reg__
	ldi	r28,lo8(__stack)
#ifdef SPH
	ldi	r29,hi8(__stack)
	out	_SFR_IO_ADDR(SPH), r29
#endif
	out	_SFR_IO_ADDR(SPL), r28

3) don't forget recompiling Ethernut library

-- 
bye,
     Radek Benedikt



More information about the En-Nut-Discussion mailing list