Browse Source

debugging support :) over gdbstub

tags/v0.2.0
Simon Schmidt 3 years ago
parent
commit
1d7f2f368b
8 changed files with 112 additions and 23 deletions
  1. 0
    3
      README.md
  2. 1
    0
      create_gz_files.py
  3. 21
    0
      doku.md
  4. 37
    0
      include/httpserver.h
  5. 17
    0
      scripts/gdboptions
  6. 14
    15
      src/main.cpp
  7. 6
    0
      start_xtensa_gdb_stub.sh
  8. 16
    5
      templ_platformio_ini

+ 0
- 3
README.md View File

upload_flags = upload_flags =
--port=8266 --port=8266
--auth=admin --auth=admin

lib_deps =
ottowinter/PCA9685 16-Channel PWM Driver Module Library @ 1.2.9
``` ```



extra_script.py → create_gz_files.py View File

#!/usr/bin/python3


import os, gzip import os, gzip
# https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/ # https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/

+ 21
- 0
doku.md View File



=> Software Timer https://ullisroboterseite.de/esp8266-timing.html#timer => Software Timer https://ullisroboterseite.de/esp8266-timing.html#timer





### __Zum aktivieren von GDBStub:__
```c
#include <GDBStub.h>

...

void setup() {
Serial.begin(460800);
gdbstub_init();
```

### __Achtung !__
GDB muss dafür compiled werden
GDB-Version aus Arduino Toolchain hat Support

```sh
$ ./start_xtensa_gdb_stub.sh
```

+ 37
- 0
include/httpserver.h View File

#ifndef __HTTPSERVER_H
#define __HTTPSERVER_H

#include <ESP8266WebServer.h>

class HTTPServer {
private:
int port;
ESP8266WebServer* server;

public:
HTTPServer(int port) {
server = new ESP8266WebServer;

// server->on("/", handleRootGz);
// server->on("/style.css", handleCssGz);
// server->on("/favicon.png", handleFaviconGz);
// server->onNotFound(handleNotFound);
server->begin(port);
}
~HTTPServer() {
server->stop();
delete server;
}

void initialize() {
server->begin(port);
}
void handleClient() {
server->handleClient();
}
};


#endif // __HTTPSERVER_H

+ 17
- 0
scripts/gdboptions View File

set remote hardware-breakpoint-limit 1
set remote hardware-watchpoint-limit 1
set remote interrupt-on-connect on
set remote kill-packet off
set remote symbol-lookup-packet off
set remote verbose-resume-packet off
mem 0x20000000 0x3fefffff ro cache
mem 0x3ff00000 0x3fffffff rw
mem 0x40000000 0x400fffff ro cache
mem 0x40100000 0x4013ffff rw cache
mem 0x40140000 0x5fffffff ro cache
mem 0x60000000 0x60001fff rw
set serial baud 460800

file .pio/build/debug/firmware.elf
target remote /dev/ttyUSB0
thb loop

+ 14
- 15
src/main.cpp View File

#include <Arduino.h> #include <Arduino.h>
#ifdef WITH_GDB_STUB

// debugging support via GDBStub over UART
#ifdef WITH_DEBUGGING_ON
#include <GDBStub.h> #include <GDBStub.h>
#endif #endif


// #include <Wire.h>
#include "PCA9685.h" #include "PCA9685.h"
extern "C" {
#include "user_interface.h"
}


#define ESP12_LED 2 #define ESP12_LED 2
#define NODEMCU_LED 16 #define NODEMCU_LED 16


extern "C" {
#include "user_interface.h"
}

os_timer_t Timer1; // Verwaltungsstruktur des Timers os_timer_t Timer1; // Verwaltungsstruktur des Timers


int c; int c;
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <WiFiClient.h> #include <WiFiClient.h>


// #include "index.html.gz.h"
// #include "style.css.gz.h"
// #include "favicon.png.gz.h"
#include "index.html.gz.h"
#include "style.css.gz.h"
#include "favicon.png.gz.h"
// images are possible // images are possible
// maybe check out FS <- SPIFFS // maybe check out FS <- SPIFFS


void handleRootGz() { void handleRootGz() {
const char* dataType = "text/html"; const char* dataType = "text/html";
server.sendHeader(F("Content-Encoding"), F("gzip")); server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(404, dataType, "debug");
// server.send(200, dataType, (const char*)index_html_gz, index_html_gz_len);
server.send(200, dataType, (const char*)index_html_gz, index_html_gz_len);
} }


void handleCssGz() { void handleCssGz() {
const char* dataType = "text/css"; const char* dataType = "text/css";
server.sendHeader(F("Content-Encoding"), F("gzip")); server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(404, dataType, "debug");
// server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len);
server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len);
} }
void handleFaviconGz() { void handleFaviconGz() {
const char* dataType = "image/png"; const char* dataType = "image/png";
server.sendHeader(F("Content-Encoding"), F("gzip")); server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(404, dataType, "debug");
// server.send(200, dataType, (const char*)favicon_png_gz, favicon_png_gz_len);
server.send(200, dataType, (const char*)favicon_png_gz, favicon_png_gz_len);
} }


void handleNotFound() { void handleNotFound() {
} }


void setup() { void setup() {
#ifdef WITH_GDB_STUB
#ifdef WITH_DEBUGGING_ON
Serial.begin(460800); Serial.begin(460800);
gdbstub_init(); gdbstub_init();
#else #else

+ 6
- 0
start_xtensa_gdb_stub.sh View File

#!/bin/bash
GDB_PATH=~/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.0-newlib4.0.0-gnu23-48f7b08/bin/xtensa-lx106-elf-gdb

cd ..
echo "Starting gdb"
$GDB_PATH -x scripts/gdboptions

+ 16
- 5
templ_platformio_ini View File

; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html


[env:esp01_1m]
[env]
platform = espressif8266 platform = espressif8266
board = esp01_1m
board = nodemcuv2
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200

extra_scripts = pre:extra_script.py extra_scripts = pre:extra_script.py


[env:serial]
upload_protocol = esptool
upload_speed = 921600

[env:ota]
; stuff for OTA ; stuff for OTA
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update ; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
upload_protocol = espota upload_protocol = espota
--port=8266 --port=8266
--auth=admin --auth=admin


lib_deps =
ottowinter/PCA9685 16-Channel PWM Driver Module Library @ 1.2.9
[env:debug]
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
upload_protocol = esptool
upload_speed = 921600






Loading…
Cancel
Save