> Our final customer wants to use only one program so that the two boards will be
> interchangeable with the same firmware loaded.
I didn't think they were compatible at the assembly code level, but comparing the programming manuals shows they haven't changed anything basic that they didn't have to. The ColdFire is closer to a 68000 than a 68020 to 68040 (or even CPU32+) as they left out a lot of the advanced addressing modes. Is the application using hardware floating point? I think that changed a lot on the CF chips that have FP, but I don't think the MCF52100 has FP at all.
I've found there's a section in a very old MCF5102 manual on Freescale's web site (from 1995, I suggest you read it) documenting an "Evaluation Module" that was a drop-in replacement for an MC68EC040. The MCF5102 was deliberately made to be code compatible with the MC68040 to aid porting, but later chips in the family dropped that ability.
If you wanted to change from using an MC68040 to a ColdFire chip, then it would have been easier to use an MCF5102 back in 1995 and not a different one 17 years later.
> but I'm unsure how to detect which one is present on the board.
These things usually have a "CPU Feature Register" of some sort. The ColdFire chips do:
"1.10 Hardware Configuration Information
ColdFire hardware configuration information is loaded into the D0 and D1 general-purpose registers after system reset."
Yu can't use that as the older ones don't seem to do that, at least not from a quick read of the programming manual. I don't think they have a "known initial state" for those registers, so they could accidentally wake up looking like the new one. The chip-specific data sheet may show something more. You may have to find an instruction that works on one architecture and traps on the other one.
> One of the problems I have is trying to write Coldfire code that will be backward-compatible
> with our original 68040 boards so that only one program is necessary.
You can't use the old compiler unless it has a "ColdFire" switch, but I see you're using CW. I don't know how anyone can guarantee that CW will generate code suitable for both a CF and a 68040 with the same configuration settings. Have Freescale given a written guarantee of that together with documentation on how to configure CW?
It would be far safer to generate two completely separate binaries and burn them both to the FLASH. Have the chip decide which binary it wants to run on startup. That would require double the FLASH storage compared to the code, and you probably aren't that lucky.
You're going to have to become a 68040 expert and a ColdFire expert to the level of knowing all the differences. That's a very tough job. Start by downloading the 68040 manuals from Freescale and reading them cover to cover. Likewise the ColdFire manuals.
Tom