Maximale Programm-Größe laut size-of

Gast #829927
Lesenswert?

Hallo!

Ich habe einen Atmel MEGA 8-16. Ich benutze das Tool size-of und habe 
während des Programmierens und Testen mit der Schaltung bemerkt, dass 
wenn die Speicherbelegung 92% übersteigt, der µC auf einmal zum spinnen 
anfängt. Lösche ich dann eine Code-Zeile (die das wirklich nicht 
auslösen kann ;)), dann funktioniert alles wieder einwandfrei.
Jetzt wollte ich mal fragen wie weit man einen µC mit Daten füllen kann 
bzw. inwieweit man sich auf die Speicherbelegungsanzeige von sizeof 
verlassen kann?

Hier ist meine:

Size after:
main.elf  :
section     size      addr
.text       7116         0
.data         40   8388704
.bss         133   8388744
.stab      11016         0
.stabstr    5523         0
Total      23828


AVR Memory Usage:
-----------------
Device: atmega8

Program:    7156 bytes (87.4% Full)
(.text + .data + .bootloader)

Data:        173 bytes (16.9% Full)
(.data + .bss + .noinit)
Gast #829956
Lesenswert?

Hast du die Optimierung (-O) nicht angeschaltet, und in der einen 
Code-Zeile steht zufällig "_delay_us(...)" o.ä.?
Dann wird die Floating-Point Library dazu gelinkt...
Ansonsten: poste mehr Info (Compiler version, Entwicklungsumgebung, 
etc...)

-Os Jörg
Gast #830006
Lesenswert?

Optimierung ist in der Makefile auf OPT = s, also auf Größe optimieren.

_delay_ms hab ich auch schon an anderen Stellen wie für die 
Initialisierung des LCD verwendet, dann müsste die eine Library immer 
schon dazugelinkt werden.


Das ist der ganze Auszug:

-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is 
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.



Size before:
main.elf  :
section     size      addr
.text       7116         0
.data         40   8388704
.bss         133   8388744
.stab      11016         0
.stabstr    5523         0
Total      23828


AVR Memory Usage:
-----------------
Device: atmega8

Program:    7156 bytes (87.4% Full)
(.text + .data + .bootloader)

Data:        173 bytes (16.9% Full)
(.data + .bss + .noinit)



Creating load file for EEPROM: main.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  --change-section-lma .eeprom=0 -O ihex main.elf main.eep
c:\Programme\WinAVR\bin\avr-objcopy.exe: there are no sections to be 
copied!
c:\Programme\WinAVR\bin\avr-objcopy.exe: --change-section-lma 
.eeprom=0x00000000 never used
make.exe: [main.eep] Error 1 (ignored)

Converting to AVR Extended COFF: main.cof
avr-objcopy --debugging --change-section-address .data-0x800000 
--change-section-address .bss-0x800000 --change-section-address 
.noinit-0x800000 --change-section-address .eeprom-0x810000 -O 
coff-ext-avr main.elf main.cof
Warning: file C:/WINDOWS/TEMP/ccaXm0WJ.s not found in symbol table, 
ignoring
Warning: ignoring function __vectors() outside any compilation unit
Warning: ignoring function __bad_interrupt() outside any compilation 
unit
avr-objcopy: --change-section-vma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-lma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-vma .noinit+0xff800000 never used
avr-objcopy: --change-section-lma .noinit+0xff800000 never used


Size after:
main.elf  :
section     size      addr
.text       7116         0
.data         40   8388704
.bss         133   8388744
.stab      11016         0
.stabstr    5523         0
Total      23828


AVR Memory Usage:
-----------------
Device: atmega8

Program:    7156 bytes (87.4% Full)
(.text + .data + .bootloader)

Data:        173 bytes (16.9% Full)
(.data + .bss + .noinit)


-------- end --------


> Process Exit Code: 0
> Time Taken: 00:01
Persönliche Seite #830129
Lesenswert?

Wolfgang wrote:
> wenn die Speicherbelegung 92% übersteigt, der µC auf einmal zum spinnen
> anfängt. Lösche ich dann eine Code-Zeile (die das wirklich nicht
> auslösen kann ;)), dann funktioniert alles wieder einwandfrei.

Wahrscheinlich wächst der Stack an irgendeiner Stelle in den Heap 
herein, dann kann es zu allerlei merkwürdigem Verhalten kommen.

Du verwendest zwar statisch nur 173 Bytes RAM, wenn Du aber noch 
malloc() oder große Arrays innerhalb von Funktionen verwendest, kann es 
leicht zu Problemen kommen. In bestimmten Situationen reicht da schon 
eine kleine Code-Änderung.

Gruß,
Roland

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren