示例#1
0
            public void GenerateConditionsBoard(ref List <EmbeddedFramework> prFrBoard)
            {
                List <PropertyEntry.Enumerated.Suggestion> lstProp = new List <PropertyEntry.Enumerated.Suggestion>();
                var propertyGroup = prFrBoard.SingleOrDefault(fr => fr.ID.Equals("com.sysprogs.arm.nordic.nrf5x.boards")).
                                    ConfigurableProperties.PropertyGroups.
                                    SingleOrDefault(pg => pg.UniqueID.Equals("com.sysprogs.bspoptions.nrf5x.board."));

                var rgBoardIfdef = new Regex("#(if|elif) defined\\(BOARD_([A-Z0-9a-z_]+)\\)");
                var rgInclude    = new Regex("#include \"([^\"]+)\"");

                var lines = File.ReadAllLines(Path.Combine(Directories.OutputDir, @"nRF5x\components\boards\boards.h"));

                lstProp.Add(new PropertyEntry.Enumerated.Suggestion()
                {
                    InternalValue = "", UserFriendlyName = "None"
                });

                for (int i = 0; i < lines.Length; i++)
                {
                    var m = rgBoardIfdef.Match(lines[i]);
                    if (!m.Success)
                    {
                        continue;
                    }

                    string boardID = m.Groups[2].Value;
                    string file    = rgInclude.Match(lines[i + 1]).Groups[1].Value;

                    MatchedFileConditions.Add(new FileCondition()
                    {
                        ConditionToInclude = new Condition.Equals()
                        {
                            Expression    = "$$com.sysprogs.bspoptions.nrf5x.board.type$$",
                            ExpectedValue = boardID,
                            IgnoreCase    = false
                        },
                        FilePath = "nRF5x/components/boards/" + file
                    });
                    lstProp.Add(new PropertyEntry.Enumerated.Suggestion()
                    {
                        InternalValue = boardID
                    });
                }
                //--ConfigurableProperties--

                propertyGroup.Properties.Add(new PropertyEntry.Enumerated
                {
                    UniqueID          = "type",
                    Name              = "Board Type",
                    DefaultEntryIndex = Enumerable.Range(0, lstProp.Count).First(i => lstProp[i].InternalValue == "PCA10040"),
                    SuggestionList    = lstProp.ToArray()
                });
            }
示例#2
0
        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();
        }