public void ValidateBSP(BoardSupportPackage bsp) { int devicesWithZeroRAM = bsp.SupportedMCUs.Count(dev => dev.RAMSize == 0); if (devicesWithZeroRAM > 0) { throw new Exception($"Found {devicesWithZeroRAM} devices with RAMSize = 0. Please fix the list."); } foreach (var dev in bsp.SupportedMCUs) { if (dev.MemoryMap != null) { bool foundMainFLASH = false; foreach (var mem in dev.MemoryMap.Memories) { if ((mem.Flags & MCUMemoryFlags.IsDefaultFLASH) == MCUMemoryFlags.IsDefaultFLASH) { foundMainFLASH = true; } if (mem.LoadedFromMemory != null) { var foundMem = dev.MemoryMap.Memories.First(m => m.Name == mem.LoadedFromMemory) ?? throw new Exception($"Could not find memory {mem.LoadedFromMemory} referenced by {mem.Name}"); } } if (!foundMainFLASH) { throw new Exception($"Memory map for {dev.ID} does not contain a FLASH memory"); } } } }
public static void Save(BoardSupportPackage bsp, String BSPRoot) { XmlTools.SaveObject(bsp, Path.Combine(BSPRoot, "BSP.XML")); string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion); TarPacker.PackDirectoryToTGZ(BSPRoot, Path.Combine(BSPRoot, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp"); BSPSummary lst = new BSPSummary { BSPName = bsp.PackageDescription, BSPID = bsp.PackageID, BSPVersion = bsp.PackageVersion, MinimumEngineVersion = bsp.MinimumEngineVersion, FileName = archiveName, }; foreach (var mcu in bsp.SupportedMCUs) { lst.MCUs.Add(new BSPSummary.MCU { Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize, UserFriendlyName = mcu.UserFriendlyName }); } XmlTools.SaveObject(lst, Path.Combine(BSPRoot, Path.ChangeExtension(archiveName, ".xml"))); }
private static void GenerateBSP(List<DeviceInfo> devList, string outputDir) { BoardSupportPackage bsp = new BoardSupportPackage { GNUTargetID = "avr", PackageID = "com.sysprogs.avr.core", PackageDescription = "AVR MCUs", GeneratedMakFileName = "avr.mak", Examples = new string[] { "Samples/LEDBlink" } }; bsp.SupportedMCUs = devList.Select(d => d.ToBSPMCU()).ToArray(); bsp.MCUFamilies = new MCUFamily[] { new MCUFamily{ ID = "avr" } }; bsp.DebugMethodPackages = new string[] { "debuggers\\core", "debuggers\\avarice" }; string defDir = Path.Combine(outputDir, "DeviceDefinitions"); Directory.CreateDirectory(defDir); foreach (var dev in devList) { MCUDefinition d = dev.ToDeviceDefinition(); if (d == null) { Console.WriteLine("Warning: no register information found for " + dev.Name); continue; } using (var fs = File.Create(Path.Combine(defDir, dev.Name + ".xml.gz"))) using (var gs = new GZipStream(fs, CompressionMode.Compress)) XmlTools.SaveObjectToStream(d, gs); } XmlTools.SaveObject(bsp, Path.Combine(outputDir, "bsp.xml")); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: AtmelStartSDKImporter <Extracted Project Directory>"); Environment.ExitCode = 1; return; } string sdkDir = args[0]; BoardSupportPackage BSP = AtmelStartPackageParser.GenerateBSPForSTARTProject(args[0], new ConsoleWarningSink()); AtmelStartPackageParser.Save(BSP, args[0]); }
private static void FixGPDSCErrors(BoardSupportPackage bsp, MCU mcu, string extractedProjectDirectory, FlagsFromMakefile flagsFromMakefile, string relativeFLASHScript) { //1. Startup files may not be referenced in the GPDSC file string[] startupFiles = Directory.GetFiles(Path.Combine(extractedProjectDirectory, Path.GetDirectoryName(relativeFLASHScript)), "*.c") .Select(f => "$$SYS:BSP_ROOT$$/" + f.Substring(extractedProjectDirectory.Length).TrimStart('\\').Replace('\\', '/')) .Except(bsp.Frameworks.SelectMany(fw => fw.AdditionalSourceFiles)) .ToArray(); //2. Some include directories are not referenced in the GPDSC file string[] extraIncludeDirs = flagsFromMakefile.RelativeIncludeDirs .Select(d => "$$SYS:BSP_ROOT$$/" + d) .Except(bsp.Frameworks.SelectMany(fw => fw.AdditionalIncludeDirs)) .ToArray(); mcu.AdditionalSourceFiles = startupFiles; mcu.CompilationFlags = mcu.CompilationFlags.Merge(new ToolFlags { IncludeDirectories = extraIncludeDirs }); }
public void ProduceBSPArchive(BoardSupportPackage bsp) { //bsp.PackageVersion = string.Format("{0:d4}{1:d2}{2:d2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); //bsp.PackageVersion += "-beta"; XmlTools.SaveObject(bsp, Path.Combine(mbedRoot, "BSP.XML")); string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion); Console.WriteLine("Creating BSP archive..."); TarPacker.PackDirectoryToTGZ(mbedRoot, Path.Combine(Path.GetDirectoryName(mbedRoot), archiveName), fn => { string relPath = fn.Substring(mbedRoot.Length + 1); if (relPath.StartsWith(".git")) { return(false); } if (relPath.ToLower() == "ParsedTargets.xml".ToLower()) { return(false); } return(true); }, subdir => !subdir.StartsWith(".git", StringComparison.CurrentCultureIgnoreCase)); var lst = new BSPGenerationTools.BSPSummary { BSPName = bsp.PackageDescription, BSPID = bsp.PackageID, BSPVersion = bsp.PackageVersion, MinimumEngineVersion = bsp.MinimumEngineVersion, FileName = archiveName, }; foreach (var mcu in bsp.SupportedMCUs) { lst.MCUs.Add(new BSPGenerationTools.BSPSummary.MCU { Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize }); } XmlTools.SaveObject(lst, Path.Combine(Path.GetDirectoryName(mbedRoot), Path.ChangeExtension(archiveName, ".xml"))); }
public void Save(BoardSupportPackage bsp, bool produceBSPArchive, bool addFixedStackHeapFramework = true) { if (addFixedStackHeapFramework) { string dir = Path.Combine(Directories.OutputDir, "StackAndHeap"); Directory.CreateDirectory(dir); File.Copy(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "StackAndHeap.c"), Path.Combine(dir, "StackAndHeap.c")); var framework = XmlTools.LoadObject <EmbeddedFramework>(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "StackAndHeap.xml")); bsp.Frameworks = LoadedBSP.Combine(bsp.Frameworks, new[] { framework }); } XmlTools.SaveObject(bsp, Path.Combine(BSPRoot, "BSP.XML")); string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion); if (produceBSPArchive) { TarPacker.PackDirectoryToTGZ(BSPRoot, Path.Combine(BSPRoot, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp"); } BSPSummary lst = new BSPSummary { BSPName = bsp.PackageDescription, BSPID = bsp.PackageID, BSPVersion = bsp.PackageVersion, MinimumEngineVersion = bsp.MinimumEngineVersion, FileName = archiveName, }; foreach (var mcu in bsp.SupportedMCUs) { lst.MCUs.Add(new BSPSummary.MCU { Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize, UserFriendlyName = mcu.UserFriendlyName }); } XmlTools.SaveObject(lst, Path.Combine(BSPRoot, Path.ChangeExtension(archiveName, ".xml"))); }
private static void GenerateBSP(List <DeviceInfo> devList, string outputDir) { BoardSupportPackage bsp = new BoardSupportPackage { GNUTargetID = "avr", PackageID = "com.sysprogs.avr.core", PackageDescription = "AVR MCUs", GeneratedMakFileName = "avr.mak", Examples = new string[] { "Samples/LEDBlink" } }; bsp.SupportedMCUs = devList.Select(d => d.ToBSPMCU()).ToArray(); bsp.MCUFamilies = new MCUFamily[] { new MCUFamily { ID = "avr" } }; bsp.DebugMethodPackages = new string[] { "debuggers\\core", "debuggers\\avarice" }; string defDir = Path.Combine(outputDir, "DeviceDefinitions"); Directory.CreateDirectory(defDir); foreach (var dev in devList) { MCUDefinition d = dev.ToDeviceDefinition(); if (d == null) { Console.WriteLine("Warning: no register information found for " + dev.Name); continue; } using (var fs = File.Create(Path.Combine(defDir, dev.Name + ".xml.gz"))) using (var gs = new GZipStream(fs, CompressionMode.Compress)) XmlTools.SaveObjectToStream(d, gs); } XmlTools.SaveObject(bsp, Path.Combine(outputDir, "bsp.xml")); }
static void GenerateBSP(string toolchainDir, string ccsDir) { string[] keys = null; string bspDir = toolchainDir + @"\msp430-bsp"; Dictionary <string, Dictionary <string, string> > tiMCUs = new Dictionary <string, Dictionary <string, string> >(StringComparer.CurrentCultureIgnoreCase); foreach (var line in File.ReadAllLines(@"..\..\msp430.csv")) { string[] cells = line.Split(';'); if (keys == null) { keys = cells; continue; } Dictionary <string, string> entry = new Dictionary <string, string>(); for (int i = 0; i < cells.Length; i++) { entry[keys[i]] = cells[i]; } tiMCUs[cells[0]] = entry; int idx = cells[0].IndexOf('-'); if (idx != -1) { tiMCUs[cells[0].Substring(0, idx)] = entry; } } Regex rgLen = new Regex(".*LENGTH = 0x([0-9a-fA-F]{4}).*"); Regex rgOrigin = new Regex(".*ORIGIN = 0x([0-9a-fA-F]{4}).*"); Regex rgPeriph = new Regex("__([^ ]+) = (0x[a-fA-F0-9]+);"); List <string> families = new List <string>(); List <MCU> MCUs = new List <MCU>(); List <MCUFamily> famList = new List <MCUFamily>(); Directory.CreateDirectory(bspDir); Directory.CreateDirectory(bspDir + "\\devices"); XmlSerializer regSer = new XmlSerializer(typeof(MCUDefinition)); string[] files = Directory.GetFiles(Path.Combine(toolchainDir, "include"), "*.h"); for (int i = 0; i < files.Length; i++) { string file = files[i]; var proc = new Process(); string mcuName = Path.GetFileNameWithoutExtension(file).ToLower(); proc.StartInfo.FileName = toolchainDir + @"\bin\msp430-elf-gcc.exe"; proc.StartInfo.Arguments = $"-I. -E {mcuName}.h -o - -mmcu={mcuName}"; proc.StartInfo.WorkingDirectory = Path.Combine(toolchainDir, "include"); proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = true; proc.Start(); List <string> lines = new List <string>(); for (; ;) { var line = proc.StandardOutput.ReadLine(); if (line == null) { break; } lines.Add(line); } proc.WaitForExit(); if (proc.ExitCode != 0) { continue; } List <HardwareRegister> regs = new List <HardwareRegister>(); MCU mcu = new MCU(); mcu.ID = mcuName; mcu.CompilationFlags.COMMONFLAGS = "-mmcu=" + mcuName; string ld = Path.ChangeExtension(file, ".ld"); if (!File.Exists(ld)) { continue; } foreach (var line in File.ReadAllLines(ld)) { if (line.StartsWith(" RAM")) { var m = rgLen.Match(line); mcu.RAMSize = int.Parse(m.Groups[1].ToString(), System.Globalization.NumberStyles.HexNumber); m = rgOrigin.Match(line); mcu.RAMBase = uint.Parse(m.Groups[1].ToString(), System.Globalization.NumberStyles.HexNumber); } if (line.StartsWith(" ROM")) { var m = rgLen.Match(line); mcu.FLASHSize = int.Parse(m.Groups[1].ToString(), System.Globalization.NumberStyles.HexNumber); m = rgOrigin.Match(line); mcu.FLASHBase = uint.Parse(m.Groups[1].ToString(), System.Globalization.NumberStyles.HexNumber); } } if (mcu.RAMSize == 0) { throw new Exception("RAM size cannot be 0"); } foreach (var line in lines) { Regex rgRegister = new Regex("extern volatile (.*) ([^ ]+) __asm__\\(\"([^\"]+)\"\\)"); var m = rgRegister.Match(line); if (!m.Success) { if (line.Contains("extern") && line.Contains("__asm__")) { throw new Exception("Suspicious line"); } continue; } string type = m.Groups[1].Value; string name = m.Groups[2].Value; if (name.EndsWith("_H") || name.EndsWith("_L")) { continue; } if (!m.Groups[3].Value.StartsWith("0x")) { throw new Exception("Invalid addr for " + name); } ulong addr = ulong.Parse(m.Groups[3].Value.Substring(2), System.Globalization.NumberStyles.HexNumber); HardwareRegister reg = new HardwareRegister(); // TODO: the registers are not all 8 bits // According to some datasheets (not all were checked): // 01FFh to 0100h -> 16 bits // 0FFh to 010h -> 8bits // 0Fh to 00h -> 8-bit SFR (special function register) if (type == "unsigned char") { reg.SizeInBits = 8; } else if (type == "unsigned int") { reg.SizeInBits = 16; } else if (type == "unsigned long int") { reg.SizeInBits = 32; } else { throw new Exception("Unknown type"); } reg.Name = name; reg.Address = m.Groups[3].Value; regs.Add(reg); } string family = "Other"; Dictionary <string, string> info; if (tiMCUs.TryGetValue(mcu.ID, out info)) { family = info["Description"]; } int idx = families.IndexOf(family); if (idx == -1) { idx = families.Count; families.Add(family); famList.Add(new MCUFamily { ID = "fam_" + idx, UserFriendlyName = family, CompilationFlags = null }); } mcu.FamilyID = "fam_" + idx.ToString(); mcu.MCUDefinitionFile = "devices\\" + mcu.ID + ".xml"; mcu.HierarchicalPath = family; MCUs.Add(mcu); MCUDefinition desc = new MCUDefinition { MCUName = mcu.ID, RegisterSets = new HardwareRegisterSet[] { new HardwareRegisterSet { Registers = regs.ToArray() } } }; //, Specs = specs }; AdjustHardwareRegisters(ccsDir, mcu.ID, ref desc.RegisterSets); using (var fs = File.Create(bspDir + "\\" + mcu.MCUDefinitionFile + ".gz")) using (var gs = new GZipStream(fs, CompressionMode.Compress)) regSer.Serialize(gs, desc); Console.WriteLine($"Processed {mcuName} ({i}/{files.Length}) [{i * 100 / files.Length}%]"); } //Build the XML file BoardSupportPackage bsp = new BoardSupportPackage { GNUTargetID = "msp430", PackageID = "com.sysprogs.msp430.core", PackageDescription = "MSP430 MCUs" }; bsp.SupportedMCUs = MCUs.ToArray(); bsp.MCUFamilies = famList.ToArray(); bsp.DebugMethodPackages = new string[] { "debuggers\\core", "debuggers\\mspdebug" }; bsp.Examples = new string[] { "Samples\\LEDBlink" }; #if BSP_ADDITIONAL_GCC_FLAGS bsp.AdditionalGCCFlags = new PropertyList { PropertyGroups = new PropertyGroup[] { new PropertyGroup { Name = "MSP430 Options", Properties = new PropertyEntry[] { new PropertyEntry.Boolean { Name = "Disable watchdog on startup", Description = "Link the crt0 modules that disable the watchdog on startup", UniqueID = "com.sysprogs.msp430.mdisable-watchdog", ValueForTrue = "-mdisable-watchdog", ValueForFalse = "", }, new PropertyEntry.Boolean { Name = "Enable libcalls for shifts", Description = "Use library routines for non-constant shifts", UniqueID = "com.sysprogs.msp430.menable-libcall-shift", ValueForTrue = "-menable-libcall-shift", ValueForFalse = "", }, new PropertyEntry.Boolean { Name = "Inline hardware multiplication", Description = "Issue inline multiplication code for 32-bit integers", UniqueID = "com.sysprogs.msp430.minline-hwmul", ValueForTrue = "-minline-hwmul", ValueForFalse = "", }, new PropertyEntry.Enumerated { Name = "Interrupt vector count", Description = "Specify number of interrupt vectors on chip:", UniqueID = "com.sysprogs.msp430.mivcnt", GNUPrefix = "-mivcnt=", SuggestionList = new PropertyEntry.Enumerated.Suggestion[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "", UserFriendlyName = "(default)" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "16" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "32" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "64" }, }, AllowFreeEntry = true, }, new PropertyEntry.Enumerated { Name = "Hardware multiplier", Description = "Define available hardware multiplier", UniqueID = "com.sysprogs.msp430.mmpy", GNUPrefix = "-mmpy=", SuggestionList = new PropertyEntry.Enumerated.Suggestion[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "", UserFriendlyName = "(default)" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "16" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "16se" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "32" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "32dw" }, } }, new PropertyEntry.Boolean { Name = "No hardware multiplication in ISRs", Description = "Assume interrupt routine does not do hardware multiplication", UniqueID = "com.sysprogs.msp430.noint-hwmul", ValueForTrue = "-noint-hwmul", ValueForFalse = "", }, new PropertyEntry.Boolean { Name = "Prologue space optimization", Description = "Use subroutine call for function prologue/epilogue when possible", UniqueID = "com.sysprogs.msp430.msave-prologue", ValueForTrue = "-msave-prologue", ValueForFalse = "", }, } } } }; #endif XmlSerializer ser = new XmlSerializer(typeof(BoardSupportPackage), PropertyEntry.EntryTypes); using (var fs = File.Create(bspDir + "\\BSP.xml")) ser.Serialize(fs, bsp); //mcuSelector1.Reset(); var lBsp = LoadedBSP.Load(new BSPSummary(bspDir), null); //mcuSelector1.AddBSP(lBsp); //embeddedDebugSettingsControl1.Reset(); //embeddedDebugSettingsControl1.AddDebugMethods(lBsp.KnownDebugMethods); }
static void Main(string[] args) { var generator = new MbedBSPGenerator("5.9.2"); bool skipRescan = args.Contains("/norescan"); string suffix = ""; generator.UpdateGitAndRescanTargets(skipRescan); ParsedTargetList parsedTargets = XmlTools.LoadObject <ParsedTargetList>(Path.Combine(generator.outputDir, "mbed", "ParsedTargets.xml")); generator.PatchBuggyFiles(); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.mbed", PackageDescription = "ARM mbed", PackageVersion = generator.Version + suffix, GNUTargetID = "arm-eabi", GeneratedMakFileName = "mbed.mak", BSPSourceFolderName = "mbed Files" }; var validTargets = parsedTargets.Targets.Where(t => t.BaseConfiguration != null).ToArray(); MCUFamily commonFamily = new MCUFamily { ID = "MBED_CORE", AdditionalSourceFiles = generator.ConvertPaths(Intersect(validTargets.Select(t => t.BaseConfiguration.SourceFiles))), AdditionalHeaderFiles = generator.ConvertPaths(Intersect(validTargets.Select(t => t.BaseConfiguration.HeaderFiles))), SymbolsRequiredByLinkerScript = new[] { "__Vectors", "Stack_Size" }, CompilationFlags = new ToolFlags { IncludeDirectories = generator.ConvertPaths(Intersect(validTargets.Select(t => t.BaseConfiguration.IncludeDirectories))), PreprocessorMacros = Intersect(validTargets.Select(t => t.BaseConfiguration.EffectivePreprocessorMacros)) } }; bsp.MCUFamilies = new[] { commonFamily }; List <MCU> mcus = new List <MCU>(); Dictionary <string, ConditionalConfigAggregator> libraryAndFeatureConfigs = new Dictionary <string, ConditionalConfigAggregator>(); Console.WriteLine("Generating target definitions..."); foreach (var target in validTargets) { if (string.IsNullOrEmpty(target.BaseConfiguration.LinkerScript)) { Console.WriteLine($"Skipping {target.ID}: no linker script defined"); continue; } var mcu = new MCU { FamilyID = commonFamily.ID, ID = target.ID, AdditionalSourceFiles = generator.ConvertPaths(target.BaseConfiguration.SourceFiles), AdditionalHeaderFiles = generator.ConvertPaths(target.BaseConfiguration.HeaderFiles), CompilationFlags = new ToolFlags { IncludeDirectories = generator.ConvertPaths(target.BaseConfiguration.IncludeDirectories), PreprocessorMacros = target.BaseConfiguration.EffectivePreprocessorMacros, LinkerScript = generator.ConvertPaths(new[] { target.BaseConfiguration.LinkerScript })[0], COMMONFLAGS = target.CFLAGS.Replace(';', ' '), }, ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup { UniqueID = "com.sysprogs.mbed.", Properties = target.BaseConfiguration.EffectiveConfigurableProperties.ToList() } } } }; generator.DetectAndApplyMemorySizes(mcu, target.BaseConfiguration.LinkerScript); if (mcu.CompilationFlags.COMMONFLAGS.Contains("-mfloat-abi")) { string[] flags = mcu.CompilationFlags.COMMONFLAGS.Split(' '); string defaultValue = flags.First(f => f.StartsWith("-mfloat-abi")); var property = new PropertyEntry.Enumerated { Name = "Floating point support", UniqueID = "floatmode", SuggestionList = new PropertyEntry.Enumerated.Suggestion[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "-mfloat-abi=soft", UserFriendlyName = "Software" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "-mfloat-abi=hard", UserFriendlyName = "Hardware" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "-mfloat-abi=softfp", UserFriendlyName = "Hardware with Software interface" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "", UserFriendlyName = "Unspecified" }, }, }; property.DefaultEntryIndex = Enumerable.Range(0, property.SuggestionList.Length).First(i => property.SuggestionList[i].InternalValue == defaultValue); flags[Array.IndexOf(flags, defaultValue)] = "$$" + mcu.ConfigurableProperties.PropertyGroups[0].UniqueID + property.UniqueID + "$$"; mcu.CompilationFlags.COMMONFLAGS = string.Join(" ", flags); mcu.ConfigurableProperties.PropertyGroups[0].Properties.Add(property); } mcu.AdditionalSourceFiles = mcu.AdditionalSourceFiles.Except(commonFamily.AdditionalSourceFiles).ToArray(); mcu.AdditionalHeaderFiles = mcu.AdditionalHeaderFiles.Except(commonFamily.AdditionalHeaderFiles).ToArray(); mcu.CompilationFlags.IncludeDirectories = mcu.CompilationFlags.IncludeDirectories.Except(commonFamily.CompilationFlags.IncludeDirectories).ToArray(); mcu.CompilationFlags.PreprocessorMacros = mcu.CompilationFlags.PreprocessorMacros.Except(commonFamily.CompilationFlags.PreprocessorMacros).ToArray(); foreach (var cfg in target.DerivedConfigurations) { cfg.MergeScatteredConfigurations(); ConditionalConfigAggregator agg; if (!libraryAndFeatureConfigs.TryGetValue(cfg.CanonicalKey, out agg)) { agg = libraryAndFeatureConfigs[cfg.CanonicalKey] = new ConditionalConfigAggregator(cfg); } agg.AddedSettingsPerTargets[target.ID] = cfg.Configuration.Subtract(target.BaseConfiguration, cfg.CanonicalKey, cfg.Library != null); } if (!generator.ConvertSoftdevicesAndPatchTarget(mcu, target.BaseConfiguration.HexFiles)) { mcu.CompilationFlags.LinkerScript = generator.ConvertPath(generator.PreprocessLinkerScriptIfNeeded(mcu.CompilationFlags.LinkerScript)); } generator.CopyAndAttachRegisterDefinitions(mcu); mcus.Add(mcu); } bsp.SupportedMCUs = mcus.ToArray(); List <FileCondition> fileConditions = new List <FileCondition>(); List <ConditionalToolFlags> conditionalFlags = new List <ConditionalToolFlags>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); Console.WriteLine("Merging library build settings..."); foreach (var agg in libraryAndFeatureConfigs.Values) { EmbeddedFramework framework = new EmbeddedFramework { ID = agg.ID, UserFriendlyName = agg.Name, AdditionalSourceFiles = generator.ConvertPaths(Union(agg.AddedSettingsPerTargets.Values.Select(t => t.SourceFiles))), AdditionalHeaderFiles = generator.ConvertPaths(Union(agg.AddedSettingsPerTargets.Values.Select(t => t.HeaderFiles))), AdditionalIncludeDirs = generator.ConvertPaths(Intersect(agg.AddedSettingsPerTargets.Values.Select(t => t.IncludeDirectories))), AdditionalPreprocessorMacros = Intersect(agg.AddedSettingsPerTargets.Values.Select(t => t.EffectivePreprocessorMacros)), }; var properties = Union(agg.AddedSettingsPerTargets.Values.Select(t => t.EffectiveConfigurableProperties), new PropertyComparerByID()).ToList(); if (properties.Count > 0) { framework.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup { UniqueID = "com.sysprogs.mbed.", Properties = properties } } } } ; foreach (var file in framework.AdditionalSourceFiles.Concat(framework.AdditionalHeaderFiles)) { var targetsWhereIncluded = agg.AddedSettingsPerTargets .Where(v => generator.ConvertPaths(v.Value.SourceFiles.Concat(v.Value.HeaderFiles)).Contains(file)) .Select(kv => kv.Key) .ToArray(); if (targetsWhereIncluded.Length == agg.AddedSettingsPerTargets.Count) { continue; //The file is included on all targets } fileConditions.Add(new FileCondition { FilePath = file, ConditionToInclude = new Condition.MatchesRegex { Expression = "$$SYS:MCU_ID$$", Regex = "^(" + string.Join("|", targetsWhereIncluded) + ")$" } }); } foreach (var kv in agg.AddedSettingsPerTargets) { var extraIncludeDirs = generator.ConvertPaths(kv.Value.IncludeDirectories).Except(framework.AdditionalIncludeDirs).ToArray(); var extraPreprocessorMacros = kv.Value.EffectivePreprocessorMacros.Except(framework.AdditionalPreprocessorMacros).ToArray(); if (extraIncludeDirs.Length == 0 && extraPreprocessorMacros.Length == 0) { continue; } ToolFlags flags = new ToolFlags(); if (extraIncludeDirs.Length > 0) { flags.IncludeDirectories = extraIncludeDirs; } if (extraPreprocessorMacros.Length > 0) { flags.PreprocessorMacros = extraPreprocessorMacros; } conditionalFlags.Add(new ConditionalToolFlags { Flags = flags, FlagCondition = new Condition.And { Arguments = new Condition[] { new Condition.ReferencesFramework { FrameworkID = framework.ID }, new Condition.Equals { Expression = "$$SYS:MCU_ID$$", ExpectedValue = kv.Key } } } }); } frameworks.Add(framework); } bsp.FileConditions = fileConditions.ToArray(); bsp.ConditionalFlags = conditionalFlags.ToArray(); bsp.Frameworks = frameworks.ToArray(); bsp.Examples = generator.DetectSampleDirs(); generator.ProduceBSPArchive(bsp); bool performTests = true; if (performTests) { RunTests(generator); } }
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: 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) { 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: 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: 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: 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); }
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" }); }
public void GeneratePackage() { Console.Write("Creating a list of MCUs... "); CreateMCUBuilders(); Console.WriteLine("done"); Console.WriteLine("Number of MCUs: {0}", _mcuBuilders.Count); Console.Write("Creating a list of MCU families... "); CreateMCUFamilyBuilders(); Console.WriteLine("done"); Console.WriteLine("Number of MCU families: {0}", _mcuFamilyBuilders.Count); Console.Write("Assigning MCUs to MCU families... "); AssignMCUsToFamilies(); Console.WriteLine("done"); Console.WriteLine("{0} MCU families have no MCUs and will be discarded: {1}", _rejectedMCUFamilies.Length, string.Join(",", _rejectedMCUFamilies.Select(mf => mf.Definition.Name))); Console.WriteLine("{0} MCUs were not assigned to any family and will be discarded: {1}", _rejectedMCUs.Length, string.Join(",", _rejectedMCUs.Select(m => m.Name))); Console.Write("Processing common files... "); ProcessCommonFiles(); Console.WriteLine("done"); Console.Write("Generating MCUs and their families... "); GenerateMCUsAndMCUFamilies(); Console.WriteLine("done"); //We don't want to include the same include paths twice (once from the family and another time from the framework), so we filter out the family-provided ones here. HashSet<string> includeDirsFromFamilies = new HashSet<string>(); foreach(var fam in _mcuFamilies) { foreach (var dir in fam.CompilationFlags.IncludeDirectories) includeDirsFromFamilies.Add(dir.Replace(fam.ID, "$$SYS:FAMILY_ID$$")); } foreach(var fw in _frameworks) { fw.AdditionalIncludeDirs = fw.AdditionalIncludeDirs.Where(d => !includeDirsFromFamilies.Contains(d)).ToArray(); }; Console.Write("Detecting GPIO prefixes... "); Regex rgBrackets = new Regex(@"\(([^\(\)]+)\)"); foreach (var fam in _mcuFamilies) { var mainIncludeFile = string.Format(@"{0}\platform\devices\M{1}\include\M{1}.h", Directories.InputDir, fam.ID); string gpioaLine = File.ReadAllLines(mainIncludeFile).First(s => s.Contains("#define GPIOA_PDOR")); var m = rgBrackets.Match(gpioaLine); if (!m.Success) throw new Exception("Cannot detect GPIO prefix for " + fam.ID); fam.AdditionalSystemVars = LoadedBSP.Combine(fam.AdditionalSystemVars, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.arm.kinetis.gpio_prefix", Value = m.Groups[1].Value.Substring(0, m.Groups[1].Value.Length - 1) } }); } Console.WriteLine("done"); Console.Write("Reading MCUs listed in Segger lists... "); var mcusFromSeggerFile = new HashSet<string>(ReadSeggerMCUs(Directories.RulesDir + "\\" + SEGGER_FILE, MANUFACTURER)); Console.WriteLine("done"); Console.Write("Generating BSP... "); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.freescale.kinetis_ksdk", PackageDescription = "Freescale Kinetis (KSDK)", GNUTargetID = "arm-eabi", GeneratedMakFileName = "kinetis.mak", MCUFamilies = _mcuFamilies.ToArray(), SupportedMCUs = _mcus.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 = MatchedFileConditions.ToArray(), PackageVersion = "1.3.2", MinimumEngineVersion = "5.0", }; Save(bsp, true); Console.WriteLine("done"); var mcusUnlistedInSeggerFile = new List<string>(); foreach (var mcu in _mcus) { var generalizedMCUName = MCUNameToGeneralizedMCUName(mcu.ID); if (!mcusFromSeggerFile.Contains(generalizedMCUName)) { mcusUnlistedInSeggerFile.Add(generalizedMCUName); } } Console.WriteLine("Generated MCU definitions: {0}\r\nGenerated families: {1}\r\nMCUs unlisted in Segger lists: {2}", _mcus.Count, _mcuFamilies.Count, mcusUnlistedInSeggerFile.Count); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
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: 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 < 1) { throw new Exception("Usage: nrf5x.exe <Nordic SW package directory>"); } bool usingIoTSDK = false; if (Directory.Exists(Path.Combine(args[0], @"components\iot\ble_6lowpan"))) { usingIoTSDK = true; Console.WriteLine("Detected IoT SDK"); } NordicBSPBuilder bspBuilder; if (usingIoTSDK) { bspBuilder = new NordicBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules_iot")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("s1xx_iot", 0x1f000, 0x2800, "nrf52", "IoT")); } else { bspBuilder = new NordicBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S130", 0x1b000, 0x13c8, "nrf51", "Bluetooth LE Universal")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S132", 0x20000, 0x2168, "nrf52832", "Bluetooth LE")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S140", 0x21000, 0x2780, "nrf52840", "Bluetooth LE")); } List <MCUBuilder> devices = new List <MCUBuilder>(); if (!usingIoTSDK) { foreach (string part in new string[] { "nRF51822", "nRF51422" }) { devices.Add(new MCUBuilder { Name = part + "_XXAA", FlashSize = 256 * 1024, RAMSize = 16 * 1024, Core = CortexCore.M0 }); devices.Add(new MCUBuilder { Name = part + "_XXAB", FlashSize = 128 * 1024, RAMSize = 16 * 1024, Core = CortexCore.M0 }); devices.Add(new MCUBuilder { Name = part + "_XXAC", FlashSize = 256 * 1024, RAMSize = 32 * 1024, Core = CortexCore.M0 }); } } devices.Add(new MCUBuilder { Name = "nRF52832_XXAA", FlashSize = 512 * 1024, RAMSize = 64 * 1024, Core = CortexCore.M4 }); devices.Add(new MCUBuilder { Name = "nRF52840_XXAA", FlashSize = 1024 * 1024, RAMSize = 256 * 1024, Core = CortexCore.M4 }); 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 <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = true; List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); 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); flags = flags.Merge(commonPseudofamily.Definition.CompilationFlags); List <ConditionalToolFlags> condFlags = new List <ConditionalToolFlags>(); foreach (var fam in allFamilies) { Console.WriteLine("Processing " + fam.Definition.Name + " family..."); string famBase = fam.Definition.Name.Substring(0, 5).ToLower(); 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); } } List <Framework> bleFrameworks = new List <Framework>(); foreach (var line in File.ReadAllLines(bspBuilder.Directories.RulesDir + @"\BLEFrameworks.txt")) { int idx = line.IndexOf('|'); string dir = line.Substring(0, idx); string desc = line.Substring(idx + 1); string id = Path.GetFileName(dir); if (!id.StartsWith("ble_")) { id = "ble_" + id; } if (dir.StartsWith("services\\", StringComparison.CurrentCultureIgnoreCase)) { id = "ble_svc_" + id.Substring(4); } bleFrameworks.Add(new Framework { Name = string.Format("Bluetooth LE - {0} ({1})", desc, Path.GetFileName(dir)), ID = "com.sysprogs.arm.nordic." + famBase + "." + id, ClassID = "com.sysprogs.arm.nordic.nrfx." + id, ProjectFolderName = "BLE " + desc, DefaultEnabled = false, CopyJobs = new CopyJob[] { new CopyJob { SourceFolder = allFamilies[0].Definition.PrimaryHeaderDir + @"\..\components\ble\" + dir, TargetFolder = dir, FilesToCopy = "*.c;*.h", } } }); } fam.Definition.AdditionalFrameworks = fam.Definition.AdditionalFrameworks.Concat(bleFrameworks).ToArray(); // Startup Files StartupFileGenerator.InterruptVectorTable[] aStartupVectors; if (usingIoTSDK) { aStartupVectors = new StartupFileGenerator.InterruptVectorTable[] { GenerateStartupFile(fam.Definition.StartupFileDir, "nRF52") } } ; else { aStartupVectors = new StartupFileGenerator.InterruptVectorTable[] { GenerateStartupFile(fam.Definition.StartupFileDir, "nRF51"), GenerateStartupFile(fam.Definition.StartupFileDir, "nRF52") } }; fam.AttachStartupFiles(aStartupVectors); // SVD Files var aMcuDef1 = (new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, "nRF51.svd"), "nRF51") }); aMcuDef1[0].MatchPredicate = m => m.Name.StartsWith("nRF51"); var aMcuDef2 = (new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, "nRF52.svd"), "nRF52") }); aMcuDef2[0].MatchPredicate = m => m.Name.StartsWith("nRF52"); fam.AttachPeripheralRegisters(aMcuDef1.Concat(aMcuDef2)); 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); SysVarEntry defaultConfigFolder51 = new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = "pca10040/s132" }; // s132_pca10036" }; SysVarEntry defaultConfigFolder52 = new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = "pca10028/s130" }; // s130_pca10028" }; foreach (var mcu in fam.MCUs) { var mcuDef = mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters); var compatibleSoftdevs = new PropertyEntry.Enumerated.Suggestion[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "nosoftdev", UserFriendlyName = "None" } }.Concat(bspBuilder.SoftDevices.Where(sd => sd.IsCompatible(mcu.Name)).Select(s => new PropertyEntry.Enumerated.Suggestion { InternalValue = s.Name, UserFriendlyName = s.UserFriendlyName })).ToArray(); if (mcuDef.ConfigurableProperties == null) { mcuDef.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup>() } } ; mcuDef.ConfigurableProperties.PropertyGroups.Add(new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Enumerated { UniqueID = NordicBSPBuilder.SoftdevicePropertyID, Name = "Softdevice", DefaultEntryIndex = 1, SuggestionList = compatibleSoftdevs, } } }); if (mcu.Name.StartsWith("nRF52")) { var prop = mcuDef.ConfigurableProperties.PropertyGroups[0].Properties.Find(p => p.UniqueID == "com.sysprogs.bspoptions.arm.floatmode") as PropertyEntry.Enumerated; var idx = Array.FindIndex(prop.SuggestionList, p => p.UserFriendlyName == "Hardware"); prop.DefaultEntryIndex = idx; prop.SuggestionList[idx].UserFriendlyName = "Hardware (required when using a softdevice)"; //Otherwise the system_nrf52.c file won't initialize the FPU and the internal initialization of the softdevice will later fail. mcuDef.AdditionalSystemVars = LoadedBSP.Combine(mcuDef.AdditionalSystemVars, new SysVarEntry[] { defaultConfigFolder51 }); } else { mcuDef.AdditionalSystemVars = LoadedBSP.Combine(mcuDef.AdditionalSystemVars, new SysVarEntry[] { defaultConfigFolder52 }); } mcuDefinitions.Add(mcuDef); } if (fam.Definition.ConditionalFlags != null) { condFlags.AddRange(fam.Definition.ConditionalFlags); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples(null, new SysVarEntry[] { defaultConfigFolder51 })) { exampleDirs.Add(sample); } // var prioritizer = new SamplePrioritizer(Path.Combine(bspBuilder.Directories.RulesDir, "SamplePriorities.txt")); // exampleDirs.Sort((a, b) => prioritizer.Prioritize(a.RelativePath, b.RelativePath)); } bspBuilder.GenerateSoftdeviceLibraries(); Console.WriteLine("Building BSP archive..."); string strPackageID, strPackageDesc, strPAckVersion; if (usingIoTSDK) { strPackageID = "com.sysprogs.arm.nordic.nrf5x-iot"; strPackageDesc = "Nordic NRF52 IoT"; strPAckVersion = "0.9"; foreach (var mcu in mcuDefinitions) { mcu.UserFriendlyName = mcu.ID + " (IoT)"; } } else { strPackageID = "com.sysprogs.arm.nordic.nrf5x"; strPackageDesc = "Nordic NRF5x Devices"; strPAckVersion = "13.0-alpha"; } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = strPackageID, PackageDescription = strPackageDesc, GNUTargetID = "arm-eabi", GeneratedMakFileName = "nrf5x.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 = strPAckVersion, FileConditions = bspBuilder.MatchedFileConditions.ToArray(), MinimumEngineVersion = "5.0", ConditionalFlags = condFlags.ToArray(), }; bspBuilder.Save(bsp, true); } } }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: nrf5x.exe <Nordic SW package directory>"); } using (var bspBuilder = new NordicBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules", @"..\..\logs"))) { bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S132", "nrf52832.*", true, null, bspBuilder.Directories.InputDir)); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S140", "nrf52840.*", true, null, bspBuilder.Directories.InputDir)); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S112", "nrf5281.*", false, null, bspBuilder.Directories.InputDir)); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S113", "nrf528.*", true, null, bspBuilder.Directories.InputDir)); List <MCUBuilder> devices = new List <MCUBuilder> { new NordicMCUBuilder("nRF52832_XXAA", 512, 64, CortexCore.M4, true, "S132", "PCA10040"), new NordicMCUBuilder("nRF52810_XXAA", 192, 24, CortexCore.M4, false, "S112", "PCA10040"), new NordicMCUBuilder("nRF52811_XXAA", 192, 24, CortexCore.M4, false, "S112", "PCA10056"), new NordicMCUBuilder("nRF52833_XXAA", 512, 128, CortexCore.M4, true, "S140", "PCA10100"), new NordicMCUBuilder("nRF52840_XXAA", 1024, 256, CortexCore.M4, true, "S140", "PCA10056"), }; List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new NordicFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); 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); flags = flags.Merge(commonPseudofamily.Definition.CompilationFlags); List <ConditionalToolFlags> condFlags = new List <ConditionalToolFlags>(); foreach (var fam in allFamilies) { fam.GenerateLinkerScripts(false); Console.WriteLine("Processing " + fam.Definition.Name + " family..."); 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); } } bspBuilder.RuleGenerator.GenerateRulesForFamily(fam.Definition); List <MCUDefinitionWithPredicate> hardwareRegisterFiles = new List <MCUDefinitionWithPredicate>(); foreach (var svd in Directory.GetFiles(fam.Definition.PrimaryHeaderDir, "*.svd")) { var name = Path.GetFileNameWithoutExtension(svd).ToUpper(); if (name == "NRF52") { name = "NRF52832"; } if (!name.StartsWith("NRF52")) { continue; } var registers = SVDParser.ParseSVDFile(svd, name); hardwareRegisterFiles.Add(new MCUDefinitionWithPredicate { MCUName = name, RegisterSets = registers.RegisterSets, MatchPredicate = m => m.Name.StartsWith(registers.MCUName, StringComparison.InvariantCultureIgnoreCase) }); } fam.AttachPeripheralRegisters(hardwareRegisterFiles); var famObj = fam.GenerateFamilyObject(MCUFamilyBuilder.CoreSpecificFlags.All); 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) { var mcuDef = mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters, false, MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); if (mcu.Name.StartsWith("nRF52832")) { //Although documented as a legacy definition, skipping this breaks fds_internal_defs.h mcuDef.CompilationFlags.PreprocessorMacros = mcuDef.CompilationFlags.PreprocessorMacros.Concat(new[] { "NRF52" }).ToArray(); } var nosoftdev = new[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "nosoftdev", UserFriendlyName = "None" } }; var compatibleSoftdevs = bspBuilder.SoftDevices.Where(sd => sd.IsCompatible(mcu.Name)).SelectMany( s => new[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = s.Name, UserFriendlyName = s.UserFriendlyName }, new PropertyEntry.Enumerated.Suggestion { InternalValue = s.Name + "_reserve", UserFriendlyName = $"{s.UserFriendlyName} (programmed separately)" } }); if (mcuDef.ConfigurableProperties == null) { mcuDef.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup>() } } ; mcuDef.ConfigurableProperties.PropertyGroups.Add(new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Enumerated { UniqueID = NordicBSPBuilder.SoftdevicePropertyID, Name = "Softdevice", DefaultEntryIndex = 1, SuggestionList = nosoftdev.Concat(compatibleSoftdevs).ToArray(), } } }); if (mcu.Name.StartsWith("nRF52") && !mcu.Name.StartsWith("nRF5281")) { var prop = mcuDef.ConfigurableProperties.PropertyGroups[0].Properties.Find(p => p.UniqueID == "com.sysprogs.bspoptions.arm.floatmode") as PropertyEntry.Enumerated; var idx = Array.FindIndex(prop.SuggestionList, p => p.UserFriendlyName == "Hardware"); prop.DefaultEntryIndex = idx; prop.SuggestionList[idx].UserFriendlyName = "Hardware (required when using a softdevice)"; //Otherwise the system_nrf52.c file won't initialize the FPU and the internal initialization of the softdevice will later fail. } string defaultConfig; if (mcu.Name.StartsWith("nRF52840")) { defaultConfig = "pca10056/s140"; } else if (mcu.Name.StartsWith("nRF52810")) { defaultConfig = "pca10040e/s112"; } else if (mcu.Name.StartsWith("nRF52811")) { defaultConfig = "pca10056e/s112"; } else { defaultConfig = "pca10040/s132"; } var extraEntries = new[] { new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = defaultConfig }, new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix_blank", Value = "pca10040" } }; mcuDef.AdditionalSystemVars = LoadedBSP.Combine(mcuDef.AdditionalSystemVars, extraEntries); mcuDefinitions.Add(mcuDef); } if (fam.Definition.ConditionalFlags != null) { condFlags.AddRange(fam.Definition.ConditionalFlags); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } string dirpca = "pca10040e/s112"; foreach (var sample in fam.CopySamples(null, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = dirpca }, new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix_blank", Value = "pca10040" } })) { exampleDirs.Add(sample); } } const string softdevExpression = "$$com.sysprogs.bspoptions.nrf5x.softdevice$$"; foreach (var softdev in bspBuilder.SoftDevices) { condFlags.Add(new ConditionalToolFlags { FlagCondition = new Condition.Equals { Expression = softdevExpression, ExpectedValue = softdev.Name + "_reserve" }, Flags = new ToolFlags { PreprocessorMacros = familyDefinitions.First().CompilationFlags.PreprocessorMacros.Where(f => f.Contains(softdevExpression)).Select(f => f.Replace(softdevExpression, softdev.Name)).ToArray(), IncludeDirectories = familyDefinitions.First().CompilationFlags.IncludeDirectories.Where(f => f.Contains(softdevExpression)).Select(f => f.Replace(softdevExpression, softdev.Name)).ToArray() } }); } bspBuilder.GenerateSoftdeviceLibraries(); bspBuilder.RuleGenerator.PatchGeneratedFrameworks(frameworks, condFlags); // CheckEntriesSample(Path.Combine(bspBuilder.Directories.OutputDir, @"nRF5x\components\libraries"), // Path.Combine(bspBuilder.Directories.OutputDir, "Samples")); Console.WriteLine("Building BSP archive..."); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.nordic.nrf5x", PackageDescription = "Nordic NRF52x Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "nrf5x.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 = "16.0", FirstCompatibleVersion = "16.0", FileConditions = bspBuilder.MatchedFileConditions.Values.ToArray(), MinimumEngineVersion = "5.0", ConditionalFlags = condFlags.ToArray(), InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints, }; bspBuilder.ValidateBSP(bsp); List <ConfigurationFixSampleReference> samplesForComputingSymbolLists = new List <ConfigurationFixSampleReference>(); foreach (var sampleName in new[] { "BLEMouse", "IoT/Icmp", "BLEMultilinkCentral", "LEDBlink_FreeRTOS" }) { samplesForComputingSymbolLists.Add(new ConfigurationFixSampleReference { MCUID = "nRF52840_XXAA", SamplePath = "$$SYS:BSP_ROOT$$/samples/" + sampleName }); } bspBuilder.ReverseFileConditions.SaveIfConsistent(bspBuilder.Directories.OutputDir, bspBuilder.ExportRenamedFileTable(), true, samplesForComputingSymbolLists.ToArray()); bspBuilder.Save(bsp, false, false); } } }
//--------------------------------- 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: 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: 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 < 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 <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); }
/// <summary> /// /// </summary> /// <param name="extractedProjectDirectory"></param> /// <param name="sink"></param> /// <returns></returns> public static BoardSupportPackage GenerateBSPForSTARTProject(string extractedProjectDirectory, IWarningSink sink) { var gpdscFile = Path.Combine(extractedProjectDirectory, "AtmelStart.gpdsc"); if (!File.Exists(gpdscFile)) { throw new Exception($"{gpdscFile} does not exist!"); } var gccMakefile = Path.Combine(extractedProjectDirectory, "gcc\\Makefile"); if (!File.Exists(gccMakefile)) { throw new Exception($"{gccMakefile} does not exist. {GCCExportHint}"); } var xml = new XmlDocument(); xml.Load(gpdscFile); string device = null; foreach (var node in xml.SelectNodes("package/generators/generator/select").OfType <XmlElement>()) { var name = node.GetAttribute("Dname"); var vendor = node.GetAttribute("Dvendor"); if (!string.IsNullOrEmpty(vendor) && !string.IsNullOrEmpty(name)) { device = name; } } if (device == null) { throw new Exception($"Could not find the device ID in {gpdscFile}"); } var flagsFromMakefile = ScanMakefileForCommonFlags(gccMakefile); var bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.samd21", GNUTargetID = "arm-eabi", PackageDescription = $"ATSAMD21 Support", BSPImporterID = ID, MCUFamilies = new[] { new MCUFamily { ID = "ATSAMD21" } }, Frameworks = xml.SelectNodes("package/components/component").OfType <XmlElement>().Select(GenerateFrameworkForComponent).Where(f => f != null).ToArray(), EmbeddedSamples = new[] { new EmbeddedProjectSample { Name = "Default Project", Description = "A basic project generated by Atmel START", AdditionalSourcesToCopy = new[] { new AdditionalSourceFile { SourcePath = "$$SYS:BSP_ROOT$$/main.c", TargetFileName = "$$PROJECTNAME$$.c", } } } } }; List <MCU> mcus = new List <MCU>(); Dictionary <string, int> headers = new Dictionary <string, int>(); string[] strFileMCU = File.ReadAllLines("../../McuAtmel.csv"); bool header_row = true; var linkerScripts = DetectLinkerScripts(extractedProjectDirectory); for (int il = 0; il < strFileMCU.Length; il++) { string line = strFileMCU[il]; string[] items = line.Split(','); if (header_row) { for (int i = 0; i < items.Length; i++) { headers[items[i]] = i; } header_row = false; continue; } String size = items[headers["Device Name"]].Substring(9, 2); String LinkerScriptLocation = linkerScripts.RelativeFLASHScript.Substring(0, linkerScripts.RelativeFLASHScript.LastIndexOf("/")) + "/samd21g" + size + "_flash.ld"; var memories = ScanLinkerScriptForMemories(Path.Combine(extractedProjectDirectory, LinkerScriptLocation)); LinkerScriptLocation = LinkerScriptLocation.Replace("*", "$$com.sysprogs.bspoptions.primary_memory$$"); LinkerScriptLocation = "$$SYS:BSP_ROOT$$/" + LinkerScriptLocation; var newMcu = new MCU { ID = items[headers["Device Name"]], FamilyID = "ATSAMD21", FLASHBase = (uint)0, FLASHSize = Int32.Parse(items[headers["Flash (kBytes)"]]), RAMBase = (uint)536870912, RAMSize = Int32.Parse(items[headers["SRAM (kBytes)"]]), CompilationFlags = new ToolFlags { PreprocessorMacros = new[] { $"__{items[headers["Device Name"]]}__" }, COMMONFLAGS = string.Join(" ", flagsFromMakefile.CommonFlags), LinkerScript = linkerScripts.LinkerScriptFormat, IncludeDirectories = flagsFromMakefile.RelativeIncludeDirs?.Select(d => "$$SYS:BSP_ROOT$$/" + d).ToArray(), LDFLAGS = "-Wl,--entry=Reset_Handler", //Unless this is specified explicitly, the gdb's "load" command won't set $pc to the entry point, requiring an explicit device reset. }, ConfigurableProperties = new PropertyList { PropertyGroups = new[] { linkerScripts.ToPropertyGroup() }.Where(g => g != null).ToList() }, MemoryMap = new AdvancedMemoryMap { Memories = memories.ToArray() } }; FixGPDSCErrors(bsp, newMcu, extractedProjectDirectory, flagsFromMakefile, linkerScripts.RelativeFLASHScript); mcus.Add(newMcu); } bsp.SupportedMCUs = mcus.ToArray(); List <AdditionalSourceFile> sourceFilesList = bsp.EmbeddedSamples[0].AdditionalSourcesToCopy.ToList(); IEnumerable <String> files = Directory.EnumerateFiles(extractedProjectDirectory); foreach (String item in files) { String target = ""; if (item.EndsWith(".h")) { target = "inc/" + Path.GetFileName(item); } else if (item.EndsWith(".c")) { target = "src/" + Path.GetFileName(item); } else { continue; } AdditionalSourceFile a = new AdditionalSourceFile { SourcePath = "$$SYS:BSP_ROOT$$/" + Path.GetFileName(item), TargetFileName = target, }; sourceFilesList.Add(a); } files = Directory.EnumerateFiles(extractedProjectDirectory + "/config"); foreach (String item in files) { String target = ""; if (item.EndsWith(".h")) { target = "config/" + Path.GetFileName(item); } else { continue; } AdditionalSourceFile a = new AdditionalSourceFile { SourcePath = "$$SYS:BSP_ROOT$$/config/" + Path.GetFileName(item), TargetFileName = target, }; sourceFilesList.Add(a); } bsp.EmbeddedSamples[0].AdditionalSourcesToCopy = sourceFilesList.ToArray(); String path = Path.Combine(extractedProjectDirectory, LoadedBSP.PackageFileName); XmlTools.SaveObject(bsp, path); return(bsp); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: nrf5x.exe <Nordic SW package directory>"); } bool usingIoTSDK = false; /* if (Directory.Exists(Path.Combine(args[0], @"components\iot\ble_6lowpan"))) * { * usingIoTSDK = true; * Console.WriteLine("Detected IoT SDK"); * }*/ if (usingIoTSDK) { bspBuilder = new NordicBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules_iot")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("s1xx_iot", 0x1f000, 0x2800, "nrf52", "IoT", bspBuilder.Directories.InputDir)); } else { bspBuilder = new NordicBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S132", "nrf52832.*", null, bspBuilder.Directories.InputDir)); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S140", "nrf52840.*", null, bspBuilder.Directories.InputDir)); bspBuilder.SoftDevices.Add(new NordicBSPBuilder.SoftDevice("S112", "nrf52810.*", null, bspBuilder.Directories.InputDir)); } List <MCUBuilder> devices = new List <MCUBuilder>(); #if NRF51_SUPPORT if (!usingIoTSDK) { foreach (string part in new string[] { "nRF51822", "nRF51422" }) { devices.Add(new MCUBuilder { Name = part + "_XXAA", FlashSize = 256 * 1024, RAMSize = 16 * 1024, Core = CortexCore.M0 }); devices.Add(new MCUBuilder { Name = part + "_XXAB", FlashSize = 128 * 1024, RAMSize = 16 * 1024, Core = CortexCore.M0 }); devices.Add(new MCUBuilder { Name = part + "_XXAC", FlashSize = 256 * 1024, RAMSize = 32 * 1024, Core = CortexCore.M0 }); } } #endif devices.Add(new MCUBuilder { Name = "nRF52832_XXAA", FlashSize = 512 * 1024, RAMSize = 64 * 1024, Core = CortexCore.M4, StartupFile = "$$SYS:BSP_ROOT$$/nRF5x/components/toolchain/gcc/gcc_startup_nrf52.S" }); devices.Add(new MCUBuilder { Name = "nRF52840_XXAA", FlashSize = 1024 * 1024, RAMSize = 256 * 1024, Core = CortexCore.M4, StartupFile = "$$SYS:BSP_ROOT$$/nRF5x/components/toolchain/gcc/gcc_startup_nrf52840.S" }); devices.Add(new MCUBuilder { Name = "nRF52810_XXAA", FlashSize = 192 * 1024, RAMSize = 24 * 1024, Core = CortexCore.M4_NOFPU, StartupFile = "$$SYS:BSP_ROOT$$/nRF5x/components/toolchain/gcc/gcc_startup_nrf52810.S" }); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); foreach (var fn in Directory.GetFiles(bspBuilder.Directories.RulesDir + @"\Families", "*.xml")) { allFamilies.Add(new NordicFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(fn))); } var rejects = BSPGeneratorTools.AssignMCUsToFamilies(devices, allFamilies); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = true; List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); 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); flags = flags.Merge(commonPseudofamily.Definition.CompilationFlags); List <ConditionalToolFlags> condFlags = new List <ConditionalToolFlags>(); foreach (var fam in allFamilies) { fam.GenerateLinkerScripts(false); Console.WriteLine("Processing " + fam.Definition.Name + " family..."); string famBase = fam.Definition.Name.Substring(0, 5).ToLower(); 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); } } List <Framework> bleFrameworks = new List <Framework>(); foreach (var line in File.ReadAllLines(bspBuilder.Directories.RulesDir + @"\BLEFrameworks.txt")) { int idx = line.IndexOf('|'); string dir = line.Substring(0, idx); string desc = line.Substring(idx + 1); string id = Path.GetFileName(dir); if (!id.StartsWith("ble_")) { id = "ble_" + id; } if (dir.StartsWith("services\\", StringComparison.CurrentCultureIgnoreCase)) { id = "ble_svc_" + id.Substring(4); } bleFrameworks.Add(new Framework { Name = string.Format("Bluetooth LE - {0} ({1})", desc, Path.GetFileName(dir)), ID = "com.sysprogs.arm.nordic." + famBase + "." + id, ClassID = "com.sysprogs.arm.nordic.nrfx." + id, ProjectFolderName = "BLE " + desc, DefaultEnabled = false, CopyJobs = new CopyJob[] { new CopyJob { SourceFolder = allFamilies[0].Definition.PrimaryHeaderDir + @"\..\components\ble\" + dir, TargetFolder = dir, FilesToCopy = "*.c;*.h", } } }); } fam.Definition.AdditionalFrameworks = fam.Definition.AdditionalFrameworks.Concat(bleFrameworks).ToArray(); // Starting from SDK 14.0 we use the original Nordic startup files & linker scripts as they contain various non-trivial logic #if GENERATE_STARTUP_FILES StartupFileGenerator.InterruptVectorTable[] aStartupVectors; if (usingIoTSDK) { aStartupVectors = new StartupFileGenerator.InterruptVectorTable[] { GenerateStartupFile(fam.Definition.StartupFileDir, "nRF52") } } ; else { aStartupVectors = new StartupFileGenerator.InterruptVectorTable[] { GenerateStartupFile(fam.Definition.StartupFileDir, "nRF51"), GenerateStartupFile(fam.Definition.StartupFileDir, "nRF52") } }; fam.AttachStartupFiles(aStartupVectors); #endif // SVD Files var aMcuDef1 = (new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, "nRF51.svd"), "nRF51") }); aMcuDef1[0].MatchPredicate = m => m.Name.StartsWith("nRF51"); var aMcuDef2 = (new MCUDefinitionWithPredicate[] { SVDParser.ParseSVDFile(Path.Combine(fam.Definition.PrimaryHeaderDir, "nRF52.svd"), "nRF52") }); aMcuDef2[0].MatchPredicate = m => m.Name.StartsWith("nRF52"); fam.AttachPeripheralRegisters(aMcuDef1.Concat(aMcuDef2)); 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); SysVarEntry suffixEntry = null; foreach (var mcu in fam.MCUs) { var mcuDef = mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters, false, MCUFamilyBuilder.CoreSpecificFlags.All & ~MCUFamilyBuilder.CoreSpecificFlags.PrimaryMemory); if (mcu.Name.StartsWith("nRF52832")) { //Although documented as a legacy definition, skipping this breaks fds_internal_defs.h mcuDef.CompilationFlags.PreprocessorMacros = mcuDef.CompilationFlags.PreprocessorMacros.Concat(new[] { "NRF52" }).ToArray(); } var compatibleSoftdevs = new[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "nosoftdev", UserFriendlyName = "None" } } .Concat(bspBuilder.SoftDevices.Where(sd => sd.IsCompatible(mcu.Name)) .SelectMany(s => new[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = s.Name, UserFriendlyName = s.UserFriendlyName }, new PropertyEntry.Enumerated.Suggestion { InternalValue = s.Name + "_reserve", UserFriendlyName = $"{s.UserFriendlyName} (programmed separately)" } })) .ToArray(); if (mcuDef.ConfigurableProperties == null) { mcuDef.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup>() } } ; mcuDef.ConfigurableProperties.PropertyGroups.Add(new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Enumerated { UniqueID = NordicBSPBuilder.SoftdevicePropertyID, Name = "Softdevice", DefaultEntryIndex = 1, SuggestionList = compatibleSoftdevs, } } }); if (mcu.Name.StartsWith("nRF52") && !mcu.Name.StartsWith("nRF52810")) { var prop = mcuDef.ConfigurableProperties.PropertyGroups[0].Properties.Find(p => p.UniqueID == "com.sysprogs.bspoptions.arm.floatmode") as PropertyEntry.Enumerated; var idx = Array.FindIndex(prop.SuggestionList, p => p.UserFriendlyName == "Hardware"); prop.DefaultEntryIndex = idx; prop.SuggestionList[idx].UserFriendlyName = "Hardware (required when using a softdevice)"; //Otherwise the system_nrf52.c file won't initialize the FPU and the internal initialization of the softdevice will later fail. } string defaultConfig; if (mcu.Name.StartsWith("nRF52840")) { defaultConfig = "pca10056/s140"; } else if (mcu.Name.StartsWith("nRF52810")) { defaultConfig = "pca10040e/s112"; } else { defaultConfig = "pca10040/s132"; } suffixEntry = new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = defaultConfig }; mcuDef.AdditionalSystemVars = LoadedBSP.Combine(mcuDef.AdditionalSystemVars, new SysVarEntry[] { suffixEntry }); mcuDefinitions.Add(mcuDef); } if (fam.Definition.ConditionalFlags != null) { condFlags.AddRange(fam.Definition.ConditionalFlags); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples(null, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.nordic.default_config_suffix", Value = "pca10040e/s112" } })) { exampleDirs.Add(sample); } } const string softdevExpression = "$$com.sysprogs.bspoptions.nrf5x.softdevice$$"; foreach (var softdev in bspBuilder.SoftDevices) { condFlags.Add(new ConditionalToolFlags { FlagCondition = new Condition.Equals { Expression = softdevExpression, ExpectedValue = softdev.Name + "_reserve" }, Flags = new ToolFlags { PreprocessorMacros = familyDefinitions.First().CompilationFlags.PreprocessorMacros.Where(f => f.Contains(softdevExpression)).Select(f => f.Replace(softdevExpression, softdev.Name)).ToArray(), IncludeDirectories = familyDefinitions.First().CompilationFlags.IncludeDirectories.Where(f => f.Contains(softdevExpression)).Select(f => f.Replace(softdevExpression, softdev.Name)).ToArray() } }); } bspBuilder.GenerateSoftdeviceLibraries(); Console.WriteLine("Building BSP archive..."); string strPackageID, strPackageDesc, strPAckVersion; if (usingIoTSDK) { strPackageID = "com.sysprogs.arm.nordic.nrf5x-iot"; strPackageDesc = "Nordic NRF52 IoT"; strPAckVersion = "0.9"; foreach (var mcu in mcuDefinitions) { mcu.UserFriendlyName = mcu.ID + " (IoT)"; } } else { strPackageID = "com.sysprogs.arm.nordic.nrf5x"; strPackageDesc = "Nordic NRF52x Devices"; strPAckVersion = "14.2R2"; } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = strPackageID, PackageDescription = strPackageDesc, GNUTargetID = "arm-eabi", GeneratedMakFileName = "nrf5x.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 = strPAckVersion, FileConditions = bspBuilder.MatchedFileConditions.ToArray(), MinimumEngineVersion = "5.0", ConditionalFlags = condFlags.ToArray(), InitializationCodeInsertionPoints = commonPseudofamily.Definition.InitializationCodeInsertionPoints, }; bspBuilder.Save(bsp, true, false); } }
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: 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 ProduceBSPArchive(string BSPRoot, BoardSupportPackage bsp) { bsp.PackageVersion = string.Format("{0:d4}{1:d2}{2:d2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); bsp.PackageVersion += "-beta"; XmlTools.SaveObject(bsp, Path.Combine(BSPRoot, "BSP.XML")); string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion); Console.WriteLine("Creating BSP archive..."); TarPacker.PackDirectoryToTGZ(BSPRoot, Path.Combine(Path.GetDirectoryName(BSPRoot), archiveName), fn => { string relPath = fn.Substring(BSPRoot.Length + 1); if (relPath.StartsWith(".git")) return false; return true; }); BSPSummary lst = new BSPSummary { BSPName = bsp.PackageDescription, BSPID = bsp.PackageID, BSPVersion = bsp.PackageVersion, MinimumEngineVersion = bsp.MinimumEngineVersion, FileName = archiveName, }; foreach (var mcu in bsp.SupportedMCUs) lst.MCUs.Add(new BSPSummary.MCU { Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize }); XmlTools.SaveObject(lst, Path.Combine(Path.GetDirectoryName(BSPRoot), Path.ChangeExtension(archiveName, ".xml"))); }
//--------------------------------- 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.3.156" }; 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); }
public void GeneratePackage() { Console.Write("Creating a list of MCUs... "); CreateMCUBuilders(); Console.WriteLine("done"); Console.WriteLine("Number of MCUs: {0}", _mcuBuilders.Count); Console.Write("Creating a list of MCU families... "); CreateMCUFamilyBuilders(); Console.WriteLine("done"); Console.WriteLine("Number of MCU families: {0}", _mcuFamilyBuilders.Count); Console.Write("Assigning MCUs to MCU families... "); AssignMCUsToFamilies(); Console.WriteLine("done"); Console.WriteLine("{0} MCU families have no MCUs and will be discarded: {1}", _rejectedMCUFamilies.Length, string.Join(",", _rejectedMCUFamilies.Select(mf => mf.Definition.Name))); Console.WriteLine("{0} MCUs were not assigned to any family and will be discarded: {1}", _rejectedMCUs.Length, string.Join(",", _rejectedMCUs.Select(m => m.Name))); Console.Write("Processing common files... "); ProcessCommonFiles(); Console.WriteLine("done"); Console.Write("Generating MCUs and their families... "); GenerateMCUsAndMCUFamilies(); Console.WriteLine("done"); //We don't want to include the same include paths twice (once from the family and another time from the framework), so we filter out the family-provided ones here. HashSet <string> includeDirsFromFamilies = new HashSet <string>(); foreach (var fam in _mcuFamilies) { foreach (var dir in fam.CompilationFlags.IncludeDirectories) { includeDirsFromFamilies.Add(dir.Replace(fam.ID, "$$SYS:FAMILY_ID$$")); } } foreach (var fw in _frameworks) { fw.AdditionalIncludeDirs = fw.AdditionalIncludeDirs.Where(d => !includeDirsFromFamilies.Contains(d)).ToArray(); } ; Console.Write("Detecting GPIO prefixes... "); Regex rgBrackets = new Regex(@"\(([^\(\)]+)\)"); foreach (var fam in _mcuFamilies) { var mainIncludeFile = string.Format(@"{0}\platform\devices\M{1}\include\M{1}.h", Directories.InputDir, fam.ID); string gpioaLine = File.ReadAllLines(mainIncludeFile).First(s => s.Contains("#define GPIOA_PDOR")); var m = rgBrackets.Match(gpioaLine); if (!m.Success) { throw new Exception("Cannot detect GPIO prefix for " + fam.ID); } fam.AdditionalSystemVars = LoadedBSP.Combine(fam.AdditionalSystemVars, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.arm.kinetis.gpio_prefix", Value = m.Groups[1].Value.Substring(0, m.Groups[1].Value.Length - 1) } }); } Console.WriteLine("done"); Console.Write("Reading MCUs listed in Segger lists... "); var mcusFromSeggerFile = new HashSet <string>(ReadSeggerMCUs(Directories.RulesDir + "\\" + SEGGER_FILE, MANUFACTURER)); Console.WriteLine("done"); Console.Write("Generating BSP... "); BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.freescale.kinetis_ksdk", PackageDescription = "Freescale Kinetis (KSDK)", GNUTargetID = "arm-eabi", GeneratedMakFileName = "kinetis.mak", MCUFamilies = _mcuFamilies.ToArray(), SupportedMCUs = _mcus.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 = MatchedFileConditions.ToArray(), PackageVersion = "1.3.2", MinimumEngineVersion = "5.0", }; Save(bsp, true); Console.WriteLine("done"); var mcusUnlistedInSeggerFile = new List <string>(); foreach (var mcu in _mcus) { var generalizedMCUName = MCUNameToGeneralizedMCUName(mcu.ID); if (!mcusFromSeggerFile.Contains(generalizedMCUName)) { mcusUnlistedInSeggerFile.Add(generalizedMCUName); } } Console.WriteLine("Generated MCU definitions: {0}\r\nGenerated families: {1}\r\nMCUs unlisted in Segger lists: {2}", _mcus.Count, _mcuFamilies.Count, mcusUnlistedInSeggerFile.Count); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
//=========================================================== 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: 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); }
public static BoardSupportPackage GenerateBSPForSTARTProject(string extractedProjectDirectory, IWarningSink sink) { var gpdscFile = Path.Combine(extractedProjectDirectory, "AtmelStart.gpdsc"); if (!File.Exists(gpdscFile)) { throw new Exception($"{gpdscFile} does not exist!"); } var gccMakefile = Path.Combine(extractedProjectDirectory, "gcc\\Makefile"); if (!File.Exists(gccMakefile)) { throw new Exception($"{gccMakefile} does not exist. {GCCExportHint}"); } var xml = new XmlDocument(); xml.Load(gpdscFile); string device = null; foreach (var node in xml.SelectNodes("package/generators/generator/select").OfType <XmlElement>()) { var name = node.GetAttribute("Dname"); var vendor = node.GetAttribute("Dvendor"); if (!string.IsNullOrEmpty(vendor) && !string.IsNullOrEmpty(name)) { device = name; } } if (device == null) { throw new Exception($"Could not find the device ID in {gpdscFile}"); } var linkerScripts = DetectLinkerScripts(extractedProjectDirectory); var memories = ScanLinkerScriptForMemories(Path.Combine(extractedProjectDirectory, linkerScripts.RelativeFLASHScript)); var flagsFromMakefile = ScanMakefileForCommonFlags(gccMakefile); var mcu = new MCU { ID = device, FamilyID = "ATSTART", FLASHBase = (uint)(memories.FirstOrDefault(m => m.Name == "rom")?.Address ?? uint.MaxValue), FLASHSize = (int)(memories.FirstOrDefault(m => m.Name == "rom")?.Size ?? uint.MaxValue), RAMBase = (uint)(memories.FirstOrDefault(m => m.Name == "ram")?.Address ?? uint.MaxValue), RAMSize = (int)(memories.FirstOrDefault(m => m.Name == "ram")?.Size ?? uint.MaxValue), CompilationFlags = new ToolFlags { PreprocessorMacros = new[] { $"__{device}__" }, COMMONFLAGS = string.Join(" ", flagsFromMakefile.CommonFlags), LinkerScript = linkerScripts.LinkerScriptFormat, IncludeDirectories = flagsFromMakefile.RelativeIncludeDirs?.Select(d => "$$SYS:BSP_ROOT$$/" + d).ToArray(), LDFLAGS = "-Wl,--entry=Reset_Handler", //Unless this is specified explicitly, the gdb's "load" command won't set $pc to the entry point, requiring an explicit device reset. }, ConfigurableProperties = new PropertyList { PropertyGroups = new[] { linkerScripts.ToPropertyGroup() }.Where(g => g != null).ToList() }, MemoryMap = new AdvancedMemoryMap { Memories = memories.ToArray() } }; var bsp = new BoardSupportPackage { PackageID = "com.sysprogs.atstart." + device, GNUTargetID = "arm-eabi", PackageDescription = $"{device} Support", MCUFamilies = new[] { new MCUFamily { ID = "ATSTART" } }, SupportedMCUs = new[] { mcu }, Frameworks = xml.SelectNodes("package/components/component").OfType <XmlElement>().Select(GenerateFrameworkForComponent).Where(f => f != null).ToArray(), EmbeddedSamples = new[] { new EmbeddedProjectSample { Name = "Default Project", Description = "A basic project generated by Atmel START", AdditionalSourcesToCopy = new[] { new AdditionalSourceFile { SourcePath = "$$SYS:BSP_ROOT$$/main.c", TargetFileName = "$$PROJECTNAME$$.c", } } } } }; FixGPDSCErrors(bsp, mcu, extractedProjectDirectory, flagsFromMakefile, linkerScripts.RelativeFLASHScript); XmlTools.SaveObject(bsp, Path.Combine(extractedProjectDirectory, LoadedBSP.PackageFileName)); return(bsp); }
//=========================================================== 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); }