示例#1
0
    private void Awake()
    {
        DeviceWidth  = Screen.width;
        DeviceHeight = Screen.height;
        m_Device     = new SoftDevice(DeviceWidth, DeviceHeight);

        m_ClearColor = m_Device.ClearColor;
    }
示例#2
0
    private void OnDestroy()
    {
        if (m_Device != null)
        {
            m_Device.Dispose();
            m_Device = null;
        }

        DestroyTargetTexture();
    }
示例#3
0
 static void BuildLinkerScriptBasedOnOriginalNordicScripts(string ldsDirectory, string generalizedName, SoftDevice sd)
 {
     for (LinkerScriptGenerationPass pass = LinkerScriptGenerationPass.BeforeFirst + 1; pass < LinkerScriptGenerationPass.AfterLast; pass++)
     {
         DoBuildLinkerScriptBasedOnOriginalNordicScripts(ldsDirectory, generalizedName, sd, pass);
     }
 }
示例#4
0
            static void BuildLinkerScriptBasedOnOriginalNordicScripts(string ldsDirectory, string generalizedName, string ldsSuffix, SoftDevice sd)
            {
                string[] providedSymbols =
                {
                    "PROVIDE(_sbss = __bss_start__);",
                    "PROVIDE(_ebss = __bss_end__);",
                    "PROVIDE(_sdata = __data_start__);",
                    "PROVIDE(_sidata = __etext);",
                    "PROVIDE(_estack = __StackTop);",
                    "PROVIDE(_edata =__data_end__);",
                    "PROVIDE(__isr_vector = __StackTop);",
                    "PROVIDE(_etext = __etext);"
                };

                List <string> lines = File.ReadAllLines(sd.LdOriginalName).ToList();

                lines.Insert(0, $"/* Based on {sd.LdOriginalName} */");

                InsertPowerMgmtData(lines);

                var m = Regex.Match(lines.Find(s => s.Contains("INCLUDE")) ?? " ", "INCLUDE[ ]*\"([a-z0-9_.]*)");

                if (m.Success)
                {
                    string[] incf = Directory.GetFiles(bspBuilder.Directories.InputDir, m.Groups[1].Value, SearchOption.AllDirectories);
                    if (incf.Count() > 1)
                    {
                        throw new Exception("more include file");
                    }
                    if (!File.Exists(Path.Combine(ldsDirectory, m.Groups[1].Value)))
                    {
                        string commonLds = Path.Combine(ldsDirectory, m.Groups[1].Value);

                        var commonLines = File.ReadAllLines(incf[0]).ToList();
                        var idx         = commonLines.IndexOf("    .text :");
                        if (idx == -1)
                        {
                            throw new Exception("Could not find the beginning of section .text");
                        }
                        commonLines.Insert(idx, "    _stext = .;");

                        File.WriteAllLines(commonLds, commonLines.ToArray());
                    }
                }

                var mems = sd.LinkerScriptWithMaximumReservedRAM;

                lines.Insert(lines.FindOrThrow(s => s.Contains("FLASH")), $"  FLASH_SOFTDEVICE (RX) : ORIGIN = 0x{FLASHBase:x8}, LENGTH = 0x{mems.FLASH.Origin - FLASHBase:x8}");
                lines.Insert(lines.FindOrThrow(s => s.Contains("RAM")), $"  SRAM_SOFTDEVICE (RWX) : ORIGIN = 0x{SRAMBase:x8}, LENGTH = 0x{mems.RAM.Origin - SRAMBase:x8}");
                var idxSectionList = lines.FindOrThrow(s => s == "SECTIONS") + 1;

                while (lines[idxSectionList].Trim() == "{")
                {
                    idxSectionList++;
                }

                if (lines[idxSectionList].Contains(". = ALIGN"))
                {
                    idxSectionList++;
                }

                lines.InsertRange(idxSectionList, new[]
                {
                    "  .softdevice :",
                    "  {",
                    "    KEEP(*(.softdevice))",
                    "    FILL(0xFFFFFFFF);",
                    $"    . = 0x{mems.FLASH.Origin - FLASHBase:x8};",
                    "  } > FLASH_SOFTDEVICE",
                    "",
                    "  .softdevice_sram :",
                    "  {",
                    "    FILL(0xFFFFFFFF);",
                    $"    . = 0x{mems.RAM.Origin - SRAMBase:x8};",
                    "  } > SRAM_SOFTDEVICE"
                }
                                  );


                lines.AddRange(providedSymbols);

                File.WriteAllLines(Path.Combine(ldsDirectory, generalizedName + "_" + sd.Name.ToLower() + "_reserve" + ldsSuffix + ".lds"), lines);
                lines.Insert(lines.FindOrThrow(s => s.Contains("MEMORY")), $"GROUP({sd.Name}_softdevice.o)");
                File.WriteAllLines(Path.Combine(ldsDirectory, generalizedName + "_" + sd.Name.ToLower() + ldsSuffix + ".lds"), lines);

                //no softdev
                lines = File.ReadAllLines(sd.LdOriginalName).ToList();
                InsertPowerMgmtData(lines);
                var indFl = lines.FindOrThrow(s => s.Contains("FLASH"));

                lines[indFl] = $"  FLASH (RX) :  ORIGIN = 0x{FLASHBase:x}, LENGTH = 0x{sd.LinkerScriptWithMaximumReservedRAM.FLASH.Origin + sd.LinkerScriptWithMaximumReservedRAM.FLASH.Length:x}";
                lines.AddRange(providedSymbols);
                File.WriteAllLines(Path.Combine(Path.Combine(ldsDirectory, generalizedName + "_nosoftdev" + ldsSuffix + ".lds")), lines);
            }
