public static void AddFPModeProperty(CoreSpecificFlags flagsToDefine, MCUFamily family) { if (family.ConfigurableProperties == null) { family.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup() } } } ; family.ConfigurableProperties.PropertyGroups[0].Properties.Add( new PropertyEntry.Enumerated { Name = "Floating point support", UniqueID = "com.sysprogs.bspoptions.arm.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 = "", UserFriendlyName = "Unspecified" }, }, DefaultEntryIndex = ((flagsToDefine & CoreSpecificFlags.DefaultHardFloat) == CoreSpecificFlags.DefaultHardFloat) ? 1 : 0, }); family.CompilationFlags.COMMONFLAGS += " $$com.sysprogs.bspoptions.arm.floatmode$$"; }
public static void AddCoreSpecificFlags(bool defineConfigurationVariables, MCUFamily family, string core) { switch (core ?? "") { case "cm0plus": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M0Plus); break; case "cm0": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M0); break; case "cm3": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M3); break; case "cm4": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M4); break; case "cm7": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M7); break; } }
internal MCUFamily ToMCUFamily() { var mcuFamily = new MCUFamily { ID = FullName, UserFriendlyName = DeviceName }; CoreFlagHelper.AddCoreSpecificFlags(true, mcuFamily, CoreName); return(mcuFamily); }
public MCUFamily GenerateFamilyObject(bool defineConfigurationVariables) { var family = new MCUFamily { ID = Definition.Name }; if (!Definition.HasMixedCores) { if (MCUs.Count == 0) { throw new Exception("No MCUs found for " + Definition.Name); } var core = MCUs[0].Core; foreach (var mcu in MCUs) { if (mcu.Core != core) { throw new Exception("Different MCUs within " + Definition.Name + " have different core types"); } } AddCoreSpecificFlags(defineConfigurationVariables, family, core); } family.CompilationFlags = family.CompilationFlags.Merge(Definition.CompilationFlags); List <string> projectFiles = new List <string>(); CopyFamilyFiles(ref family.CompilationFlags, projectFiles); family.AdditionalSourceFiles = projectFiles.Where(f => !IsHeaderFile(f)).ToArray(); family.AdditionalHeaderFiles = projectFiles.Where(f => IsHeaderFile(f)).ToArray(); family.AdditionalSystemVars = LoadedBSP.Combine(family.AdditionalSystemVars, Definition.AdditionalSystemVars); if (Definition.ConfigurableProperties != null) { if (family.ConfigurableProperties == null) { family.ConfigurableProperties = new PropertyList(); } family.ConfigurableProperties.Import(Definition.ConfigurableProperties); } return(family); }
public static void AddCoreSpecificFlags(CoreSpecificFlags flagsToDefine, MCUFamily family, string core) { CortexCore translatedCore = core switch { "cm0plus" => CortexCore.M0Plus, "cm0" => CortexCore.M0, "cm3" => CortexCore.M3, "cm33" => CortexCore.M33_FPU, "cm33_nodsp" => CortexCore.M33, "cm4" => CortexCore.M4, "cm7" => CortexCore.M7, _ => CortexCore.Invalid }; AddCoreSpecificFlags(flagsToDefine, family, translatedCore); } }
public static void AddCoreSpecificFlags(bool defineConfigurationVariables, MCUFamily family, string core) { switch(core ?? "") { case "cm0": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M0); break; case "cm3": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M3); break; case "cm4": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M4); break; case "cm7": AddCoreSpecificFlags(defineConfigurationVariables, family, CortexCore.M7); break; } }
public static void MergeFamilies(MCUFamily updatedFamily, MCUFamily familyToCopy) { updatedFamily.GDBStartupCommands = LoadedBSP.Combine(familyToCopy.GDBStartupCommands, updatedFamily.GDBStartupCommands); updatedFamily.AdditionalSystemVars = LoadedBSP.Combine(familyToCopy.AdditionalSystemVars, updatedFamily.AdditionalSystemVars); if (updatedFamily.ConfigurableProperties == null) { updatedFamily.ConfigurableProperties = familyToCopy.ConfigurableProperties; } else if (familyToCopy.ConfigurableProperties != null) { var lst = new List <PropertyGroup>(); lst.AddRange(familyToCopy.ConfigurableProperties.PropertyGroups); lst.AddRange(updatedFamily.ConfigurableProperties.PropertyGroups); updatedFamily.ConfigurableProperties.PropertyGroups = lst; } updatedFamily.CompilationFlags = familyToCopy.CompilationFlags.Merge(updatedFamily.CompilationFlags); updatedFamily.AdditionalSourceFiles = LoadedBSP.Combine(familyToCopy.AdditionalSourceFiles, updatedFamily.AdditionalSourceFiles); updatedFamily.AdditionalHeaderFiles = LoadedBSP.Combine(familyToCopy.AdditionalHeaderFiles, updatedFamily.AdditionalHeaderFiles); updatedFamily.AdditionalMakefileLines = LoadedBSP.Combine(familyToCopy.AdditionalMakefileLines, updatedFamily.AdditionalMakefileLines); }
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); } }
internal static void AddCoreSpecificFlags(bool defineConfigurationVariables, MCUFamily family, CortexCore core) { string coreName = null; switch (core) { case CortexCore.M0: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0" }; coreName = "M0"; break; case CortexCore.M0Plus: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0plus -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0PLUS" }; coreName = "M0"; break; case CortexCore.M3: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m3 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM3" }; coreName = "M3"; break; case CortexCore.M4: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m4 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM4" }; family.CompilationFlags.ASFLAGS = "-mfpu=fpv4-sp-d16"; coreName = "M4"; break; case CortexCore.M7: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m7 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM7" }; coreName = "M7"; break; default: throw new Exception("Unsupported core type"); } if (defineConfigurationVariables) { if (core == CortexCore.M0) { family.AdditionalSystemVars = new SysVarEntry[] { new SysVarEntry { Key = PrimaryMemoryOptionName, Value = "flash" } } } ; else { family.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Enumerated { Name = "Execute from", UniqueID = PrimaryMemoryOptionName, SuggestionList = new PropertyEntry.Enumerated.Suggestion[] { new PropertyEntry.Enumerated.Suggestion { InternalValue = "flash", UserFriendlyName = "FLASH" }, new PropertyEntry.Enumerated.Suggestion { InternalValue = "sram", UserFriendlyName = "SRAM" }, } } } } } }; if (core == CortexCore.M4 || core == CortexCore.M7) { family.ConfigurableProperties.PropertyGroups[0].Properties.Add( new PropertyEntry.Enumerated { Name = "Floating point support", UniqueID = "com.sysprogs.bspoptions.arm.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 = "", UserFriendlyName = "Unspecified" }, } }); family.CompilationFlags.COMMONFLAGS += " $$com.sysprogs.bspoptions.arm.floatmode$$"; } } if (coreName != null) { family.AdditionalSystemVars = LoadedBSP.Combine(family.AdditionalSystemVars, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.bspoptions.arm.core", Value = coreName } }); } } }
//--------------------------------- 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); }
internal static void AddCoreSpecificFlags(bool defineConfigurationVariables, MCUFamily family, CortexCore core) { string coreName = null; switch (core) { case CortexCore.M0: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0" }; coreName = "M0"; break; case CortexCore.M0Plus: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0plus -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0PLUS" }; coreName = "M0"; break; case CortexCore.M3: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m3 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM3" }; coreName = "M3"; break; case CortexCore.M4: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m4 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM4" }; family.CompilationFlags.ASFLAGS = "-mfpu=fpv4-sp-d16"; coreName = "M4"; break; case CortexCore.M7: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m7 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM7" }; coreName = "M7"; break; default: throw new Exception("Unsupported core type"); } if (defineConfigurationVariables) { if (core != CortexCore.M0) { family.ConfigurableProperties = new PropertyList { PropertyGroups = new List<PropertyGroup> { new PropertyGroup { Properties = new List<PropertyEntry> { } } } }; if (core == CortexCore.M4 || core == CortexCore.M7) { family.ConfigurableProperties.PropertyGroups[0].Properties.Add( new PropertyEntry.Enumerated { Name = "Floating point support", UniqueID = "com.sysprogs.bspoptions.arm.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 = "", UserFriendlyName = "Unspecified"}, } }); family.CompilationFlags.COMMONFLAGS += " $$com.sysprogs.bspoptions.arm.floatmode$$"; } } if (coreName != null) family.AdditionalSystemVars = LoadedBSP.Combine(family.AdditionalSystemVars, new SysVarEntry[] { new SysVarEntry { Key = "com.sysprogs.bspoptions.arm.core", Value = coreName } }); } }
public MCUFamily GenerateFamilyObject(CoreSpecificFlags flagsToGenerate, bool allowExcludingStartupFiles = false) { var family = new MCUFamily { ID = Definition.Name }; if (!Definition.HasMixedCores) { if (MCUs.Count == 0) { throw new Exception("No MCUs found for " + Definition.Name); } var core = MCUs[0].Core; foreach (var mcu in MCUs) { if (mcu.Core != core) { throw new Exception("Different MCUs within " + Definition.Name + " have different core types"); } } AddCoreSpecificFlags(flagsToGenerate, family, core); } family.CompilationFlags = family.CompilationFlags.Merge(Definition.CompilationFlags); List <string> projectFiles = new List <string>(); CopyFamilyFiles(ref family.CompilationFlags, projectFiles); family.AdditionalSourceFiles = projectFiles.Where(f => !IsHeaderFile(f)).ToArray(); family.AdditionalHeaderFiles = projectFiles.Where(f => IsHeaderFile(f)).ToArray(); family.AdditionalSystemVars = LoadedBSP.Combine(family.AdditionalSystemVars, Definition.AdditionalSystemVars); if (Definition.ConfigurableProperties != null || allowExcludingStartupFiles) { if (family.ConfigurableProperties == null) { family.ConfigurableProperties = new PropertyList(); } if (Definition.ConfigurableProperties != null) { family.ConfigurableProperties.Import(Definition.ConfigurableProperties); } if (allowExcludingStartupFiles && MCUs != null) { family.ConfigurableProperties.Import(new PropertyList { PropertyGroups = new List <PropertyGroup>() { new PropertyGroup { Properties = new List <PropertyEntry> { new PropertyEntry.Boolean { DefaultValue = false, ValueForTrue = "1", Name = "Exclude the startup file from project", UniqueID = IgnoreStartupFileProperty, } } } } }); foreach (var mcu in MCUs) { if (mcu.StartupFile != null) { BSP.MatchedFileConditions.Add(new FileCondition { FilePath = mcu.StartupFile, ConditionToInclude = new Condition.Not { Argument = new Condition.Equals { Expression = $"$${IgnoreStartupFileProperty}$$", ExpectedValue = "1" } } }); } } } } return(family); }
//--------------------------------- 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); }
internal static void AddCoreSpecificFlags(CoreSpecificFlags flagsToDefine, MCUFamily family, CortexCore core) { //WARNING: If the proper string coreName = null, freertosPort = null; switch (core) { case CortexCore.M0: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0" }; freertosPort = "ARM_CM0"; coreName = "M0"; break; case CortexCore.M0Plus: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m0plus -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM0PLUS" }; freertosPort = "ARM_CM0"; coreName = "M0"; break; case CortexCore.M3: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m3 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM3" }; coreName = "M3"; freertosPort = "ARM_CM3"; break; case CortexCore.M33: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m33 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM33" }; coreName = "M33"; freertosPort = "ARM_CM33_NTZ/non_secure"; break; case CortexCore.M33_FPU: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM33" }; coreName = "M33"; freertosPort = "ARM_CM33_NTZ/non_secure"; break; case CortexCore.M4: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM4" }; freertosPort = "ARM_CM4F"; coreName = "M4"; break; case CortexCore.M4_NOFPU: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m4 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM4" }; coreName = "M4"; freertosPort = "ARM_CM3"; break; case CortexCore.M7: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CM7" }; coreName = "M7"; freertosPort = "ARM_CM7/r0p1"; break; case CortexCore.R5F: family.CompilationFlags.COMMONFLAGS = "-mcpu=cortex-r5 -mfpu=vfpv3-d16 -mthumb"; family.CompilationFlags.PreprocessorMacros = new string[] { "ARM_MATH_CR5" }; break; default: return; } if ((flagsToDefine & CoreSpecificFlags.FPU) == CoreSpecificFlags.FPU) { if (core == CortexCore.M4 || core == CortexCore.M7 || core == CortexCore.R5F || core == CortexCore.M33_FPU) { AddFPModeProperty(flagsToDefine, family); } } List <SysVarEntry> vars = new List <SysVarEntry>(); if (coreName != null) { vars.Add(new SysVarEntry { Key = "com.sysprogs.bspoptions.arm.core", Value = coreName }); } if (freertosPort != null) { vars.Add(new SysVarEntry { Key = "com.sysprogs.freertos.default_port", Value = freertosPort }); } if (vars.Count > 0) { family.AdditionalSystemVars = LoadedBSP.Combine(family.AdditionalSystemVars, vars.ToArray()); } }
public MCUFamily BuildMCUFamily() { var mcuFamily = new MCUFamily { ID = FamilyID, UserFriendlyName = Device.FullName + Device.MakeCoreSuffix(Core), CompilationFlags = new ToolFlags() }; if (FlagsDerivedFromSamples?.Contains("-mcpu") == true) { mcuFamily.CompilationFlags.COMMONFLAGS = FlagsDerivedFromSamples; if (FlagsDerivedFromSamples.Contains("-mfpu")) { CoreFlagHelper.AddFPModeProperty(CoreFlagHelper.CoreSpecificFlags.DefaultHardFloat, mcuFamily); } } else { CoreFlagHelper.AddCoreSpecificFlags(CoreFlagHelper.CoreSpecificFlags.FPU | CoreFlagHelper.CoreSpecificFlags.DefaultHardFloat, mcuFamily, Core.Type); } int coreIndex = 0; for (int i = 0; i < Device.Cores.Length; i++) { if (Device.Cores[i].ID == Core.ID) { coreIndex = i; break; } } mcuFamily.AdditionalSystemVars = new[] { new SysVarEntry { Key = "REDLINK:VENDOR_ID", Value = Device.VendorID }, new SysVarEntry { Key = "REDLINK:DEVICE_ID", Value = Device.ID }, new SysVarEntry { Key = "REDLINK:DEBUG_OPTIONS", Value = Device.RedLinkServerOptions?.FirstOrDefault() ?? "" }, new SysVarEntry { Key = "REDLINK:CORE_INDEX", Value = coreIndex.ToString() }, new SysVarEntry { Key = "REDLINK:CORE_COUNT", Value = Device.Cores.Length.ToString() }, }; if (DiscoveredLinkerScripts != null) { if (DiscoveredLinkerScripts.Length == 1) { mcuFamily.CompilationFlags.LinkerScript = DiscoveredLinkerScripts[0].GetBSPPath(); } else { const string optionID = "com.sysprogs.imported.ksdk2x.linker_script"; mcuFamily.CompilationFlags.LinkerScript = $"$$SYS:BSP_ROOT$$/$${optionID}$$"; if ((mcuFamily.ConfigurableProperties?.PropertyGroups?.Count ?? 0) == 0) { mcuFamily.ConfigurableProperties = new PropertyList { PropertyGroups = new List <PropertyGroup> { new PropertyGroup() } } } ; mcuFamily.ConfigurableProperties.PropertyGroups[0].Properties.Add(new PropertyEntry.Enumerated { UniqueID = optionID, Name = "Linker script", AllowFreeEntry = false, SuggestionList = DiscoveredLinkerScripts.Select(p => new PropertyEntry.Enumerated.Suggestion { InternalValue = p.RelativePath, UserFriendlyName = Path.GetFileName(p.RelativePath) }).ToArray() }); } } return(mcuFamily); }
internal MCUFamily ToMCUFamily() { var mcuFamily = new MCUFamily { ID = FullName, UserFriendlyName = DeviceName }; CoreFlagHelper.AddCoreSpecificFlags(true, mcuFamily, CoreName); return mcuFamily; }