-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpyTestGdb.py
executable file
·63 lines (53 loc) · 1.48 KB
/
pyTestGdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import subprocess
import os
import time
def readPrintout():
c = proc.stdout.read1()
while c != b'':
for line in c.decode("utf-8").splitlines():
print(line)
time.sleep(.5)
c = proc.stdout.read1()
c = proc.stderr.read1()
while c != b'':
for line in c.decode("utf-8").splitlines():
print(line)
c = proc.stderr.read1()
#arm-none-eabi-gdb --nh --nx
# --eval-command="set verbose on"
# --eval-command="target extended-remote 192.168.42.1:54321"
# bin/nomagic_probe.elf
cmd = 'arm-none-eabi-gdb --nh --nx build/rp2040_nomagic_probe.elf'
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print('started gdb')
time.sleep(1)
os.set_blocking(proc.stdout.fileno(), False)
os.set_blocking(proc.stderr.fileno(), False)
readPrintout()
time.sleep(1)
print('sending verbose on')
proc.stdin.write('set verbose on\r\n'.encode())
proc.stdin.flush()
time.sleep(.5)
readPrintout()
proc.stdin.write('show verbose\r\n'.encode())
proc.stdin.flush()
time.sleep(.5)
readPrintout()
time.sleep(1)
print('sending remote')
proc.stdin.write('target extended-remote 192.168.42.1:54321\r\n'.encode())
proc.stdin.flush()
time.sleep(.5)
readPrintout()
time.sleep(20)
readPrintout()
remainder = proc.communicate()[0]
print(remainder.decode("utf-8"))
print('Done!')
if proc.returncode == 0:
print('Command succeeded!')
else:
print('Command failed!')