Is there a simple way to detect when code is running in the bootloader section on an arbitrary XMEGA device?
Say I write a bootloader. I don't want to have to hard code the bootloader address, or re-compile for each different memory size. But I also need to use pgm_ functions with addresses calculated for data in the bootloader section, and maybe measure the size of the app section too.
If the code knows it is running in the bootloader section it can figure out all this information fairly easily.
There doesn't seem to bit a bit in some register that tells me this. I thought of trying to see how many bits are available in the RAMPZ register for ELPM, but I'm not sure if unused bits really are always zero as the manual claims and devices with EBI will always have the full 8 anyway.