示例#5
0
            void DoBuildLinkerScriptBasedOnOriginalNordicScripts(string ldsDirectory, string generalizedName, SoftDevice sd, LinkerScriptGenerationPass pass)
            {
                string[] providedSymbols =
                {
                    "PROVIDE(_sbss = __bss_start__);",
                    "PROVIDE(_ebss = __bss_end__);",
                    "PROVIDE(_sdata = __data_start__);",
                    "PROVIDE(_sidata = __etext);",
                    "PROVIDE(_estack = __StackTop);",
                    "PROVIDE(_edata =__data_end__);",
                    "PROVIDE(__isr_vector = __StackTop);",
                    "PROVIDE(_etext = __etext);"
                };


                string suffix;

                if (pass == LinkerScriptGenerationPass.Nosoftdev)
                {
                    suffix = "nosoftdev";
                }
                else if (pass == LinkerScriptGenerationPass.Reserve)
                {
                    suffix = $"{sd.Name.ToLower()}_reserve";
                }
                else
                {
                    suffix = sd.Name.ToLower();
                }

                int idx = generalizedName.IndexOf('_');

                if (!sd.LinkerScriptWithMaximumReservedRAM.TryGetValue(generalizedName.Substring(0, idx), out var mems))
                {
                    if (pass == LinkerScriptGenerationPass.Nosoftdev)
                    {
                        return;
                    }
                    File.WriteAllText(Path.Combine(ldsDirectory, $"{generalizedName}_{suffix}.lds"), $"/* The Nordic SDK did not include a linker script for this device/softdevice combination.\r\nIf you would like to use it nonetheless, consider porting another linker script based on the device/softdevice specifications. */\r\nINPUT(UNSUPPORTED_DEVICE_SOFTDEVICE_COMBINATION)\r\n");

                    _MissingSoftdeviceScripts.Add(new MissingSoftdeviceScriptInfo {
                        MCU = generalizedName, Softdevice = sd.Name
                    });
                    return;
                }

                List <string> lines = File.ReadAllLines(mems.FullPath).ToList();

                lines.Insert(0, $"/* Based on {mems.FullPath} */");

                InsertPowerMgmtData(lines);

                var m = Regex.Match(lines.Find(s => s.Contains("INCLUDE")) ?? " ", "INCLUDE[ ]*\"([a-z0-9_.]*)");

                if (m.Success)
                {
                    string[] incf = Directory.GetFiles(Directories.InputDir, m.Groups[1].Value, SearchOption.AllDirectories);
                    if (incf.Length > 1)
                    {
                        throw new Exception("Ambiguous 'common' include file.");
                    }
                    if (!File.Exists(Path.Combine(ldsDirectory, m.Groups[1].Value)))
                    {
                        string commonLds = Path.Combine(ldsDirectory, m.Groups[1].Value);

                        var commonLines = File.ReadAllLines(incf[0]).ToList();
                        idx = commonLines.IndexOf("    .text :");
                        if (idx == -1)
                        {
                            throw new Exception("Could not find the beginning of section .text");
                        }
                        commonLines.Insert(idx, "    _stext = .;");

                        File.WriteAllLines(commonLds, commonLines.ToArray());
                    }
                }


                if (pass == LinkerScriptGenerationPass.Nosoftdev)
                {
                    idx        = lines.FindOrThrow(s => s.Contains("FLASH"));
                    lines[idx] = $"  FLASH (RX) :  ORIGIN = 0x{FLASHBase:x}, LENGTH = 0x{mems.FLASH.Origin + mems.FLASH.Length - FLASHBase:x}";
                    idx        = lines.FindOrThrow(s => s.Contains("RAM ("));
                    lines[idx] = $"  RAM (RWX) :  ORIGIN = 0x{SRAMBase:x}, LENGTH = 0x{mems.RAM.Origin + mems.RAM.Length - SRAMBase:x}";
                }
                else
                {
                    lines.Insert(lines.FindOrThrow(s => s.Contains("FLASH")), $"  FLASH_SOFTDEVICE (RX) : ORIGIN = 0x{FLASHBase:x8}, LENGTH = 0x{mems.FLASH.Origin - FLASHBase:x8}");
                    lines.Insert(lines.FindOrThrow(s => s.Contains("RAM")), $"  SRAM_SOFTDEVICE (RWX) : ORIGIN = 0x{SRAMBase:x8}, LENGTH = 0x{mems.RAM.Origin - SRAMBase:x8}");
                    var idxSectionList = lines.FindOrThrow(s => s == "SECTIONS") + 1;
                    while (lines[idxSectionList].Trim() == "{")
                    {
                        idxSectionList++;
                    }

                    if (lines[idxSectionList].Contains(". = ALIGN"))
                    {
                        idxSectionList++;
                    }

                    if (pass == LinkerScriptGenerationPass.Regular)
                    {
                        lines.InsertRange(idxSectionList, new[] {
                            "  .softdevice :",
                            "  {",
                            "    KEEP(*(.softdevice))",
                            "    FILL(0xFFFFFFFF);",
                            $"    . = 0x{mems.FLASH.Origin - FLASHBase:x8};",
                            "  } > FLASH_SOFTDEVICE",
                            "",
                            "  .softdevice_sram :",
                            "  {",
                            "    FILL(0xFFFFFFFF);",
                            $"    . = 0x{mems.RAM.Origin - SRAMBase:x8};",
                            "  } > SRAM_SOFTDEVICE"
                        });

                        lines.Insert(lines.FindOrThrow(s => s.Contains("MEMORY")), $"GROUP({sd.Name}_softdevice.o)");
                    }
                }

                lines.AddRange(providedSymbols);

                File.WriteAllLines(Path.Combine(ldsDirectory, $"{generalizedName}_{suffix}.lds"), lines);
            }