OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [docs/] [doxygen/] [07_debugger.doxy] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
/**
2
 @page debugger_page RISC-V debugger
3
 
4
 @section dbg_overview_section Overview
5
 
6
 This debugger was specially developed as a software utility to interact
7
 with our SOC implementation in \c riscv_soc repository. The main
8
 purpose was to provide convinient way to develop and debug our
9
 Satellite Navigation firmware that can not be debugged by any other
10
 tool provided RISC-V community. Additionally, we would like to use
11
 the single unified application capable to work with Real and Simulated
12
 platforms without any modification of source code.
13
 Debugger provides base functionality such as: run control,
14
 read/write memory, registers and CSRs, breakpoints. It allows to
15
 reload FW image and reset target.
16
 Also we are developing own version of the CPU simulator
17
 (analog of \c spike) that can be extended with peripheries models to
18
 Full SOC simulator. These extensions for the debugger simplify
19
 porting procedure (Zephyr OS for an example) so that
20
 simulation doesn't require any hardware and allows to develop SW and HW
21
 simultaneously.
22
 
23
 @section dbg_prj_structure_section Project structure
24
 
25
 General idea of the project is to develop one \c Core library
26
 providing API methods for registering \c classes, \c services, \c attributes
27
 and methods to interact with them. Each extension plugin registers one or
28
 several class services performing some usefull work. All plugins are
29
 built as an independent libraries that are opening by \c Core library
30
 at initialization stage with the call of method plugin_init().
31
 All Core API methods start with \c RISCV_... prefix:
32
 
33
 @code
34
   void RISCV_register_class(IFace *icls);
35
 *
36
   IFace *RISCV_create_service(IFace *iclass, const char *name,
37
                               AttributeType *args);
38
 *
39
   IFace *RISCV_get_service(const char *name);
40
   ...
41
 @endcode
42
 
43
 Configuration of the debugger and plugins is fully described in JSON
44
 formatted configuration files targets/target_name.json.
45
 These files store all instantiated services names, attributes values
46
 and interconnect among plugins.
47
 
48
 This configuration can be saved to/load from file at any
49
 time. By default command \c exit will save current debugger state into
50
 file (including full command history).
51
 
52
 @note You can manually add/change new Registers/CSRs names and indexes
53
       by modifying this config file without changing source code.
54
 
55
 @par Folders description
56
    -# \b libdgb64g - Core library (so/dll) that provides standard API
57
 methods defined in file \c api_core.h.
58
    -# \b appdbg64g - Executable (exe) file implements functionality of
59
                      the console debugger.
60
    -# \a Plugins:
61
      -# \b simple_plugin - Simple plugin (so/dll library) just for
62
                      demonstration of the integration with debugger.
63
      -# \b cpu_fnc_plugin - Functional model of the RISC-V CPU
64
                     (so/dll library).
65
      -# \b cpu_sysc_plugin - Precise SystemC model of RIVER CPU
66
                     (so/dll library).
67
      -# \b socsim_plugin - Functional models of the peripheries
68
                     and assembled board (so/dll library). This plugin
69
                     registers several classes: \c UART, \c GPIO, \c SRAM,
70
                     \c ROMs and etc.
71
 
72
 
73
 @section eth_link_section Ethernet setup
74
 
75
 The Ethernet Media Access Controller (GRETH) provides an interface between
76
 an AMBA-AXI bus and Ethernet network. It supports 10/100 Mbit speed in both
77
 full- and half-duplex modes. Integrated EDCL submodule implements hardware
78
 decoding of UDP traffic and redirects EDCL request directly on AXI system
79
 bus. The AMBA interface consists of an AXI slave
80
 interface for configuration and control and an AXI master interface
81
 for transmit and receive data. There is one DMA engine for the transmitter
82
 and one for receiver. EDCL submodule and both DMA engines share the same
83
 AXI master interface.
84
 
85
 @subsection eth_confgure_section Configure Host Computer
86
 To make development board visible in your local network your should
87
 properly specify connection properties. In this chapter I will show how to
88
 configure the host computer (Windows 7 or Linux) to communicate with the
89
 FPGA hardware over Ethernet.
90
 
91
 @note If you also want simultaneous Internet access your host computer
92
       requires a second Ethernet port. I couldn't find workable
93
       configuration via router.
94
 
95
 @warning I recommend you to make restore point before you start.
96
 
97
 @subsection eth_cfgwin Configure Windows Host
98
 
99
 Let's setup the following network configuration that allows to work with
100
 FPGA board and to be connected to Internet. I use different Ethernet
101
 ports and different subnets (192.168.0.x and 192.168.1.x accordingly).
102
 
103
 Ethernet config
104
 @latexonly {\includegraphics{../doxygen/pics/eth_common.png}} @endlatexonly
105
 
106
 @par Host IP and subnet definition:
107
    -# Open \c cmd console.
108
    -# Use \c ipconfig command to determine network settings.
109
 @verbatim
110
    ipconfig /all
111
 @endverbatim
112
    -# Find your IP address (in my case it's 192.168.1.4)
113
    -# Check and change if needed default IP address of SOC as follow.
114
 
115
 @par Setup hard-reset FPGA IP address:
116
    -# Open in editor rocket_soc.vhd.
117
    -# Find place where grethaxi module is instantiated.
118
    -# Change generic ipaddrh and ipaddrl parameters so that
119
 they belonged another subnet (Default values: C0A8.0033 corresponding
120
 to 192.168.0.51) than Internet connection.
121
 
122
 @par Configure the Ethernet card for your FPGA hardware
123
    -# Load pre-built image file into FPGA board (located in
124
 ./rocket_soc/bit_files/ folder) or use your own one.
125
    -# Open Network and Sharing Center via Control Panel
126
 
127
 ControlPanel
128
 @latexonly {\includegraphics[scale=0.7]{../doxygen/pics/eth_win1.png}} @endlatexonly
129
 
130
    -# Click on Local Area Connection 2 link
131
 
132
 ControlPanel
133
 @latexonly {\includegraphics{../doxygen/pics/eth_win2.png}} @endlatexonly
134
 
135
    -# Click on Properties to open properties dialog.
136
 
137
 ControlPanel
138
 @latexonly {\includegraphics{../doxygen/pics/eth_win3.png}} @endlatexonly
139
 
140
    -# Disable all network services except Internet Protocol Version 4
141
 as shown on figure above.
142
    -# Select enabled service and click on Properties button.
143
 
144
 ControlPanel
145
 @latexonly {\includegraphics{../doxygen/pics/eth_win4.png}} @endlatexonly
146
 
147
    -# Specify unique IP as shown above so that FPGA and your Local
148
 Connection were placed in the same subnet.
149
    -# Leave the subnet mask set to the default value 255.255.255.0.
150
    -# Click OK.
151
 
152
 @par Check connection
153
    -# Check presence of the Ethernet activity by blinking LEDs near the
154
 Ethernet connector on FPGA board
155
    -# Run \c arp command to see arp table entries.
156
 @verbatim
157
    arp -a -v
158
 @endverbatim
159
 
160
 Check arp
161
 @latexonly {\includegraphics{../doxygen/pics/eth_check1.png}} @endlatexonly
162
 
163
    -# MAC supports only ARP and EDCL requests on hardware level and it cannot
164
 respond on others without properly installed software. By this reason ping
165
 won't work without running OS on FPGA target but it maybe usefull to ping
166
 FPGA target so that it can force updating of the ARP table or use the
167
 commands:
168
 @verbatim
169
    ipconfig /release
170
    ipconfig /renew
171
 @endverbatim
172
 
173
 @subsection eth_cfglin_section Configure Linux Host
174
 
175
 Let's setup the similar network configuration on Linux host.
176
    -# Check ipaddrh and ipaddrl values that are hardcoded
177
 on top-level of SOC (default values: C0A8.0033 corresponding
178
 to 192.168.0.51).
179
    -# Set host IP value in the same subnet using the \c ifconfig command.
180
 You might need to enter a password to use the \c sudo command.
181
 @verbatim
182
      % sudo ifconfig eth0 192.168.0.53 netmask 255.255.255.0
183
 @endverbatim
184
    -# Enter the following command in the shell to check that the changes
185
 took effect:
186
 @verbatim
187
      % ifconfig eth0
188
 @endverbatim
189
 
190
 @subsection eth_appl_section Run Application
191
 
192
 Now your FPGA board is ready to interact with the host computer via Ethernet.
193
 You can find detailed information about MAC (GRETH)
194
 in [GRLIB IP Core User's Manual](http://gaisler.com/products/grlib/grip.pdf).
195
 
196
 There you can find:
197
   -# DMA Configuration registers description (Rx/Tx Descriptors tables and entries).
198
   -# EDCL message format.
199
   -# \c GRLIB itself includes C-example that configure MAC Rx/Tx queues
200
 and start transmission of the 1500 Mbyte of data to define Bitrate in Mbps.
201
 
202
 We provide debugger functionality via Ethernet.
203
 See @link dbg_link Debugger description @endlink page.
204
 
205
 
206
 
207
 @section dbg_connect_section Debug session
208
 
209
 @subsection dbg_connect_1 Plugins interaction
210
 
211
 Core library uses UDP protocol to communicate with all targets: FPGA or
212
 simulators. The general structure is looking like on the following figure:
213
 
214
 sim debug
215
 @latexonly {\includegraphics[scale=0.9]{../doxygen/pics/dbg_sim.png}} @endlatexonly
216
 
217
 or with real Hardware
218
 
219
 fpga debug
220
 @latexonly {\includegraphics[scale=0.8]{../doxygen/pics/dbg_fpga.png}} @endlatexonly
221
 
222
 GUI plugin uses QT-libraries and interacts with the core library using the
223
 text console input interface. GUI generates the same text commands
224
 that are available in debugger console for any who's using this debugger.
225
 That's why any presented in GUI widgets information can be achieved
226
 in console mode.
227
 
228
 @subsection dbg_connect_2 Start Debugger
229
 
230
 We provide several targets that can run software (bootloader, firmware
231
 or user specific application) without any source code modifications:
232
 
233
 Start Configuration            | Description
234
 -------------------------------|-----------------
235
 $ ./_run_functional_sim.sh[bat]| Functional RISC-V Full System Model
236
 $ ./_run_systemc_sim.sh[bat]   | Use SystemC Precise Model of RIVER CPU
237
 $ ./_run_fpga_gui.sh[bat]      | FPGA board. Default port 'COM3', TAP IP = 192.168.0.51
238
 *
239
 To run debugger with the real FPGA target connected via Ethernet do:
240
 
241
 @code
242
     # cd rocket_soc/debugger/win32build/debug
243
     # _run_functional_sim.bat
244
 @endcode
245
 
246
 The result should look like on the picture below:
247
 
248
 debugger 1-st look
249
 @latexonly {\includegraphics[scale=0.8]{../doxygen/pics/dbg_gui_start.png}} @endlatexonly
250
 
251
 @par Example of the debug session
252
 Switch ON all User LEDs on board:
253
 @code
254
      riscv# help                     -- Print full list of commands
255
      riscv# csr MCPUID               -- Read supported ISA extensions
256
      riscv# read 0xfffff000 20       -- Read 20 bytes from PNP module
257
      riscv# write 0x80000000 4 0xff  -- Write into GPIO new LED value
258
      riscv# loadelf helloworld       -- Load elf-file to board RAM and run
259
 @endcode
260
 
261
 Console mode view
262
 
263
 HW debug example
264
 @latexonly {\includegraphics{../doxygen/pics/dbg_testhw.png}} @endlatexonly
265
 
266
 @subsection dbg_connect_3 Debug Zephyr OS kernel with symbols
267
 
268
 Build Zephyr kernel from scratch using our patches enabling 64-bits RISC-V
269
 architecture support:
270
 @code
271
     $ mkdir zephyr_160
272
     $ cd zephyr_160
273
     $ git clone https://gerrit.zephyrproject.org/r/zephyr
274
     $ cd zephyr
275
     $ git checkout tags/v1.6.0
276
     $ cp ../../riscv_vhdl/zephyr/v1.6.0-riscv64-base.diff .
277
     $ cp ../../riscv_vhdl/zephyr/v1.6.0-riscv64-exten.diff .
278
     $ git apply v1.6.0-riscv64-base.diff
279
     $ git apply v1.6.0-riscv64-exten.diff
280
 @endcode
281
 
282
 Then build elf-file:
283
 @code
284
    $ export ZEPHYR_BASE=/home/zephyr_160/zephyr
285
    $ cd zephyr/samples/shell
286
    $ make ARCH=riscv64 CROSS_COMPILE=/home/your_path/gnu-toolchain-rv64ima/bin/riscv64-unknown-elf- BOARD=riscv_gnss 2>&1
287
 @endcode
288
 
289
 Load debug symbols from elf-file without target reprogramming (or with):
290
 @code
291
    riscv# loadelf zephyr.elf
292
    riscv# loadelf zephyr.elf nocode
293
 @endcode
294
 
295
 debugger symbols
296
 @latexonly {\includegraphics[scale=1.0]{../doxygen/pics/dbg_gui_symb.png}} @endlatexonly
297
 
298
 Now becomes available the following features:
299
 - Stack trace with function names
300
 - Function names in Disassembler including additional information for
301
   branch and jump instructions in column \c 'comment'.
302
 - Symbol Browser with filter.
303
 - Opening Disassembler and Memory Viewer widgets in a new window by name.
304
 
305
 Debugger provides additional features that could simplify software
306
 development:
307
 - Clock Per Instruction (CPI) hardware measure
308
 - Bus utilization information
309
 - Others. List of a new features is constantly increasing.
310
 
311
 debugger FPGA+GUI
312
 @latexonly {\includegraphics[scale=0.8]{../doxygen/pics/dbg_fpga_gui1.png}} @endlatexonly
313
 
314
 
315
 @section dbg_troubles_section Troubleshooting
316
 
317
 @subsection dbg_trouble_1 Image Files not found
318
 
319
 If you'll get the error messages that image files not found
320
 
321
 File not found
322
 @latexonly {\includegraphics[scale=0.8]{../doxygen/pics/dbg_err1.png}} @endlatexonly
323
 
324
 To fix this problem do the following steps:
325
     -# Close debugger console using \c exit command.
326
     -# Open config_file_name.json file in any editor.
327
     -# Find strings that specify these paths and correct them. Simulator
328
 uses the same images as VHDL platform for ROMs intialization. You can find
329
 them in 'rocket_soc/fw_images' directory. After that you should
330
 see something like follow:
331
 
332
 Simulator output
333
 @latexonly {\includegraphics[scale=0.8]{../doxygen/pics/dbg_simout1.png}} @endlatexonly
334
 
335
 Debug your target. All commands that are available for Real Hardware
336
 absolutely valid for the Simulation. Users shouldn't see any difference
337
 between these targets this is our purpose.
338
 
339
 @subsection dbg_trouble_2 Can't open COM3 when FPGA is used
340
 
341
    -# Open fpga_gui.json
342
    -# Change value ['ComPortName','COM3'], on your one
343
       (for an example on \c ttyUSB0).
344
 
345
 @subsection dbg_trouble_3 EDCL: No response. Break read transaction
346
 
347
 This error means that host cannot locate board with specified IP address.
348
 Before you continue pass through the following checklist:
349
    -# You should properly @link eth_link setup network connection @endlink
350
 and see FPGA board in ARP-table.
351
    -# If you've changed default FPGA IP address:
352
          -# Open _run_fpga_gui.bat (*.sh)
353
          -# Change value ['BoardIP','192.168.0.51'] on your one.
354
    -# Run debugger
355
 
356
 
357
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.