You need to program in an Arduino-style bootloader to your chip. To do this you need the Sparkfun AVR Programmer and the AVRDude executable. There isn't really an "off the shelf" 644P compatible bootloader; if you search for Optiboot and get the sources, it has support for the 644p.
After your bootloader works, you would use a plain serial connection to your chip (using USART0 with an appropriate USB to TTL converter - SparkFun sells those also). The boards.txt file works with the Arduino IDE to specify the various settings for your project.
I read somewhere that it is possible to use a programmer like the Pocket AVR programmer while you use the Arduino IDE (basically you don't need the serial connection), but I don't have any idea how that would work.
I mate has used the 644P for a few Arduino projects with no issues at all, using the Sanguino Bootloader. It acts just like a regular Arduino but with more IO etc.
Its just the part of getting the IDE to program over the ISP port via the Pocket Programmer that I dont understand how to set up.
Getting the IDE to program over USB via a FTDI connection to a 644P is no problem.
I just dont know how to put them both together.
I dont have the board on me to test either. Its currently being used in a workshop, so when I go to do the upgrade I need to do, I need it to work else the machine will be out of action till I figure out how to fix it.
I programmed it via Bascom AVR using an old Parallel programmer in the past, but want to upgarde it to Arduino and use the newer sparkfun pocket programmer as the PC that had the parallel port has since died, and I cant find the parallel programmer I used either...
Using the Sparkfun programmer should be identical to using the Bascom/parallel port programmer - it's the same concept. AVRDude will talk to the Sparkfun programmer no problem.
That seems to be the part you would need to change, but I dunno what to change it to yet.
BOOM!FOUND
How to Use the Arduino IDE with an External Programmer
You'll have to figure out what to change on the boards.txt but shouldn't be too hard. Heck I may do this myself.
This should work for 328 w/arduino as isp.
However I am wondering if its possible to set the fuse bits with this also, like what is done for the bootloader, but without actually uploading a bootloader hex file...
Like can I add the following lines (just as an example), and when I tell it to upload the bootloader, it will just modify the fuse bits to suit etc?
Maybe I will just have to write the fuses via the AVRdude and then program with the method above, since fuses only get set once (or at least low freq).
Ya know that makes me wanna start building a "Never Ending boards.txt" file for whoever needs it because it's aggrivating to see that things are done time and time again, and documented but then it get's swept in a sea of data that's really hard to search for, and then you have to go looking for it all over again. Maybe something of a wiki?
How I change fuse settings without ever leaving the IDE...
The examples are based on a breadboard ATmega168 running from either an external 16 MHz crystal, or the internal oscillator at 8 MHz, or the internal oscillator at 1 MHz.
Ensure the Arduino IDE is not running.
Add entries to "boards.txt"...
###########################################################################
bb168at16.name=ATmega168 @ 16 MHz
# The following MAY work (pick one)...
# bb168at16.upload.protocol=avrispv2
# bb168at16.upload.using=arduino:arduinoisp
bb168at16.upload.using=pololu
bb168at16.upload.maximum_size=16384
bb168at16.upload.speed=19200
# Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms; [CKSEL=1111 SUT=11]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Boot Flash section size=128 words Boot start address=$1F80; [BOOTSZ=11]
bb168at16.bootloader.low_fuses=0xFF
bb168at16.bootloader.high_fuses=0xD4
bb168at16.bootloader.extended_fuses=0x07
bb168at16.bootloader.path=empty
bb168at16.bootloader.file=empty168at16.hex
bb168at16.bootloader.unlock_bits=0x3F
bb168at16.bootloader.lock_bits=0x0F
bb168at16.build.mcu=atmega168
bb168at16.build.f_cpu=16000000L
bb168at16.build.core=arduino
###########################################################################
bb168at8.name=ATmega168 @ 8 MHz
# The following MAY work (pick one)...
# bb168at8.upload.protocol=avrispv2
# bb168at8.upload.using=arduino:arduinoisp
bb168at8.upload.using=pololu
bb168at8.upload.maximum_size=16384
bb168at8.upload.speed=19200
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 65 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Boot Flash section size=128 words Boot start address=$1F80; [BOOTSZ=11]
bb168at8.bootloader.low_fuses=0xE2
bb168at8.bootloader.high_fuses=0xD7
bb168at8.bootloader.extended_fuses=0x07
bb168at8.bootloader.path=empty
bb168at8.bootloader.file=empty168at8.hex
bb168at8.bootloader.unlock_bits=0x3F
bb168at8.bootloader.lock_bits=0x0F
bb168at8.build.mcu=atmega168
bb168at8.build.f_cpu=8000000L
bb168at8.build.core=arduino
###########################################################################
bb168at1.name=ATmega168 @ 1 MHz
# The following MAY work (pick one)...
# bb168at1.upload.protocol=avrispv2
# bb168at1.upload.using=arduino:arduinoisp
bb168at1.upload.using=pololu
bb168at1.upload.maximum_size=16384
bb168at1.upload.speed=19200
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 65 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Boot Flash section size=128 words Boot start address=$1F80; [BOOTSZ=11]
bb168at1.bootloader.low_fuses=0x62
bb168at1.bootloader.high_fuses=0xD7
bb168at1.bootloader.extended_fuses=0x07
bb168at1.bootloader.path=empty
bb168at1.bootloader.file=empty168at1.hex
bb168at1.bootloader.unlock_bits=0x3F
bb168at1.bootloader.lock_bits=0x0F
bb168at1.build.mcu=atmega168
bb168at1.build.f_cpu=1000000L
bb168at1.build.core=arduino
###########################################################################
Start the Arduino IDE.
Enter or load an empty / do nothing sketch...
void setup( void )
{
}
void loop( void )
{
}
Select the first board from your new set (e.g. "ATmega168 @ 16 MHz")
Click Verify
Open Explorer (the thing used to browse the harddrive)
Navigate to the temporary directory; in Windows the path "%TEMP%" gets you there.
In a sub-directory in the temporary directory, locate the corresponding dot-hex file. If the sketch is named "sketch_feb28a" the dot-hex will be named "sketch_feb28a.cpp.hex".
Copy the dot-hex file.
Navigate to the "Arduino/hardware/arduino/bootloaders" directory.
Create a sub-directory named "empty".
Navigate into the "empty" sub-directory.
Paste the dot-hex file.
Rename the dot-hex file to something appropriate for the board like "empty168at16.hex". This filename is the value for the "bootloader.file" entry in "boards.txt".
Switch to the Arduino IDE.
Select the next board (e.g. "ATmega168 @ 8 MHz").
Click Verify
Switch to Explorer
Navigate to the temporary directory (%TEMP%)
In a sub-directory in the temporary directory, locate the corresponding dot-hex file. If the sketch is named "sketch_feb28a" the dot-hex will be named "sketch_feb28a.cpp.hex".
Copy the dot-hex file.
Navigate to the "Arduino/hardware/arduino/bootloaders/empty" directory.
Paste the dot-hex file.
Rename the dot-hex file to something appropriate for the board like "empty168at8.hex".
Repeat steps 16 through 25 for any additional boards.
Close and restart the Arduino IDE.
It is now possible to change the fuse settings with impunity...
Select one of the new boards (like "ATmega168 @ 16 MHz").
Click Tools / Burn Bootloader.
The fuse settings are changed and an empty / do nothing sketch is uploaded. The processor is "hardware safe" and ready with the new fuse settings. For more examples, refer to the Tiny Core boards.txt file and "bootloaders"... http://code.google.com/p/arduino-tiny/
Just curious about the BOOTRST fuse bit.
If I understand correctly, when this bit is programmed, it executes the bootloader code, and then the application code after a reset?
If the bit is unprogrammed, then it executes the application code immediately after a reset?
So I assume, when you normally have a bootloader present, you want BOOTRST programmed?
But in this case, I assume it doesnt really matter since the bootloader file is blank?
Is that correct, or have I interpreted this incorrectly.