I'm using a HC9S12C64 in a product, which after numerous updates now is close to its memory limit. The plan is to migrate to the 128k version, thus extending lifetime of the product. The larger chip is pin compatible, so there is no problem there.
However, future updates will require that the programming software can find out the target size of the mcu in order not to try to update 64k mcus with out of range code generated for 128k target. The flash loader in the mcu is general, and doesn't care of its target size. Nor do I want to compile the loader for different targets.
Is there a register in the mcu which tells the size of its memory, or do I have to use some akward method such as making trial reads and catch the illegal address reset or something in order to find out.