Where to put Bootloader Key in Ram, what address is the last ram address?
It really doesn't matter that much where you put your key, as long as your program and bootloader both agree on it.

You will just be setting a couple of bytes in RAM, setting the watchdog, then you should enter a while(1); loop so nothing else happens.  You should also disable interrupts before you start as well. It doesn't matter if you overwrite memory used by the program, since that program is no longer running.  Once the bootloader is finished and done with, it doesn't care what you do with that bit of RAM, so you can just use it as per normal in your program.

If you do want to "reserve" the memory in your program so it doesn't get used for anything else, you can place a variable in a separate section located at a specific address, and nothing else will be put there.  Something like:

volatile uint32_t blkey __attribute__((section(".blkey")));


and then tell the compiler where that section is located by adding this to the linker:

-Wl,-section-start=.blkey=0x&lt;ADDRESS&gt;


That way you don't really care about what else is going on - that section is then set aside from the rest of your program.