Esempio n. 1
0
        public static void ProcessFolder(String TargetFolder)
        {
            Console.WriteLine("Processing: " + TargetFolder);
            DirectoryInfo dInfoTarget = new DirectoryInfo(TargetFolder);

            FileInfo[]          fIfoLinker = (new DirectoryInfo(Path.Combine(TargetFolder, "gcc"))).GetFiles("*.ld");
            GccLinkerfileParser lParser    = null;

            if (fIfoLinker.Length > 0)
            {
                lParser = new GccLinkerfileParser(fIfoLinker[0].FullName);
            }

            //
            // Parse the makefile and convert into magic data...
            //
            GccMakefileParser mParser = new GccMakefileParser(Path.Combine(Path.Combine(Path.Combine(TargetFolder, "gcc"), "Makefile")));

            //
            // Create segger sub-directory if not existing
            //
            if (!Directory.Exists(Path.Combine(TargetFolder, "segger")))
            {
                Directory.CreateDirectory(Path.Combine(TargetFolder, "segger"));
            }

            if (dInfoTarget.Name.Equals("bsp") || dInfoTarget.Name.Equals("hal"))
            {
                //
                // Process as a library
                //
                SeggerEmProject emPrj = new SeggerEmProject("libam_" + dInfoTarget.Name, Path.Combine(TargetFolder, "segger"), mParser, lParser, true);
                emPrj.Create();
            }
            else
            {
                //
                // Process as a normal project
                //
                SeggerEmProject emPrj = new SeggerEmProject(dInfoTarget.Name, Path.Combine(TargetFolder, "segger"), mParser, lParser, false);
                emPrj.Create();

                //
                // A normal project needs also a Segger-IDE compatible startup - read-in GCC startup and converting to Segger style
                //
                FileInfo[] fIfos = (new DirectoryInfo(Path.Combine(TargetFolder, "gcc"))).GetFiles("startup_*.c");
                if (fIfos.Length > 0)
                {
                    GccStartupParser sParser = new GccStartupParser(fIfos[0].FullName);
                    sParser.Create(Path.Combine(Path.Combine(TargetFolder, "segger"), emPrj.StartupFileName));
                }
                else
                {
                    Console.WriteLine("  WARNING: No startup-file found");
                }
            }
        }
 public SeggerEmProject(String ProjectName, String ProjectFolder, GccMakefileParser makeFile, GccLinkerfileParser linkerFile, Boolean IsLibrary)
 {
     this.makeFile      = makeFile;
     this.ProjectName   = ProjectName;
     this.ProjectFolder = ProjectFolder;
     this.IsLibrary     = IsLibrary;
     //
     // Set device name and memory options dependend by the MCU series name specified in the makefile
     //
     if (makeFile.Vars["PART"].Equals("apollo3blue"))
     {
         this.DevName  = "AMA3B1KK-KBR";
         this.RomStart = 0x0000C000;
         this.RomSize  = 1024 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 384 * 1024;
     }
     else if (makeFile.Vars["PART"].Equals("apollo3"))
     {
         DevName       = "AMA3B1KK-KBR";
         this.RomStart = 0x0000C000;
         this.RomSize  = 1024 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 384 * 1024;
     }
     else if (makeFile.Vars["PART"].Equals("apollo2"))
     {
         DevName       = "AMAPH1KK-KBR";
         this.RomStart = 0x00000000;
         this.RomSize  = 1024 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 256 * 1024;
     }
     else if (makeFile.Vars["PART"].Equals("apollo2blue"))
     {
         DevName       = "AMAPH1KK-KBR";
         this.RomStart = 0x00000000;
         this.RomSize  = 1024 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 256 * 1024;
     }
     else if (makeFile.Vars["PART"].Equals("apollo1"))
     {
         DevName       = "APOLLO512-KBR";
         this.RomStart = 0x00000000;
         this.RomSize  = 512 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 64 * 1024;
     }
     else if (makeFile.Vars["PART"].Equals("apollo"))
     {
         DevName       = "APOLLO512-KBR";
         this.RomStart = 0x00000000;
         this.RomSize  = 512 * 1024 - this.RomStart;
         this.RamStart = 0x10000000;
         this.RamSize  = 64 * 1024;
         this.makeFile.Vars["PART"] = "apollo1";
     }
     else
     {
         if (linkerFile != null)
         {
             this.RomStart = (int)linkerFile.RomStart;
             this.RomSize  = (int)linkerFile.RomSize;
             this.RamStart = (int)linkerFile.RamStart;
             this.RamSize  = (int)linkerFile.RamSize;
             if (this.makeFile.Vars.ContainsKey("PART"))
             {
                 DevName = this.makeFile.Vars["PART"];
             }
         }
     }
     this.StartupFileName = ReplaceVars("startup_{PART}.s");
 }