ATmega64A EEPROM Not Retaining Data After Flashing Main Firmware

Thread Starter

akash.kumar123

Joined Jul 20, 2026
4
I am trying to flash EEPROM data into an ATmega64A using USBasp and AVRDUDE. I first flash the EEPROM code, which is supposed to store the MAC address in EEPROM memory. After that, I flash the main firmware.

However, after flashing the main code, the device does not read the MAC address from EEPROM, and it looks like the EEPROM data is not being stored properly or gets erased during the flashing process.

I have already checked the code flow, but I am not sure whether the issue is in the EEPROM writing code, the main code reading logic, or the flashing/board settings. I want to know the correct procedure to store EEPROM data permanently and prevent it from being erased when flashing the main firmware.

Any help on what I should check in the code or Arduino/AVRDUDE settings would be appreciated.

procedure for the flasing the code:

Zonal Controller (ATmega64A-AU)
  • Install the MegaCore board package in the Arduino IDE.
  • Open Tools → Board and select ATmega64 from the MegaCore boards.
  • Connect the USBASP programmer and select Tools → Programmer → USBasp.
  • Configure the remaining settings (Clock, BOD, Bootloader, etc.) according to the hardware design.


    4.6 Generating the HEX File
    • Open the required .ino file in the Arduino IDE (Zonal Controller Main, Zonal Controller EEPROM, or Sensor firmware).
    • Configure the Arduino IDE under the Tools menu as described (select the correct board, programmer, and other settings).
    • Click Sketch → Verify/Compile to ensure the code compiles successfully.
    • Click Sketch → Export Compiled Binary to generate the .hex file.
    • The generated .hex file will be saved in the same folder as the source code (.ino) file.
    • Use the generated .hex file for programming with AVRDUDE.
  • 4.7 Flashing the Zonal Controller using AVRDUDE
    • Open AVRDUDEX, select USBasp, USB Port, and ATmega64A, then click Detect.
    • Select the EEPROM .hex file in the Flash box and click Write → Program!. Do not use the .eep file or EEPROM box.
    • Power OFF → ON to reset the controller.
    • Select the Main Firmware .hex file in the Flash box and click Write → Program!.
 

Attachments

Top