Ejemplo n.º 1
0
 public RenesasGDBStub(DebugStartContext context, RenesasDebugSettings settings, RenesasGDBServerCommandLine cmdLine, int gdbPort, IExternalToolInstance tool, string peripheralFile, bool loadFLASH)
 {
     Tool            = tool;
     _CmdLine        = cmdLine;
     _GDBPort        = gdbPort;
     _Settings       = settings;
     _PeripheralFile = peripheralFile;
     _LoadFLASH      = loadFLASH;
 }
Ejemplo n.º 2
0
        public IGDBStubInstance StartGDBStub(IDebugStartService startService, DebugStartContext context)
        {
            var settings = (RenesasDebugSettings)context.Configuration ?? new RenesasDebugSettings();

            var cmdLine = new RenesasGDBServerCommandLine(settings.CommandLineArguments);
            int gdbPort;

            using (var allocator = startService.BeginAllocatingTCPPorts())
            {
                cmdLine.GDBPort       = gdbPort = allocator.AllocateUnusedTCPPort("SYS:GDB_PORT");
                cmdLine.AuxiliaryPort = allocator.AllocateUnusedTCPPort("com.sysprogs.renesas.auxiliary_port");
            }

            string debugComponentLinkFile = Path.Combine(GetOpenOCDDirectory(context.Method.Directory), "DebugCompLink.txt");

            if (!File.Exists(debugComponentLinkFile))
            {
                throw new Exception($"{debugComponentLinkFile} does not exist");
            }

            cmdLine.DeviceID = startService.MCU.ExpandedMCU.ID;
            if (cmdLine.DebugInterface == null)
            {
                cmdLine.DebugInterface = "EZ";
            }

            bool programNow;

            switch (settings.ProgramMode)
            {
            case ProgramMode.Disabled:
                programNow = false;
                break;

            case ProgramMode.Auto:
                programNow = !startService.IsCurrentFirmwareAlreadyProgrammed();
                break;

            default:
                programNow = true;
                break;
            }

            cmdLine.SetSeparatedValue("-ueraseRom=", programNow ? "1" : "0");

            string debugComponentDir = File.ReadAllText(debugComponentLinkFile);
            string e2gdbServer       = Path.Combine(debugComponentDir, "e2-server-gdb.exe");

            if (!File.Exists(e2gdbServer))
            {
                throw new Exception("Could not find " + e2gdbServer);
            }

            var tool = startService.LaunchCommandLineTool(new CommandLineToolLaunchInfo
            {
                Command          = e2gdbServer,
                Arguments        = cmdLine.CommandLine,
                WorkingDirectory = Path.GetDirectoryName(e2gdbServer)
            });

            return(new RenesasGDBStub(context, settings, cmdLine, gdbPort, tool, $@"{debugComponentDir}\IoFiles\{startService.MCU.ExpandedMCU.ID}.sfrx", programNow));
        }