static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: risc-v.exe <freedom-e-sdk directory>"); } var bspBuilder = new RISCVBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); PathTools.CopyDirectoryRecursive(@"..\..\bsp-template", bspBuilder.Directories.OutputDir); var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspBuilder.BSPRoot, "bsp.xml")); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); List <string> projectFiles = new List <string>(); PropertyList unused = null; if (commonPseudofamily.Definition.CoreFramework != null) { foreach (var job in commonPseudofamily.Definition.CoreFramework.CopyJobs) { job.CopyAndBuildFlags(bspBuilder, projectFiles, null, ref unused); } } List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(bsp.Frameworks); frameworks.AddRange(commonPseudofamily.GenerateFrameworkDefinitions()); bsp.Frameworks = frameworks.ToArray(); var samples = commonPseudofamily.CopySamples(frameworks).ToArray(); bsp.Examples = samples.Select(s => s.RelativePath).ToArray(); var mainFamily = bsp.MCUFamilies.First(); if (mainFamily.AdditionalSourceFiles != null || mainFamily.AdditionalHeaderFiles != null || bsp.FileConditions != null) { throw new Exception("TODO: merge lists"); } mainFamily.AdditionalSourceFiles = projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray(); mainFamily.AdditionalHeaderFiles = projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray(); bsp.FileConditions = bspBuilder.MatchedFileConditions.ToArray(); XmlTools.SaveObject(bsp, Path.Combine(bspBuilder.BSPRoot, "BSP.XML")); }
private void ProcessCommonFiles() { _commonPseudofamily = new MCUFamilyBuilder(this, XmlTools.LoadObject <FamilyDefinition>(Directories.RulesDir + @"\CommonFiles.xml")); _commonPseudofamily.CopyFamilyFiles(ref _flags, _projectFiles); if (_commonPseudofamily.Definition.AdditionalFrameworks != null) { foreach (var framework in _commonPseudofamily.Definition.AdditionalFrameworks) { SynthesizeAndAppendCopyJobFromCMakeFiles(framework); } } foreach (var fw in _commonPseudofamily.GenerateFrameworkDefinitions()) { _frameworks.Add(fw); } foreach (var sample in _commonPseudofamily.CopySamples(_frameworks)) { _exampleDirs.Add(sample); } }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: risc-v.exe <freedom-e-sdk directory with build logs>"); } const string TargetVariable = "com.sysprogs.riscv.target"; const string LinkerScriptVariant = "com.sysprogs.riscv.linkerscript"; string linkerScriptTemplate = $"$$SYS:BSP_ROOT$$/bsp/$${TargetVariable}$$/metal.$${LinkerScriptVariant}$$.lds"; const string FamilyName = "SIFIVE"; using (var bspBuilder = new RISCVBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules", @"..\..\logs"))) { BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.riscv.sifive", PackageDescription = "SiFive Freedom E Devices", GNUTargetID = "riscv64-unknown-elf", RequiredToolchainID = "com.visualgdb.risc-v", GeneratedMakFileName = "sifive.mak", PackageVersion = "1.0", MinimumEngineVersion = "5.4", MCUFamilies = new[] { new MCUFamily { ID = FamilyName, CompilationFlags = new ToolFlags { IncludeDirectories = new[] { $"$$SYS:BSP_ROOT$$/bsp/$${TargetVariable}$$/install/include" }, LinkerScript = linkerScriptTemplate, AdditionalLibraries = new[] { "c", "gcc", "m" }, }, ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Enumerated { UniqueID = LinkerScriptVariant, Name = "Default Linker Script", SuggestionList = new [] { "default", "freertos", "ramrodata", "scratchpad" }.Select(s => new PropertyEntry.Enumerated.Suggestion { InternalValue = s }).ToArray(), } } } } } } } }; List <MCU> mcus = new List <MCU>(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); List <MCUDefinitionWithPredicate> registers = new List <MCUDefinitionWithPredicate>(); foreach (var bspDir in Directory.GetDirectories(Path.Combine(bspBuilder.Directories.InputDir, "bsp"))) { var target = Path.GetFileName(bspDir); var logFile = Path.Combine(bspBuilder.Directories.InputDir, target + ".log"); if (!File.Exists(logFile)) { throw new Exception($"Missing {logFile}. Please run _buildall.sh in the SDK directory using WSL."); } var parsedLog = BuildLogFileParser.ParseRISCVBuildLog(logFile); if (parsedLog.LinkerScript == null) { throw new Exception("Unknown linker script"); } var script = bspBuilder.WSLPathToBSPPath(parsedLog.LinkerScript).Replace('/', '\\'); if (StringComparer.InvariantCultureIgnoreCase.Compare(script, linkerScriptTemplate.Replace($"$${TargetVariable}$$", target).Replace($"$${LinkerScriptVariant}$$", "default").Replace('/', '\\')) != 0) { throw new Exception("Unexpected linker script: " + script); } var memories = LinkerScriptTools.ScanLinkerScriptForMemories(script.Replace("$$SYS:BSP_ROOT$$", bspBuilder.Directories.InputDir)); var mcu = new MCU { ID = target.ToUpper(), UserFriendlyName = target.ToUpper(), FamilyID = FamilyName, MemoryMap = new AdvancedMemoryMap { Memories = memories, }, CompilationFlags = new ToolFlags { IncludeDirectories = parsedLog.allIncludes.Where(inc => inc != ".").Select(bspBuilder.WSLPathToBSPPath).ToArray(), PreprocessorMacros = parsedLog.allDefines.Where(kv => !kv.Key.StartsWith("PACKAGE")).Select(kv => $"{kv.Key}={kv.Value}").ToArray(), COMMONFLAGS = string.Join(" ", parsedLog.allFlags), LDFLAGS = string.Join(" ", parsedLog.AllLDFlags), }, AdditionalSystemVars = new[] { new SysVarEntry { Key = TargetVariable, Value = target, } }, RAMSize = (int)(memories.FirstOrDefault(m => m.Name == "ram")?.Size ?? 0), FLASHSize = (int)(memories.FirstOrDefault(m => m.Name == "rom")?.Size ?? 0), MCUDefinitionFile = $"DeviceDefinitions/{target.ToUpper()}.xml", }; if (mcu.RAMSize < 0) { mcu.RAMSize = 0; } var parsedSVD = SVDParser.ParseSVDFile(Path.Combine(bspDir, "design.svd"), target.ToUpper()); parsedSVD.MatchPredicate = new MCUPredicateImpl(mcu).Match; registers.Add(parsedSVD); commonPseudofamily.MCUs.Add(new MCUBuilder { Name = mcu.ID }); mcus.Add(mcu); } commonPseudofamily.AttachPeripheralRegisters(registers); bsp.SupportedMCUs = mcus.ToArray(); List <string> projectFiles = new List <string>(); PropertyList unused = null; if (commonPseudofamily.Definition.CoreFramework != null) { foreach (var job in commonPseudofamily.Definition.CoreFramework.CopyJobs) { job.CopyAndBuildFlags(bspBuilder, projectFiles, null, ref unused, null); } } bsp.Frameworks = commonPseudofamily.GenerateFrameworkDefinitions().ToArray(); var samples = commonPseudofamily.CopySamples(bsp.Frameworks).ToArray(); bsp.Examples = samples.Select(s => s.RelativePath).ToArray(); var mainFamily = bsp.MCUFamilies.First(); if (mainFamily.AdditionalSourceFiles != null || mainFamily.AdditionalHeaderFiles != null || bsp.FileConditions != null) { throw new Exception("TODO: merge lists"); } mainFamily.AdditionalSourceFiles = projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray(); mainFamily.AdditionalHeaderFiles = projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray(); bsp.FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(); XmlTools.SaveObject(bsp, Path.Combine(bspBuilder.BSPRoot, "BSP.XML")); } }
static void Main(string[] args) { var regKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Sysprogs\BSPGenerators\STM32"); var sdkRoot = regKey.GetValue("SDKRoot") as string ?? throw new Exception("Please specify STM32 SDK root via registry"); var cubeRoot = regKey.GetValue("CubeMXRoot") as string ?? throw new Exception("Please specify STM32CubeMX location via registry"); if (args.Contains("/fetch")) { //This will load the latest SDK list from the STM32CubeMX directory and will fetch/unpack them to our SDKRoot directory. //Before running this, ensure the STM32CubeMX has the up-to-date SDK definitions (using the 'check for update' function), as //otherwise the BSP generator will fetch the old versions. SDKFetcher.FetchLatestSDKs(sdkRoot, cubeRoot); } string rulesetName = args.FirstOrDefault(a => a.StartsWith("/rules:"))?.Substring(7) ?? STM32Ruleset.Classic.ToString(); STM32Ruleset ruleset = Enum.GetValues(typeof(STM32Ruleset)) .OfType <STM32Ruleset>() .First(v => StringComparer.InvariantCultureIgnoreCase.Compare(v.ToString(), rulesetName) == 0); ///If the MCU list format changes again, create a new implementation of the IDeviceListProvider interface, switch to using it, but keep the old one for reference & easy comparison. IDeviceListProvider provider = new DeviceListProviders.CubeProvider(); var bspBuilder = new STM32BSPBuilder(new BSPDirectories(sdkRoot, @"..\..\Output\" + rulesetName, @"..\..\rules\" + rulesetName), cubeRoot); Directory.CreateDirectory(@"..\..\Logs"); using (var wr = new ParseReportWriter(@"..\..\Logs\registers.log")) { var devices = provider.LoadDeviceList(bspBuilder); if (devices.Where(d => d.FlashSize == 0 && !d.Name.StartsWith("STM32MP1")).Count() > 0) { throw new Exception($"Some deviceshave FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); string extraFrameworksFile = Path.Combine(bspBuilder.Directories.RulesDir, "FrameworkTemplates.xml"); if (!File.Exists(extraFrameworksFile) && File.Exists(Path.ChangeExtension(extraFrameworksFile, ".txt"))) { extraFrameworksFile = Path.Combine(bspBuilder.Directories.RulesDir, File.ReadAllText(Path.ChangeExtension(extraFrameworksFile, ".txt"))); } Dictionary <string, STM32SDKCollection.SDK> sdksByVariable = bspBuilder.SDKList.SDKs.ToDictionary(s => $"$$STM32:{s.Family}_DIR$$"); List <STM32SDKCollection.SDK> referencedSDKs = new List <STM32SDKCollection.SDK>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\families", "*.xml")) { var fam = XmlTools.LoadObject <FamilyDefinition>(fn); if (File.Exists(extraFrameworksFile)) { int idx = fam.PrimaryHeaderDir.IndexOf('\\'); string baseDir = fam.PrimaryHeaderDir.Substring(0, idx); if (!baseDir.StartsWith("$$STM32:")) { throw new Exception("Invalid base directory. Please recheck the family definition."); } string baseFamName = fam.Name; if (baseFamName.EndsWith("_M4")) { baseFamName = baseFamName.Substring(0, baseFamName.Length - 3); } referencedSDKs.Add(sdksByVariable[baseDir]); var dict = new Dictionary <string, string> { { "STM32:FAMILY_EX", fam.Name }, { "STM32:FAMILY", baseFamName }, { "STM32:FAMILY_DIR", baseDir }, }; var extraFrameworkFamily = XmlTools.LoadObject <FamilyDefinition>(extraFrameworksFile); //USB host/device libraries are not always compatible between different device families. Hence we need to ship separate per-family copies of those. var expandedExtraFrameworks = extraFrameworkFamily.AdditionalFrameworks.Select(fw => { fw.ID = VariableHelper.ExpandVariables(fw.ID, dict); fw.Name = VariableHelper.ExpandVariables(fw.Name, dict); fw.RequiredFrameworks = ExpandVariables(fw.RequiredFrameworks, dict); fw.IncompatibleFrameworks = ExpandVariables(fw.IncompatibleFrameworks, dict); foreach (var job in fw.CopyJobs) { job.SourceFolder = VariableHelper.ExpandVariables(job.SourceFolder, dict); job.TargetFolder = VariableHelper.ExpandVariables(job.TargetFolder, dict); job.AdditionalIncludeDirs = VariableHelper.ExpandVariables(job.AdditionalIncludeDirs, dict); } return(fw); }); //Furthermore, some families do not include a USB host peripheral and hence do not contain a USB Host library. We need to skip it automatically. var extraFrameworksWithoutMissingFolders = expandedExtraFrameworks.Where(fw => fw.CopyJobs.Count(j => { string expandedJobSourceDir = j.SourceFolder; bspBuilder.ExpandVariables(ref expandedJobSourceDir); return(!Directory.Exists(expandedJobSourceDir)); }) == 0); fam.AdditionalFrameworks = fam.AdditionalFrameworks.Concat(extraFrameworksWithoutMissingFolders).ToArray(); } bspBuilder.InsertLegacyHALRulesIfNecessary(fam, bspBuilder.ReverseFileConditions); switch (ruleset) { case STM32Ruleset.STM32WB: allFamilies.Add(new STM32WBFamilyBuilder(bspBuilder, fam)); break; case STM32Ruleset.STM32MP1: allFamilies.Add(new STM32MP1FamilyBuilder(bspBuilder, fam)); break; case STM32Ruleset.Classic: default: allFamilies.Add(new STM32ClassicFamilyBuilder(bspBuilder, fam)); break; } } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0 && ruleset == STM32Ruleset.Classic) { Console.WriteLine("Globally unsupported MCUs:"); foreach (var r in rejects) { Console.WriteLine("\t{0}", r.Name); } } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); string specificDeviceForDebuggingPeripheralRegisterGenerator = args.FirstOrDefault(a => a.StartsWith("/periph:"))?.Substring(8); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } List <ConditionalToolFlags> allConditionalToolFlags = new List <ConditionalToolFlags>(); foreach (var fam in allFamilies) { bspBuilder.GetMemoryMcu(fam); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir, fam, specificDeviceForDebuggingPeripheralRegisterGenerator, wr), throwIfNotFound: specificDeviceForDebuggingPeripheralRegisterGenerator == null); } familyDefinitions.Add(fam.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All, true)); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters && specificDeviceForDebuggingPeripheralRegisterGenerator == null)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } if (fam.Definition.ConditionalFlags != null) { allConditionalToolFlags.AddRange(fam.Definition.ConditionalFlags); } } foreach (var sample in commonPseudofamily.CopySamples(null, allFamilies.Where(f => f.Definition.AdditionalSystemVars != null).SelectMany(f => f.Definition.AdditionalSystemVars))) { exampleDirs.Add(sample); } var prioritizer = new SamplePrioritizer(Path.Combine(bspBuilder.Directories.RulesDir, "SamplePriorities.txt")); exampleDirs.Sort((a, b) => prioritizer.Prioritize(a.RelativePath, b.RelativePath)); var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspBuilder.Directories.RulesDir, "BSPTemplate.xml")); bsp.MCUFamilies = familyDefinitions.ToArray(); bsp.SupportedMCUs = mcuDefinitions.ToArray(); bsp.Frameworks = frameworks.ToArray(); bsp.Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(); bsp.TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(); bsp.PackageVersion = bspBuilder.SDKList.BSPVersion; bsp.FileConditions = bspBuilder.MatchedFileConditions.ToArray(); bsp.InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints; bsp.ConditionalFlags = allConditionalToolFlags.ToArray(); bspBuilder.SDKList.SDKs = referencedSDKs.Distinct().ToArray(); XmlTools.SaveObject(bspBuilder.SDKList, Path.Combine(bspBuilder.BSPRoot, "SDKVersions.xml")); bspBuilder.ValidateBSP(bsp); bspBuilder.ReverseFileConditions.SaveIfConsistent(bspBuilder.Directories.OutputDir, bspBuilder.ExportRenamedFileTable(), ruleset == STM32Ruleset.STM32WB); File.Copy(@"..\..\stm32_compat.h", Path.Combine(bspBuilder.BSPRoot, "stm32_compat.h"), true); Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); } }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: rm57x.exe <RM57x generated HAL directory>"); } string DirSDK = args[0]; using (var bspBuilder = new RM57xBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules", @"..\..\log"))) { var xml = new XmlDocument(); xml.Load(Path.Combine(bspBuilder.Directories.InputDir, "NonRTOS\\NonRTOS.hcg")); var deviceID = xml.DocumentElement.SelectSingleNode("DEVICE/device")?.InnerText ?? throw new Exception("Failed to extract the device ID"); var familyID = xml.DocumentElement.SelectSingleNode("DEVICE/family")?.InnerText ?? throw new Exception("Failed to extract the family ID"); CortexCore core; bool isBigEndian = false; bool isThumb = true; switch (deviceID) { case "RM57L843ZWT": core = CortexCore.R5; break; case "TMS570LS1224PGE": core = CortexCore.R4; isBigEndian = true; isThumb = false; break; default: throw new Exception($"Unknown ARM Cortex core for {deviceID}. Please update the logic above."); } bool noPeripheralRegisters = args.Contains("/noperiph"); bool noPack = args.Contains("/nopack"); var nonRTOSDir = Path.GetFullPath(Path.Combine(bspBuilder.Directories.InputDir, "NonRTOS")); var linkerScriptPath = Directory.GetFiles(nonRTOSDir, "*.ld", SearchOption.AllDirectories)[0]; MCUFamilyBuilder famBuilder = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(Path.Combine(bspBuilder.Directories.RulesDir, "families\\rm57x.xml"))); famBuilder.Definition.Name = familyID; if (isBigEndian) { famBuilder.Definition.CompilationFlags.COMMONFLAGS += " -mbig-endian -mbe32"; } //string deviceDefinitionFile = @"DeviceDefinitions/CC_3220.xml"; var memories = LinkerScriptTools.ScanLinkerScriptForMemories(linkerScriptPath); famBuilder.MCUs.Add(new MCUBuilder { Core = core, FPU = FPUType.DP, FlashSize = (int)memories.First(m => m.Name == "FLASH").Size, RAMSize = (int)memories.First(m => m.Name == "RAM").Size, Name = deviceID, //MCUDefinitionFile = deviceDefinitionFile, StartupFile = null }); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); MCUFamilyBuilder commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var famObj = famBuilder.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref famObj.CompilationFlags, projectFiles); famObj.AdditionalSourceFiles = famObj.AdditionalSourceFiles.Concat(projectFiles).ToArray(); if (!Directory.Exists(Path.Combine(bspBuilder.Directories.InputDir, "FreeRTOS"))) { Console.WriteLine("Missing FreeRTOS directory. Skipping FreeRTOS framework and project sample..."); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Where(f => !f.ID.Contains("freertos")).ToArray(); commonPseudofamily.Definition.SmartSamples = commonPseudofamily.Definition.SmartSamples.Where(f => f.EmbeddedSample.Name.IndexOf("freertos", StringComparison.InvariantCultureIgnoreCase) == -1).ToArray(); } foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } if (!noPeripheralRegisters) { famBuilder.AttachPeripheralRegisters(ParsePeripheralRegisters(famBuilder.Definition.PrimaryHeaderDir, deviceID)); } if (!isThumb) { famObj.CompilationFlags.COMMONFLAGS = famObj.CompilationFlags.COMMONFLAGS.Replace("-mthumb", "-marm"); } List <MCU> mcuDefinitions = new List <MCU>(); foreach (var mcuDef in famBuilder.MCUs) { var mcu = mcuDef.GenerateDefinition(famBuilder, bspBuilder, !noPeripheralRegisters, true); mcu.AdditionalSystemVars = (mcu.AdditionalSystemVars ?? new SysVarEntry[0]).Concat(new[] { new SysVarEntry { Key = "com.sysprogs.linker_script", Value = linkerScriptPath.Substring(nonRTOSDir.Length + 1).Replace('\\', '/') }, CreateHeaderFileVariable(nonRTOSDir, "common.h"), CreateHeaderFileVariable(nonRTOSDir, "gio.h"), CreateHeaderFileVariable(nonRTOSDir, "het.h"), }).ToArray(); mcuDefinitions.Add(mcu); } ApplyKnownPatches(bspBuilder.Directories.OutputDir); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti." + deviceID, PackageDescription = $"TI {deviceID} Device", GNUTargetID = "arm-eabi", GeneratedMakFileName = familyID + ".mak", MCUFamilies = new[] { famObj }, SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(), ConditionalFlags = commonPseudofamily.Definition.ConditionalFlags, PackageVersion = "1.0" }; bspBuilder.Save(bsp, !noPack); //StandaloneBSPValidator.Program.Main(new[] { "..\\..\\cc3220.validatejob", "f:\\bsptest" }); } }
//--------------------------------- static void Main(string[] args) { if (args.Length < 1) throw new Exception("Usage: cc3200.exe <cc3200 SW package directory>"); string DirSDK = args[0]; var bspBuilder = new CC3200BSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); List<string> additionalSources = new List<string> { "$$SYS:BSP_ROOT$$/StartupFiles/startup_gcc.c" }; MCUFamily fam = new MCUFamily { ID = "CC3200", UserFriendlyName = "CC3200", CompilationFlags = new ToolFlags { PreprocessorMacros = new string[] { "gcc" }, IncludeDirectories = new string[] {"$$SYS:BSP_ROOT$$/SDK/driverlib", "$$SYS:BSP_ROOT$$/SDK/inc", "$$SYS:BSP_ROOT$$/SDK", "$$SYS:BSP_ROOT$$/common", "$$SYS:BSP_ROOT$$/SDK/oslib", "$$SYS:BSP_ROOT$$/netapps", "$$SYS:BSP_ROOT$$/SDK/simplelink", "$$SYS:BSP_ROOT$$/SDK/simplelink/include", "$$SYS:BSP_ROOT$$/SDK/simplelink_extlib/provisioninglib", "." }, COMMONFLAGS = "-mcpu=cortex-m4 -mthumb", }, AdditionalSourceFiles = additionalSources.ToArray(), }; bool noPeripheralRegisters = args.Contains("/noperiph"); string astrPathDefinition = ""; if (!noPeripheralRegisters) astrPathDefinition = @"DeviceDefinitions/CC_3200.xml"; fam.ConfigurableProperties = new PropertyList(); List<MCUFamily> familyDefinitions = new List<MCUFamily>(); familyDefinitions.Add(fam); List<MCU> mcuDefinitions = new List<MCU>(); mcuDefinitions.Add(new MCU { MCUDefinitionFile = astrPathDefinition, FamilyID = "CC3200", ID = "XCC3200JR", RAMBase = 0x20004000, RAMSize = 240 * 1024, CompilationFlags = new ToolFlags { LinkerScript = "$$SYS:BSP_ROOT$$/LinkerScripts/XCC3200JR.lds" }, HierarchicalPath = @"TI ARM\CC3200" }); mcuDefinitions.Add(new MCU { MCUDefinitionFile = astrPathDefinition, FamilyID = "CC3200", ID = "XCC3200HZ", RAMBase = 0x20004000, RAMSize = 176 * 1024, CompilationFlags = new ToolFlags { LinkerScript = "$$SYS:BSP_ROOT$$/LinkerScripts/XCC3200HZ.lds" }, HierarchicalPath = @"TI ARM\CC3200" }); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<MCUFamilyBuilder.CopiedSample> exampleDirs = new List<MCUFamilyBuilder.CopiedSample>(); MCUFamilyBuilder commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); //Embedded Frameworks var AddFrW = GenereteAddFrameWorks(bspBuilder.Directories, "EmbFrameworks.txt"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) frameworks.Add(fw); var flags = new ToolFlags(); List<string> projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) exampleDirs.Add(sample); foreach (var mcuDef in mcuDefinitions) commonPseudofamily.MCUs.Add(new MCUBuilder { Name = mcuDef.ID }); commonPseudofamily.Definition.FamilySubdirectory = ""; if (!noPeripheralRegisters) commonPseudofamily.AttachPeripheralRegisters(ParsePeripheralRegisters(Path.Combine(DirSDK, @"cc3200-sdk\inc"))); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.cc3200", PackageDescription = "TI CC3200 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "cc3200.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "1.3" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: rs14100.exe <rs14100 SW package directory>"); } using (var bspBuilder = new RS14100BSPBuilder(BSPDirectories.MakeDefault(args))) { bool noPeripheralRegisters = args.Contains("/noperiph"); bool noPack = args.Contains("/nopack"); MCUFamilyBuilder famBuilder = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(Path.Combine(bspBuilder.Directories.RulesDir, "rs14100.xml"))); foreach (var name in new[] { "RS14100" }) { famBuilder.MCUs.Add(new MCUBuilder { Core = CortexCore.M4, FlashSize = 0x000EE000, RAMSize = 0x00030000, Name = name, LinkerScriptPath = $"$$SYS:BSP_ROOT$$/DeviceDefinition/arm-gcc-link.ld", StartupFile = "$$SYS:BSP_ROOT$$/DeviceDefinition/startup_RS1xxxx.c" }); } List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); var famObj = famBuilder.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); List <string> projectFiles = new List <string>(); if (!noPeripheralRegisters) { var definition = SVDParser.ParseSVDFile(Path.Combine(bspBuilder.Directories.InputDir, "RS1xxxx.svd"), "RS14100"); definition.MatchPredicate = m => true; famBuilder.AttachPeripheralRegisters(new[] { definition }, "DeviceDefinition"); } foreach (var fw in famBuilder.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in famBuilder.CopySamples()) { exampleDirs.Add(sample); } List <MCU> mcuDefinitions = new List <MCU>(); foreach (var mcuDef in famBuilder.MCUs) { var mcu = mcuDef.GenerateDefinition(famBuilder, bspBuilder, !noPeripheralRegisters, true); mcuDefinitions.Add(mcu); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.rs14100", PackageDescription = "Redpine RS14100 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "rs14100.mak", MCUFamilies = new[] { famObj }, SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(), PackageVersion = "1.1.3" }; bspBuilder.ValidateBSP(bsp); bspBuilder.Save(bsp, !noPack, false); //StandaloneBSPValidator.Program.RunJob( "..\\..\\rs14100.validatejob", "f:\\bsptest"); } }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: nxp.exe <NXP SW package directory>"); } var bspBuilder = new NxpBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuNXPLpcDevices.csv", "Part Number", "Flash (KB)", "SRAM(kB)", "CPU", true); RemoveDuplicateMCU(ref devices); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> examples = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { examples.Add(sample); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, "cr_startup_lpc8xx.c", fam)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir + "\\" + fam.Definition.FamilySubdirectory, fam)); } var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { examples.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.nxp_lpc", PackageDescription = "NXP LPC Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "nxp_lpc.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = examples.Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "2.1" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 2) { throw new Exception("Usage: stm32.exe <SW package directory> <STM32Cube directory>"); } var bspBuilder = new STM32BSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules"), args[1]); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\stm32devices.csv", "Part Number", "FLASH Size (Prog)", "Internal RAM Size", "Core", true); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0) { Console.WriteLine("Globally unsupported MCUs:"); foreach (var r in rejects) { Console.WriteLine("\t{0}", r.Name); } } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var fam in allFamilies) { bspBuilder.GetMemoryMcu(fam); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir, fam)); } familyDefinitions.Add(fam.GenerateFamilyObject(true)); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } foreach (var sample in commonPseudofamily.CopySamples(null, allFamilies.Where(f => f.Definition.AdditionalSystemVars != null).SelectMany(f => f.Definition.AdditionalSystemVars))) { exampleDirs.Add(sample); } var prioritizer = new SamplePrioritizer(Path.Combine(bspBuilder.Directories.RulesDir, "SamplePriorities.txt")); exampleDirs.Sort((a, b) => prioritizer.Prioritize(a.RelativePath, b.RelativePath)); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.stm32", PackageDescription = "STM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "stm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), PackageVersion = "4.1", IntelliSenseSetupFile = "stm32_compat.h", FileConditions = bspBuilder.MatchedFileConditions.ToArray(), MinimumEngineVersion = "5.1", FirstCompatibleVersion = "3.0", InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints, }; File.Copy(@"..\..\stm32_compat.h", Path.Combine(bspBuilder.BSPRoot, "stm32_compat.h"), true); Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); }
//---------------------------------------------- static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: EFM32.exe <Atmel SW package directory>"); } var bspBuilder = new AtmelBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuAtmel.csv", "Device Name", "Flash (kBytes)", "SRAM (kBytes)", "CPU", true); RemoveDuplicateMCU(ref devices); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); CopyAddSourceFiles(bspBuilder.Directories.InputDir); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); //Embedded Frameworks var AddFrW = GenereteAddFrameWorks(bspBuilder.Directories, "ServicesFrimwork.txt"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); AddFrW = GenereteAddFrameWorksDir(bspBuilder.Directories, "sam"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); AddFrW = GenereteAddFrameWorksDir(bspBuilder.Directories, "sam0"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); var memoryLayouts = fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir, fam)); } foreach (var mcu in fam.MCUs) { var mcuDef = mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters); var layout = memoryLayouts[mcu.Name]; var ram = layout.Memories.First(m => m.Type == MemoryType.RAM); var flash = layout.Memories.First(m => m.Type == MemoryType.FLASH); mcuDef.RAMBase = ram.Start; mcuDef.RAMSize = (int)ram.Size; mcuDef.FLASHBase = flash.Start; mcuDef.FLASHSize = (int)flash.Size; mcuDefinitions.Add(mcuDef); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.atmel.sam-cortex", PackageDescription = "Atmel ARM Cortex Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "atmel.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "3.35.2" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: rm57x.exe <RM57x generated HAL directory>"); } string DirSDK = args[0]; var bspBuilder = new RM57xBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); bool noPeripheralRegisters = args.Contains("/noperiph"); bool noPack = args.Contains("/nopack"); MCUFamilyBuilder famBuilder = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(Path.Combine(bspBuilder.Directories.RulesDir, "families\\rm57x.xml"))); //string deviceDefinitionFile = @"DeviceDefinitions/CC_3220.xml"; foreach (var name in new[] { "RM57L843ZWT" }) { famBuilder.MCUs.Add(new MCUBuilder { Core = CortexCore.R5F, FlashSize = 4096 * 1024, RAMSize = 512 * 1024, Name = name, //MCUDefinitionFile = deviceDefinitionFile, StartupFile = null }); } List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); MCUFamilyBuilder commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var famObj = famBuilder.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref famObj.CompilationFlags, projectFiles); famObj.AdditionalSourceFiles = famObj.AdditionalSourceFiles.Concat(projectFiles).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } if (!noPeripheralRegisters) { famBuilder.AttachPeripheralRegisters(ParsePeripheralRegisters(famBuilder.Definition.PrimaryHeaderDir)); } List <MCU> mcuDefinitions = new List <MCU>(); foreach (var mcuDef in famBuilder.MCUs) { var mcu = mcuDef.GenerateDefinition(famBuilder, bspBuilder, !noPeripheralRegisters, true); mcuDefinitions.Add(mcu); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.rm57x", PackageDescription = "TI RM57Lx Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "rm57x.mak", MCUFamilies = new[] { famObj }, SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), ConditionalFlags = commonPseudofamily.Definition.ConditionalFlags, PackageVersion = "1.0" }; bspBuilder.Save(bsp, !noPack); //StandaloneBSPValidator.Program.Main(new[] { "..\\..\\cc3220.validatejob", "f:\\bsptest" }); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: EFM32.exe <SLab SW package directory>"); } var bspBuilder = new SLabBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); /* * var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuSiliconLabs.csv", * "Part No.", "Flash (kB)", "Ram (kB)", "MCU Core", true); * RemoveDuplicateMCU(ref devices); * var devicesOld = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuSiliconLabsOld.csv", * "Part No.", "Flash (kB)", "Ram (kB)", "MCU Core", true); * RemoveDuplicateMCU(ref devicesOld); * * * foreach (var d in devicesOld) * if (!devices.Contains(d)) * devices.Add(d); */ var devices = GetMcuFromSDK(bspBuilder.Directories.InputDir); RemoveDuplicateMCU(ref devices); if (devices.Where(d => d.RAMSize == 0 || d.FlashSize == 0).Count() > 0) { throw new Exception($"Some devices are RAM Size ({devices.Where(d => d.RAMSize == 0).Count()}) = 0 or FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); // foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) // allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); // foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) // allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); //------------ var ignoreFams = File.ReadAllLines(Path.Combine(bspBuilder.Directories.RulesDir, "rulesfamaly.txt")); string DirDevices = Path.Combine(bspBuilder.Directories.InputDir, @"platform\Device\SiliconLabs"); string[] lstSubDir = Directory.GetDirectories(DirDevices); foreach (var fl in lstSubDir) { string vNameSubDir = Path.GetFileNameWithoutExtension(fl); string StartupFile = Directory.GetFiles(Path.Combine(DirDevices, vNameSubDir, @"Source\GCC"), "startup_*.c")[0].Replace(bspBuilder.Directories.InputDir, @"$$BSPGEN:INPUT_DIR$$"); CopyJob[] CopyJobs = { new CopyJob() { FilesToCopy = "-*startup_*;*.h;*.c", TargetFolder = "Devices", ProjectInclusionMask = "*.c", AutoIncludeMask = "*.h", SourceFolder = DirDevices + "\\" + vNameSubDir } }; //MCUClassifier[] ddd = { new MCUClassifier() }; //if (!fl.EndsWith("BGM13")) //continue; bool flignore = false; foreach (var igf in ignoreFams) { if (fl.Contains(igf)) { flignore = true; } } if (flignore) { continue; } //if (!fl.Contains("EFR32BG21")) // continue; allFamilies.Add(new MCUFamilyBuilder(bspBuilder, new FamilyDefinition() { Name = vNameSubDir, DeviceRegex = SetDeviceRegex(vNameSubDir.ToUpper(), lstSubDir), FamilySubdirectory = vNameSubDir, PrimaryHeaderDir = "$$BSPGEN:INPUT_DIR$$", StartupFileDir = StartupFile, CoreFramework = new Framework() { CopyJobs = CopyJobs.ToArray() }, Subfamilies = new MCUClassifier[] { }.ToArray() })); } //------------ var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir + "\\" + fam.Definition.FamilySubdirectory + "\\Devices", fam)); } foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.silabs.efm32", PackageDescription = "Silabs EFM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "efm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "5.6.0" }; bspBuilder.Save(bsp, true); }
//---------------------------------------------- static void Main(string[] args) { if (args.Length < 1) throw new Exception("Usage: EFM32.exe <Atmel SW package directory>"); var bspBuilder = new AtmelBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuAtmel.csv", "Device Name", "Flash (kBytes)", "SRAM (kBytes)", "CPU", true); RemoveDuplicateMCU(ref devices); List<MCUFamilyBuilder> allFamilies = new List<MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List<MCUFamily> familyDefinitions = new List<MCUFamily>(); List<MCU> mcuDefinitions = new List<MCU>(); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<MCUFamilyBuilder.CopiedSample> exampleDirs = new List<MCUFamilyBuilder.CopiedSample>(); CopyAddSourceFiles(bspBuilder.Directories.InputDir); bool noPeripheralRegisters = args.Contains("/noperiph"); List<KeyValuePair<string, string>> macroToHeaderMap = new List<KeyValuePair<string, string>>(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); //Embedded Frameworks var AddFrW = GenereteAddFrameWorks(bspBuilder.Directories, "ServicesFrimwork.txt"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); AddFrW = GenereteAddFrameWorksDir(bspBuilder.Directories, "sam"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); AddFrW =GenereteAddFrameWorksDir(bspBuilder.Directories, "sam0"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) frameworks.Add(fw); var flags = new ToolFlags(); List<string> projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) exampleDirs.Add(sample); foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) Console.WriteLine("\t{0}", mcu.Name); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir , fam)); foreach (var mcu in fam.MCUs) mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); foreach (var fw in fam.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var sample in fam.CopySamples()) exampleDirs.Add(sample); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.atmel.sam-cortex", PackageDescription = "Atmel ARM Cortex Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "atmel.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "1.0" }; bspBuilder.Save(bsp, true); }
private void ProcessCommonFiles() { _commonPseudofamily = new MCUFamilyBuilder(this, XmlTools.LoadObject<FamilyDefinition>(Directories.RulesDir + @"\CommonFiles.xml")); _commonPseudofamily.CopyFamilyFiles(ref _flags, _projectFiles); if (_commonPseudofamily.Definition.AdditionalFrameworks != null) { foreach (var framework in _commonPseudofamily.Definition.AdditionalFrameworks) { SynthesizeAndAppendCopyJobFromCMakeFiles(framework); } } foreach (var fw in _commonPseudofamily.GenerateFrameworkDefinitions()) { _frameworks.Add(fw); } foreach (var sample in _commonPseudofamily.CopySamples(_frameworks)) { _exampleDirs.Add(sample); } }
static void Main(string[] args) { if (args.Length < 2) throw new Exception("Usage: stm32.exe <SW package directory> <STM32Cube directory>"); var bspBuilder = new STM32BSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules"), args[1]); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\stm32devices.csv", "Part Number", "FLASH Size (Prog)", "Internal RAM Size", "Core", true); List<MCUFamilyBuilder> allFamilies = new List<MCUFamilyBuilder>(); foreach(var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\families", "*.xml")) allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0) { Console.WriteLine("Globally unsupported MCUs:"); foreach (var r in rejects) Console.WriteLine("\t{0}", r.Name); } List<MCUFamily> familyDefinitions = new List<MCUFamily>(); List<MCU> mcuDefinitions = new List<MCU>(); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<MCUFamilyBuilder.CopiedSample> exampleDirs = new List<MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var fam in allFamilies) { bspBuilder.GetMemoryMcu(fam); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) Console.WriteLine("\t{0}", mcu.Name); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); if (!noPeripheralRegisters) fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir, fam)); familyDefinitions.Add(fam.GenerateFamilyObject(true)); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); foreach (var fw in fam.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var sample in fam.CopySamples()) exampleDirs.Add(sample); } foreach (var sample in commonPseudofamily.CopySamples(null, allFamilies.Where(f => f.Definition.AdditionalSystemVars != null).SelectMany(f => f.Definition.AdditionalSystemVars))) exampleDirs.Add(sample); var prioritizer = new SamplePrioritizer(Path.Combine(bspBuilder.Directories.RulesDir, "SamplePriorities.txt")); exampleDirs.Sort((a,b) => prioritizer.Prioritize(a.RelativePath, b.RelativePath)); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.stm32", PackageDescription = "STM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "stm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), PackageVersion = "4.0", IntelliSenseSetupFile = "stm32_compat.h", FileConditions = bspBuilder.MatchedFileConditions.ToArray(), MinimumEngineVersion = "5.1", FirstCompatibleVersion = "3.0", InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints, }; File.Copy(@"..\..\stm32_compat.h", Path.Combine(bspBuilder.BSPRoot, "stm32_compat.h"), true); Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: cc3220.exe <cc3220 SW package directory>"); } string DirSDK = args[0]; using (var bspBuilder = new CC3220BSPBuilder(BSPDirectories.MakeDefault(args))) { bool noPeripheralRegisters = args.Contains("/noperiph"); bool noPack = args.Contains("/nopack"); MCUFamilyBuilder famBuilder = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(Path.Combine(bspBuilder.Directories.RulesDir, "families\\cc3220.xml"))); string deviceDefinitionFile = @"DeviceDefinitions/CC_3220.xml"; foreach (var name in new[] { "CC3220SF", "CC3220S", "CC3235SF", "CC3235S" }) { famBuilder.MCUs.Add(new MCUBuilder { Core = CortexCore.M4, FPU = FPUType.SP, FlashSize = name.EndsWith("SF") ? 1024 * 1024 : 0, RAMSize = 256 * 1024, Name = name, MCUDefinitionFile = deviceDefinitionFile, //LinkerScriptPath = $"$$SYS:BSP_ROOT$$/source/ti/boards/{name}_LAUNCHXL/{name}_LAUNCHXL_$$com.sysprogs.cc3220.rtos$$.lds", StartupFile = null }); } List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); MCUFamilyBuilder commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var famObj = famBuilder.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref famObj.CompilationFlags, projectFiles); famObj.AdditionalSourceFiles = famObj.AdditionalSourceFiles.Concat(projectFiles).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } if (!noPeripheralRegisters) { famBuilder.AttachPeripheralRegisters(ParsePeripheralRegisters(famBuilder.Definition.PrimaryHeaderDir)); } List <MCU> mcuDefinitions = new List <MCU>(); foreach (var mcuDef in famBuilder.MCUs) { var mcu = mcuDef.GenerateDefinition(famBuilder, bspBuilder, !noPeripheralRegisters, true); mcuDefinitions.Add(mcu); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.cc3220", PackageDescription = "TI CC3220 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "cc3220.mak", MCUFamilies = new[] { famObj }, SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(), ConditionalFlags = commonPseudofamily.Definition.ConditionalFlags, PackageVersion = "4.20.00" }; bspBuilder.Save(bsp, !noPack); //StandaloneBSPValidator.Program.Main(new[] { "..\\..\\cc3220.validatejob", "f:\\bsptest" }); } }
static void Main(string[] args) { if (args.Length < 1) throw new Exception("Usage: tiva.exe <Tiva SW package directory>"); var bspBuilder = new TivaBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\Tivadevices.csv", "Part Number", "Flash (KB)", "SRAM(kB)", "CPU", true); List<MCUFamilyBuilder> allFamilies = new List<MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List<MCUFamily> familyDefinitions = new List<MCUFamily>(); List<MCU> mcuDefinitions = new List<MCU>(); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<MCUFamilyBuilder.CopiedSample> exampleDirs = new List<MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List<KeyValuePair<string, string>> macroToHeaderMap = new List<KeyValuePair<string, string>>(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List<string> projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) exampleDirs.Add(sample); foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) Console.WriteLine("\t{0}", mcu.Name); } foreach(var mcu in fam.MCUs) { string fn = string.Format("{0}\\inc\\{1}.h", fam.Definition.PrimaryHeaderDir, mcu.Name); if (!File.Exists(fn)) throw new Exception("Missing device header file"); macroToHeaderMap.Add(new KeyValuePair<string, string>(mcu.Name, mcu.Name.ToLower() + ".h")); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.PrimaryHeaderDir, "startup_gcc.c", fam)); if (!noPeripheralRegisters) fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); foreach (var fw in fam.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var sample in fam.CopySamples()) exampleDirs.Add(sample); } using (var sw = File.CreateText(Path.Combine(bspBuilder.BSPRoot, "SDK", "inc", "tiva_device.h"))) { sw.WriteLine("#pragma once"); sw.WriteLine(); bool first = true; foreach(var kv in macroToHeaderMap) { sw.WriteLine("#{0}if defined({1})", first ? "" : "el", kv.Key); sw.WriteLine("\t#include \"{0}\"", kv.Value); first = false; } sw.WriteLine("#else"); sw.WriteLine("#error Device type not specified"); sw.WriteLine("#endif"); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.tiva", PackageDescription = "TI Tiva Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "tiva.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), PackageVersion = "2.1.3.156" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: EFM32.exe <SLab SW package directory>"); } var bspBuilder = new SLabBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuSiliconLabs.csv", "Part No.", "Flash (kB)", "Ram (kB)", "MCU Core", true); RemoveDuplicateMCU(ref devices); var devicesOld = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuSiliconLabsOld.csv", "Part No.", "Flash (kB)", "Ram (kB)", "MCU Core", true); RemoveDuplicateMCU(ref devicesOld); foreach (var d in devicesOld) { if (!devices.Contains(d)) { devices.Add(d); } } if (devices.Where(d => d.RAMSize == 0 || d.FlashSize == 0).Count() > 0) { throw new Exception($"Some devices are RAM Size ({devices.Where(d => d.RAMSize == 0).Count()}) = 0 or FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir + "\\" + fam.Definition.FamilySubdirectory + "\\Devices", fam)); } foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.silabs.efm32", PackageDescription = "Silabs EFM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "efm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "5.1.2" }; bspBuilder.Save(bsp, true); }
//--------------------------------- static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: cc3200.exe <cc3200 SW package directory>"); } string DirSDK = args[0]; var bspBuilder = new CC3200BSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); List <string> additionalSources = new List <string> { "$$SYS:BSP_ROOT$$/StartupFiles/startup_gcc.c" }; MCUFamily fam = new MCUFamily { ID = "CC3200", UserFriendlyName = "CC3200", CompilationFlags = new ToolFlags { PreprocessorMacros = new string[] { "gcc" }, IncludeDirectories = new string[] { "$$SYS:BSP_ROOT$$/SDK/driverlib", "$$SYS:BSP_ROOT$$/SDK/inc", "$$SYS:BSP_ROOT$$/SDK", "$$SYS:BSP_ROOT$$/common", "$$SYS:BSP_ROOT$$/SDK/oslib", "$$SYS:BSP_ROOT$$/netapps", "$$SYS:BSP_ROOT$$/SDK/simplelink", "$$SYS:BSP_ROOT$$/SDK/simplelink/include", "$$SYS:BSP_ROOT$$/SDK/simplelink_extlib/provisioninglib", "." }, COMMONFLAGS = "-mcpu=cortex-m4 -mthumb", }, AdditionalSourceFiles = additionalSources.ToArray(), }; bool noPeripheralRegisters = args.Contains("/noperiph"); string astrPathDefinition = ""; if (!noPeripheralRegisters) { astrPathDefinition = @"DeviceDefinitions/CC_3200.xml"; } fam.ConfigurableProperties = new PropertyList(); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); familyDefinitions.Add(fam); List <MCU> mcuDefinitions = new List <MCU>(); mcuDefinitions.Add(new MCU { MCUDefinitionFile = astrPathDefinition, FamilyID = "CC3200", ID = "XCC3200JR", RAMBase = 0x20004000, RAMSize = 240 * 1024, CompilationFlags = new ToolFlags { LinkerScript = "$$SYS:BSP_ROOT$$/LinkerScripts/XCC3200JR.lds" }, HierarchicalPath = @"TI ARM\CC3200" }); mcuDefinitions.Add(new MCU { MCUDefinitionFile = astrPathDefinition, FamilyID = "CC3200", ID = "XCC3200HZ", RAMBase = 0x20004000, RAMSize = 176 * 1024, CompilationFlags = new ToolFlags { LinkerScript = "$$SYS:BSP_ROOT$$/LinkerScripts/XCC3200HZ.lds" }, HierarchicalPath = @"TI ARM\CC3200" }); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); MCUFamilyBuilder commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); //Embedded Frameworks var AddFrW = GenereteAddFrameWorks(bspBuilder.Directories, "EmbFrameworks.txt"); commonPseudofamily.Definition.AdditionalFrameworks = commonPseudofamily.Definition.AdditionalFrameworks.Concat(AddFrW).ToArray(); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } foreach (var mcuDef in mcuDefinitions) { commonPseudofamily.MCUs.Add(new MCUBuilder { Name = mcuDef.ID }); } commonPseudofamily.Definition.FamilySubdirectory = ""; if (!noPeripheralRegisters) { commonPseudofamily.AttachPeripheralRegisters(ParsePeripheralRegisters(Path.Combine(DirSDK, @"cc3200-sdk\inc"))); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.cc3200", PackageDescription = "TI CC3200 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "cc3200.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "3.0" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: tiva.exe <Tiva SW package directory>"); } var bspBuilder = new TivaBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\Tivadevices.csv", "Part Number", "Flash (KB)", "SRAM(kB)", "CPU", true); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } foreach (var mcu in fam.MCUs) { string fn = string.Format("{0}\\inc\\{1}.h", fam.Definition.PrimaryHeaderDir, mcu.Name); if (!File.Exists(fn)) { throw new Exception("Missing device header file"); } macroToHeaderMap.Add(new KeyValuePair <string, string>(mcu.Name, mcu.Name.ToLower() + ".h")); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.PrimaryHeaderDir, "startup_gcc.c", fam)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir)); } var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } using (var sw = File.CreateText(Path.Combine(bspBuilder.BSPRoot, "SDK", "inc", "tiva_device.h"))) { sw.WriteLine("#pragma once"); sw.WriteLine(); bool first = true; foreach (var kv in macroToHeaderMap) { sw.WriteLine("#{0}if defined({1})", first ? "" : "el", kv.Key); sw.WriteLine("\t#include \"{0}\"", kv.Value); first = false; } sw.WriteLine("#else"); sw.WriteLine("#error Device type not specified"); sw.WriteLine("#endif"); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.tiva", PackageDescription = "TI Tiva Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "tiva.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), PackageVersion = "2.1.4.178" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: msp432_bsp_generator.exe <MSP432 SW package directory>"); } var bspBuilder = new Msp432Builder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile( bspBuilder.Directories.RulesDir + @"\msp432devices.csv", "Part Number", "Non-volatile Memory (KB)", "RAM(KB)", "CPU", true); var allMCUFamilyBuilders = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allMCUFamilyBuilders.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allMCUFamilyBuilders); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); var projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); var exampleDirs = new List <string>(); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } bool noPeripheralRegisters = args.Contains("/noperiph"); var familyDefinitions = new List <MCUFamily>(); var mcuDefinitions = new List <MCU>(); var frameworks = new List <EmbeddedFramework>(); foreach (var mcuFamilyBuilder in allMCUFamilyBuilders) { var rejectedMCUs = mcuFamilyBuilder.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", mcuFamilyBuilder.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } mcuFamilyBuilder.AttachStartupFiles(new[] { StartupFilesParser.Parse( mcuFamilyBuilder.Definition.Name, mcuFamilyBuilder.Definition.PrimaryHeaderDir, mcuFamilyBuilder.Definition.Name + "_startup_gcc.c") }); if (!noPeripheralRegisters) { var headerFiles = Directory.GetFiles(mcuFamilyBuilder.Definition.PrimaryHeaderDir + "\\inc", "*.h"); var headerFileRegex = new Regex(mcuFamilyBuilder.Definition.DeviceRegex, RegexOptions.IgnoreCase); var familyHeaderFiles = headerFiles.Where(headerFile => headerFileRegex.Match(headerFile.Substring(headerFile.LastIndexOf("\\") + 1)).Success).ToArray(); if (familyHeaderFiles.Length == 0) { throw new Exception("No header file found for MCU family"); } else if (familyHeaderFiles.Length > 1) { throw new Exception("Only one header file expected for MCU family"); } var registersParser = new RegistersParser(familyHeaderFiles[0]); mcuFamilyBuilder.AttachPeripheralRegisters(new[] { new MCUDefinitionWithPredicate { MCUName = mcuFamilyBuilder.Definition.Name, RegisterSets = registersParser.Parse(), MatchPredicate = m => true } }); } var familyObject = mcuFamilyBuilder.GenerateFamilyObject(true); familyObject.AdditionalSourceFiles = LoadedBSP.Combine(familyObject.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); familyObject.AdditionalHeaderFiles = LoadedBSP.Combine(familyObject.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); familyObject.AdditionalSystemVars = LoadedBSP.Combine(familyObject.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); familyObject.CompilationFlags = familyObject.CompilationFlags.Merge(flags); familyDefinitions.Add(familyObject); mcuFamilyBuilder.GenerateLinkerScripts(false); foreach (var mcu in mcuFamilyBuilder.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(mcuFamilyBuilder, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in mcuFamilyBuilder.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in mcuFamilyBuilder.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.msp432", PackageDescription = "TI MSP432 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "msp432.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.ToArray(), PackageVersion = "1.0" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) throw new Exception("Usage: nxp.exe <NXP SW package directory>"); var bspBuilder = new NxpBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuNXPLpcDevices.csv", "Part Number", "Flash (KB)", "SRAM(kB)", "CPU", true); RemoveDuplicateMCU(ref devices); List<MCUFamilyBuilder> allFamilies = new List<MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List<MCUFamily> familyDefinitions = new List<MCUFamily>(); List<MCU> mcuDefinitions = new List<MCU>(); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<string> exampleDirs = new List<string>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List<KeyValuePair<string, string>> macroToHeaderMap = new List<KeyValuePair<string, string>>(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List<string> projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) exampleDirs.Add(sample); foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) Console.WriteLine("\t{0}", mcu.Name); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, "cr_startup_lpc8xx.c", fam)); if (!noPeripheralRegisters) fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir +"\\" +fam.Definition.FamilySubdirectory,fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); foreach (var fw in fam.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var sample in fam.CopySamples()) exampleDirs.Add(sample); } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.nxp_lpc", PackageDescription = "NXP LPC Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "nxp_lpc.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "2.1" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: msp432_bsp_generator.exe <MSP432 SW package directory>"); } var bspBuilder = new Msp432Builder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile( bspBuilder.Directories.RulesDir + @"\msp432devices.csv", "Part Number", "Non-volatile Memory (KB)", "RAM(KB)", "CPU", true); var allMCUFamilyBuilders = new List<MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allMCUFamilyBuilders.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allMCUFamilyBuilders); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); var projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); var exampleDirs = new List<string>(); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } bool noPeripheralRegisters = args.Contains("/noperiph"); var familyDefinitions = new List<MCUFamily>(); var mcuDefinitions = new List<MCU>(); var frameworks = new List<EmbeddedFramework>(); foreach (var mcuFamilyBuilder in allMCUFamilyBuilders) { var rejectedMCUs = mcuFamilyBuilder.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", mcuFamilyBuilder.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } mcuFamilyBuilder.AttachStartupFiles(new[] { StartupFilesParser.Parse( mcuFamilyBuilder.Definition.Name, mcuFamilyBuilder.Definition.PrimaryHeaderDir, mcuFamilyBuilder.Definition.Name + "_startup_gcc.c") }); if (!noPeripheralRegisters) { var headerFiles = Directory.GetFiles(mcuFamilyBuilder.Definition.PrimaryHeaderDir + "\\inc", "*.h"); var headerFileRegex = new Regex(mcuFamilyBuilder.Definition.DeviceRegex, RegexOptions.IgnoreCase); var familyHeaderFiles = headerFiles.Where(headerFile => headerFileRegex.Match(headerFile.Substring(headerFile.LastIndexOf("\\") + 1)).Success).ToArray(); if (familyHeaderFiles.Length == 0) { throw new Exception("No header file found for MCU family"); } else if (familyHeaderFiles.Length > 1) { throw new Exception("Only one header file expected for MCU family"); } var registersParser = new RegistersParser(familyHeaderFiles[0]); mcuFamilyBuilder.AttachPeripheralRegisters(new[] { new MCUDefinitionWithPredicate { MCUName = mcuFamilyBuilder.Definition.Name, RegisterSets = registersParser.Parse(), MatchPredicate = m => true } }); } var familyObject = mcuFamilyBuilder.GenerateFamilyObject(true); familyObject.AdditionalSourceFiles = LoadedBSP.Combine(familyObject.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); familyObject.AdditionalHeaderFiles = LoadedBSP.Combine(familyObject.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); familyObject.AdditionalSystemVars = LoadedBSP.Combine(familyObject.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); familyObject.CompilationFlags = familyObject.CompilationFlags.Merge(flags); familyDefinitions.Add(familyObject); mcuFamilyBuilder.GenerateLinkerScripts(false); foreach (var mcu in mcuFamilyBuilder.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(mcuFamilyBuilder, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in mcuFamilyBuilder.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in mcuFamilyBuilder.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.ti.msp432", PackageDescription = "TI MSP432 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "msp432.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.ToArray(), PackageVersion = "1.0" }; bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 2) { throw new Exception("Usage: stm32.exe <SW package directory> <STM32Cube directory>"); } ///If the MCU list format changes again, create a new implementation of the IDeviceListProvider interface, switch to using it, but keep the old one for reference & easy comparison. IDeviceListProvider provider = new DeviceListProviders.CubeProvider(); var bspBuilder = new STM32BSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules"), args[1]); var devices = provider.LoadDeviceList(bspBuilder); if (devices.Where(d => d.RAMSize == 0 || d.FlashSize == 0).Count() > 0) { throw new Exception($"Some devices are RAM Size ({devices.Where(d => d.RAMSize == 0).Count()}) = 0 or FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0) { Console.WriteLine("Globally unsupported MCUs:"); foreach (var r in rejects) { Console.WriteLine("\t{0}", r.Name); } } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); var files = string.Join("\r\n", File.ReadAllLines(@"E:\ware\Logfile.CSV").Select(l => l.Split(',')[4].Trim('\"')).Distinct().OrderBy(x => x).ToArray()); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var fam in allFamilies) { bspBuilder.GetMemoryMcu(fam); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(fam.Definition.PrimaryHeaderDir, fam)); } familyDefinitions.Add(fam.GenerateFamilyObject(true)); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } foreach (var sample in commonPseudofamily.CopySamples(null, allFamilies.Where(f => f.Definition.AdditionalSystemVars != null).SelectMany(f => f.Definition.AdditionalSystemVars))) { exampleDirs.Add(sample); } var prioritizer = new SamplePrioritizer(Path.Combine(bspBuilder.Directories.RulesDir, "SamplePriorities.txt")); exampleDirs.Sort((a, b) => prioritizer.Prioritize(a.RelativePath, b.RelativePath)); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.stm32", PackageDescription = "STM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "stm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), PackageVersion = "4.5R2", IntelliSenseSetupFile = "stm32_compat.h", FileConditions = bspBuilder.MatchedFileConditions.ToArray(), MinimumEngineVersion = "5.1", FirstCompatibleVersion = "3.0", InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints, }; File.Copy(@"..\..\stm32_compat.h", Path.Combine(bspBuilder.BSPRoot, "stm32_compat.h"), true); Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: EFM32.exe <SLab SW package directory>"); } var bspBuilder = new SLabBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); var ignoredFamilyNames = File.ReadAllLines(Path.Combine(bspBuilder.Directories.RulesDir, "rulesfamaly.txt")); string DirDevices = Path.Combine(bspBuilder.Directories.InputDir, @"platform\Device\SiliconLabs"); string[] allFamilySubdirectories = Directory.GetDirectories(DirDevices); Console.WriteLine("Enumerating devices..."); foreach (var dir in allFamilySubdirectories) { string familyName = Path.GetFileNameWithoutExtension(dir); if (ignoredFamilyNames.FirstOrDefault(n => dir.Contains(n)) != null) { continue; } var devices = GetMCUsForFamily(dir); Console.WriteLine($" {familyName}: {devices.Count} devices"); ValidateMCUNames(devices); if (devices.Where(d => d.RAMSize == 0 || d.FlashSize == 0).Count() > 0) { throw new Exception($"Some devices are RAM Size ({devices.Where(d => d.RAMSize == 0).Count()}) = 0 or FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } if (devices.Count == 0) { throw new Exception("No devices for " + familyName); } string StartupFile = Directory.GetFiles(Path.Combine(DirDevices, familyName, @"Source\GCC"), "startup_*.c")[0].Replace(bspBuilder.Directories.InputDir, @"$$BSPGEN:INPUT_DIR$$"); var copyJob = new CopyJob() { FilesToCopy = "-*startup_*;*.h;*.c", TargetFolder = "Devices", ProjectInclusionMask = "*.c", AutoIncludeMask = "*.h", SourceFolder = DirDevices + "\\" + familyName }; var fam = new MCUFamilyBuilder(bspBuilder, new FamilyDefinition() { Name = familyName, FamilySubdirectory = familyName, PrimaryHeaderDir = "$$BSPGEN:INPUT_DIR$$", StartupFileDir = StartupFile, CoreFramework = new Framework() { CopyJobs = new[] { copyJob } }, Subfamilies = new MCUClassifier[] { }.ToArray() }); fam.MCUs.AddRange(devices); allFamilies.Add(fam); } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } Console.WriteLine("Processing families..."); int cnt = 0; foreach (var fam in allFamilies) { Console.WriteLine($" {fam.Definition.Name} ({++cnt}/{allFamilies.Count})..."); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir + "\\" + fam.Definition.FamilySubdirectory + "\\Devices", fam)); } foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.silabs.efm32", PackageDescription = "Silabs EFM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "efm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "5.8.3" }; Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); }
//=========================================================== static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: InfineonXMC.exe <InfineonXMC SW package directory>"); } using (var bspBuilder = new InfineonXMCBSPBuilder(BSPDirectories.MakeDefault(args))) { var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuInfineonDevices.csv", "Product", "Program Memory(KB) ", "SRAM (KB) ", "CORE", true); devices = UpdateListMCU(devices); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0) { throw new Exception($"Found {rejects.Count} MCUs not assigned to any family"); } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <string> exampleDirs = new List <string>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample.RelativePath); } foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir)); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, @"CMSIS\Infineon\SVD\" + fam.Definition.Name + ".svd"), fam.Definition.Name) }); } var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample.RelativePath); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.infineon.xmc", PackageDescription = "Infineon XMC Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "infineon_xmc.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.ToArray(), FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(), PackageVersion = "2.1.24R2" }; bspBuilder.Save(bsp, true); } }
//=========================================================== static void Main(string[] args) { if (args.Length < 1) throw new Exception("Usage: InfineonXMC.exe <InfineonXMC SW package directory>"); var bspBuilder = new InfineonXMCBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); var devices = BSPGeneratorTools.ReadMCUDevicesFromCommaDelimitedCSVFile(bspBuilder.Directories.RulesDir + @"\McuInfineonDevices.csv", "Product", "Program Memory(KB) ", "SRAM (KB) ", "CORE", true); devices = UpdateListMCU(devices); List<MCUFamilyBuilder> allFamilies = new List<MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) allFamilies.Add(new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(fn))); var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); if (rejects.Count > 0) throw new Exception($"Found {rejects.Count} MCUs not assigned to any family"); List<MCUFamily> familyDefinitions = new List<MCUFamily>(); List<MCU> mcuDefinitions = new List<MCU>(); List<EmbeddedFramework> frameworks = new List<EmbeddedFramework>(); List<string> exampleDirs = new List<string>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List<KeyValuePair<string, string>> macroToHeaderMap = new List<KeyValuePair<string, string>>(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject<FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); var flags = new ToolFlags(); List<string> projectFiles = new List<string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) exampleDirs.Add(sample.RelativePath); foreach (var fam in allFamilies) { var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) Console.WriteLine("\t{0}", mcu.Name); } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir)); if (!noPeripheralRegisters) fam.AttachPeripheralRegisters(new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, @"CMSIS\Infineon\SVD\" + fam.Definition.Name + ".svd"), fam.Definition.Name) }); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); foreach (var mcu in fam.MCUs) mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); foreach (var fw in fam.GenerateFrameworkDefinitions()) frameworks.Add(fw); foreach (var sample in fam.CopySamples()) exampleDirs.Add(sample.RelativePath); } UpdateNameMcuToSeggerFormat(ref mcuDefinitions); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.infineon.xmc", PackageDescription = "Infineon XMC Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "infineon_xmc.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "2.1.8" }; bspBuilder.Save(bsp, true); }