What do the fuse settings in the boards.txt file do?

Okay, simple question. What's the point of the fuse settings in the boards.txt file? I've tried to changing them and they do nothing. Looking at the verbose upload, they're never sent.

I've searched, but it's not clear if you can even set fuses when using a bootloader. It seems that you can't. So, what's the point of the fuse settings in the boards.txt file if you can't set fuses anyway? I've tried from an Uno/Optiboot as well as a bare ATmega328P/Optiboot and neither will set fuses.

At this point, I'm going to resort to compiling Optiboot with my own settings as this seems to be the only way. Am I missing something here? It seems odd that I can't find anything that flat out says when you can and can't set fuses. Lots of talk about fuses, which I fully understand, just setting them the way I want seems illusive.

Thanks!

Tim

Okay, simple question. What's the point of the fuse settings in the boards.txt file? I've tried to changing them and they do nothing. Looking at the verbose upload, they're never sent.

Ok, simple. The fuse byte values for the board entries in the boards.txt file are used only for one thing by the IDE, and that is when you do a burn bootloader from the IDE. That is where the fuse value come from that will be passed to AVRDUDE to burn the correct fuse bytes for the target board/chip.

The arduino IDE does not have or give any user options to burn fuse bytes manually from the IDE, other then when you perform a burn bootloader operation using a ISP programmer. Using AVRDUDE manually via it's command line mode is one method you can use to change fuse bytes.

Lefty

teckel: Okay, simple question. What's the point of the fuse settings in the boards.txt file? I've tried to changing them and they do nothing. Looking at the verbose upload, they're never sent.

They get set when you do a "burn bootloader"

retrolefty: Ok, simple. The fuse byte values for the board entries in the boards.txt file are used only for one thing by the IDE, and that is when you do a burn bootloader from the IDE. That is where the fuse value come from that will be passed to AVRDUDE to burn the correct fuse bytes for the target board/chip.

