forked from rsta2/circle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.txt
55 lines (34 loc) · 3.16 KB
/
debug.txt
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
DEBUG
Single-core Circle applications can be source-level debugged using the GNU debugger (GDB) and one of the following GDB stubs:
* Alpha GDB server by Farjump (special version for Circle)
https://github.com/farjump/Alpha_Raspberry_Pi_Circle
* rpi_stub by turboscrew@GitHub (standalone GDB stub for Raspberry Pi 2 and 3)
https://github.com/turboscrew/rpi_stub
This file describes how to use rpi_stub. Instructions for the Alpha GDB server can be found using the URL given above.
RPI-STUB
Single-core Circle applications can be source-level debugged on the Raspberry Pi 2 and 3 using the GNU debugger (GDB) and rpi_stub. To do this you need:
* An USB to serial converter (which uses 3.3V) connected to the UART of the Raspberry Pi 2/3
* GNU debugger which was build with target support for ARM.
* rpi_stub from https://github.com/turboscrew/rpi_stub
There is already a ready build kernel7.img in the Debug/ subdirectory. For the Raspberry Pi 3 you need a recent version of it.
The file kernel7.img has to be installed on a Micro-SD card along with the firmware files also required to boot Circle (see the file boot/README for this). You have to create a cmdline.txt file on the Micro-SD card (if it is not already there) and write the following options into it:
rpi_stub_baud=115200 rpi_stub_mmu rpi_stub_interrupt=fiq rpi_stub_enable_neon
This sets the serial baud rate and enables the MMU and caches in rpi_stub and the FIQ interrupt mode. Because Circle mostly does not use the FIQ this mode is recommended for Circle. Furthermore rpi_stub enables NEON and the support for XML description of NEON registers.
Before building a Circle application which should be debugged with rpi_stub you have to enable the define
#define USE_RPI_STUB_AT 0x1F000000
in include/circle/sysconfig.h. This prevents Circle from enabling the MMU by itself (it is already enabled), Circle will not install own exception handlers (done by rpi_stub) and will not access the UART any more because it is used by rpi_stub. Log messages will go to the screen in this case (exception from this see below). Applications build with USE_RPI_STUB_AT defined do normally not run without rpi_stub loaded.
rpi_stub allows sending log messages to the GDB client. You have to set "logdev=ttyS1" in cmdline.txt to use this.
To use GDB do the following:
* Connect your USB to serial converter to your host computer.
* Put the Micro-SD card into your Raspberry Pi 2/3 and power it on.
* Start GDB and give the following commands:
file kernel.elf # the executable to be debugged (in current directory here)
set serial baud 115200 # set baud rate used for the serial interface
target remote /dev/ttyUSB0 # your serial interface (may vary)
load # transfer the executable (may take some seconds)
break CKernel::Run # set breakpoint at the entry of CKernel::Run()
cont # continue program
The program will return to GDB when the breakpoint is reached. You can then further continue the program and interrupt it with Ctrl-C, single step it with "step" or "next" or set some further breakpoints.
All GDB commands are explained here:
https://sourceware.org/gdb/current/onlinedocs/gdb/
Thanks to turboscrew@GitHub for providing rpi_stub!