Go Down

Topic: Burn bootloader before setting fuses? (Read 822 times) previous topic - next topic

Lsnyman

I am using Atmel studio 6.1 and the Avrisp MkII to burn Atmega 328P with Optiboot bootloader. My question is, does it matter if you set the fuses before or after burning the bootloader? The Atmel studio is set to erase device before programming, does this clear the fuse settings?
I use the following fuse settings. L=0XFF H=0XDE Ex=0X05 Lock=0X0F
However, after setting the fuses, if I exit the fuse settings page an return again, the Low and High are correct but the Extended has changed to 0XFD? Also the lockbit has changed to 0XFF?
If I burn the bootloader first and then set the fuses and lockbits, after exiting and reading fuses again fuses are as above but the lock bit reads 0XCF. Why would these change?
I have had a few occasions where after a few days my arduino sketch mysteriously gets corrupted and I have to reload it. I was wondering if it had anything to do with the order of burning bootloader and setting fuses.
I guess that is a few questions.
Any help is appreciated.

CrossRoads

I always burn the fuses first. I leave the lock bits unlocked.
The  upper bits on some fuses are not actually there, so having 0 or 1 does  not make a difference, make sure the ones that do exist are correct.

The ATmega328Pprovides six Lock bits. These can be left unprogrammed ("1") or can be programmed ("0") to obtain the additional features listed in Table 28-2. The Lock bits can only be erased to "1" with the Chip Erase command.

The ATmega328/P has three Fuse bytes. Table 28-4 - Table 28-9 on page 288 describe
briefly the functionality of all the fuses and how they are mapped into the Fuse bytes. Note that the fuses are read
as logical zero, "0", if they are programmed.

Lock Byte - only 6 of 8 bits are used
Lock Bit Byte Bit No Description Default Value
7 - 1 (unprogrammed)
6 - 1 (unprogrammed)
BLB12(2) 5 Boot Lock bit 1 (unprogrammed)
BLB11(2) 4 Boot Lock bit 1 (unprogrammed)
BLB02(2) 3 Boot Lock bit 1 (unprogrammed)
BLB01(2) 2 Boot Lock bit 1 (unprogrammed)
LB2 1 Lock bit 1 (unprogrammed)
LB1 0 Lock bit 1 (unprogrammed)

Extended Byte - only 3 of 8 bits are  used
Extended Fuse Byte Bit No Description Default Value
- 7 - 1
- 6 - 1
- 5 - 1
- 4 - 1
- 3 - 1
BODLEVEL2(1) 2 Brown-out Detector trigger level 1 (unprogrammed)
BODLEVEL1(1) 1 Brown-out Detector trigger level 1 (unprogrammed)
BODLEVEL0(1) 0 Brown-out Detector trigger level 1 (unprogrammed)

High Byte - all bits are used
High Fuse Byte Bit No Description Default Value
RSTDISBL(1) 7 External Reset Disable 1 (unprogrammed)
DWEN 6 debugWIRE Enable 1 (unprogrammed)
SPIEN(2) 5
Enable Serial Program and
Data Downloading
0 (programmed, SPI
programming enabled)
WDTON(3) 4 Watchdog Timer Always On 1 (unprogrammed)
EESAVE 3
EEPROM memory is
preserved through the Chip
Erase
1 (unprogrammed), EEPROM
not reserved
BOOTSZ1 2
Select Boot Size
(see
Table 27-7 on page 280,
Table 27-10 on page 281 and
Table 27-13 on page 282
for details)
0 (programmed)(4)
BOOTSZ0 1
Select Boot Size
(see
Table 27-7 on page 280,
Table 27-10 on page 281 and
Table 27-13 on page 282
for details)
0 (programmed)(4)
BOOTRST 0 Select Reset Vector 1 (unprogrammed)

Low Byte - all bits are  used
Low Fuse Byte Bit No Description Default Value
CKDIV8(4) 7 Divide clock by 8 0 (programmed)
CKOUT(3) 6 Clock output 1 (unprogrammed)
SUT1 5 Select start-up time 1 (unprogrammed)(1)
SUT0 4 Select start-up time 0 (programmed)(1)
CKSEL3 3 Select Clock source 0 (programmed)(2)
CKSEL2 2 Select Clock source 0 (programmed)(2)
CKSEL1 1 Select Clock source 1 (unprogrammed)(2)
CKSEL0 0 Select Clock source 0 (programmed)(2)


The status of the Fuse bits is not affected by Chip Erase. Note that the Fuse bits are locked if Lock bit1 (LB1) is
programmed. Program the Fuse bits before programming the Lock bits.

Well, that formatting fell apart!
See Section 28 of the datasheet.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

hiduino

#2
Jun 20, 2013, 11:40 pm Last Edit: Jun 21, 2013, 12:02 am by hiduino Reason: 1

I use the following fuse settings. L=0XFF H=0XDE Ex=0X05 Lock=0X0F
However, after setting the fuses, if I exit the fuse settings page an return again, the Low and High are correct but the Extended has changed to 0XFD? Also the lockbit has changed to 0XFF?


The Extended fuse setting 0xFD and 0x05 are the same thing.  Only the lower 3 bits are significant.  The upper 5 bits are undefined, so they will read back as unprogrammed.


If I burn the bootloader first and then set the fuses and lockbits, after exiting and reading fuses again fuses are as above but the lock bit reads 0XCF. Why would these change?


The Lock bits 0xCF and 0x0F are the same also.  Again only the lower 6-bits are significant for the lock bits.  The upper 2  bits are undefined so they will also read back as unprogrammed.

Go Up