Sections for avr-objcopy
When you compile an AVR C program, you get object code, which you have to convert into HEX format to flash onto the chip. You do this using avr-objcopy, and there are apparently several valid ways of doing it. I recommend learning about what the -j and -R flags are doing when you come across tutorials with this command in them. I was using one from a tutorial that looked like this:
avr-objcopy -j .text -O ihex some.o some.hex
That’s all fine and dandy except it only works for programs that don’t end up using the .data section of the object code! Now, this wouldn’t be a big deal if there were any warnings about this, but there aren’t – you just have to know to add a -j .data. A better solution, posted here by clawson, is to use the -R flag to remove parts you know you do not want. Here’s my current strategy:
avr-objcopy -R .fuse -R .lock -R .eeprom some.o some.hex
This fixed 2 separate problems when I did it, one with struct initialization and one with my LCD displaying block characters for strings but working for single characters.