I am trying to flash a custom board with an ATMEGA328P-AU with a MySensors sketch to read the temperature from a BME280 and send it to a base station. Due to the minimized design, I only have an ICSP header and TX/RX.
I have connected an USBasp (latest firmware from 2011) to the ICSP header and TX to RX of a USB-to-Serial adapter on the same computer (so it gets the ground from the USBasp).
This works fine in the beginning:
- I can set the fuses with -U lfuse:w:0xe2:m -U hfuse:w:0xd2:m -U efuse:w:0xfe (though I need to use -B1000, don’t know if that is normal when the DIV8 clock divider is in place initially)
- I can flash (using the Arduino IDE) and run through the MySensors security peronalizer (writes AES and HMAC key to EEPROM)
- I can flash and run the example sketch from the Bluedot BME280 library and get the temperature.
- I can flash and run my MySensors sketch with debug enabled. It exchanges encrypted and signed messages with the base station, but cannot read the temperature. I THINK this is because the DEBUG mode doesn’t leave it enough RAM.
- I tried to flash the same sketch with debug disabled (since RF communications tested working), but now I got
avrdude: verification error, first mismatch at byte 0x0000 0x00 != 0x0c avrdude: verification error; content mismatch avrdude: verification error; content mismatch
From now on. I cannot communicate with the chip anymore. All I get is
~/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C ~/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p atmega328p -B1000 -v -F avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/home/kay/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf" User configuration file is "/home/kay/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : usb Using Programmer : usbasp Setting bit clk period : 1000.0 AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : usbasp Description : USBasp, http://www.fischl.de/usbasp/ avrdude: set SCK frequency to 1000 Hz avrdude: error: program enable: target doesn't answer. 1 avrdude: initialization failed, rc=-1 avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x988c72 avrdude: Expected signature for ATmega328P is 1E 95 0F avrdude done. Thank you.
The device signature stays the same when the programmer is run unconnected.
I have gone through 3 ATMEGAs like this, now. They pretty much all failed roughly at the same step. For the first one, I did not have a pullup for the CS of the SPI radio in place, so I pulled it to HIGH with a jumper cable. This worked, I got through the steps on top. When I thought I was almost finished, I soldered a 10k pullup in place, connected it again, flashed, and the chip was gone.
I thought I maybe damaged something with the jumper wire when D10 went low, so I desoldered the chip and replaced it with a new one. I went through the steps, and when I just wanted to do the supposedly last flash, it died as described above.
I replaced the chip again, and it went essentially exactly like the time before. Only difference between the last flash and the one before was that in flash end-1 debug was disabled and it supposedly ran out of memory (but did not crash, it just read 0°C, send the package and went on) and in the last run, debug was disabled, but uploading failed. So if something was destroyed, it happened during or directly after flash end-1.
ANY idea what could have killed my chips?
Some more info:
- Radio is an RFM69HCW. Pull-up on CS was in place all the time in try 2 and 3.
- 3.3k pull-ups (measured) on I2C
- 2 100nF ceramic caps on the back of the PCB under the chip, with direct connections to both VCC/GND double pairs,
10uF ceramic and 220uF tantalum close to the chip.
- 100nF at the radio (also close to the 10uF and the 220uF), 100nF next to the socket of the BME280 module.