I was leaning to this conclusion, till I looked at the Optiboot bootloader's Makefile which has it's own fuse settings. So, you set the fuses in the Makefile and compile the bootloader (which I've already done), then send the bootloader to the chip where you set the fuses a second time? Why in both places? If they're different, which one wins?

retrolefty: The arduino IDE does not have or give any user options to burn fuse bytes manually from the IDE, other then when you perform a burn bootloader operation using a ISP programmer. Using AVRDUDE manually via it's command line mode is one method you can use to change fuse bytes.

I've tried using AVRDUDE to set fuses without success. It seems that one of two things are not allowing it to work. One, because I installed a bootloader I can't change the fuses (doesn't seem likely). Or two, because I'm using the bootloader for communications with AVRDUDE I can't set the fuses (I'm using an FTDI USB to serial IC to communicate using AVRDUDE).

Thanks! Tim

You can only change the fuses using ICSP programming (the 6-pin header) or high-voltage programming.

Be cautious changing the fuses in the boards.txt file. Some settings make it impossible to reprogram the chip, were you successful in changing them (impossible that is, without a high-voltage programmer).

till I looked at the Optiboot bootloader's Makefile which has it's own fuse settings. So, you set the fuses in the Makefile and compile the bootloader (which I've already done), then send the bootloader to the chip where you set the fuses a second time? Why in both places? If they're different, which one wins?

Fuse values aren't stored in the .hex files, they're only used "immediately" when you burn the bootloader. If you use one of the _isp targets in the optiboot Makefile, it will burn those fuses and the bootload to your chip. If you use the Arduino IDE "burn bootloader" command, it will use the fuses from boards.txt instead (because it doesn't see or build optiboot from source/Makefile, it's only using the existing .hex files.) Hopefully, the fuse values are rather similar.

teckel: (I'm using an FTDI USB to serial IC to communicate using AVRDUDE).

There's your problem.

You need an ISP programmer to set fuses.

westfw:

till I looked at the Optiboot bootloader's Makefile which has it's own fuse settings. So, you set the fuses in the Makefile and compile the bootloader (which I've already done), then send the bootloader to the chip where you set the fuses a second time? Why in both places? If they're different, which one wins?

Fuse values aren't stored in the .hex files, they're only used "immediately" when you burn the bootloader. If you use one of the _isp targets in the optiboot Makefile, it will burn those fuses and the bootload to your chip. If you use the Arduino IDE "burn bootloader" command, it will use the fuses from boards.txt instead (because it doesn't see or build optiboot from source/Makefile, it's only using the existing .hex files.) Hopefully, the fuse values are rather similar.

Very helpful, that makes sense.

My project needs an ultra low powered ATmega328p. I'm running at 2 MHz so I can use down to 1.8 volts (and most of the time it's in power down sleep mode with everything powered down, even the brown-out detection). Everything works fine, except for programming difficulties because default Optiboot runs at 16 MHz with a baud rate of 115200 (which is too fast at 2 MHz). What I've had to do is switch crystals back and forth between 16 and 2 MHz. 16 Mhz to program, 2 MHz to test. This is very tedious, and won't work once the board is fabricated.

So, just some small tweaks to the bootloader (9600 baud rate) and fuse settings: low=0xFB (0.9-3.0 MHz), extended=0x06 (1.8 v brown-out) should allow me to only ever use a 2 MHz crystal. I had hoped there was a way by just setting fuses and without using a custom bootloader. But, it appears that's not the case. I've just been spoiled by the Teensy, which allows me to simply select the CPU speed from a menu in the Arduino IDE. But, it appears Optiboot was not designed in such fashion.

Tim

[quote author=Nick Gammon link=topic=154454.msg1158463#msg1158463 date=1363406772] You can only change the fuses using ICSP programming (the 6-pin header) or high-voltage programming. [/quote]

Maybe what confused me was that my FTDI USB to serial programmer also has a 6-pin header. It's similar to this https://www.adafruit.com/products/284 So, when I hear "Connect your 6-pin header from your programmer and set the fuses", it would seem that I can do it with a FTDI USB to serial programmer, but I guess that's not the case. I know I can do it with the Arduino ISP, just figured it could also be done via USB to serial.

Thanks for your help!

Tim

That’s not an ICSP 6-pin header. They are usually 2 rows of 3. They would be labelled MISO, Vcc, MOSI, SCK, Reset, Gnd.

Everything works fine, except for programming difficulties because default Optiboot runs at 16 MHz with a baud rate of 115200 (which is too fast at 2 MHz)

Build an ICSP header on the board and program using that. Then it just works at the SPI clock speed, which you can adjust.

Well, you could simply use the existing bootloader with a 2MHz crystal, at which point it would run at (115200*16/2 = 14400bps) You might still want the custom fuse settings for the lower speed crystal; you'd probably have to use avrdude directly to program them. Neither the optiboot makefiles nor the Arduino IDE has a way to JUST program fuses, but it might be possible.

Teensy is "real" USB, so any speed you specify is just "emulated", I think.

[quote author=Nick Gammon link=topic=154454.msg1159437#msg1159437 date=1363467913] Build an ICSP header on the board and program using that. Then it just works at the SPI clock speed, which you can adjust. [/quote]

After going through the gyrations of compiling a custom bootloader to force 2 MHz and a slower serial speed, that's exactly what I ended up doing, just using an ICSP header.

I had an USBasp with the old firmware which gave the SCK error. So, I used an Uno running Arduino ISP to upgrade the firmware on the USBasp to get rid of the SCK error. I then just added a ICSP header and programed the ATmega without a bootloader. Works fine at 2 MHz as the speed can be selected.

Had to go full circle (and remember that I had an USBasp) before the obvious option was used.

Thanks again, Tim

westfw: Well, you could simply use the existing bootloader with a 2MHz crystal, at which point it would run at (115200*16/2 = 14400bps) You might still want the custom fuse settings for the lower speed crystal; you'd probably have to use avrdude directly to program them. Neither the optiboot makefiles nor the Arduino IDE has a way to JUST program fuses, but it might be possible.

Teensy is "real" USB, so any speed you specify is just "emulated", I think.

That was one of the first things I tried. It attempted to work, but failed. It was like the baud rate was close but slightly off or something.

Tim