Ejemplo n.º 1
0
        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";
        }
Ejemplo n.º 2
0
        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";
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        /// <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;
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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();
        }