thanks sam, i knew i was forgetting / misrepresenting some important stuff. that is a high-quality brain dump.
important clarification for anyone following along:
- NVRAM isn’t used for text or rodata, it’s defined as a dedicated flash region for arbitrary usage. the linker script defines its size with
__flash_nvram_size__ (default 256K, half of total flash) and places it at the end of the flash section. (this could always be changed if necessary.) nothing will go in nvram unless we specify it with an attribute or abuse the flash controller. on teletype i think it’s only used for scene storage.
- the summary line (berkeley-style size report) includes both flash and allocaed INTRAM. so it is actually not that useful if we just want to know how much space remains for code and rodata.
here’s example output from the buld script:
SIZE teletype.elf
teletype.elf :
section size addr
.reset 0x200c 0x80000000
.rela.got 0x0 0x8000200c
.init 0x1a 0x8000200c
.text 0x18718 0x80002028
.exception 0x200 0x8001a800
.fini 0x18 0x8001aa00
.rodata 0x5550 0x8001aa18
.dalign 0x4 0x4
.ctors 0x8 0x8
.dtors 0x8 0x10
.jcr 0x4 0x18
.got 0x0 0x1c
.data 0x1000 0x1c
.bss 0x3dec 0x1044
.heap 0x111d0 0x4e30
[debug, comment omitted here ]
.stack 0x2000 0x16000
.flash_nvram 0x2ed82 0x80040000
.debug_ranges 0x5b38 0x0
Total 0x2b493f9
text data bss dec hex filename
0x1fea6 0x1014 0x45d42 420860 66bfc teletype.elf
(these reports are produced by calling avr32-size -Ax and -Bx respectively on teletype.elf.)
i’d expect that the free space left to us for instructions and rodata can be found by taking the ending address of the last flash section (.rodata, so 0x8001aa18 + 0x5550 = 0x8000x1ff68) and subtracting it from the starting address of nvram (0x80040000), which gives 0x20098 or ~128K. my last estimate was off because it included .bss and .data, which roughly adds up.
does that calculation seem right now? if so, it would probably be useful to have the makefile perform it somehow.
oh, and an outstanding question i have is whether the linker will complain if we add too much stuff to .text, .data and/or .rodata. i’m 99.9% sure that it will but don’t have the patience to test it right now.