8000 source level debugging via serial port by freeck · Pull Request #4336 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

source level debugging via serial port #4336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
843919f
Create gdb-debug
freeck Feb 9, 2018
6323017
Delete gdb-debug
freeck Feb 9, 2018
d6ff725
Create GDB-DEBUG
freeck Feb 9, 2018
ca468ae
Delete GDB-DEBUG
freeck Feb 9, 2018
ea3dfba
Create readme.txt
freeck Feb 9, 2018
b128089
Delete readme.txt
freeck Feb 9, 2018
a4119f5
Create README.txt
freeck Feb 9, 2018
783c871
Create gdbcmds
freeck Feb 9, 2018
136b594
Update gdbcmds
freeck Feb 9, 2018
765fe41
Create library.properties
freeck Feb 9, 2018
3792c02
Update library.properties
freeck Feb 9, 2018
2ffd636
Update library.properties
freeck Feb 9, 2018
52b3cec
Update library.properties
freeck Feb 9, 2018
fa5451c
Update library.properties
freeck Feb 9, 2018
7e6a4ef
Update library.properties
freeck Feb 9, 2018
dbf6ae3
Create readme.txt
freeck Feb 9, 2018
461220a
Delete readme.txt
freeck Feb 9, 2018
99c4bef
Create readme.txt
freeck Feb 9, 2018
3f9158c
Add files via upload
freeck Feb 9, 2018
54b1dc1
Create read
freeck Feb 9, 2018
b13bbec
Add files via upload
freeck Feb 9, 2018
6eb174a
Update README.txt
freeck Feb 9, 2018
6ea79a6
Create read
freeck Feb 9, 2018
309ebaa
Add files via upload
freeck Feb 9, 2018
66be5d3
Delete read
freeck Feb 9, 2018
d3c5c3d
Add files via upload
freeck Feb 9, 2018
967bcc4
Update Instructions.rst
freeck Feb 9, 2018
30f2322
Update Instructions.rst
freeck Feb 9, 2018
d5193f2
Delete Blink.ino
freeck Feb 9, 2018
ed806ee
Delete read
freeck Feb 9, 2018
14aa837
Update README.txt
freeck Feb 9, 2018
ad0dcdd
Update library.properties
freeck Feb 9, 2018
8de6b02
Add files via upload
freeck Feb 10, 2018
f3ce176
Delete Instructions.rst
freeck Feb 10, 2018
b683ed7
Add files via upload
freeck Feb 10, 2018
501ed90
Update instructions.rst
freeck Feb 10, 2018
b6bddab
Update instructions.rst
freeck Feb 10, 2018
e626334
Update instructions.rst
freeck Feb 10, 2018
fdf6a21
Add files via upload
freeck Feb 10, 2018
fa20c18
Update instructions.rst
freeck Feb 10, 2018
767c2c6
Update instructions.rst
freeck Feb 10, 2018
decb996
Update instructions.rst
freeck Feb 10, 2018
f7fade5
Update instructions.rst
freeck Feb 10, 2018
951e38e
Update instructions.rst
freeck Feb 10, 2018
4b6abeb
Update instructions.rst
freeck Feb 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add files via upload
  • Loading branch information
freeck authored Feb 9, 2018
commit 3f9158c56293f4072edd12f446b9e69640373c83
24 changes: 24 additions & 0 deletions libraries/GDBStub-source-level-debug/src/License
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ESPRESSIF MIT License

Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>

Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, it is free of charge, to any person obtaining a copy of this software and associated documentation files (the ��Software��), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ��AS IS��, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


���� MIT ����֤

��Ȩ (c) 2015 <������Ϣ�Ƽ����Ϻ������޹�˾>

������֤��Ȩ������������Ϣ�Ƽ� ESP8266 ��Ʒ��Ӧ�ÿ������ڴ�����£�������֤�����Ȩ�κλ�ø�������������ĵ���ͳ��Ϊ�������������������Ƶؾ�Ӫ�����������������Ƶ�ʹ�á����ơ��޸ġ��ϲ������淢�С�ɢ��������Ȩ������������������������Ȩ��������Ȩ����������ЩȨ����ͬʱ������������������

�����������������и����ж�����������ϵİ�Ȩ��������Ȩ������

�������������������ṩ��û���κ���ȷ�򰵺��ĵ������������������ڹ��������ԡ��ʺ�ijһ�ض���;�ͷ���Ȩ�ı�֤�����ߺͰ�Ȩ���������κ�����¾�����������������ʹ��������Ժ�ͬ��ʽ��������Ȩ��������ʽ������κ����⡢�𺦻��������θ���




69 changes: 69 additions & 0 deletions libraries/GDBStub-source-level-debug/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

GDBSTUB
=======

Intro
-----

While the ESP8266 supports the standard Gnu set of C programming utilities, for now the choice of debuggers
has been limited: there is an attempt at [OpenOCD support](https://github.com/projectgus/openocd), but at
the time of writing, it doesn't support hardware watchpoints and breakpoints yet, and it needs a separate
JTAG adapter connecting to the ESP8266s JTAG pins. As an alternative, [Cesanta](https://www.cesanta.com/)
has implemented a barebones[GDB stub](https://blog.cesanta.com/esp8266-gdb) in their Smart.js solution -
unfortunately, this only supports exception catching and needs some work before you can use it outside of
the Smart.js platform. Moreover, it also does not work with FreeRTOS.

For internal use, we at Espressif desired a GDB stub that works with FreeRTOS and is a bit more capable,
so we designed our own implementation of it. This stub works both under FreeRTOS as well as the OS-less
SDK and is able to catch exceptions and do backtraces on them, read and write memory, forward [os_]printf
statements to gdb, single-step instructions and set hardware break- and watchpoints. It connects to the
host machine (which runs gdb) using the standard serial connection that's also used for programming.

In order to be useful the gdbstub has to be used in conjunction with an xtensa-lx106-elf-gdb, for example
as generated by the [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk) project.

Usage
-----
* Grab the gdbstub project and put the files in a directory called 'gdbstub' in your project. You can do this
either by checking out the Git repo, or adding the Git repo as a submodule to your project if it's already
in Git.
* Modify your Makefile. You'll need to include the gdbstub sources: if your Makefile is structured like the
ones in the Espressif examples, you can add `gdbstub` to the `SUBDIRS` define and `gdbstub/libgdbstub.a` to the
`COMPONENTS_eagle.app.v6` define. Also, you probably want to add `-ggdb` to your compiler flags (`TARGET_LDFLAGS`)
and, if you are debugging, change any optimation flags (-Os, -O2 etc) into `-Og`. Finally, make sure your Makefile
also compiles .S files.
* Configure gdbstub by editting `gdbstub-cfg.h`. There are a bunch of options you can tweak: FreeRTOS or bare SDK,
private exception/breakpoint stack, console redirection to GDB, wait till debugger attachment etc. You can also
configure the options by including the proper -Dwhatever gcc flags in your Makefiles.
* In your user_main.c, add an `#include <../gdbstub/gdbstub.h>` and call `gdbstub_init();` somewhere in user_main.
* Compile and flash your board.
* Run gdb, depending on your configuration immediately after resetting the board or after it has run into
an exception. The easiest way to do it is to use the provided script: xtensa-lx106-elf-gdb -x gdbcmds -b 38400
Change the '38400' into the baud rate your code uses. You may need to change the gdbcmds script to fit the
configuration of your hardware and build environment.

Notes
-----
* Using software breakpoints ('br') only works on code that's in RAM. Code in flash can only have a hardware
breakpoint ('hbr').
* Due to hardware limitations, only one hardware breakpount and one hardware watchpoint are available.
* Pressing control-C to interrupt the running program depends on gdbstub hooking the UART interrupt.
If some code re-hooks this afterwards, gdbstub won't be able to receive characters. If gdbstub handles
the interrupt, the user code will not receive any characters.
* Continuing from an exception is not (yet) supported in FreeRTOS mode.
* The WiFi hardware is designed to be serviced by software periodically. It has some buffers so it
will behave OK when some data comes in while the processor is busy, but these buffers are not infinite.
If the WiFi hardware receives lots of data while the debugger has stopped the CPU, it is bound
to crash. This will happen mostly when working with UDP and/or ICMP; TCP-connections in general will
not send much more data when the other side doesn't send any ACKs.

License
-------
This gdbstub is licensed under the Espressif MIT license, as described in the License file.


Thanks
------
* Cesanta, for their initial ESP8266 exception handling only gdbstub,
* jcmvbkbc, for providing an incompatible but interesting gdbstub for other Xtensa CPUs,
* Sysprogs (makers of VisualGDB), for their suggestions and bugreports.
Loading
0