Some clarification needed...

Hi,

So I've been experimenting programming my fleet of Arduinos (currently Nano, Pro Mini and a Due) with other means than just the standard USB port. I bought an USB to 6-pin serial FTDI cable and an USBasp programmer from ebay. Correct me if I'm wrong:

  • To be able to program with normal USB connection or the FTDI cable you need a bootloader on your Arduino
  • You can burn a bootloader onto the Arduino using the USBasp.
  • If you upload your sketch using the USBasp directly, you'll loose the bootloader (i.e. you can't subsequently update the code using USB or the FTDI cable until you've burned the bootloader again).

What is the case with new ATmegas? If I build a device with my own custom PCB using say a new ATmega328P, what do I need to do to it before being able to program it using the Arduino IDE via USB / FTDI or the USBasp?

I keep hearing / reading about fuses you need to set. Where can I find more info about this and how do you actually set them?

One more question: Does burning the bootloader wipe out the sketch/code in the process?

kbrown: - To be able to program with normal USB connection or the FTDI cable you need a bootloader on your Arduino - You can burn a bootloader onto the Arduino using the USBasp. - If you upload your sketch using the USBasp directly, you'll loose the bootloader (i.e. you can't subsequently update the code using USB or the FTDI cable until you've burned the bootloader again).

Yes, yes and yes.

About brand new atmegas328P, you have to change their default fuses settings , that's why first you must burn bootloader with Arduino IDE (which sets the fuses automatically) . Then you can either upload via USB or use USBASP, which will erase bootloader but not fuses configuration. You can burn fuses manually with usbasp and AVR DUDE commands, but this is for advanced users.

And yes, uploading bootloader wipes previous data sketchs.

Well, fuses are the main configuration which includes clock speed, code protection, eeprom protection, external/internal osc and more. They can be set just once and then upload code many times (by usb or usasp) withouth the need of touching them again. Although you can change them as many times as you can manually, but there are specific setup and If you dont follow them you can brick the chip. Also there is the DWEN fuse that you should never touch. But again, if you are using arduino IDE you probably don't have to worry about this.

The Uno uses the Atmega328P-PU (I’ve put the -PU at the end as sometimes people get that confused the P), so no difference at all.

Programming the bootloader causes a chip erase first, so yes, everything is wiped.

In the IDE if you use the ‘burn bootloader’ function, it sets the fuses for you. The datasheet has all the information you could ever want about what they do. This is useful for calculating the fuse bytes: http://www.engbedded.com/fusecalc/

All your other points are correct.

Awesome. Thanks very much guys!