Outline: The plan is to expand an existing sketch to incorporate a different setup() due to the new H/W (the main processing loop will mostly remain intact). The H/W difference is that the new Arduino has an expanded memory IC EEPROM of 256KB vs the current one of 4KB. The sketch should work on BOTH H/W bases to avoid having to keep track of multiple s/w baselines.
Q: Is there a programmatic way to determine which H/W the sketch is working with during the setup()? Perhaps a H/W diagnostic library that would do the trick?
The easiest way would be to define a revision byte at the beginning of your EEPROM. Read that and it then the code will react accordingly. If your existing 4K code does not have that, then define a new revision byte at the top most memory value. If you read the last bye of the 256K EEPROM, it will return a certain value. If you read the last byte of a 256K EEPROM, but it is only 4K in size, you will get some other value (0xFF or an error or ??). Either way, your setup() code will react to that value and "do the right thing"
the idea is that EEPROMs wrap the addresses.
Assume you have an EEPROM with unknown size.
make a copy of address 0 to restore later.
loop address A over powers of 2
make a copy of the address A
write unique bit pattern to address A
if the bit pattern is visible on address 0 the EEPROM wrapped the address and thus is smaller.
at the end restore original content.
E.g. if you write a 0x55 to address 32768 and it becomes visible at address 0 the EEPROM wrapped the address and thus the EEPROM is not 32 KB.
Worked quite well, you should try it on your EEPROMs to see if it works.