I have designed my bootloader and would like to program the hex via ISP to the MCU. However, the hex file is placed at location 0x0000 and I would like my boot code to be place at the start of the boot section , the NRWW section. I understand it is the linker which generates the addresses and the mapping and I would like to modify the linker script. I am using Atmel studio 6 as my environment and on searching online I found that it is the .text attribute of the flash that has to be changed to point to the start of the boot code and not the usual 0x00 which is the application section. How should I change these settings within AS6 so that my boot code is flashed to the right location.
P.S. I am using another Arduino UNO as an ISP as described in their tutorial.
Go to the “project configuration” page, and select “Memory settings” from the AVR/GNU Linker section of the “toolchain” panel. Add a “Flash Segment” for .text at the desired WORD address. For example. optiboot uses “.text= 0x3f00”, which will become a linker option " -Wl,-section-start=.text=0x7e00 " (gnu linker wants byte addresses, so it gets doubled.)
@westfw Thanks for your reply! I wanted to know if the interrupt vector is mapped at the start of the boot section when you burn the boot code. Normally, when you burn any hex file the interrupt vector table is always mapped at 0x00, isn’t it? I was reading your answer to a similar question. Below is the link to it. I specifically wanted to know what should be my asm jump instruction look like. Should I jump to 0x0000(where apparently the IVT resides) or should I jump to 0x34 i.e. after the IVT table. Thanks a lot for replying back.
I wanted to know if the interrupt vector is mapped at the start of the boot section when you burn the boot code
No. There's a separate configuration bit to change the vector table location (IVSEL in MCUCR) It's set by code, rather than by fuse. See section 12.5.1 of the datasheet.
Note that most of the Arduino bootloaders do not change the vector table location, because they do no use interrupts.
(to start the application, you should jump to 0x0. There is no reason for the application to actually start immediately after the vectors. In fact it definitely won't, under relatively common circumstances (like: use of PGMSPACE...))