configtool: Add avrdude flags option to settings

Some target devices need extra avrdude command line switches to
get them to upload successfully.  There are dozens of options which
may be useful to different people. Instead of breaking all the possible
options out into separate fields, provide a generic "Program Flags" text
field which the user can fill in similar to the CFLAGS and LDFLAGS
settings.

The Arduino Mega2560 bootloader was changed[1] to report an error when
asked to erase flash because it has never actually implemented erasing
flash. To program this bootloader with avrdude requires the -D switch
to avoid flash erase. But it seems that every arduino will work fine
with -D, as evidenced by the fact that the Arduino IDE always [2]
includes -D in the avrdude commandline. Presumably the flash is erased
during/before programming anyway and the separate erase step is unneeded.

Perhaps the -D should be always added to avrdude command line in
configtool and in Makefile-AVR.  But I haven't tested any other boards
yet, and I'm being more cautious even though the Arduino IDE does
otherwise.

[1] arduino/Arduino#543
[2] d8e5997328/app/src/processing/app/debug/AvrdudeUploader.java (L168)
This commit is contained in:
Phil Hord 2016-05-17 12:57:16 -04:00
parent bb56874088
commit 90fbdd314a
2 changed files with 18 additions and 10 deletions

View File

@ -419,9 +419,9 @@ class Upload(wx.Dialog):
cmdpath = ScriptTools(self.settings).figureCommandPath("avrdude") cmdpath = ScriptTools(self.settings).figureCommandPath("avrdude")
hexpath = "\"" + join(self.root, "teacup.hex") + "\"" hexpath = "\"" + join(self.root, "teacup.hex") + "\""
cmd = cmdpath + " -c %s -b %s -p %s -P %s -U flash:w:%s:i" % \ cmd = cmdpath + " -c %s %s -b %s -p %s -P %s -U flash:w:%s:i" % \
(self.settings.programmer, self.baud, self.cpu, self.settings.port, (self.settings.programmer, self.settings.programflags, self.baud,
hexpath) self.cpu, self.settings.port, hexpath)
self.script.append(cmd) self.script.append(cmd)
def uploadUpdate(self, evt): def uploadUpdate(self, evt):

View File

@ -12,13 +12,14 @@ CFLAGS = 1
LDFLAGS = 2 LDFLAGS = 2
OBJCOPYFLAGS= 3 OBJCOPYFLAGS= 3
PROGRAMMER = 4 PROGRAMMER = 4
PORT = 5 PROGRAMFLAGS = 5
UPLOADSPEED = 6 PORT = 6
NUMTEMPS = 7 UPLOADSPEED = 7
MINADC = 8 NUMTEMPS = 8
MAXADC = 9 MINADC = 9
T0 = 10 MAXADC = 10
R1 = 11 T0 = 11
R1 = 12
class Settings: class Settings:
@ -33,6 +34,7 @@ class Settings:
self.ldflags = "" self.ldflags = ""
self.objcopyflags = "" self.objcopyflags = ""
self.programmer = "wiring" self.programmer = "wiring"
self.programflags = ""
self.port = "/dev/ttyACM0" self.port = "/dev/ttyACM0"
self.uploadspeed = 38400 self.uploadspeed = 38400
@ -66,6 +68,8 @@ class Settings:
self.port = value self.port = value
elif opt == "objcopyflags": elif opt == "objcopyflags":
self.objcopyflags = value self.objcopyflags = value
elif opt == "programflags":
self.programflags = value
elif opt == "t0": elif opt == "t0":
self.t0 = value self.t0 = value
elif opt == "r1": elif opt == "r1":
@ -95,6 +99,7 @@ class Settings:
self.cfg.set(self.section, "ldflags", str(self.ldflags)) self.cfg.set(self.section, "ldflags", str(self.ldflags))
self.cfg.set(self.section, "objcopyflags", str(self.objcopyflags)) self.cfg.set(self.section, "objcopyflags", str(self.objcopyflags))
self.cfg.set(self.section, "programmer", str(self.programmer)) self.cfg.set(self.section, "programmer", str(self.programmer))
self.cfg.set(self.section, "programflags", str(self.programflags))
self.cfg.set(self.section, "port", str(self.port)) self.cfg.set(self.section, "port", str(self.port))
self.cfg.set(self.section, "t0", str(self.t0)) self.cfg.set(self.section, "t0", str(self.t0))
self.cfg.set(self.section, "r1", str(self.r1)) self.cfg.set(self.section, "r1", str(self.r1))
@ -139,6 +144,7 @@ class SettingsDlg(wx.Dialog):
htLDFlags = "Flags passed to avr-gcc to be passed on to the linker." htLDFlags = "Flags passed to avr-gcc to be passed on to the linker."
htObjCopy = "Flags passed to avr-objcopy." htObjCopy = "Flags passed to avr-objcopy."
htProgrammer = "The programmer type - passed to avrdude." htProgrammer = "The programmer type - passed to avrdude."
htProgramFlags = "Extra flags passed to avrdude."
htPort = "The port to which the controller is connected. Typically a " \ htPort = "The port to which the controller is connected. Typically a " \
"path starting with /dev/... on Linux or Mac OS X, or some " \ "path starting with /dev/... on Linux or Mac OS X, or some " \
"COM... on Windows." "COM... on Windows."
@ -159,6 +165,7 @@ class SettingsDlg(wx.Dialog):
["LD Flags", settings.ldflags, htLDFlags], ["LD Flags", settings.ldflags, htLDFlags],
["Object Copy Flags", settings.objcopyflags, htObjCopy], ["Object Copy Flags", settings.objcopyflags, htObjCopy],
["AVR Programmer", settings.programmer, htProgrammer], ["AVR Programmer", settings.programmer, htProgrammer],
["AVR Upload Flags", settings.programflags, htProgramFlags],
["Port", settings.port, htPort], ["Port", settings.port, htPort],
["Upload Speed", settings.uploadspeed, htSpeed], ["Upload Speed", settings.uploadspeed, htSpeed],
["Number of Temps", settings.numTemps, htNumTemps], ["Number of Temps", settings.numTemps, htNumTemps],
@ -244,6 +251,7 @@ class SettingsDlg(wx.Dialog):
self.settings.ldflags = self.teList[LDFLAGS].GetValue() self.settings.ldflags = self.teList[LDFLAGS].GetValue()
self.settings.objcopyflags = self.teList[OBJCOPYFLAGS].GetValue() self.settings.objcopyflags = self.teList[OBJCOPYFLAGS].GetValue()
self.settings.programmer = self.teList[PROGRAMMER].GetValue() self.settings.programmer = self.teList[PROGRAMMER].GetValue()
self.settings.programflags = self.teList[PROGRAMFLAGS].GetValue()
self.settings.port = self.teList[PORT].GetValue() self.settings.port = self.teList[PORT].GetValue()
self.settings.uploadspeed = self.teList[UPLOADSPEED].GetValue() self.settings.uploadspeed = self.teList[UPLOADSPEED].GetValue()
self.settings.numTemps = self.teList[NUMTEMPS].GetValue() self.settings.numTemps = self.teList[NUMTEMPS].GetValue()