-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: add test for ROM symbols in GDB
- Loading branch information
Showing
8 changed files
with
143 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# The following lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(gdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | | ||
| ----------------- | ----- | -------- | -------- | -------- | -------- | | ||
|
||
# IDF GDB test application | ||
|
||
This project tests if `idf.py gdb` works correct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "hello_world_main.c" | ||
INCLUDE_DIRS "") | ||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: CC0-1.0 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "sdkconfig.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "esp_chip_info.h" | ||
#include "esp_flash.h" | ||
|
||
void app_main(void) | ||
{ | ||
printf("Hello world!\n"); | ||
|
||
/* Print chip information */ | ||
esp_chip_info_t chip_info; | ||
uint32_t flash_size; | ||
esp_chip_info(&chip_info); | ||
printf("This is %s chip with %d CPU core(s), WiFi%s%s, ", | ||
CONFIG_IDF_TARGET, | ||
chip_info.cores, | ||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", | ||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); | ||
|
||
printf("silicon revision %d, ", chip_info.revision); | ||
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { | ||
printf("Get flash size failed"); | ||
return; | ||
} | ||
|
||
printf("%uMB %s flash\n", flash_size / (1024 * 1024), | ||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); | ||
|
||
printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size()); | ||
|
||
for (int i = 10; i >= 0; i--) { | ||
printf("Restarting in %d seconds...\n", i); | ||
vTaskDelay(1000 / portTICK_PERIOD_MS); | ||
} | ||
printf("Restarting now.\n"); | ||
fflush(stdout); | ||
esp_restart(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
import os | ||
import re | ||
import signal | ||
import subprocess | ||
import sys | ||
|
||
import pexpect | ||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
try: | ||
from idf_py_actions.debug_ext import get_openocd_arguments | ||
except ModuleNotFoundError: | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..')) | ||
from idf_py_actions.debug_ext import get_openocd_arguments | ||
|
||
|
||
@pytest.mark.supported_targets | ||
@pytest.mark.test_jtag_arm | ||
def test_idf_gdb(dut: Dut) -> None: | ||
# Need to wait a moment to connect via OpenOCD after the hard reset happened. | ||
# Along with this check that app runs ok | ||
dut.expect('Hello world!') | ||
|
||
# Don't need to have output from UART any more | ||
dut.serial.stop_redirect_thread() | ||
|
||
with open(os.path.join(dut.logdir, 'ocd.log'), 'w') as ocd_log: | ||
ocd = subprocess.Popen(f'openocd {get_openocd_arguments(dut.target)}', stdout=ocd_log, stderr=ocd_log, shell=True) | ||
|
||
try: | ||
gdb_env = os.environ.copy() | ||
gdb_env['ESP_IDF_GDB_TESTING'] = '1' | ||
|
||
with open(os.path.join(dut.logdir, 'gdb.log'), 'w') as gdb_log, \ | ||
pexpect.spawn(f'idf.py -B {dut.app.binary_path} gdb --batch', | ||
env=gdb_env, | ||
timeout=60, | ||
logfile=gdb_log, | ||
encoding='utf-8', | ||
codec_errors='ignore') as p: | ||
p.expect(re.compile(r'add symbol table from file.*bootloader.elf')) | ||
p.expect(re.compile(r'add symbol table from file.*rom.elf')) | ||
p.expect_exact('hit Temporary breakpoint 1, app_main ()') | ||
finally: | ||
try: | ||
ocd.send_signal(signal.SIGINT) | ||
ocd.communicate(timeout=15) | ||
except subprocess.TimeoutExpired: | ||
ocd.kill() | ||
ocd.communicate() |