2

I'm doing a bootloader for AVR in ATMELStudio7, when generating the .hex it is created from the address 0x00 but the bootloader has to go from the address 0x1e000, if anyone knows how to change this in the compiled options I would appreciate it.

1 Answers1

4
  • Go to Project Properties (Alt + F7)
  • Select Toolchain
  • Select AVR/GNU Linker -> Memory Settings
  • in the "FLASH segment" section press "Add Item" button and type:

.text=0xF000

(UPD) Note, this address is in words, i.e. if you want to put an 8KB bootloader into a 128KB device (the byte offset is 0x1E000), then word offset will be 0xF000. A 4KB bootloader on a 32KB device will be 0x3800, and so on.

press OK, and compile the project. It will tell the linker where start address of the main code section is located.

By the way, be careful when using pgmspace.h in bootloaders on >64k devices, since constants in flash, which usually are placed into lower 64k, now will be placed in the upper addresses as well, and might be inaccessible using usual pgm_read... macros. In that case use pgm_get_far_address, and pgm_read_..._far macros.

AterLux
  • 4,566
  • 2
  • 10
  • 13