Electronic – Designing a linker script for use with MPLAB ICD 2

mplabpic

I need to alter the 18F452 linker script so that it allocates memory for resources used by the MPLAB ICD 2. I'm not sure how exactly to go about doing this, so could anyone please make any suggestions as to how to do this or refer me to some useful resources? Any help would be much appreciated.

Best Answer

I sortof remember that the ICD2 uses a few bytes of RAM and a few words of code space on that chip. It would be helpful if you look up what resources the ICD2 requires and post it so that we can give explicit examples how to deal with it.

One method is to modify the linker script, as you said. You simply shrink the effected memory regions to not cover the ICD2 areas. As far as the linker is concerned, that memory doesn't exists, so it won't place your code or variables there.

Another way is to deliberately reserve space in those regions at the appropriate fixed addresses in the source code, but then not use that space. By providing a address parameter to the CODE and UDATA directives, it makes the resulting sections fixed so the linker has no choice about where to place it. Since the dummy sections will be forced over the ICD areas, the linker won't place your code there. No linker files need be changed.

Yet another way is to use the new Microchip linker files which contain conditionals that automatically shrink some of the memory regions when a debug switch is set. I don't remember what exactly that switch is, but it shouldn't be hard to figure out by looking at the linker file.