Skip to content

Commit b3153d2

Browse files
rgundiAnas Nashif
authored and
Anas Nashif
committed
intel_s1000: scripts: debug, debugserver and flash scripts
This patchset creates Debug, Debugserver and Flash scripts ensuring support in the ZephyrBinaryRunner mode. Change-Id: Ib4f7820b1c6a045bd67cf4a031be99cf61e65eca Signed-off-by: Rajavardhan Gundi <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 567482f commit b3153d2

File tree

7 files changed

+219
-0
lines changed

7 files changed

+219
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(BOARD_FLASH_RUNNER intel_s1000)
2+
set(BOARD_DEBUG_RUNNER intel_s1000)
3+
4+
board_finalize_runner_args(intel_s1000
5+
"--board-dir=${ZEPHYR_BASE}/boards/xtensa/intel_s1000_crb/"
6+
"--xt-ocd-dir=/opt/Tensilica/xocd-12.0.4/xt-ocd"
7+
"--ocd-topology=topology_dsp0_flyswatter2.xml"
8+
"--ocd-jtag-instr=dsp0_gdb.txt"
9+
"--gdb-flash-file=load_elf.txt"
10+
"--gdb=${TOOLCHAIN_HOME}/bin/xt-gdb"
11+
"--kernel-elf=zephyr/zephyr.elf"
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(${ZEPHYR_BASE}/boards/common/intel_s1000_crb.board.cmake)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#Initialization script format
2+
#COMMAND LENGTH DATA
3+
#
4+
#COMMAND: 1 - Scan DR branch
5+
# 2 - Scan IR branch
6+
# 3 - Send TRST
7+
#
8+
#LENGTH: Number of bits to send out (in decimal format).
9+
#
10+
#DATA: Data to send out. A sequence of bytes separated by space.
11+
# The rightmost bit is scanned out first. E.g. (B4 B3 B2 B1 B0)
12+
#
13+
## Examples
14+
#
15+
# Perform TAP Reset:
16+
3
17+
## all stap disable
18+
2 8 12
19+
1 6 0
20+
# Scan out MTAP IDCODE command (0x2) a265013h
21+
## all stap enable
22+
2 8 12
23+
1 6 01
24+
#
25+
#
26+
# Scan out (2 cores):
27+
# Send Trax Access IR command to 1st core and bypass to 2nd
28+
#2 10 3 9F
29+
# Write to DOSR register of 1st core (NAR part)
30+
#1 9 1 07
31+
# Write 32 bits to DOSR register (NDR part)
32+
#1 33 1 98 13 45 ab
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
target remote localhost:20000
2+
3+
# make SRAM writable
4+
set *(0x71d10) = 0
5+
set *(0x71d20) = 0
6+
7+
# disable xtensa core power saving
8+
set *(0x71F90) = 0x71
9+
10+
set pagination off
11+
set confirm off
12+
load zephyr/zephyr.elf
13+
file zephyr/zephyr.elf
14+
c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<configuration>
2+
<controller id='Controller0' module='ft2232' probe='flyswatter2' speed='10MHz' />
3+
<driver id='XtensaDriver0' cust-idcode='00140101,LX6' module='xtensa' step-intr='mask,stepover,setps' />
4+
5+
<driver id='TraxDriver0' module='trax' />
6+
<chain controller='Controller0'>
7+
<tap id='TAP2' irwidth='8' />
8+
<tap id='TAP0' irwidth='5' />
9+
</chain>
10+
11+
<system module='jtag'>
12+
<component id='Component0' tap='TAP0' config='trax' />
13+
14+
</system>
15+
<device id='Xtensa0' component='Component0' driver='XtensaDriver0' />
16+
17+
<application id='GDBStub0' module='gdbstub' port='20000'>
18+
<target device='Xtensa0' />
19+
</application>
20+
21+
</configuration>

scripts/support/runner/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
from . import pyocd
2222
from . import qemu
2323
from . import xtensa
24+
from . import intel_s1000
2425

2526
__all__ = ['ZephyrBinaryRunner']

scripts/support/runner/intel_s1000.py

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Copyright (c) 2018 Intel Corporation.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
'''Runner for debugging and flashing Intel_s1000 devices'''
6+
from os import path
7+
from .core import ZephyrBinaryRunner
8+
import time
9+
import signal
10+
11+
DEFAULT_XT_GDB_PORT = 20000
12+
13+
class intel_s1000BinaryRunner(ZephyrBinaryRunner):
14+
'''Runner front-end for Intel_s1000.'''
15+
16+
def __init__(self,
17+
board_dir, xt_ocd_dir,
18+
ocd_topology, ocd_jtag_instr, gdb_flash_file,
19+
elf_name, gdb,
20+
gdb_port=DEFAULT_XT_GDB_PORT, debug=False):
21+
super(intel_s1000BinaryRunner, self).__init__(debug=debug)
22+
self.board_dir = board_dir
23+
self.xt_ocd_dir = xt_ocd_dir
24+
self.ocd_topology = ocd_topology
25+
self.ocd_jtag_instr = ocd_jtag_instr
26+
self.gdb_flash_file = gdb_flash_file
27+
self.elf_name = elf_name
28+
self.gdb_cmd = gdb
29+
self.gdb_port = gdb_port
30+
31+
@classmethod
32+
def name(cls):
33+
return 'intel_s1000'
34+
35+
@classmethod
36+
def do_add_parser(cls, parser):
37+
# Required
38+
39+
# Optional
40+
parser.add_argument('--gdb-port', default=DEFAULT_XT_GDB_PORT,
41+
help='xt-gdb port, defaults to 20000')
42+
parser.add_argument('--xt-ocd-dir', default='/opt/Tensilica/xocd-12.0.4/xt-ocd',
43+
help='ocd-dir, defaults to /opt/Tensilica/xocd-12.0.4/xt-ocd')
44+
parser.add_argument('--ocd-topology', default='topology_dsp0_flyswatter2.xml',
45+
help='ocd-topology, defaults to topology_dsp0_flyswatter2.xml')
46+
parser.add_argument('--ocd-jtag-instr', default='dsp0_gdb.txt',
47+
help='ocd-jtag-instr, defaults to dsp0_gdb.txt')
48+
parser.add_argument('--gdb-flash-file', default='load_elf.txt',
49+
help='gdb-flash-file, defaults to load_elf.txt')
50+
51+
@classmethod
52+
def create_from_args(command, args):
53+
return intel_s1000BinaryRunner(
54+
args.board_dir, args.xt_ocd_dir,
55+
args.ocd_topology, args.ocd_jtag_instr, args.gdb_flash_file,
56+
args.kernel_elf, args.gdb,
57+
gdb_port=args.gdb_port, debug=args.verbose)
58+
59+
def do_run(self, command, **kwargs):
60+
kwargs['ocd-topology'] = path.join(self.board_dir, 'support', self.ocd_topology)
61+
kwargs['ocd-jtag-instr'] = path.join(self.board_dir, 'support', self.ocd_jtag_instr)
62+
kwargs['gdb-flash-file'] = path.join(self.board_dir, 'support', self.gdb_flash_file)
63+
64+
if command == 'flash':
65+
self.flash(**kwargs)
66+
elif command == 'debugserver':
67+
self.debugserver(**kwargs)
68+
else:
69+
self.do_debug()
70+
71+
def flash(self, **kwargs):
72+
topology_file = kwargs['ocd-topology']
73+
jtag_instr_file = kwargs['ocd-jtag-instr']
74+
gdb_flash_file = kwargs['gdb-flash-file']
75+
76+
self.print_gdbserver_message(self.gdb_port)
77+
server_cmd = [self.xt_ocd_dir,
78+
'-c', topology_file,
79+
'-I', jtag_instr_file]
80+
81+
# Start the server
82+
# Note that XTOCD always fails the first time. It has to be
83+
# relaunched the second time to work.
84+
self.popen_ignore_int(server_cmd)
85+
time.sleep(3)
86+
server_proc = self.popen_ignore_int(server_cmd)
87+
time.sleep(3)
88+
89+
# Start the client
90+
gdb_cmd = [self.gdb_cmd, '-x', gdb_flash_file]
91+
client_proc = self.popen_ignore_int(gdb_cmd)
92+
93+
# Wait for 3 seconds (waiting for XTGDB to finish)
94+
time.sleep(3)
95+
96+
# At this point, the ELF image is loaded and the program is in
97+
# execution. Now we can quit the client (xt-gdb) and the server
98+
# (xt-ocd) as they are not needed anymore. The loaded program
99+
# (ELF) will continue to run though.
100+
client_proc.terminate()
101+
server_proc.terminate()
102+
103+
def do_debug(self):
104+
if self.elf_name is None:
105+
raise ValueError('Cannot debug; elf is missing')
106+
if self.gdb_cmd is None:
107+
raise ValueError('Cannot debug; no gdb specified')
108+
109+
gdb_cmd = [self.gdb_cmd,
110+
'-ex', 'target remote :{}'.format(self.gdb_port),
111+
self.elf_name]
112+
113+
# The below statement will consume the "^C" keypress ensuring
114+
# the python main application doesn't exit. This is important
115+
# since ^C in gdb means a "halt" operation.
116+
previous = signal.signal(signal.SIGINT, signal.SIG_IGN)
117+
try:
118+
self.check_call(gdb_cmd)
119+
finally:
120+
signal.signal(signal.SIGINT, previous)
121+
122+
def print_gdbserver_message(self, gdb_port):
123+
print('Intel S1000 GDB server running on port {}'.format(gdb_port))
124+
125+
def debugserver(self, **kwargs):
126+
topology_file = kwargs['ocd-topology']
127+
jtag_instr_file = kwargs['ocd-jtag-instr']
128+
129+
self.print_gdbserver_message(self.gdb_port)
130+
server_cmd = [self.xt_ocd_dir,
131+
'-c', topology_file,
132+
'-I', jtag_instr_file]
133+
134+
# Note that XTOCD always fails the first time. It has to be
135+
# relaunched the second time to work.
136+
self.popen_ignore_int(server_cmd)
137+
time.sleep(3)
138+
self.check_call(server_cmd)

0 commit comments

Comments
 (0)