How are you flashing code 2? If there is a setting in your programmer software to preserve EEPROM values while flashing the chip, you should enable that.

Melabs serial programmer has these under 'options-erase-data' and 'options-program-data' which can be unchecked to preserve your EEPROM contents.