Bootloader writing succesful, but can't upload sketches afterwards

Hi,

I want to write a bootloader to fresh Atmega328-pau chips. It took me quite a time to get to this level (at least make it perform the bootloader flashing), but now I only can't upload sketches. Let me explain the process, if anyone has an idea please let me know.

1. Get fuse settings from working mini pro
I used: How do I read the fuse bits from within my sketch? - Arduino Stack Exchange

The fuses I got back:

Low: 0xFF
High: 0xDA
Ext: 0xFD
Lock: 0xCF

2. Flash Atmega-chip
I used the setup as below. I soldered every wire to make sure that there are no connection problems.. It is an Arduino Nano with ArduinoISP to it communicating with the chip (over SPI)

The command:

C:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude -P COM4 -c avrisp -b 19200 -e -p m328p -v -u -U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0xfd:m -U lock:w:0xCF:m -C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

See the attached log.

3. Testing

Scenario 1

  1. I take a good working Arduino Mini Pro and remove the Atmega328p-au chip (call this chip; Chip1) from it
  2. I take a fresh Atmega328p-au chip (Chip2), flash it like above, then soldered back to an Arduino Mini Pro board (doesnt work)
  3. Upload Blink example sketch: Doesnt work: avrdude: stk500_getsync() attempt 1 of 10: not in sync

Scenario 2

  1. I remove the flashed chip (Chip2) and re-installed the original chip which was on the Arduino Mini pro (Chip1)
  2. Upload blink example sketch: Works (so my soldering is not the problem)

Scenario 3

  1. I remove the original chip which was on the Arduino Mini pro (Chip1)
  2. I flash the chip as above and reinstall it
  3. Upload Blink example sketch: Doesnt work: avrdude: stk500_getsync() attempt 1 of 10: not in sync

Own idea's :

  1. The flasher has a 16MHz oscillator, the arduino mini pro 8mhz I think,maybe this causes problems?

  2. I use the -p avrisp option to program (Programmer Type : STK500 Description : Atmel AVR ISP), however I'm doing it with the ArduinoISP (however setting that makes writing impossible)

  3. Lock-writing has an error perhaps?

avrdude: writing lock (1 bytes):

Writing |                                                    | 0% 0.00s ***failed; [b]<--- failed? Why failed?[/b]
Writing | ################################################## | 100% 0.06s

avrdude: 1 bytes of lock written

AVRLog.txt (5.31 KB)

Why mess with all the fuses and command stuff!?!? Just hit Burn bootloader in the IDE (after setting up the hardware, selecting the right programmer and board).

I would suggest trying it the normal way first :slight_smile:

Your avrdude command set the fuses, but you never wrote the bootloader, just set the fuses.

Why not use burn bootloader command from ide???

The ide does the nootloading in two steps - it writes fuses with one invocation of avrdude, and then writes the bootloader ti flash with a second one.

BOom!! WORKS! (tl;dr it seems that chips connected during bootloading with an 16mhz oscillator only work afterwards at 16mhz oscillator boards ??)

I tried so many different things;

  1. different sketch uploaders
  2. different programmers (arduino as isp (both nano & uno), bought arduino isp r3...)
  3. fuse settings
  4. upload from ide / commandline
  5. ... many many things ...

nothing seemed to work

so i thought, maybe the mini pro is wrecked due to all soldering/desoldering ?? lets try another one....

it works!! cooool ,wow.. but how ?

by sheer luck, i grabbed by accident a 16mhz mini pro variant (i bought only 8mhz, so the supplier must have mixed it up). swapping the chip from a non working 8mhz mini pro to a arduino nano (16mhz); still works!

then i swapped the oscillators only, and the opposite happened: the board that didnt work before, now started working, and vice versa

so in end i use the original arduino isp r3 with tqfp32 atmega328pau programmer (which has 16mhz oscillator), bootloader written from ide (using arduinoisp.org).