I've got a little scripting problem I was hoping someone more familiar with the binutils and command line could help me with.
One problem that's been plaguing users of my bootloaders is that they have trouble figuring out the correct starting address of the bootloader, which they have to plug into the makefile in order to relocate the .bootloader section correctly. This is actually just a simple formula:
(FLASH_SECTION_SIZE_BYTES - BOOT_SECTION_SIZE_BYTES) * 1024
But since GCC requires a byte address yet AVRStudio currently reports word addresses for the bootloader sections, I thought it would be easier if I could make this automatic.
Right now I've got this partial solution:
# Starting byte address of the bootloader, as a byte address - # computed via the formula: # BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024) # # Note that the bootloader size and start address # given in AVRStudio is in words and not bytes, # and so will need to be doubled to obtain the byte # starting address needed by AVR-GCC. FLASH_SIZE_KB = 128 BOOT_SECTION_SIZE_KB = 4 BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
Which just requires that the user alter the FLASH_SIZE_KB value, as the bootloader section size should be constant for each bootloader unless I make a major revision.
I'd still like to automate the extraction of FLASH_SIZE_KB from the selected AVR model however. Does anyone have a good idea for my makefile, so that the value of FLASH_SIZE_KB can be determines automatically from the MCU setting?
- Dean :twisted: