public frmProjConfig(AVRProject myProj, EnviroSettings mySettings) { InitializeComponent(); this.myProj = myProj; this.mySettings = mySettings; myBurner = new ProjectBurner(myProj); for (int i = 0; i < dropPart.Items.Count; i++) { string str = (string)dropPart.Items[i]; str = str.Substring(str.IndexOf('=') + 2); str = str.Substring(0, str.IndexOf(' ')); dropPart.Items[i] = str.Trim(); } for (int i = 0; i < dropProg.Items.Count; i++) { string str = (string)dropProg.Items[i]; str = str.Substring(0, str.IndexOf('=')); dropProg.Items[i] = str.Trim(); } doNotAllowClose = false; PopulateForm(); }
public BurnerPanel(AVRProject project) { allowEvents = false; InitializeComponent(); this.BackColor = System.Drawing.SystemColors.Control; this.project = project; projBurner = new ProjectBurner(project); dropProg.Items.Clear(); dropProg.Items.AddRange(ProjectBurner.GetAvailProgrammers(true)); dropPart.Items.Clear(); if (dropProg.Items.Count > 0) { dropPart.Items.AddRange(ProjectBurner.GetAvailParts((string)dropProg.Items[0], true)); } dropBaud.SelectedIndex = 0; ProjToForm(); }
public frmProjIDE(AVRProject myProject, EnviroSettings mySettings) { this.myProject = myProject; this.mySettings = mySettings; InitializeComponent(); myBuilder = new ProjectBuilder(myProject, txtOutputMsg, listErrWarn); myBuilder.DoneWork += new ProjectBuilder.EventHandler(myBuilder_DoneWork); myBurner = new ProjectBurner(myProject); serialPortControlPanel = new SerialPortPanel("com0", 9600); tabSerialPort.Controls.Add(serialPortControlPanel); serialPortControlPanel.SerialPortException += new SerialPortPanel.SerialPortErrorHandler(serialPortControlPanel_SerialPortException); myEditorTabsPanel = new EditorTabsPanel(myProject, mySettings); splitFileTreeEditorTabs.Panel2.Controls.Add(myEditorTabsPanel); try { helpToolStripMenuItem.DropDownItems.Add(MenuWebLink.GetMenuLinkRoot("Resources", "helplinks.xml")); } catch (Exception ex) { txtOutputMsg.Text += "Failed to Load Help->Resource Links\r\n" + ex.ToString(); } FillRecentProjects(); RefreshFileTree(); }
public AvrDudeWindow(AVRProject project) { InitializeComponent(); // two projects allow changes to be discarded this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); grpboxBurnerPanel.Controls.Add(burnerPanel); burnerPanel.Dock = DockStyle.Fill; burnerPanel.ProjToForm(); dropDetectionType.SelectedIndex = 0; dropMemoryType.SelectedIndex = 0; // this is the only way i can think of that will // allow the user to view the progress bar live // by using the command line window // because redirecting STDERR doesn't work since // the .NET built-in stream redirection only has // the ability to read line by line so the progress // bar is lost ProjectBuilder.SetEnviroVarsForProc(avrdude.StartInfo); avrdude.StartInfo.FileName = "cmd"; }
public static void GetPortOverride(ref string args, AVRProject project) { string res = ""; try { if (string.IsNullOrEmpty(project.BurnPort) == false) { res = "-P " + project.BurnPort; if (project.BurnPort.Length > 3) { int portNum; if (project.BurnPort.StartsWith("COM") && int.TryParse(project.BurnPort.Substring(3), out portNum)) { res = "-P //./" + project.BurnPort; } } } } catch { } args += res; res = ""; if (project.BurnBaud != 0) { res = " -b " + project.BurnBaud.ToString("0"); } args += res; args = args.Trim(); }
public static void LaunchScan(AVRProject project_, Dictionary <string, EditorPanel> editorList_) { if (SettingsManagement.AutocompleteEnable == false) { return; } if (bgScanner == null) { bgScanner = new Thread(new ThreadStart(BackgroundScan)); } bgHasQuit.Reset(); moreWorkRequired.Reset(); if (bgScanner.IsAlive) { quitScan = true; moreWorkRequired.Set(); bgHasQuit.WaitOne(); } project = project_; editorList = editorList_; bgScanner = new Thread(new ThreadStart(BackgroundScan)); bgScanner.IsBackground = true; bgScanner.Priority = ThreadPriority.Lowest; bgScanner.Start(); }
private CopyCatWizard(AVRProject project) { InitializeComponent(); this.project = project; txtPath.Text = project.DirPath; }
private void btnSaveAndClose_Click(object sender, EventArgs e) { burnerPanel.FormToProj(); project.BurnFuseBox = txtYourFusebox.Text.Trim(); this.originalProject = this.project.CopyProperties(this.originalProject); this.Close(); }
public frmWelcome(EnviroSettings mySettings, AVRProject myProject) { InitializeComponent(); this.mySettings = mySettings; this.mySettings.FillListBox(listRecentFiles); this.myProject = myProject; }
public Wizard(AVRProject project) { this.project = project; InitializeComponent(); this.DialogResult = DialogResult.Cancel; string[] templateList = ProjTemplate.GetTemplateNames(); foreach (string tempName in templateList) { dropTemplates.Items.Add(tempName); } if (dropTemplates.Items.Count == 0) { dropTemplates.Items.Add("No Templates Available"); } string lastTemp = SettingsManagement.LastTemplate; if (lastTemp == null) lastTemp = ""; if (dropTemplates.Items.Contains(lastTemp)) dropTemplates.SelectedIndex = dropTemplates.Items.IndexOf(lastTemp); else dropTemplates.SelectedIndex = 0; // warning, hack string lastFileType = SettingsManagement.LastInitialFileType; if (lastFileType == null) lastFileType = ""; if (dropFileType.Items.Contains(lastFileType)) dropFileType.SelectedIndex = dropFileType.Items.IndexOf(lastFileType); else dropFileType.SelectedIndex = 0; if (dropFileType.SelectedIndex < 0) dropFileType.SelectedIndex = 0; if (dropTemplates.SelectedIndex < 0) dropTemplates.SelectedIndex = 0; if (string.IsNullOrEmpty(SettingsManagement.FavFolder)) { string mydocs = Program.CleanFilePath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) + Path.DirectorySeparatorChar + "Projects"; SettingsManagement.FavFolder = mydocs; } txtFolderPath.Text = SettingsManagement.FavFolder + Path.DirectorySeparatorChar; string newFileName = DateTime.Now.ToString("MM_dd_yyyy").Replace(' ', '_').Replace('-', '_').Replace(Path.AltDirectorySeparatorChar, '_').Replace(Path.DirectorySeparatorChar, '_'); ; char[] illegalChars = Path.GetInvalidFileNameChars(); foreach (char c in illegalChars) { newFileName.Replace(c, '_'); } Random r = new Random(); txtProjName.Text = "Sketch_" + newFileName + "_" + r.Next(15).ToString("X"); }
public EditorTabsPanel(AVRProject myProject, EnviroSettings mySettings) { this.myProject = myProject; this.mySettings = mySettings; InitializeComponent(); this.BackColor = SystemColors.Control; this.Dock = DockStyle.Fill; }
public static void Main() { EnviroSettings mySettings = new EnviroSettings(); AVRProject myProject = new AVRProject(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmWelcome(mySettings, myProject)); if (myProject.IsReady) Application.Run(new frmProjIDE(myProject, mySettings)); }
public ProjectBuilder(AVRProject myProject, TextBox myOutput, ListView myErrorList) { this.myProject = myProject; this.myFileList = myProject.FileList; this.myOutput = myOutput; this.myErrorList = myErrorList; this.worker = new BackgroundWorker(); this.worker.DoWork += new DoWorkEventHandler(worker_DoWork); this.worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); }
public EditorPanel(ProjectFile file, AVRProject project, IDEWindow parent) { InitializeComponent(); this.parent = parent; this.file = file; this.project = project; SettingsManagement.LoadEditorState(this); this.Icon = GraphicsResx.file; }
public static void Main() { EnviroSettings mySettings = new EnviroSettings(); AVRProject myProject = new AVRProject(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmWelcome(mySettings, myProject)); if (myProject.IsReady) { Application.Run(new frmProjIDE(myProject, mySettings)); } }
public static string GetArgs(AVRProject project) { string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, project); string res = String.Format("-p {0} -c {1} {2} {3}", project.BurnPart.ToUpperInvariant(), project.BurnProgrammer, overrides, project.BurnOptions); while (res.Contains(" ")) { res = res.Replace(" ", " "); } return(res); }
public FuseCalculator(AVRProject project) { InitializeComponent(); this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); tabAVRDUDE.Controls.Add(burnerPanel); this.Text = "Fuse Calculator for " + project.Device.ToUpperInvariant(); txtYourFusebox.Text = project.BurnFuseBox; }
public WelcomeWindow(AVRProject project) { InitializeComponent(); SettingsManagement.FillListBox(listRecentFiles); this.project = project; this.Icon = GraphicsResx.mainicon; chkShowWelcomeAtStart.Checked = SettingsManagement.WelcomeWindowAtStart; backgroundWorker1.RunWorkerAsync(); }
public void StartBuild() { workingFileList = new Dictionary <string, ProjectFile>(); workingFileList.Clear(); foreach (KeyValuePair <string, ProjectFile> file in myFileList) { ProjectFile newFile = (ProjectFile)file.Value.Clone(); workingFileList.Add(file.Key, newFile); } workingProject = (AVRProject)myProject.Clone(); TextBoxModify(myOutput, "", TextBoxChangeMode.Set); ListViewModify(myErrorList, null, ListViewChangeMode.Clear); worker.RunWorkerAsync(); }
public ProjectBuilder(AVRProject project, TextBox outputTextbox, ListView errorList, ListView errorOnlyList) { this.project = project; this.origFileList = project.FileList; this.outputTextbox = outputTextbox; this.errorList = errorList; this.errorOnlyList = errorOnlyList; this.worker = new BackgroundWorker(); this.worker.DoWork += new DoWorkEventHandler(worker_DoWork); this.worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); this.makefileWorker = new BackgroundWorker(); this.makefileWorker.DoWork += new DoWorkEventHandler(makefileWorker_DoWork); this.makefileWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(makefileWorker_RunWorkerCompleted); PrepProject(); }
public BurnerPanel(AVRProject project) { allowEvents = false; InitializeComponent(); this.BackColor = System.Drawing.SystemColors.Control; this.project = project; projBurner = new ProjectBurner(project); dropProg.Items.Clear(); dropProg.Items.AddRange(ProjectBurner.GetAvailProgrammers(true)); dropPart.Items.Clear(); if (dropProg.Items.Count > 0) dropPart.Items.AddRange(ProjectBurner.GetAvailParts((string)dropProg.Items[0], true)); dropBaud.SelectedIndex = 0; ProjToForm(); }
/// <summary> /// Makes a copy of AVRProject, used by the background worker of the project builder /// </summary> /// <returns>Reference to the Cloned AVRProject</returns> public AVRProject Clone() { AVRProject newObject = new AVRProject(); newObject = CopyProperties(newObject); return newObject; }
static public bool ApplyTemplate(string name, AVRProject proj) { int appCnt = 0; XmlElement template; if (templates.TryGetValue(name, out template)) { XmlElement docx = (XmlElement)template.CloneNode(true); List<string> alreadyInherited = new List<string>(); alreadyInherited.Add(name); bool foundNew; do { foundNew = false; string inheritedInnerXml = ""; foreach (XmlElement param in docx.GetElementsByTagName("Inherit")) { string inheritName = param.InnerText.Trim(); if (alreadyInherited.Contains(inheritName) == false) { XmlElement inherited; if (templates.TryGetValue(inheritName, out inherited)) { inheritedInnerXml += inherited.InnerXml; alreadyInherited.Add(inheritName); foundNew = true; } } } docx.InnerXml += inheritedInnerXml; } while (foundNew); AVRProject.LoadTemplateCommonProperties(ref appCnt, docx, proj); if (appCnt >= 2) proj.HasBeenConfigged = true; try { foreach (XmlElement i in docx.GetElementsByTagName("CreateFile")) { string fname = i.GetAttribute("name"); if (string.IsNullOrEmpty(fname) == false) { try { ProjectFile f = new ProjectFile(Program.AbsPathFromRel(proj.DirPath, fname), proj); if (proj.FileList.ContainsKey(fname.ToLowerInvariant()) == false) { proj.FileList.Add(fname.ToLowerInvariant(), f); proj.ShouldReloadFiles = true; if (f.Exists == false) { Program.MakeSurePathExists(f.FileDir); File.WriteAllText(f.FileAbsPath, " "); foreach (XmlElement k in i.GetElementsByTagName("Template")) { File.WriteAllText(f.FileAbsPath, FileTemplate.CreateFile(f.FileName, proj.FileNameNoExt, k.InnerText)); break; } } } } catch { } } } } catch { return false; } return true; } else return false; }
public static void Show(AVRProject project) { CopyCatWizard ccw = new CopyCatWizard(project); ccw.Show(); }
public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); splash = new SplashScreen(); splash.Show(); try { SettingsManagement.Load(); FileTemplate.Unpack(); ProjTemplate.Load(); if (SettingsManagement.AutocompleteEnable) KeywordImageGen.GenerateKeywordImages(); } catch (Exception ex) { ErrorReportWindow.Show(ex, "Initialization Error"); } try { UpdateMech.CheckForUpdates(); } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error Checking Updates"); } try { AVRProject newProject = new AVRProject(); if (args.Length > 0) { string fname = args[0]; if (newProject.Open(fname) == true) { SettingsManagement.AddFileAsMostRecent(fname); } else { MessageBox.Show("Error, failed to open file"); } } else if (SettingsManagement.OpenLastProject) { if (string.IsNullOrEmpty(SettingsManagement.LastProjectPath) == false) { if (newProject.Open(SettingsManagement.LastProjectPath) == true) { SettingsManagement.AddFileAsMostRecent(SettingsManagement.LastProjectPath); } else { MessageBox.Show("Error, failed to open file"); } } } KeywordScanner.Initialize(); Application.Run(new IDEWindow(newProject)); if (newProject.IsReady) { if (SettingsManagement.SaveRecentList() == false) { MessageBox.Show("Error, Could Not Save Recent File List"); } } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Main IDE Error"); } try { if (UpdateMech.HasFinishedChecking) { if (UpdateMech.UpdateAvailable) { try { if (MessageBox.Show("An Updated Version of AVR Project IDE is Available (" + SettingsManagement.Version + " to " + UpdateMech.NewBuildID + "). Would you like to download it?", "Update Available", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(Properties.Resources.WebsiteURL); } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Updater Error"); } } } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error Checking Updates"); } try { if (SettingsManagement.LastRunVersion != SettingsManagement.Version) { NotifyOfUserAction(); } SettingsManagement.LastRunVersion = SettingsManagement.Version; } catch { } }
public void PopulateList(AVRProject newProj, Dictionary <string, EditorPanel> newList) { project = newProj; editorList = newList; PopulateList(); }
public static void GetPortOverride(ref string args, AVRProject project) { string res = ""; try { if (string.IsNullOrEmpty(project.BurnPort) == false) { res = "-P " + project.BurnPort; if (project.BurnPort.Length > 3) { int portNum; if (project.BurnPort.StartsWith("COM") && int.TryParse(project.BurnPort.Substring(3), out portNum)) { res = "-P //./" + project.BurnPort; } } } } catch { } args += res; res = ""; if (project.BurnBaud != 0) res = " -b " + project.BurnBaud.ToString("0"); args += res; args = args.Trim(); }
/// <summary> /// generates a makefile in the same way AVRStudio generates one /// </summary> /// <param name="proj">the project containing the settings</param> /// <returns>returns true if successful</returns> public static bool GenerateNormal(AVRProject projOrig) { AVRProject proj = projOrig.Clone(); bool success = true; StreamWriter writer = null; try { writer = new StreamWriter(proj.DirPath + Path.DirectorySeparatorChar + "Makefile"); writer.WriteLine("##################################"); writer.WriteLine("## Makefile for project: {0}", proj.SafeFileNameNoExt); writer.WriteLine("## Generated by AVR Project IDE: {0}", Properties.Resources.WebsiteURL); writer.WriteLine("##################################"); writer.WriteLine(); writer.WriteLine("## General Flags"); writer.WriteLine("PROJECT = {0}", proj.SafeFileNameNoExt); writer.WriteLine("MCU = {0}", proj.Device.ToLowerInvariant()); writer.WriteLine("BURNMCU = {0}", proj.BurnPart.ToLowerInvariant()); writer.WriteLine("BURNPROGRAMMER = {0}", proj.BurnProgrammer.ToLowerInvariant()); writer.WriteLine("OUTDIR = {0}", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("TARGET = $(OUTDIR)/$(PROJECT).elf"); writer.WriteLine("CC = avr-gcc"); writer.WriteLine("CCXX = avr-g++"); writer.WriteLine(); writer.WriteLine("## Flags common to C, ASM, and Linker"); writer.WriteLine("COMMON = -mmcu=$(MCU)"); writer.WriteLine(); writer.WriteLine("## Flags common to C only"); writer.WriteLine("CFLAGS = $(COMMON)"); writer.WriteLine("CONLYFLAGS = {0}", proj.OtherOptionsForC); string cflags = proj.OtherOptions.Trim(); if (proj.ClockFreq != 0) cflags += " -DF_CPU=" + Math.Round(proj.ClockFreq).ToString("0") + "UL "; cflags += proj.Optimization + " "; if (proj.UnsignedChars) cflags += "-funsigned-char "; if (proj.UnsignedBitfields) cflags += "-funsigned-bitfields "; if (proj.PackStructs) cflags += "-fpack-struct "; if (proj.ShortEnums) cflags += "-fshort-enums "; if (proj.FunctionSections) cflags += "-ffunction-sections "; if (proj.DataSections) cflags += "-fdata-sections "; writer.WriteLine("CFLAGS += {0}", cflags.Trim()); writer.WriteLine("CFLAGS += -MD -MP -MT $(*F).o"); writer.WriteLine(); writer.WriteLine("## Flags common to ASM only"); writer.WriteLine("ASMFLAGS = $(COMMON)"); writer.WriteLine("ASMFLAGS += $(CFLAGS)"); writer.WriteLine("ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2"); writer.WriteLine("ASMFLAGS += {0}", proj.OtherOptionsForS); writer.WriteLine(); writer.WriteLine("## Flags common to CPP/CXX only"); writer.WriteLine("CXXFLAGS = $(COMMON)"); writer.WriteLine("CXXFLAGS += $(CFLAGS)"); writer.WriteLine("CXXFLAGS += {0}", proj.OtherOptionsForCPP); writer.WriteLine(); writer.WriteLine("## Flags common to Linker only"); writer.WriteLine("LDFLAGS = $(COMMON)"); writer.WriteLine("LDFLAGS += -Wl,-Map=$(OUTDIR)/$(PROJECT).map"); writer.WriteLine("LDFLAGS += -Wl,--gc-sections"); if (proj.UseInitStack) { writer.WriteLine("LDFLAGS += -Wl,--defsym=__stack=0x{0:X}", proj.InitStackAddr); } foreach (MemorySegment seg in proj.MemorySegList.Values) { int addr = (int)seg.Addr; if (seg.Type.ToLowerInvariant() == "sram") { addr += 0x800000; } else if (seg.Type.ToLowerInvariant() == "eeprom") { addr += 0x810000; } writer.WriteLine("LDFLAGS += -Wl,-section-start={0}=0x{1:X}", seg.Name, addr); } if (string.IsNullOrEmpty(proj.LinkerOptions) == false) { writer.WriteLine("LDFLAGS += {0}", proj.LinkerOptions); } writer.WriteLine(); writer.WriteLine("## Flags for Intel HEX file production"); writer.WriteLine("HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature"); writer.WriteLine(); writer.WriteLine("HEX_EEPROM_FLAGS = -j .eeprom"); writer.WriteLine("HEX_EEPROM_FLAGS += --set-section-flags=.eeprom=\"alloc,load\""); writer.WriteLine("HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings"); foreach (MemorySegment seg in proj.MemorySegList.Values) { if (seg.Type.ToLowerInvariant() == "eeprom") { writer.WriteLine("HEX_EEPROM_FLAGS += --change-section-lma {0}=0x{1}", seg.Name, seg.Addr); } } string incdirs = "-I\".\" "; foreach (string s in proj.IncludeDirList) { if (string.IsNullOrEmpty(s) == false) incdirs += "-I\"" + s + "\" "; } incdirs = incdirs.Trim(); if (string.IsNullOrEmpty(incdirs) == false) { writer.WriteLine(); writer.WriteLine("## Include Directories"); writer.WriteLine("INCLUDES = {0}", incdirs); } string linklibstr = ""; foreach (string obj in proj.LinkLibList) { if (string.IsNullOrEmpty(obj) == false) { if (obj.StartsWith("lib")) { linklibstr += "-l" + obj.Substring(3).TrimEnd('a').TrimEnd('.') + " "; } else { string libName = Path.GetFileNameWithoutExtension(obj); if (libName.StartsWith("lib")) libName = libName.Substring(3); string libPath = Path.GetDirectoryName(obj); linklibstr += "-l" + libName + " "; if (proj.LibraryDirList.Contains(libPath) == false) proj.LibraryDirList.Add(libPath); } } } linklibstr = linklibstr.Trim(); if (string.IsNullOrEmpty(linklibstr) == false) { writer.WriteLine(); writer.WriteLine("## Libraries"); writer.WriteLine("LIBS = {0}", linklibstr); } string libdirs = ""; foreach (string s in proj.LibraryDirList) { if (string.IsNullOrEmpty(s) == false) libdirs += "-L\"" + s + "\" "; } libdirs = libdirs.Trim(); if (string.IsNullOrEmpty(libdirs) == false) { writer.WriteLine(); writer.WriteLine("## Library Directories"); writer.WriteLine("LIBDIRS = {0}", libdirs); } string ofiles = ""; string compileStr = ""; foreach (KeyValuePair<string, ProjectFile> file in proj.FileList) { if (file.Value.ToCompile && file.Value.FileExt != "h" && file.Value.FileExt != "hpp" && file.Value.FileExt != "pde") { ofiles += file.Value.FileNameNoExt + ".o "; compileStr += file.Value.FileNameNoExt + ".o: ./" + file.Value.FileRelPathTo(proj.DirPath).Replace('\\', '/'); compileStr += Environment.NewLine; if (file.Value.FileExt == "s") { compileStr += "\t $(CC) $(INCLUDES) "; compileStr += "$(ASMFLAGS)"; } else if (file.Value.FileExt == "c") { compileStr += "\t $(CC) $(INCLUDES) "; compileStr += "$(CFLAGS) $(CONLYFLAGS)"; } else if (file.Value.FileExt == "cpp" || file.Value.FileExt == "cxx") { compileStr += "\t $(CCXX) $(INCLUDES) "; compileStr += "$(CXXFLAGS)"; } compileStr += " -c "; compileStr += file.Value.Options.Trim(); compileStr += " $<" + Environment.NewLine + Environment.NewLine; } } ofiles = ofiles.Trim(); writer.WriteLine(); writer.WriteLine("## Link these object files to be made"); writer.WriteLine("OBJECTS = {0}", ofiles); string linkobjstr = ""; foreach (string s in proj.LinkObjList) { if (string.IsNullOrEmpty(s) == false) linkobjstr += "\"" + s + "\" "; } writer.WriteLine(); writer.WriteLine("## Link objects specified by users"); writer.WriteLine("LINKONLYOBJECTS = {0}", linkobjstr.Trim()); writer.WriteLine(); writer.WriteLine("## Compile"); writer.WriteLine(); writer.WriteLine("all: $(TARGET)"); writer.WriteLine(); writer.WriteLine(compileStr); writer.WriteLine(); writer.WriteLine(); writer.WriteLine("$(OUTDIR):"); writer.WriteLine("\t mkdir $@"); writer.WriteLine(); writer.WriteLine(); writer.WriteLine("## Link"); writer.WriteLine("$(TARGET): $(OBJECTS) $(OUTDIR)"); writer.WriteLine("\t-rm -rf $(TARGET) $(OUTDIR)/$(PROJECT).map"); writer.WriteLine("\t $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)"); writer.WriteLine("\t-rm -rf $(OBJECTS) {0}", (ofiles + " ").Replace(".o ", ".d ")); writer.WriteLine("\t-rm -rf $(OUTDIR)/$(PROJECT).hex $(OUTDIR)/$(PROJECT).eep $(OUTDIR)/$(PROJECT).lss"); writer.WriteLine("\tavr-objcopy -O ihex $(HEX_FLASH_FLAGS) $(TARGET) $(OUTDIR)/$(PROJECT).hex"); writer.WriteLine("\tavr-objcopy $(HEX_FLASH_FLAGS) -O ihex $(TARGET) $(OUTDIR)/$(PROJECT).eep || exit 0"); writer.WriteLine("\tavr-objdump -h -S $(TARGET) >> $(OUTDIR)/$(PROJECT).lss"); writer.WriteLine("\t@avr-size -C --mcu=${MCU} ${TARGET}"); writer.WriteLine(); writer.WriteLine("## Program"); writer.WriteLine("burn:"); string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, proj); writer.WriteLine("\tavrdude -p $(BURNMCU) -c $(BURNPROGRAMMER) {2} -U flash:w:$(OUTDIR)/$(PROJECT).hex:a {4}", proj.BurnPart, proj.BurnProgrammer, overrides, proj.FileNameNoExt, proj.BurnOptions); writer.WriteLine(); writer.WriteLine("burnfuses:"); BurnerPanel.GetPortOverride(ref overrides, proj); writer.WriteLine("\tavrdude -p $(BURNMCU) -c $(BURNPROGRAMMER) {2} {3} {4}", proj.BurnPart, proj.BurnProgrammer, overrides, proj.BurnFuseBox, proj.BurnOptions); writer.WriteLine(); writer.WriteLine("## Clean target"); writer.WriteLine(".PHONY: clean"); writer.WriteLine("clean:"); writer.WriteLine("\t-rm -rf $(OBJECTS) {0} $(OUTDIR)/$(PROJECT).elf $(OUTDIR)/$(PROJECT).map $(OUTDIR)/$(PROJECT).lss $(OUTDIR)/$(PROJECT).hex $(OUTDIR)/$(PROJECT).eep $(OUTDIR)", (ofiles + " ").Replace(".o ", ".d ")); } catch { success = false; } try { writer.Close(); } catch { success = false; } return success; }
/// <summary> /// generates a makefile that's meant for arduino /// this uses the makefile that arduino provided but replacing some placeholders /// with custom options /// </summary> /// <param name="proj">project with settings</param> /// <returns>true if successful</returns> public static bool GenerateArduino(AVRProject proj) { bool success = true; StreamWriter writer = null; try { writer = new StreamWriter(proj.DirPath + "\\Makefile"); string makefileTemplate = ASCIIEncoding.ASCII.GetString(Properties.Resources.arduinomakefile); makefileTemplate = makefileTemplate.Replace("###@@@INSTALL_DIR@@@###", ""); makefileTemplate = makefileTemplate.Replace("###@@@AVRDUDE_PART@@@###", proj.BurnPart); makefileTemplate = makefileTemplate.Replace("###@@@AVRDUDE_OPTIONS@@@###", proj.BurnOptions); makefileTemplate = makefileTemplate.Replace("###@@@AVRDUDE_PROGRAMMER@@@###", proj.BurnProgrammer); makefileTemplate = makefileTemplate.Replace("###@@@MCU@@@###", proj.Device.ToLowerInvariant()); makefileTemplate = makefileTemplate.Replace("###@@@F_CPU@@@###", proj.ClockFreq.ToString()); string cinc = ""; foreach (string s in proj.IncludeDirList) { if (string.IsNullOrEmpty(s) == false) cinc += "-I\"" + s + "\" "; } makefileTemplate = makefileTemplate.Replace("###@@@MORE_CINC@@@###", cinc); string checklist = ""; if (proj.PackStructs) checklist += "-fpack-struct "; if (proj.ShortEnums) checklist += "-fshort-enums "; if (proj.UnsignedChars) checklist += "-funsigned-char "; if (proj.UnsignedBitfields) checklist += "-funsigned-bitfields "; makefileTemplate = makefileTemplate.Replace("###@@@CTUNING@@@###", checklist); string moreLDSFLAGS = ""; if (proj.UseInitStack) { moreLDSFLAGS += String.Format(Environment.NewLine + "LDFLAGS += -Wl,--defsym=__stack=0x{0:X}", proj.InitStackAddr); } foreach (MemorySegment seg in proj.MemorySegList.Values) { int addr = (int)seg.Addr; if (seg.Type.ToLowerInvariant() == "sram") { addr += 0x800000; } else if (seg.Type.ToLowerInvariant() == "eeprom") { addr += 0x810000; } moreLDSFLAGS += String.Format(Environment.NewLine + "LDFLAGS += -Wl,-section-start={0}=0x{1:X}", seg.Name, addr); } if (string.IsNullOrEmpty(proj.LinkerOptions) == false) { moreLDSFLAGS += String.Format(Environment.NewLine + "LDFLAGS += {0}", proj.LinkerOptions); } string libdirs = ""; foreach (string s in proj.LibraryDirList) { if (string.IsNullOrEmpty(s) == false) libdirs += "-L\"" + s + "\" "; } libdirs = libdirs.Trim(); if (string.IsNullOrEmpty(libdirs) == false) { moreLDSFLAGS += " " + libdirs; } string linklibstr = ""; foreach (string s in proj.LinkLibList) { if (string.IsNullOrEmpty(s) == false) { if (s.StartsWith("lib")) { linklibstr += "-l" + s.Substring(3).TrimEnd('a').TrimEnd('.') + " "; } else { linklibstr += "-l\"" + s.TrimEnd('a').TrimEnd('.') + "\" "; } } } linklibstr = linklibstr.Trim(); if (string.IsNullOrEmpty(linklibstr) == false) { moreLDSFLAGS += " " + linklibstr; } makefileTemplate = makefileTemplate.Replace("###@@@MORE_LDFLAGS@@@###", moreLDSFLAGS); string addEEPROM = ""; foreach (MemorySegment seg in proj.MemorySegList.Values) { if (seg.Type.ToLowerInvariant() == "eeprom") { addEEPROM += String.Format("--change-section-lma {0}=0x{1} ", seg.Name, seg.Addr); } } makefileTemplate = makefileTemplate.Replace("###@@@ADD_EEPROM_ADDRS@@@###", addEEPROM); writer.Write(makefileTemplate); } catch { success = false; } try { writer.Close(); } catch { success = false; } return success; }
private void PrepProject() { // clone the project workingProject = (AVRProject)project.Clone(); // make a clone of the file list workingFileList = workingProject.FileList; //new Dictionary<string, ProjectFile>(); //workingFileList.Clear(); //foreach (KeyValuePair<string, ProjectFile> file in workingProject.FileList) //{ // ProjectFile newFile = (ProjectFile)file.Value.Clone(); // workingFileList.Add(file.Key, newFile); //} // all this cloning is to make sure the background worker thread used for the build // doesn't access the same resources as the main thread return; }
public ProjectBurner(AVRProject project) { this.project = project; // a reference to this proccess is kept so it can be killed avrdude = new Process(); }
public ConfigWindow(AVRProject project) { InitializeComponent(); if (orderedDevices == null) { orderedDevices = new List <string>(); } if (orderedDevices.Count == 0) { foreach (string s in dropDevices.Items) { if (orderedDevices.Contains(s.ToLowerInvariant()) == false) { orderedDevices.Add(s.ToLowerInvariant()); } } string pathToXmls = SettingsManagement.AppInstallPath + "chip_xml" + Path.DirectorySeparatorChar; if (Directory.Exists(pathToXmls)) { foreach (FileInfo fi in new DirectoryInfo(pathToXmls).GetFiles()) { if (fi.Name.ToLowerInvariant() != "interruptvectors.xml") { if (fi.Name.ToLowerInvariant().EndsWith(".xml")) { string name = Path.GetFileNameWithoutExtension(fi.Name).ToLowerInvariant().Trim(); if (orderedDevices.Contains(name) == false) { orderedDevices.Add(name); } } } } } orderedDevices.Sort((x, y) => string.Compare(x, y)); } dropDevices.Items.Clear(); foreach (string s in orderedDevices) { dropDevices.Items.Add(s); } this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); grpBoxBurnerPanel.Controls.Add(burnerPanel); burnerPanel.Dock = DockStyle.Fill; this.originalProject.HasBeenConfigged = true; this.project.HasBeenConfigged = true; string[] templateList = ProjTemplate.GetTemplateNames(); foreach (string tempName in templateList) { dropTemplates.Items.Add(tempName); } if (dropTemplates.Items.Count == 0) { dropTemplates.Items.Add("No Templates Available"); } dropTemplates.SelectedIndex = 0; PopulateForm(); }
private void ApplyChanges() { FormToProj(); this.originalProject = this.project.CopyProperties(this.originalProject); }
public void Run(ProjectFile file, AVRProject proj) { try { string cmd = this.cmdStr; if (string.IsNullOrEmpty(cmd)) { return; } Process p = new Process(); p.StartInfo.FileName = cmd; if (proj != null) { if (proj.IsReady) { p.StartInfo.WorkingDirectory = proj.DirPath; } } string args = this.argsStr; if (string.IsNullOrEmpty(args) == false) { if (proj != null) { if (proj.IsReady) { args = args.Replace("%PROJNAME%", proj.FileNameNoExt); args = args.Replace("%PROJDIR%", proj.DirPath); args = args.Replace("%PROJOUTFOLDER%", proj.OutputDir); args = args.Replace("%PROJCHIP%", proj.Device); if (file != null) { args = args.Replace("%FILENAMENOEXT%", file.FileNameNoExt); args = args.Replace("%FILEEXT%", file.FileExt); args = args.Replace("%FILEDIR%", file.FileDir); } } } ProjectBuilder.SetEnviroVarsForProc(p.StartInfo); p.StartInfo.Arguments = args; } string dir = this.dirStr; if (string.IsNullOrEmpty(dir) == false) { if (proj != null) { if (proj.IsReady) { dir = dir.Replace("%PROJDIR%", proj.DirPath); dir = dir.Replace("%PROJOUTFOLDER%", proj.OutputDir); if (file != null) { dir = dir.Replace("%FILEDIR%", file.FileDir); } } } p.StartInfo.WorkingDirectory = dir; } if (p.Start()) { // } else { MessageBox.Show(String.Format("Process '{0} {1}' failed to start.", cmd, args)); } } catch (Exception ex) { MessageBox.Show("Error during execution: " + ex.Message); } }
/// <summary> /// Makes a copy of AVRProject, used by the background worker of the project builder /// </summary> /// <returns>Reference to the Cloned AVRProject</returns> public object Clone() { object newObject = new AVRProject(); ((AVRProject)newObject).BurnOptions = this.BurnOptions; ((AVRProject)newObject).BurnPart = this.BurnPart; ((AVRProject)newObject).BurnProgrammer = this.BurnProgrammer; ((AVRProject)newObject).ClockFreq = this.ClockFreq; ((AVRProject)newObject).Device = this.Device; ((AVRProject)newObject).dirPath = this.DirPath; ((AVRProject)newObject).FilePath = this.FilePath; ((AVRProject)newObject).InitStackAddr = this.InitStackAddr; ((AVRProject)newObject).LinkerOptions = this.LinkerOptions; ((AVRProject)newObject).Optimization = this.Optimization; ((AVRProject)newObject).OtherOptions = this.OtherOptions; ((AVRProject)newObject).OutputDir = this.OutputDir; ((AVRProject)newObject).PackStructs = this.PackStructs; ((AVRProject)newObject).ShortEnums = this.ShortEnums; ((AVRProject)newObject).UnsignedBitfields = this.UnsignedBitfields; ((AVRProject)newObject).UnsignedChars = this.UnsignedChars; ((AVRProject)newObject).UseInitStack = this.UseInitStack; ((AVRProject)newObject).fileList = new Dictionary<string, ProjectFile>(); ((AVRProject)newObject).fileList.Clear(); foreach (KeyValuePair<string, ProjectFile> file in this.FileList) { ProjectFile newFile = (ProjectFile)file.Value.Clone(); ((AVRProject)newObject).fileList.Add(file.Key, newFile); } ((AVRProject)newObject).includeDirList = new List<string>(); ((AVRProject)newObject).includeDirList.Clear(); foreach (string dir in this.IncludeDirList) { ((AVRProject)newObject).includeDirList.Add((string)dir.Clone()); } ((AVRProject)newObject).libraryDirList = new List<string>(); ((AVRProject)newObject).libraryDirList.Clear(); foreach (string dir in this.LibraryDirList) { ((AVRProject)newObject).libraryDirList.Add((string)dir.Clone()); } ((AVRProject)newObject).linkLibList = new List<string>(); ((AVRProject)newObject).linkLibList.Clear(); foreach (string obj in this.LinkLibList) { ((AVRProject)newObject).linkLibList.Add((string)obj.Clone()); } ((AVRProject)newObject).linkObjList = new List<string>(); ((AVRProject)newObject).linkObjList.Clear(); foreach (string obj in this.LinkObjList) { ((AVRProject)newObject).linkObjList.Add((string)obj.Clone()); } ((AVRProject)newObject).memorySegList = new List<MemorySegment>(); ((AVRProject)newObject).memorySegList.Clear(); foreach (MemorySegment obj in this.MemorySegList) { ((AVRProject)newObject).memorySegList.Add(new MemorySegment(obj.Type, obj.Name, obj.Addr)); } return newObject; }
/// <summary> /// determines what kind of makefile to generate /// works by checking if the project includes pde files /// </summary> /// <param name="proj">project with settings and file list</param> /// <returns>true if makefile is generated successfully</returns> public static bool Generate(AVRProject proj) { if (proj.UseArduinoMakefile) return GenerateArduino(proj); else return GenerateNormal(proj); }
/// <summary> /// Makes a copy of AVRProject, used by the background worker of the project builder /// </summary> /// <returns>Reference to the Cloned AVRProject</returns> public object Clone() { object newObject = new AVRProject(); ((AVRProject)newObject).BurnOptions = this.BurnOptions; ((AVRProject)newObject).BurnPart = this.BurnPart; ((AVRProject)newObject).BurnProgrammer = this.BurnProgrammer; ((AVRProject)newObject).ClockFreq = this.ClockFreq; ((AVRProject)newObject).Device = this.Device; ((AVRProject)newObject).dirPath = this.DirPath; ((AVRProject)newObject).FilePath = this.FilePath; ((AVRProject)newObject).InitStackAddr = this.InitStackAddr; ((AVRProject)newObject).LinkerOptions = this.LinkerOptions; ((AVRProject)newObject).Optimization = this.Optimization; ((AVRProject)newObject).OtherOptions = this.OtherOptions; ((AVRProject)newObject).OutputDir = this.OutputDir; ((AVRProject)newObject).PackStructs = this.PackStructs; ((AVRProject)newObject).ShortEnums = this.ShortEnums; ((AVRProject)newObject).UnsignedBitfields = this.UnsignedBitfields; ((AVRProject)newObject).UnsignedChars = this.UnsignedChars; ((AVRProject)newObject).UseInitStack = this.UseInitStack; ((AVRProject)newObject).fileList = new Dictionary <string, ProjectFile>(); ((AVRProject)newObject).fileList.Clear(); foreach (KeyValuePair <string, ProjectFile> file in this.FileList) { ProjectFile newFile = (ProjectFile)file.Value.Clone(); ((AVRProject)newObject).fileList.Add(file.Key, newFile); } ((AVRProject)newObject).includeDirList = new List <string>(); ((AVRProject)newObject).includeDirList.Clear(); foreach (string dir in this.IncludeDirList) { ((AVRProject)newObject).includeDirList.Add((string)dir.Clone()); } ((AVRProject)newObject).libraryDirList = new List <string>(); ((AVRProject)newObject).libraryDirList.Clear(); foreach (string dir in this.LibraryDirList) { ((AVRProject)newObject).libraryDirList.Add((string)dir.Clone()); } ((AVRProject)newObject).linkLibList = new List <string>(); ((AVRProject)newObject).linkLibList.Clear(); foreach (string obj in this.LinkLibList) { ((AVRProject)newObject).linkLibList.Add((string)obj.Clone()); } ((AVRProject)newObject).linkObjList = new List <string>(); ((AVRProject)newObject).linkObjList.Clear(); foreach (string obj in this.LinkObjList) { ((AVRProject)newObject).linkObjList.Add((string)obj.Clone()); } ((AVRProject)newObject).memorySegList = new List <MemorySegment>(); ((AVRProject)newObject).memorySegList.Clear(); foreach (MemorySegment obj in this.MemorySegList) { ((AVRProject)newObject).memorySegList.Add(new MemorySegment(obj.Type, obj.Name, obj.Addr)); } return(newObject); }
private void btnSaveAndClose_Click(object sender, EventArgs e) { burnerPanel.FormToProj(); this.originalProject = this.project.CopyProperties(this.originalProject); this.Close(); }
public ProjectFile(string fileAbsPath, AVRProject project) { this.project = project; FileAbsPath = fileAbsPath; if (FileExt == "c" || FileExt == "s" || FileExt == "cpp" || FileExt == "cxx" || FileExt == "pde") ToCompile = true; options = ""; isOpen = false; treeNode = new TreeNode(FileName); treeNode.ImageKey = "file2.ico"; treeNode.SelectedImageKey = "file2.ico"; treeNode.StateImageKey = "file2.ico"; treeNode.Checked = toCompile; }
public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); splash = new SplashScreen(); splash.Show(); try { SettingsManagement.Load(); FileTemplate.Unpack(); ProjTemplate.Load(); if (SettingsManagement.AutocompleteEnable) { KeywordImageGen.GenerateKeywordImages(); } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Initialization Error"); } try { UpdateMech.CheckForUpdates(); } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error Checking Updates"); } try { AVRProject newProject = new AVRProject(); if (args.Length > 0) { string fname = args[0]; if (newProject.Open(fname) == true) { SettingsManagement.AddFileAsMostRecent(fname); } else { MessageBox.Show("Error, failed to open file"); } } else if (SettingsManagement.OpenLastProject) { if (string.IsNullOrEmpty(SettingsManagement.LastProjectPath) == false) { if (newProject.Open(SettingsManagement.LastProjectPath) == true) { SettingsManagement.AddFileAsMostRecent(SettingsManagement.LastProjectPath); } else { MessageBox.Show("Error, failed to open file"); } } } KeywordScanner.Initialize(); Application.Run(new IDEWindow(newProject)); if (newProject.IsReady) { if (SettingsManagement.SaveRecentList() == false) { MessageBox.Show("Error, Could Not Save Recent File List"); } } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Main IDE Error"); } try { if (UpdateMech.HasFinishedChecking) { if (UpdateMech.UpdateAvailable) { try { if (MessageBox.Show("An Updated Version of AVR Project IDE is Available (" + SettingsManagement.Version + " to " + UpdateMech.NewBuildID + "). Would you like to download it?", "Update Available", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(Properties.Resources.WebsiteURL); } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Updater Error"); } } } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error Checking Updates"); } try { if (SettingsManagement.LastRunVersion != SettingsManagement.Version) { NotifyOfUserAction(); } SettingsManagement.LastRunVersion = SettingsManagement.Version; } catch { } }
public static string GetArgs(AVRProject project) { string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, project); string res = String.Format("-p {0} -c {1} {2} {3}", project.BurnPart.ToUpperInvariant(), project.BurnProgrammer, overrides, project.BurnOptions); while (res.Contains(" ")) res = res.Replace(" ", " "); return res; }
public static bool Generate(AVRProject proj) { bool success = true; StreamWriter writer = null; try { writer = new StreamWriter(proj.DirPath + "\\Makefile"); writer.WriteLine("##################################"); writer.WriteLine("## Makefile for project: {0}", proj.FileNameNoExt); writer.WriteLine("##################################"); writer.WriteLine(); writer.WriteLine("## General Flags"); writer.WriteLine("PROJECT = {0}", proj.FileNameNoExt); writer.WriteLine("MCU = {0}", proj.Device); writer.WriteLine("TARGET = {0}/$(PROJECT).elf", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("CC = avr-gcc"); writer.WriteLine(); writer.WriteLine("## Flags common to C, ASM, and Linker"); writer.WriteLine("COMMON = -mmcu=$(MCU)"); writer.WriteLine(); writer.WriteLine("## Flags common to C only"); writer.WriteLine("CFLAGS = $(COMMON)"); string cflags = ""; cflags += "-Wall "; cflags += "-gdwarf-2 "; cflags += "-std=gnu99 "; if (proj.ClockFreq != 0) { cflags += "-DF_CPU=" + Convert.ToString(Math.Round(proj.ClockFreq)) + "UL "; } cflags += proj.Optimization + " "; if (proj.UnsignedChars) { cflags += "-funsigned-char "; } if (proj.UnsignedBitfields) { cflags += "-funsigned-bitfields "; } if (proj.PackStructs) { cflags += "-fpack-struct "; } if (proj.ShortEnums) { cflags += "-fshort-enums "; } writer.WriteLine("CFLAGS += {0} {1}", cflags.Trim(), proj.OtherOptions.Trim()); writer.WriteLine("CFLAGS += -MD -MP -MT $(*F).o"); writer.WriteLine(); writer.WriteLine("## Flags common to ASM only"); writer.WriteLine("ASMFLAGS = $(COMMON)"); writer.WriteLine("ASMFLAGS += $(CFLAGS)"); writer.WriteLine("ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2"); writer.WriteLine(); writer.WriteLine("## Flags common to Linker only"); writer.WriteLine("LDFLAGS = $(COMMON)"); writer.WriteLine("LDFLAGS += {0}", proj.LinkerOptions); writer.WriteLine("LDFLAGS += -Wl,-Map={0}/$(PROJECT).map", proj.OutputDir.Replace('\\', '/')); if (proj.UseInitStack) { writer.WriteLine("LDFLAGS += -Wl,--defsym=__stack=0x{0:X}", proj.InitStackAddr); } foreach (MemorySegment seg in proj.MemorySegList) { int addr = (int)seg.Addr; if (seg.Type.ToLower() == "sram") { addr += 0x800000; } else if (seg.Type.ToLower() == "eeprom") { addr += 0x810000; } writer.WriteLine("LDFLAGS += -Wl,-section-start={0}=0x{1:X}", seg.Name, addr); } writer.WriteLine(); writer.WriteLine("## Flags for Intel HEX file production"); writer.WriteLine("HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature"); writer.WriteLine(); writer.WriteLine("HEX_EEPROM_FLAGS = -j .eeprom"); writer.WriteLine("HEX_EEPROM_FLAGS += --set-section-flags=.eeprom=\"alloc,load\""); writer.WriteLine("HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings"); foreach (MemorySegment seg in proj.MemorySegList) { if (seg.Type.ToLower() == "eeprom") { writer.WriteLine("HEX_EEPROM_FLAGS += --change-section-lma {0}=0x{1}", seg.Name, seg.Addr); } } string incdirs = ""; foreach (string s in proj.IncludeDirList) { if (string.IsNullOrEmpty(s) == false) { incdirs += "-I\"" + s + "\" "; } } incdirs = incdirs.Trim(); if (string.IsNullOrEmpty(incdirs) == false) { writer.WriteLine(); writer.WriteLine("## Include Directories"); writer.WriteLine("INCLUDES = {0}", incdirs); } string libdirs = ""; foreach (string s in proj.LibraryDirList) { if (string.IsNullOrEmpty(s) == false) { libdirs += "-L\"" + s + "\" "; } } libdirs = libdirs.Trim(); if (string.IsNullOrEmpty(libdirs) == false) { writer.WriteLine(); writer.WriteLine("## Library Directories"); writer.WriteLine("LIBDIRS = {0}", libdirs); } string linklibstr = ""; foreach (string s in proj.LinkLibList) { if (string.IsNullOrEmpty(s) == false) { if (s.StartsWith("lib")) { linklibstr += "-l" + s.Substring(3).TrimEnd('a').TrimEnd('.') + " "; } else { linklibstr += "-l\"" + s.TrimEnd('a').TrimEnd('.') + "\" "; } } } linklibstr = linklibstr.Trim(); if (string.IsNullOrEmpty(linklibstr) == false) { writer.WriteLine(); writer.WriteLine("## Libraries"); writer.WriteLine("LIBS = {0}", linklibstr); } string ofiles = ""; string compileStr = ""; foreach (KeyValuePair <string, ProjectFile> file in proj.FileList) { if (file.Value.ToCompile && file.Value.FileExt != "h") { ofiles += file.Value.FileNameNoExt + ".o "; compileStr += file.Value.FileNameNoExt + ".o: ./" + file.Value.FileRelPath.Replace('\\', '/'); compileStr += "\r\n"; compileStr += "\t $(CC) $(INCLUDES) "; if (file.Value.FileExt == "s") { compileStr += "$(ASMFLAGS)"; } else if (file.Value.FileExt == "c") { compileStr += "$(CFLAGS)"; } compileStr += " -c "; compileStr += file.Value.Options.Trim(); compileStr += " $<\r\n\r\n"; } } ofiles = ofiles.Trim(); writer.WriteLine(); writer.WriteLine("## Link these object files to be made"); writer.WriteLine("OBJECTS = {0}", ofiles); string linkobjstr = ""; foreach (string s in proj.LinkObjList) { if (string.IsNullOrEmpty(s) == false) { linkobjstr += "\"" + s + "\" "; } } writer.WriteLine(); writer.WriteLine("## Link objects specified by users"); writer.WriteLine("LINKONLYOBJECTS = {0}", linkobjstr.Trim()); writer.WriteLine(); writer.WriteLine("## Compile"); writer.WriteLine(); writer.WriteLine("all: $(TARGET)"); writer.WriteLine(); writer.WriteLine(compileStr); writer.WriteLine(); writer.WriteLine("## Link"); writer.WriteLine("$(TARGET): $(OBJECTS)"); writer.WriteLine("\t-rm -rf $(TARGET) {0}/$(PROJECT).map", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("\t $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)"); writer.WriteLine("\t-rm -rf $(OBJECTS) {0}", (ofiles + " ").Replace(".o ", ".d ")); writer.WriteLine("\t-rm -rf {0}/$(PROJECT).hex {0}/$(PROJECT).eep {0}/$(PROJECT).lss", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("\tavr-objcopy -O ihex $(HEX_FLASH_FLAGS) $(TARGET) {0}/$(PROJECT).hex", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("\tavr-objcopy $(HEX_FLASH_FLAGS) -O ihex $(TARGET) {0}/$(PROJECT).eep || exit 0", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("\tavr-objdump -h -S $(TARGET) >> {0}/$(PROJECT).lss", proj.OutputDir.Replace('\\', '/')); writer.WriteLine("\t@avr-size -C --mcu=${MCU} ${TARGET}"); writer.WriteLine(); writer.WriteLine("## Clean target"); writer.WriteLine(".PHONY: clean"); writer.WriteLine("clean:"); writer.WriteLine("\t-rm -rf $(OBJECTS) {1} {0}/$(PROJECT).elf {0}/$(PROJECT).map {0}/$(PROJECT).lss {0}/$(PROJECT).hex {0}/$(PROJECT).eep", proj.OutputDir.Replace('\\', '/'), (ofiles + " ").Replace(".o ", ".d ")); } catch { success = false; } try { writer.Close(); } catch { success = false; } return(success); }
private void btnClone_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPath.Text)) { MessageBox.Show("The path cannot be empty"); return; } if (Program.MakeSurePathExists(txtPath.Text)) { string targetDir = txtPath.Text + Path.DirectorySeparatorChar + project.FileNameNoExt; if (Program.MakeSurePathExists(targetDir)) { AVRProject newProject = new AVRProject(); newProject = project.CopyProperties(newProject); newProject.FileList.Clear(); newProject.FilePath = targetDir + Path.DirectorySeparatorChar + project.FileNameNoExt + ".avrproj"; foreach (KeyValuePair<string, ProjectFile> file in project.FileList) { try { string nfpath; if (file.Value.FileRelProjPath.StartsWith("..")) { if (radCopyAll.Checked) { string extDir = targetDir + Path.DirectorySeparatorChar + "external_files"; nfpath = extDir + Path.DirectorySeparatorChar + file.Value.FileName; } else { nfpath = file.Value.FileAbsPath; } } else { nfpath = targetDir + Path.DirectorySeparatorChar + file.Value.FileRelProjPath; } ProjectFile npf = new ProjectFile(nfpath, newProject); npf.Options = file.Value.Options; npf.ToCompile = file.Value.ToCompile; if (file.Value.FileAbsPath != nfpath) { if (Program.MakeSurePathExists(npf.FileDir)) { try { File.Copy(file.Value.FileAbsPath, nfpath, true); newProject.FileList.Add(file.Key, npf); } catch (Exception ex) { MessageBox.Show("Error while copying '" + file.Key + "' to '" + nfpath + "' : " + ex.Message); return; } } else { MessageBox.Show("Error while creating '" + npf.FileDir + "'"); return; } } } catch (Exception ex) { MessageBox.Show("Error during the cloning process: " + ex.Message); return; } } try { if (chkCopyUnmanaged.Checked) { Program.CopyAll(new DirectoryInfo(project.DirPath), new DirectoryInfo(targetDir)); } if (newProject.Save() == SaveResult.Successful) { if (chkOpenAfterClone.Checked) { try { System.Diagnostics.Process.Start(newProject.DirPath); } catch (Exception ex) { MessageBox.Show("Could not open folder: " + ex.Message); } } this.Close(); } else { MessageBox.Show("An error occured, the project XML (.avrproj) file did not save."); } } catch (Exception ex) { MessageBox.Show("Error during the cloning process: " + ex.Message); return; } } else { MessageBox.Show("The path cannot be found or created"); return; } } else { MessageBox.Show("The path cannot be found or created"); return; } this.Close(); }
public FileAddWizard(AVRProject project) { oldExt = SettingsManagement.LastFileExt; InitializeComponent(); this.project = project; if (project.FileList.Count == 0) { this.txtFileName.Text = project.FileNameNoExt; } this.SelectedExtension = SettingsManagement.LastFileExt; this.dropTemplates.Items.Clear(); this.dropTemplates.Items.Add("none"); this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("none"); foreach (FileInfo f in new DirectoryInfo(FileTemplate.TemplateFolderPath).GetFiles()) { if (f.Name.ToLowerInvariant().Trim().EndsWith(".txt")) this.dropTemplates.Items.Add(Path.GetFileNameWithoutExtension(f.Name)); } if (project.FileList.Count > 0) { if (this.SelectedExtension == "c" || this.SelectedExtension == "cpp" || this.SelectedExtension == "pde") { if (this.dropTemplates.Items.Contains("defaultcode")) this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultcode"); } else if (this.SelectedExtension == "h" || this.SelectedExtension == "hpp") { if (this.dropTemplates.Items.Contains("defaultheader")) this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultheader"); } } else { if (this.SelectedExtension == "c" || this.SelectedExtension == "cpp") { if (this.dropTemplates.Items.Contains("initialmain")) this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("initialmain"); } else if (this.SelectedExtension == "pde") { if (this.dropTemplates.Items.Contains("initialpde")) this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("initialpde"); } else if (this.SelectedExtension == "h" || this.SelectedExtension == "hpp") { if (this.dropTemplates.Items.Contains("defaultheader")) this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultheader"); } } this.txtDirLoc.Text = project.DirPath.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, }) + Path.DirectorySeparatorChar; this.txtDirLoc.SelectionStart = this.txtDirLoc.Text.Length; this.txtDirLoc.SelectionLength = 0; this.txtDirLoc.ScrollToCaret(); }
public AVRProject CopyProperties(AVRProject project) { //LoadWaitWindow lww = new LoadWaitWindow(); //lww.Show(); project.IsReady = this.IsReady; project.FilePath = this.FilePath; project.BurnOptions = this.BurnOptions; project.BurnPart = this.BurnPart; project.BurnProgrammer = this.BurnProgrammer; project.BurnBaud = this.BurnBaud; project.BurnPort = this.BurnPort; project.BurnFuseBox = this.BurnFuseBox; project.BurnAutoReset = this.BurnAutoReset; project.ClockFreq = this.ClockFreq; project.Device = this.Device; project.dirPath = this.DirPath; project.FilePath = this.FilePath; project.InitStackAddr = this.InitStackAddr; project.LinkerOptions = this.LinkerOptions; project.Optimization = this.Optimization; project.OtherOptions = this.OtherOptions; project.OtherOptionsForC = this.OtherOptionsForC; project.OtherOptionsForCPP = this.OtherOptionsForCPP; project.OtherOptionsForS = this.OtherOptionsForS; project.OutputDir = this.OutputDir; project.PackStructs = this.PackStructs; project.ShortEnums = this.ShortEnums; project.UnsignedBitfields = this.UnsignedBitfields; project.UnsignedChars = this.UnsignedChars; project.FunctionSections = this.FunctionSections; project.DataSections = this.DataSections; project.UseInitStack = this.UseInitStack; project.LastFile = this.LastFile; project.HasBeenConfigged = this.HasBeenConfigged; project.ShouldReloadDevice = this.ShouldReloadDevice; project.ShouldReloadFiles = this.ShouldReloadFiles; project.ShouldReloadClock = this.ShouldReloadClock; project.fileList = new Dictionary<string, ProjectFile>(); project.fileList.Clear(); foreach (KeyValuePair<string, ProjectFile> file in this.FileList) { ProjectFile newFile = file.Value.Clone(); project.fileList.Add(file.Key, newFile); } project.includeDirList = new List<string>(); project.includeDirList.Clear(); foreach (string dir in this.IncludeDirList) { project.includeDirList.Add((string)dir.Clone()); } project.libraryDirList = new List<string>(); project.libraryDirList.Clear(); foreach (string dir in this.LibraryDirList) { project.libraryDirList.Add((string)dir.Clone()); } project.linkLibList = new List<string>(); project.linkLibList.Clear(); foreach (string obj in this.LinkLibList) { project.linkLibList.Add((string)obj.Clone()); } project.linkObjList = new List<string>(); project.linkObjList.Clear(); foreach (string obj in this.LinkObjList) { project.linkObjList.Add((string)obj.Clone()); } project.memorySegList = new Dictionary<string, MemorySegment>(); project.memorySegList.Clear(); foreach (MemorySegment obj in this.MemorySegList.Values) { project.memorySegList.Add(obj.Name, new MemorySegment(obj.Type, obj.Name, obj.Addr)); } project.ArduinoCoreOverride = this.ArduinoCoreOverride; project.APSXmlElementList = new List<XmlElement>(); project.APSXmlElementList.Clear(); foreach (XmlElement obj in this.APSXmlElementList) { project.APSXmlElementList.Add((XmlElement)obj.Clone()); } //lww.Close(); return project; }
public FileAddWizard(AVRProject project) { oldExt = SettingsManagement.LastFileExt; InitializeComponent(); this.project = project; if (project.FileList.Count == 0) { this.txtFileName.Text = project.FileNameNoExt; } this.SelectedExtension = SettingsManagement.LastFileExt; this.dropTemplates.Items.Clear(); this.dropTemplates.Items.Add("none"); this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("none"); foreach (FileInfo f in new DirectoryInfo(FileTemplate.TemplateFolderPath).GetFiles()) { if (f.Name.ToLowerInvariant().Trim().EndsWith(".txt")) { this.dropTemplates.Items.Add(Path.GetFileNameWithoutExtension(f.Name)); } } if (project.FileList.Count > 0) { if (this.SelectedExtension == "c" || this.SelectedExtension == "cpp" || this.SelectedExtension == "pde") { if (this.dropTemplates.Items.Contains("defaultcode")) { this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultcode"); } } else if (this.SelectedExtension == "h" || this.SelectedExtension == "hpp") { if (this.dropTemplates.Items.Contains("defaultheader")) { this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultheader"); } } } else { if (this.SelectedExtension == "c" || this.SelectedExtension == "cpp") { if (this.dropTemplates.Items.Contains("initialmain")) { this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("initialmain"); } } else if (this.SelectedExtension == "pde") { if (this.dropTemplates.Items.Contains("initialpde")) { this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("initialpde"); } } else if (this.SelectedExtension == "h" || this.SelectedExtension == "hpp") { if (this.dropTemplates.Items.Contains("defaultheader")) { this.dropTemplates.SelectedIndex = this.dropTemplates.Items.IndexOf("defaultheader"); } } } this.txtDirLoc.Text = project.DirPath.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, }) + Path.DirectorySeparatorChar; this.txtDirLoc.SelectionStart = this.txtDirLoc.Text.Length; this.txtDirLoc.SelectionLength = 0; this.txtDirLoc.ScrollToCaret(); }
public ProjectBurner(AVRProject myProject) { this.myProject = myProject; avrdude = new Process(); }
private void btnClone_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPath.Text)) { MessageBox.Show("The path cannot be empty"); return; } if (Program.MakeSurePathExists(txtPath.Text)) { string targetDir = txtPath.Text + Path.DirectorySeparatorChar + project.FileNameNoExt; if (Program.MakeSurePathExists(targetDir)) { AVRProject newProject = new AVRProject(); newProject = project.CopyProperties(newProject); newProject.FileList.Clear(); newProject.FilePath = targetDir + Path.DirectorySeparatorChar + project.FileNameNoExt + ".avrproj"; foreach (KeyValuePair <string, ProjectFile> file in project.FileList) { try { string nfpath; if (file.Value.FileRelProjPath.StartsWith("..")) { if (radCopyAll.Checked) { string extDir = targetDir + Path.DirectorySeparatorChar + "external_files"; nfpath = extDir + Path.DirectorySeparatorChar + file.Value.FileName; } else { nfpath = file.Value.FileAbsPath; } } else { nfpath = targetDir + Path.DirectorySeparatorChar + file.Value.FileRelProjPath; } ProjectFile npf = new ProjectFile(nfpath, newProject); npf.Options = file.Value.Options; npf.ToCompile = file.Value.ToCompile; if (file.Value.FileAbsPath != nfpath) { if (Program.MakeSurePathExists(npf.FileDir)) { try { File.Copy(file.Value.FileAbsPath, nfpath, true); newProject.FileList.Add(file.Key, npf); } catch (Exception ex) { MessageBox.Show("Error while copying '" + file.Key + "' to '" + nfpath + "' : " + ex.Message); return; } } else { MessageBox.Show("Error while creating '" + npf.FileDir + "'"); return; } } } catch (Exception ex) { MessageBox.Show("Error during the cloning process: " + ex.Message); return; } } try { if (chkCopyUnmanaged.Checked) { Program.CopyAll(new DirectoryInfo(project.DirPath), new DirectoryInfo(targetDir)); } if (newProject.Save() == SaveResult.Successful) { if (chkOpenAfterClone.Checked) { try { System.Diagnostics.Process.Start(newProject.DirPath); } catch (Exception ex) { MessageBox.Show("Could not open folder: " + ex.Message); } } this.Close(); } else { MessageBox.Show("An error occured, the project XML (.avrproj) file did not save."); } } catch (Exception ex) { MessageBox.Show("Error during the cloning process: " + ex.Message); return; } } else { MessageBox.Show("The path cannot be found or created"); return; } } else { MessageBox.Show("The path cannot be found or created"); return; } this.Close(); }
public Wizard(AVRProject project) { this.project = project; InitializeComponent(); this.DialogResult = DialogResult.Cancel; string[] templateList = ProjTemplate.GetTemplateNames(); foreach (string tempName in templateList) { dropTemplates.Items.Add(tempName); } if (dropTemplates.Items.Count == 0) { dropTemplates.Items.Add("No Templates Available"); } string lastTemp = SettingsManagement.LastTemplate; if (lastTemp == null) { lastTemp = ""; } if (dropTemplates.Items.Contains(lastTemp)) { dropTemplates.SelectedIndex = dropTemplates.Items.IndexOf(lastTemp); } else { dropTemplates.SelectedIndex = 0; } // warning, hack string lastFileType = SettingsManagement.LastInitialFileType; if (lastFileType == null) { lastFileType = ""; } if (dropFileType.Items.Contains(lastFileType)) { dropFileType.SelectedIndex = dropFileType.Items.IndexOf(lastFileType); } else { dropFileType.SelectedIndex = 0; } if (dropFileType.SelectedIndex < 0) { dropFileType.SelectedIndex = 0; } if (dropTemplates.SelectedIndex < 0) { dropTemplates.SelectedIndex = 0; } if (string.IsNullOrEmpty(SettingsManagement.FavFolder)) { string mydocs = Program.CleanFilePath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) + Path.DirectorySeparatorChar + "Projects"; SettingsManagement.FavFolder = mydocs; } txtFolderPath.Text = SettingsManagement.FavFolder + Path.DirectorySeparatorChar; string newFileName = DateTime.Now.ToString("MM_dd_yyyy").Replace(' ', '_').Replace('-', '_').Replace(Path.AltDirectorySeparatorChar, '_').Replace(Path.DirectorySeparatorChar, '_');; char[] illegalChars = Path.GetInvalidFileNameChars(); foreach (char c in illegalChars) { newFileName.Replace(c, '_'); } Random r = new Random(); txtProjName.Text = "Sketch_" + newFileName + "_" + r.Next(15).ToString("X"); }
internal static void LoadTemplateCommonProperties(ref int appCnt, XmlElement docx, AVRProject proj) { foreach (XmlElement param in docx.GetElementsByTagName("ClockFreq")) { proj.ClockFreq = decimal.Parse(param.InnerText, System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowTrailingWhite); appCnt++; } foreach (XmlElement param in docx.GetElementsByTagName("Device")) { proj.Device = param.InnerText; appCnt++; } foreach (XmlElement param in docx.GetElementsByTagName("LinkerOpt")) { proj.LinkerOptions = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("OtherOpt")) { proj.OtherOptions = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("OtherOptionsForC")) { proj.OtherOptionsForC = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("OtherOptionsForCPP")) { proj.OtherOptionsForCPP = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("OtherOptionsForS")) { proj.OtherOptionsForS = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("Optimization")) { proj.Optimization = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("UseInitStack")) { proj.UseInitStack = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("InitStackAddr")) { try { if (param.InnerText.ToLowerInvariant().StartsWith("0x")) { proj.InitStackAddr = Convert.ToUInt32(param.InnerText, 16); } else { proj.InitStackAddr = Convert.ToUInt32("0x" + param.InnerText, 16); } } catch { } } foreach (XmlElement param in docx.GetElementsByTagName("PackStructs")) { proj.PackStructs = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("ShortEnums")) { proj.ShortEnums = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("UnsignedBitfields")) { proj.UnsignedBitfields = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("UnsignedChars")) { proj.UnsignedChars = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("FunctionSections")) { proj.FunctionSections = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("DataSections")) { proj.DataSections = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("BurnPart")) { proj.BurnPart = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("BurnProgrammer")) { proj.BurnProgrammer = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("BurnOptions")) { proj.BurnOptions = param.InnerText; } foreach (XmlElement param in docx.GetElementsByTagName("BurnBaud")) { try { proj.BurnBaud = int.Parse(param.InnerText); } catch { } } foreach (XmlElement param in docx.GetElementsByTagName("BurnAutoReset")) { proj.BurnAutoReset = Program.StringToBool(param); } foreach (XmlElement param in docx.GetElementsByTagName("BurnFuseBox")) { proj.BurnFuseBox = param.InnerText; } foreach (XmlElement container in docx.GetElementsByTagName("IncludeDirList")) { foreach (XmlElement i in container.GetElementsByTagName("DirPath")) { if (proj.IncludeDirList.Contains(i.InnerText) == false) proj.IncludeDirList.Add(i.InnerText); } } foreach (XmlElement container in docx.GetElementsByTagName("LibraryDirList")) { foreach (XmlElement i in container.GetElementsByTagName("DirPath")) { if (proj.LibraryDirList.Contains(i.InnerText) == false) proj.LibraryDirList.Add(i.InnerText); } } foreach (XmlElement container in docx.GetElementsByTagName("LinkObjList")) { foreach (XmlElement i in container.GetElementsByTagName("Obj")) { if (proj.LinkObjList.Contains(i.InnerText) == false) proj.LinkObjList.Add(i.InnerText); } } foreach (XmlElement container in docx.GetElementsByTagName("LinkLibList")) { foreach (XmlElement i in container.GetElementsByTagName("Lib")) { if (proj.LinkLibList.Contains(i.InnerText) == false) proj.LinkLibList.Add(i.InnerText); } } foreach (XmlElement container in docx.GetElementsByTagName("MemorySegList")) { foreach (XmlElement i in container.GetElementsByTagName("Segment")) { try { XmlElement type = (XmlElement)i.GetElementsByTagName("Type")[0]; XmlElement name = (XmlElement)i.GetElementsByTagName("Name")[0]; XmlElement addr = (XmlElement)i.GetElementsByTagName("Addr")[0]; uint address; if (addr.InnerText.ToLowerInvariant().StartsWith("0x")) { address = Convert.ToUInt32(addr.InnerText, 16); } else { address = Convert.ToUInt32("0x" + addr.InnerText, 16); } string nameStr = name.InnerText.Trim(); string typeStr = type.InnerText.Trim(); if (string.IsNullOrEmpty(nameStr) == false && string.IsNullOrEmpty(typeStr) == false) { MemorySegment seg = new MemorySegment(typeStr, nameStr, address); if (proj.MemorySegList.ContainsKey(nameStr) == false) proj.MemorySegList.Add(nameStr, seg); } } catch { } } } foreach (XmlElement param in docx.GetElementsByTagName("ArduinoCoreOverride")) { proj.ArduinoCoreOverride = param.InnerText; } }