2013-03-28 Freakduino Errata
Written by Akiba   
Thursday, 28 March 2013

Hi everyone.

Robin Scheibler, a Safecast member and also a Freakduino user, discovered and informed me about a dangerous bug in the AVR settings on the Freakduino. All Freakduinos purchased before 2013-03-28 are set to have a 4 kB bootloader (2048 words). In the Freakduino tutorial,  I mention to use the Arduino IDE board setting "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ATmega328". This board setting assumes a 2 kB bootloader (1024 words). Using this board setting, the Arduino IDE will protect against any sketch that uses more than 30,720 bytes. However since the bootloader on the Freakduino is set to 4 kB, the bootloader starts at 28,672 bytes. Any sketch that's between 28,672 bytes and 30,720 bytes will overwrite the bootloader. 

There are various workarounds for this:

1) Modify the boards.txt file:

The following should be added somewhere in the boards.txt file:

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

freakduino.name=Freakduino w/ ATmega328

freakduino.upload.protocol=arduino
freakduino.upload.maximum_size=28672
freakduino.upload.speed=57600

freakduino.bootloader.low_fuses=0xE2
freakduino.bootloader.high_fuses=0xDA
freakduino.bootloader.extended_fuses=0xFF
freakduino.bootloader.path=atmega
freakduino.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
freakduino.bootloader.unlock_bits=0x3F
freakduino.bootloader.lock_bits=0x0F

freakduino.build.mcu=atmega328p
freakduino.build.f_cpu=8000000L
freakduino.build.core=arduino
freakduino.build.variant=standard

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

This board description sets the maximum upload size to 28,672 bytes. Once you modify the boards.txt file, restart the Arduino IDE and select "Freakduino w/ ATmega328" in the Tools/Board setting.

  • On Windows, the boards.txt file is located in the $ARDUINO/hardware/arduino directory.
  • On OSX, the boards.txt file takes a bit more work to get to:
    • Right click (or ctrl-leftclick) on the Arduino icon and select "Show package contents"
    • Navigate to "Contents/Resources/Java/hardware/Arduino". You should see boards.txt in this folder. 
  • On Linux, the boards.txt file is located at: /usr/share/arduino/hardware/arduino/boards.txt

boards

2) Reprogram the MCU fuses (if you have a programmer)

If you have access to an AVR programmer, you can reprogram the fuses for a 2 kB bootloader (1024 words) and use the original board setting  "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ATmega328". To do this, you would need to:

1) Set the fuses for the flash size you want. In this case, it would be 1024 words or 2 kB.

2) Reprogram the bootloader. You can get the bootloader here from the Arduino directory at: 

$ARDUINO/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex

Programmer

 3) Replace the MCU

I can mail an MCU to you with the fuses programmed for a 2 kB bootloader. Then you can use the original settings and not need to modify the boards.txt file. I only ask that you send me the original MCU once you receive the new one. If you choose this option, please email me at support(aatt)freaklabsstore.com with your name and shipping address. Please send me the name that you used to purchase the board so I can verify. 

I'm sorry about this issue, and it's due to carelessness on my part for not paying close enough attention to the fuse settings. This issue will be corrected on all MCUs from now on. If you have questions or concerns, please email me at support(aatt)freaklabsstore.com.

Sorry again and thanks for your understanding.

Akiba

 

Hits: 17986
Trackback(0)
Comments (8)Add Comment
Huh?
written by Jim2, March 29, 2013
How can that fix the problem? If you reprogram the fuse, don't you need to actually _move_ the bootloader to 0x3c00 while you're at it? Does it even fit in 2kb?
report abuse
vote down
vote up
Votes: +0
...
written by Akiba, March 29, 2013
Sorry, I should have mentioned that the bootloader is located in the Arduino directory under $ARDUINO/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex

You would also need to reprogram the bootloader after changing the fuse settings.

I've updated the post to reflect this. Sorry about that.

Also, to answer your question, it will fit in 2 kB. This is the original size that it should be in.
report abuse
vote down
vote up
Votes: +0
Arduino 1.5 needs some changes
written by Ethan T, April 21, 2013
I was getting exceptions when attempting to program with the new Arduino 1.5 beta IDE, using the custom boards.txt entries. I modified the provided entries to match what I was seeing for other boards in the new version of boards.txt, and I no longer get exceptions. Here is my version:


freakduino.name=Freakduino w/ ATmega328
freakduino.upload.tool=avrdude
freakduino.upload.protocol=arduino
freakduino.upload.maximum_size=28672
freakduino.upload.speed=57600

freakduino.bootloader.tool=avrdude
freakduino.bootloader.low_fuses=0xE2
freakduino.bootloader.high_fuses=0xDA
freakduino.bootloader.extended_fuses=0xFF
freakduino.bootloader.unlock_bits=0x3F
freakduino.bootloader.lock_bits=0x0F
freakduino.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex

freakduino.build.mcu=atmega328p
freakduino.build.f_cpu=8000000L
freakduino.build.core=arduino
freakduino.build.variant=standard
report abuse
vote down
vote up
Votes: +0
...
written by Akiba, April 21, 2013
Thanks for the heads up. I haven't tried the Arduino v1.5 build yet. I'll try to check it out tonight.
report abuse
vote down
vote up
Votes: +0
Larger maximum_size
written by fakufaku, May 12, 2014
Hi Akiba,

If you change the fuse setting for a smaller bootloader, why did you not keep the maximum sketch size at 30,720 ?

Also, with the new IDE, it is now possible to add extra boards.txt files in a 'hardware' folder for different boards. You could provide such a file for the freakduino, that would make it super easy to update the bootloader.

Cheers,
Robin
report abuse
vote down
vote up
Votes: +0
...
written by aakiba, May 12, 2014
I'm trying to avoid requiring a modification of the boards.txt and Arduino core files. A lot of the beginning users are hesitant to modify these files. The current bootloader automatically has the correct settings for the default boards.txt file. I only have a different hardware profile for the long range boards since it's a little bit unavoidable.
report abuse
vote down
vote up
Votes: +0
...
written by fakufaku, May 13, 2014
You don't need to modify any of the arduino IDE files. The IDE now supports 3rd party hardware. You might want to take a look at the 'Third party hardware' section of http://arduino.cc/en/guide/Environment

You create a new boards.txt file and place it in a 'freakduino' folder inside a 'hardware' folder. Very similar to libraries.
report abuse
vote down
vote up
Votes: +0
...
written by aakiba, May 13, 2014
Oh interesting. I'll check it out.
report abuse
vote down
vote up
Votes: +0

Write comment

busy