Memory Usage Issues¶
Here's some statistics from our library (trunk, revision 1580)
Dragonfly Library
text data bss dec hex filename 814 0 6 820 334 analog.o 236 0 2 238 ee battery.o 1892 16 43 1951 79f bom.o 106 0 0 106 6a buzzer.o 1424 0 0 1424 590 dio.o 236 0 0 236 ec dragonfly_lib.o 182 0 0 182 b6 eeprom.o 1378 0 0 1378 562 encoders.o 992 1 9 1002 3ea i2c.o 904 6 0 910 38e lcd.o 2088 13 3 2104 838 lights.o 150 0 0 150 96 motor.o 878 0 0 878 36e move.o 1418 28 0 1446 5a6 odometry.o 318 0 0 318 13e rangefinder.o 22 0 0 22 16 reset.o 594 23 0 617 269 serial.o 188 0 5 193 c1 spi.o 264 2 6 272 110 time.o 14084 89 74 14247 37a7 (TOTALS)
Old Wireless Library
text data bss dec hex filename 276 0 0 276 114 sensor_matrix.o 738 0 162 900 384 wireless.o 248 0 0 248 f8 wl_basic.o 56 10 0 66 42 wl_error_group.o 2096 26 6 2128 850 wl_token_ring.o 1944 48 120 2112 840 xbee.o // I've been editing this file, and the data and bss sections should have been larger 5358 84 288 5730 1662 (TOTALS)
User Code (Unit Tests as an example)
text data bss dec hex filename 22 0 0 22 16 main.o 124 68 0 192 c0 test_analog.o 186 0 0 186 ba test_dio.o 334 298 0 632 278 test_eeprom.o 226 108 0 334 14e test_encoders.o 6 0 0 6 6 test_inits.o 82 222 0 304 130 test_lcd.o 2410 15 0 2425 979 test_lights.o 386 0 0 386 182 test_motors.o 366 20 0 386 182 test_rangefinder.o 488 201 0 689 2b1 test_tokenring.o 200 107 0 307 133 test_usb.o 450 86 0 536 218 test_wireless.o 238 138 0 376 178 test_xbee.o 1910 40 120 2070 816 xbee.o 7428 1303 120 8851 2293 (TOTALS)
Totals:
text data bss dec hex filename 26870 1476 482 28828 709c (TOTALS FROM ABOVE) 30766 1650 1060 33476 82c4 main.elf
There's still some discrepancy between our measured total and the final size, which should be the avr libraries.
Here's a list of some things that are from the avr library in the elf symbol table:
data/bss: C.0.1714 10 C.1.1715 10 C.1.1418 6 C.1.1452 6 __clz_tab 256 total of 298 bytes
This still isn't enough to make up for the difference in the data/bss sections, but it's closer.
The good news is that we're currently at 2710 bytes in RAM (for the unit tests) out of 4096 bytes, so there is a little bit of leeway for the user code and the stack.
Note: Enabling debug flags greatly increases memory usage, since there's many error strings. In xbee.c alone, the data section is increased by 700 bytes. It may be necessary to clean this up, standardizing error strings and moving them into program space.