public static void ProcessFolder(String TargetFolder) { Console.WriteLine("Please copy this tool into the root folder of the AmbiqSuite and execute"); 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 crossworks sub-directory if not existing // if (!Directory.Exists(Path.Combine(TargetFolder, "crossworks"))) { Directory.CreateDirectory(Path.Combine(TargetFolder, "crossworks")); } if (dInfoTarget.Name.Equals("bsp") || dInfoTarget.Name.Equals("hal")) { // // Process as a library // CrossworksProject emPrj = new CrossworksProject("libam_" + dInfoTarget.Name, Path.Combine(TargetFolder, "crossworks"), mParser, lParser, true); emPrj.Create(); } else { // // Process as a normal project // CrossworksProject emPrj = new CrossworksProject(dInfoTarget.Name, Path.Combine(TargetFolder, "crossworks"), mParser, lParser, false); emPrj.Create(); // // A normal project needs also a Crossworks-IDE compatible startup - read-in GCC startup and converting to Crossworks 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, "crossworks"), emPrj.StartupFileName)); } else { Console.WriteLine(" WARNING: No startup-file found"); } } }
public CrossworksProject(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; this.ApolloVersion = 3; } 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; this.ApolloVersion = 3; } 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; this.ApolloVersion = 2; } 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; this.ApolloVersion = 2; } 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; this.ApolloVersion = 1; } 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"; this.ApolloVersion = 1; } 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"); }