If you already played with avrdude or some other tool to modify the ATmega’s fuses, probably you already configured it incorrectly and it stopped to boot.

Today I faced this same issue while flashing my BK-AVR128 board and it stop to boot.
Even the avrdude stopped to work to detect the chip:

$ avrdude -c usbasp -p atmega128 -t

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

But fortunately I found a solution in this page: http://www.larsen-b.com/Article/260.html

He used another Arduino board to create 1MHz clock, but I decided to use my STM32F4Discovery board running NuttX and just configuring the MCO1 pin (PA8) to output around 4MHz.

To do it, I just modified the file boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c and added this code inside the stm32_bringup() function:

/* Configuration to enable MCO1 in PA8 */

#define BOARD_CFGR_MC01_SOURCE RCC_CFGR_MCO1_HSE
#define BOARD_CFGR_MC01_DIVIDER RCC_CFGR_MCO1PRE_DIV2

stm32_configgpio(GPIO_MCO1);
stm32_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER);

After compiling the stm32f4discovery:nsh board profile I flashed it using the OpenOCD command:

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"

I confirmed in the oscilloscope that the pin PA8 was generating 4MHz!!!

So I just used two wires to connect the GND from STM32F4Discovery to GND of the BK-AVR128 board and connected the PA8 from STM32F4Discovery to XTAL1 of the BK-AVR128.

Then I run the command to flash the correct fuses values to the board:

$ avrdude -c usbasp -p atmega128 -U hfuse:w:0x19:m -U lfuse:w:0xff:m -U efuse:w:0xff:m

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9702 (probably m128)
avrdude: reading input file "0x19"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x19:
avrdude: load data hfuse data from input file 0x19:
avrdude: input file 0x19 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xff"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xff:
avrdude: load data efuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xfd != 0xff
avrdude: verification error; content mismatch

avrdude: safemode: efuse changed! Was ff, and is now fd
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK (E:FF, H:19, L:FF)

avrdude done. Thank you.

Note that avrdude said the values didn’t match and asked to changed back, but I typed “No”!

After that everything worked again and I put the original 8MHz crystal in the board and the programmer still working:

$ avrdude -c usbasp -p atmega128 -t

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9702 (probably m128)
avrdude> quit