I'm trying to upload a boot loader to a blank atmega328p.
But this process is sooo confusing to me.
Im using a usbtiny programmer with an atmel target board,
on a Linux system.
I'm gonna be using an external crystal for the clock, 16mHz.
As far as i now this process is like this:
Unlock fuse bits, set new fuse bits, upload the boot loader, lock fuse bits.
But how to do this with avrdude is where I get confused.
Getting the high and low fuse bits form the m328 is pretty easy
avrdude -c usbtiny -p m328p -v
hfuse is D9 and the lfuse is 62 and the extended is FF.
But what value to i use to lock and unlock the fuses?
Also I tried using this fuse calculator to get my new fuse values
http://www.engbedded.com/fusecalc/
But it's so confusing, I think I'm suppose to use 0xDA for hfuse and
0xFF for lfuse, some one suggested that to me. I never got
those values from the calculator.
Not sure but I think the code would be something like:
avrdude -c usbtiny -p m328p -U lock:w:0xFF:m -U lfuse:w;0xFF:m -U hfuse:w:0xDA:m
Not sure about the "-U lock" value.
Then the bootloader would be:
avrdude -c usbtiny -p m328p -U flash:w:path/to/bootloader
Then re-lock the fuse bit:
avrdude -c usbtiny -p m329p -U lock 0xFF
Again not sure about the lock fuse bit value.
So how did I do? Was I close?
Is the lock fuse bit the same as the extended fuse bit??
Forgive me if this a completely stupid question, I want to get this right and not end up with a bricked chip.
I just wish there was an easier way to calculate the fuses,
that calculator I linked to is a bit daunting to us new guys.
Any insight and constructive criticism would be helpful.