Specifying alternative avrdude.conf?


Is it possible to specify an alternative avrdude.conf file for a given build/upload?
Or, alternatively, specify a unique attribute within a given avrdude.conf file?

Specifically, I’d like to increase the program memory size for an atmelavr platform.


Are you trying to make a configuration for a new type of microcontroller with a different memory size?

Something like that, yes. It’s still effectively an ATMega328, but we have added more program memory.

We can make it work by explicitly changing the conf file, but then it applies to ALL micros of that architecture. And I’d like to have the option to select that configuration only when I’m targeting this specific hardware.

How did you perform the miracle of getting an ATMega328 with more physical flash space if I may ask? :smiley:

Well anyways can you as a first thing try and go into your PIO folder (/home/<user>.platformio on Linux/Max, C:\Users\<User>\.platformio on Windows) and there into platforms\atmelavr\boards. Then find the JSON file for that board option you’re currently using in your platformio.ini. (uno?) and try and change the maximum_size field. I’m not yet sure if that directly carries over into the used avrdude.conf though. What exact setting did you change there to make it work?

1 Like

OK actually the avrdude.conf thing is set in here: platform-atmelavr/main.py at develop · platformio/platform-atmelavr · GitHub

However in PlatformIO you have the possibility to call a Python script which exchanges certain paramters in the environment (docs), specifically you should be able to change the UPLOADERFLAGS array which contains the path to the used avrdude.conf. I’ll see if I can get a script to work.

Here’s a working script.


platform = atmelavr
board = uno
framework = arduino
extra_scripts = custom_avrdude.py


Import("env", "projenv")

# Upload actions

def before_upload(source, target, env):
	print("Uploader flags before change:")
	old_flags = env["UPLOADERFLAGS"]
	# replace the avrdude.conf entry with another path
	# create new list of flags
	new_flags = []
	new_config = "C:\\Users\\Maxi\\Desktop\\new_avrdude.conf"
	for entry in old_flags:
		if "avrdude.conf" in entry:
		# copy over the old entry unmodified
	# replace old flags in the environment.
	env.Replace(UPLOADERFLAGS = new_flags)
	print("New uplaod flags:")

# register pre-upload action	
env.AddPreAction("upload", before_upload)

Let me know if it works. Upload as usual using pio run -t upload or your IDE targets.


…and try and change the maximum_size field

I tried that, but it does not appear to get passed along to avrdude, unfortunately. The programmer errors out as soon as it hits addres 0x8010:


So, I think something still needs to be explicitly changed for avrdude.

How did you perform the miracle of getting an ATMega328 with more physical flash space if I may ask?

Absolutely you may ask! :slight_smile:

Our boards are all FPGA-based, and so we have the ability to do a number of custom things to the design. Adding more pmem is an idea we have been discussing and wanting to do for a while. We are able to take advantage of additional flash memory on the FPGA of our newest board for more program memory space.

Still testing things out, but it seems to be working. However, we currently have to modify the avrdude.conf in a more global way to make it work. At least with Arduino.

Since I am a PlatformIO fan, I figured I’d see what options were available to me. I see that you already followed up with a possible solution using a Python script for some pre-processing. I’ll have to give that a try.

Where do I put the custom python script? Just in my src/ directory?


Main project directory, in the same folder where the platformio.ini is.

Ok, thanks! I’ll try it.

Where is the “Import” function defined?

It comes from the SCons build system that PIO includes automatically. Its type() is SCons.Script.SConscript.DefaultEnvironmentCall'. See Redirecting..., source probably here.

I apologies for the simple questions. But, since I am using the IDE and not running the PIO CLI, where can I pass the “-t upload” option?

Which exact IDE are you using? VSCode?

Yes. I am using VSC.

Upload button is in the bottom toolbar of the program. (Redirecting...). Alternatively accessable via the command palette (keyboard shortcut Ctrl+Shift+P and search for “upload”).

Oh, no… I mean, how can I tell the tool to run that python script as part of the build/upload?

That’s what the platformio.ini modification is for, the line extra_scripts = custom_avrdude.py does it; see documentation here and here.

Sigh… I am an idiot. Yep. Now I see that. Sorry!

At the end of the day it just matters that there’s working solution :). Don’t forget to change the path to the avrdude.conf to your modified file, too.