Pages: 1 [2]   Go Down
Author Topic: Sparkfun Pocket AVR Programmer with IDE (again)  (Read 7321 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 

1. Ensure the Arduino IDE is not running.

2. Add entries to "boards.txt"...

Code:
###########################################################################

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

###########################################################################

3. Start the Arduino IDE.

4. Enter or load an empty / do nothing sketch...

Code:
void setup( void )
{
}

void loop( void )
{
}

5. Select the first board from your new set (e.g. "ATmega168 @ 16 MHz")

6. Click Verify

7. Open Explorer (the thing used to browse the harddrive)

8. Navigate to the temporary directory; in Windows the path "%TEMP%" gets you there.

9. 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".

10. Copy the dot-hex file.

11. Navigate to the "Arduino/hardware/arduino/bootloaders" directory. 

12. Create a sub-directory named "empty".

13. Navigate into the "empty" sub-directory.

14. Paste the dot-hex file.

15. 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".

16. Switch to the Arduino IDE.

17. Select the next board (e.g. "ATmega168 @ 8 MHz").

18. Click Verify

19. Switch to Explorer

20. Navigate to the temporary directory (%TEMP%)

21. 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".

22. Copy the dot-hex file.

23. Navigate to the "Arduino/hardware/arduino/bootloaders/empty" directory. 

24. Paste the dot-hex file.

25. Rename the dot-hex file to something appropriate for the board like "empty168at8.hex".

26. Repeat steps 16 through 25 for any additional boards.

27. Close and restart the Arduino IDE.


It is now possible to change the fuse settings with impunity...

1. Select one of the new boards (like "ATmega168 @ 16 MHz").

2. 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/

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now that is beautiful.

So I just need to create the hex of a blank app and load that with the boards.txt and I am away laughing.
I will test it now

Thank you very much
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Regards
J
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
##############################################################

atmega644p.name=[usbtinyisp]ATmega644P

atmega644p.upload.using=usbtinyisp
atmega644p.upload.maximum_size=63488

# Ext. Crystal Osc 8Mhz+, Start-up time 16K CK + 65 ms; [CKSEL=1111 SUT=11]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Boot Flash section size=512 words Boot start address=$7E00; [BOOTSZ=11]
# Boot Reset vector Disabled [BOOTRST=1]

atmega644p.bootloader.low_fuses=0xFF
atmega644p.bootloader.high_fuses=0xDF
atmega644p.bootloader.extended_fuses=0xFC
atmega644p.bootloader.path=empty
atmega644p.bootloader.file=empty644p.hex
atmega644p.bootloader.unlock_bits=0x3F
atmega644p.bootloader.lock_bits=0x0F

atmega644p.build.mcu=atmega644p
atmega644p.build.f_cpu=16000000L
atmega644p.build.core=arduino

##############################################################

Time for some testing
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just curious about the BOOTRST fuse bit.

Does this help...
http://arduino.cc/forum/index.php/topic,52947.msg378494.html#msg378494
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just confirming the boards.txt I listed above works perfectly, with the procedure to make the bootloader.hex blank file that Coding Badly gave.

Brilliant, thanks.

J
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for taking the time to follow-up.
Logged

Pages: 1 [2]   Go Up
Jump to: