Rename tools to ao-<foo>
[fw/altos] / ao-tools / ao-dbg / ao-dbg.1
1 .\"
2 .\" Copyright © 2009 Keith Packard <keithp@keithp.com>
3 .\"
4 .\" This program is free software; you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation; either version 2 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful, but
10 .\" WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 .\" General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License along
15 .\" with this program; if not, write to the Free Software Foundation, Inc.,
16 .\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 .\"
18 .\"
19 .TH S51 1 "s51" ""
20 .SH NAME
21 s51 \- hex debugger for cc1111 processors
22 .SH SYNOPSIS
23 .B "s51"
24 [\-t \fIcpu-type\fP]
25 [\-X \fIfrequency\fP]
26 [\-c]
27 [\-r \fIlisten-port\fP]
28 [\-Z \fIlisten-port\fP]
29 [\-s]
30 [\-S]
31 [\-p \fIprompt\fP]
32 [\-V]
33 [\-v]
34 [\-H]
35 [\-h]
36 [\-m]
37 .SH DESCRIPTION
38 .I s51
39 connects to a cc1111 processor through a cp1203-based USB-to-serial
40 converter board, using the GPIO pins available on that chip. It provides an
41 interface compatible with the 8051 emulator of the same name (s51), but
42 communicating with the real chip instead of an emulation. Using a modified
43 version of the SDCC debugger (sdcdb), you can control program execution
44 on the target machine at source-level.
45
46 .SH OPTIONS
47 The command line options are designed to be compatible with the 8051
48 emulator so that it can be used with sdcdb. As such, they're all one letter
49 long.
50 .IP "\-t \fIcpu-type\fP"
51 The 8051 emulator can operate as one of several different chips. Oddly, the
52 real hardware cannot, so this option is ignored.
53 .IP "\-X \fIfrequency\fP"
54 Similarly, the emulator can pretend to run at an arbitrary frequency
55 which the real hardware cannot do. Ignored.
56 .IP "\-c"
57 .IP "\-s"
58 .IP "\-S"
59 .IP "\-v"
60 .IP "\-V"
61 All ignored.
62 .IP "\-r \fIlisten-port\fP, -Z \fIlisten-port\fP"
63 The emulator and sdcdb communicate through a network socket. This option
64 switches the debugger from communicating through stdin/stdout to listening
65 on a specific network port instead. Once a connection is made, the debugger
66 continues on, using that network port for command input and output. The
67 debugger uses port 9756, and attempts to connect before launching s51, so if
68 s51 is listening on this port before sdcdb is started, sdcdb will end up
69 talking to the existing s51 instance. That's often useful for debugging s51
70 itself.
71 .IP "\-p \fIprompt\fP"
72 This sets the command prompt to the specified string.
73 .IP "\-P"
74 This sets the command prompt to a single NUL character. This is for use by
75 sdcdb.
76 .IP "\-h"
77 This should print a usage message, but does nothing useful currently.
78 .IP "\-m"
79 This option is not present in the original 8051 emulator, and causes s51 to
80 dump all commands and replies that are received from and sent to sdcdb.
81 .SH COMMANDS
82 Once started, s51 connects to the cc1111 via the CP2103 using libusb2 and
83 then reads and executes commands, either from stdin, or the nework
84 connection to sdcdb.
85 .PP
86 Unlike the command line, s51 contains built-in help for each of these
87 commands, via the 'help' command. Most of the commands are available in a
88 long form and a single character short form. Below, the short form follows
89 the long form after a comma.
90 .IP "help, ? {command}"
91 Without arguments, prints a list of available commands. With an argument
92 prints more detail about the specific command
93 .IP "quit, q"
94 Terminates the application, without changing the state of the target
95 processor.
96 .IP "di [start] [end]"
97 Dumps imem (256 bytes of "internal" memory) from start to end (inclusive).
98 .IP "ds [start] [end]"
99 Dumps sprs from start to end (inclusive). Note that while most sprs are
100 visible in the global address space, some are not, so use this command
101 instead of "dx" to read them.
102 .IP "dx [start] [end]"
103 Dump external (global) memory from start to end (inclusive).
104 .IP "set, t <prefix> [start] {data ...}"
105 Store to the memory space specified by prefix where prefix is one of "xram",
106 "rom", "iram", or "sfr". Store bytes starting at start.
107 .IP "dump, d <prefix> [start] [end]"
108 Dump from the memory space specified by prefix, where prefix is one of
109 "xram", "rom", "iram" or "sfr". Dumps from start to end (inclusive).
110 .IP "file [filename]"
111 Specifies an intel-format hex file (ihx) that contains the contents of the
112 rom area loaded into the cc1111. This is used to respond to requests to dump
113 rom memory contents without getting them from the cc1111 (which is slow).
114 .IP "pc, p {address}"
115 If the address argument is given, this sets the program counter to the
116 specified value. Otherwise, the current program counter value is displayed.
117 .IP "break, b [address]"
118 Sets a breakpoint at the specified address. This uses the built-in hardware
119 breakpoint support in the cc1111. As a result, it supports no more than four
120 breakpoints at once. You must therefore use a modified version of sdcdb which
121 changes how program execution is controlled to work within this limit.
122 .IP "clear, c [address]"
123 Clear a breakpoint from the specified address.
124 .IP "run, r, go, g {start} {stop}"
125 Resumes execution of the program. If the start argument is present, then it
126 begins at that address, otherwise it continues running at the current pc. If
127 a stop argument is present, then a temporary breakpoint is set at that
128 address. This temporary breakpoint will be removed when execution hits it.
129 .IP "next, n"
130 Step one instruction. In the original s51 program this would ignore
131 subroutines, but as sdcdb doesn't require this functionality, it's not
132 available here.
133 .IP "step, s"
134 Step one instruction.
135 .IP "load, l [filename]"
136 This is not implemented, but it is supposed to load a hex file into flash.
137 Use the ccload program instead.
138 .IP "halt, h"
139 Halt the processor. This is the only command which can be sent while the
140 program is running. It is ignored at other times.
141 .IP "reset, res"
142 Reset the processor. This pulls the reset pin low and re-enables debug mode.
143 Check the cc1111 documentation to see precisely what this does.
144 .IP "status"
145 This dumps the cc1111 debug status register.
146 .IP "info, i breakpoints, b"
147 List the current breakpoints.
148 .IP "info, i help, ?"
149 List the things you can get info on.
150 .IP "stop"
151 This doesn't do anything and is present only to retain compatibility with
152 the original 8051 emulator.
153 .SH "BOARD BRINGUP DEBUGGING"
154 .PP
155 While the original purpose for this program was to connect the source
156 debugger with the hardware, it can also be used as a low-level hex debugger
157 all on its own. In particular, all of the cc1111 peripherals can be
158 manipulated directly from the s51 command line.
159 .IP "Starting s51"
160 If the CP2103 is plugged in, and the CC1111 is connected correctly, the
161 \'s51\' command itself should connect to the device without trouble.
162 Note that the CP2103 must have the GPIO pins configured correctly as well.
163 .IP
164 $ s51
165 .br
166 Welcome to the non-simulated processor
167 .br
168 > status
169 .br
170         CPU halted
171 .br
172         Halted by debug command
173 .br
174 >
175 .IP "Turning on LEDs"
176 Two of the cc1111 GPIO pins, P1_0 and P1_1 are capable of driving external
177 LEDs. To control these, set the Port 1 direction bits to make these output
178 pins and then change the Port 1 data to set them high or low:
179 .IP
180 > set sfr 0xfe 0x02     # set P1DIR to 0x2
181 .br
182 > set sfr 0x90 0x02     # set P1_1 to high
183 .br
184 > set sfr 0x90 0x00     # set P1_1 to low
185 .IP "Reading the A/D converters"
186 The six A/D converter inputs can each be connected to any of the P0 pins,
187 ground, the A/D voltage refernece, an internal temperature sensor or VDD/3.
188 To read one of these values, select an A/D converter to use then start the
189 conversion process. The cc1111 manual has the table for selecting the input
190 on page 144.
191 .IP
192 To configure one of the P0 pins for use by the A/D unit, we program the
193 ADCCFG register, setting the bits in that which match the pins desired:
194 .IP
195 > set sfr 0xf2 0x3f     # enable all 6 A/D inputs
196 .IP
197 To trigger a single conversion, we ask the A/D unit to perform an 'extra'
198 conversion, which means to do a single conversion not a whole sequence of
199 conversions. This is controlled by the ADCCON3 register at 0xB6:
200 .IP
201 > set sfr 0xb6 0xb2     # sample P0_2 using 12 bits of precision
202 .br
203 > ds 0xba 0xbb          # dump the ADC data low and high regs
204 .br
205 > set sfr 0xb6 0xbe     # sample internal temperature sensor
206 .br
207 > ds 0xba 0xbb          # dump the ADC data low and high regs
208 .SH "SEE ALSO"
209 sdcdb(1), ccload(1)
210 .SH AUTHOR
211 Keith Packard