0

I am writing one boot loader code and application code for SAMD21G17D controller. I want to run my application code separately for debugging (not dependent on boot loader). I have only changed starting location of application code in linker script.

#ifndef ROM_ORIGIN
#  define ROM_ORIGIN 0x2000
#endif
#ifndef ROM_LENGTH
#  define ROM_LENGTH 0x10000

After updating the linker script, i have checked the generated map file for vector table relocation, and starting flash memory address (0x2000) in the generated hex file (MPLAB X ide), both are fine.

But when i am debuggging my application control is not hitting into Reset Handler function. If the ROM origin is 0x0 (starting from bootloader) then it is fine. I do not to jump from boot loader to application code. Is there any solution that i can directly jump to my application code (Any linker or compiler flags or any other options). IDE and compiler i am using is listed below:

IDE - MPLAB V5.30 Controller: SAMD21G18 Compiler: XC32 Debugger: EDBG (On Chip)

  • the reset handler is at address 0x00000004 and you cant change that, if you want to move your entry point then put 0x2000 bytes of padding but make sure that you point it it in the second word of that padding. or dont use reset to start the code, instead resume 0x2000 or 0x2001 depending on your tool. (set the pc to 0x2000 or have the tool run from or resume from 0x2000 or 0x2001 (if using the pc then 0x2000 is correct not 0x2001)). – old_timer May 31 '20 at 00:27
  • ahh, rereading your title, if you want to do it with a reset then you need to pad, not change the rom start address. I dont use that tool but that is likely what is going on examine the dump/disassembly of the tool output to confirm that the reset vectors start at 0 and the code at 0x2000 which I doubt is happening. – old_timer May 31 '20 at 00:31
  • Looks like the page size is 64 bytes and erase/row size is 256 bytes so technically you can separately load a binary into flash at that address. You could build for that address and have a separate bootloader that reads the value at 0x2004 and puts that in a register and uses bx to branch there. assuming the ide/whatever doesnt erase 0x0000-0x1fff when it writes your 0x2000 based program, also assuming it is putting a vector table at 0x2000 (examine the output of the tool). – old_timer May 31 '20 at 00:38

0 Answers0