I am using at91sam4e16e and working on bootloader. boot region is defined at 0x400000 and application region is at 0x420000 onwards.
i have downloaded bootloader code into that region and compiled application code with 0x420000 link address. now I want to download that application to 0x420000 using Jtag but when I download it, all the memory goes erased and only application remains.
In avr, I could prevent the boot area in debugger option; How to do the same in sam4e?
regards, shreyas.
Go to project options.
In Debugger -> Images
you can download extra image.
Note that I have only used this with the Debug info only
-option enabled, but I have bundled bootloader with my app, so it is a bit different situation. (You can bundle bootloader in Linker -> Input
tab.)
I also had a problem that since application wasn't in normal starting location, I had to initialize program counter, and stack pointer registers manually. You can do this by defining a macro file in Debugger -> Setup
.
Macro file could look like this (note that this is for different MCU, so you may have different registers/addresses):
execUserReset()
{
// Set the stack pointer
MSP = *(int*)0x00008000;
// Set the program counter
PC = *(int*)0x00008004;
}
This macro file skips bootloader when using debugger reset, but you could also make macro file which enters bootloader on reset by using different addresses.
Edit: Bundling the bootloader:
It's been a while since I have done this, so hopefully I remember everything.
You need to add your bootloader .bin
file to Linker -> Input -> Raw binary image
. Also define symbol bootloader
, and section .bootloader
. (I think alignment needs to be specified too, even if you use absolute placement.)
Add your bootloader
symbol to Keep symbols:
box above. This should make sure that bootloader is always included.
In your linker file, add line
place at address mem:0x00000000 { section .bootloader };
to place bootloader at specific address (change address to match your bootloader address).