Is it possible to define the high, low and extended fuses of a script without editing the boards.txt file? I want to define them in the header of the script so that it doesn't matter which variation of board I'm using, they will always be set correctly.
I'll not download the firmware to the microcontroller using bootloader, but I'll use an Atmel programmer instead.
Setting of the fuses cannot be done from anywhere within the code. They're only settable over isp, and the Arduino ide only does it when you do burn bootloader.
If you're manually uploading with avrdude, just add in the appropriate command-line options. If using a different utility, consult the documentation for that software to see how to use it to set fuses.
Also, do note that fuse seems are not checked during the upload process from the ide. It doesn't know what the fuses are when uploading...
It sounds like what you want is a major change, and it presents some questions, conceptually, I mean, what about different chips with different fuse layouts?
Thank you for your explanation. Yes, I'm using avrdude and so far I've been programming the microcontroller and its fuses with the following instruction:
However, as far as I know the .HEX file already includes the definition of the fuses (which is given by the boards.txt file). I suppose that if the fuses were correctly defined in the HEX, I wouldn't need to include their definition in the command line.
What I seek is to reduce the number of sources of error as much as possible. This is a code that needs to be compiled and programmed a lot, so it would be great if I wouldn't need to select the "personalized" board in the IDE nor adding the fuse definitions in the command line. It might be too much to I ask, but any suggestion is welcome
Regarding your last question, unfortunately I'm stuck with the atmega328p, and I can't change it to another one with different fuse layouts.
I'm sorry to bother you, but do you know if the .HEX file doesn't include the fuse bytes because that is the way in which the Atmel microcontrollers work, or is it because of a limitation of the Arduino IDE? I've used Microchip microcontrollers in the past and I believe that they do include these configuration bytes in the .HEX file generated.
This is an example of an .HEX file generated by Microchip (notice the length difference of the first few lines, which seem to be related to configuration bytes) :
do you know if the .HEX file doesn't include the fuse bytes because that is the way in which the Atmel microcontrollers work, or is it because of a limitation of the Arduino IDE?
It seems to be a limitation of the AVR tools that pre-dates "Arduino" by a long while. None of the Atmel, gcc, or avrdude-like tools established any standard for putting fuse values in the .hex files, and none seem to exist
I think that relatively recent gcc/etc can put fuse values into the .elf file, but I'm not sure which tools support propagating those values to the actual hardware.
Thank you westfw, that's a shame.
I'll keep programming the microcontrollers as usual, setting the fuses individually with an avrdude instruction. Thanks for your feedback.