Hi, I have a project that uses an Atmega328P. I am rapidly running out of program memory (maximum reported is 30720) however I only ever program using my USBAsp via the Arduino interface.
Am I right in thinking that I can steal some of the bootloader space since I only ever use the USBAsp and then approach the maximum hex size of 32kb?
If so, is it possible to make modify my Arduino IDE install such that when I go to Sketch, Upload Using Programmer that it sets up avrdude correctly?
Delta_G:
If you're going to use a programmer like that then you don't need any part of the bootloader. You can have the entire flash space for your code.
Great! Do you know if there is a step-by-step for technically challenged people like myself to follow anywhere?
Yes, it's unfortunate that the Arduino IDE does not adjust the program storage space calculation depending on the upload method. This has nothing to do with AVRDUDE, the IDE does a check before uploading but it always assumes that the space for the bootloader must be preserved even when you're not using a bootloader.
The most simple solution is:
Open the boards.txt associated with the board you are using with a text editor. You can find the location of this file by opening one of the SPI library examples, doing Sketch > Show Sketch Folder, then navigating up 4 folder levels.
Change the upload.maximum_size value from 30720 to 32768.
Save the file.
Restart the Arduino IDE if it's running.
The problem with the above is that you will need to redo that change every time you update to a new version of the hardware package (or IDE if the package is Arduino AVR Boards). The better solution is to create a custom hardware package so that you will only need to ever make the change once. Since you don't need a bootloader this package will consist of only a boards.txt file, everything else can be referenced from Arduino AVR Boards. If this is something you would like to do I can provide instructions.
pert:
Yes, it's unfortunate that the Arduino IDE does not adjust the program storage space calculation depending on the upload method. This has nothing to do with AVRDUDE, the IDE does a check before uploading but it always assumes that the space for the bootloader must be preserved even when you're not using a bootloader.
The most simple solution is:
Open the boards.txt associated with the board you are using with a text editor. You can find the location of this file by opening one of the SPI library examples, doing Sketch > Show Sketch Folder, then navigating up 4 folder levels.
Change the upload.maximum_size value from 30720 to 32768.
Save the file.
Restart the Arduino IDE if it's running.
The problem with the above is that you will need to redo that change every time you update to a new version of the hardware package (or IDE if the package is Arduino AVR Boards). The better solution is to create a custom hardware package so that you will only need to ever make the change once. Since you don't need a bootloader this package will consist of only a boards.txt file, everything else can be referenced from Arduino AVR Boards. If this is something you would like to do I can provide instructions.
Thanks so much - some instructions would be great if you don't mind. So I don't need to change any fuse settings or anything - are they done automatically when choosing "Upload Using Programmer"?
Scroll down to the Barebones ATmega Chips (no bootloader) entry. Click on it.
Click "Install"
Wait for installation to finish.
Click "Close"
Tools > Board > ATmega328/328p
Tools > Processor > ATmega328p
Tools > Clock > select the clock speed of your board
The other useful thing about this hardware package is that it will automatically do an "Upload Using Programmer" style upload when you click the standard Upload button.
Scroll down to the Barebones ATmega Chips (no bootloader) entry. Click on it.
Click "Install"
Wait for installation to finish.
Click "Close"
Tools > Board > ATmega328/328p
Tools > Processor > ATmega328p
Tools > Clock > select the clock speed of your board
The other useful thing about this hardware package is that it will automatically do an "Upload Using Programmer" style upload when you click the standard Upload button.
After I changed my code to the following, I have found that it starts to behave badly (sometimes starts, sometimes doesn't) when the sketch length exceeds 30720.
I have used the pin to watch when it starts properly and when it doesn't.
Is there any way that I can use >30720 with stability?
Thanks very much
void setup() {
pinMode(9, OUTPUT);
digitalWrite(9,HIGH);
delay(3000);
digitalWrite(9,LOW);
delay(3000);
digitalWrite(9,HIGH);
delay(3000);
digitalWrite(9,LOW);
// now copy paste delay(3000); until the sketch length approaches 100%
delay(3000); // hundreds of times
}
void loop() {
}