Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions src/flash/nor/esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
Expand All @@ -25,8 +23,8 @@

#include "imp.h"
#include <target/smp.h>
#include <target/esp_xtensa_apptrace.h>
#include <target/esp32.h>
#include <target/espressif/esp_xtensa_apptrace.h>
#include <target/espressif/esp32.h>
#include "esp_xtensa.h"
#include "contrib/loaders/flash/esp/esp32/stub_flasher_image.h"

Expand Down
8 changes: 3 additions & 5 deletions src/flash/nor/esp32c3.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <target/esp32c3.h>
#include <target/esp_riscv_algorithm.h>
#include <target/espressif/esp32c3.h>
#include <target/espressif/esp_riscv_algorithm.h>
#include "imp.h"
#include "esp_riscv.h"
#include "contrib/loaders/flash/esp/esp32c3/stub_flasher_image.h"
Expand Down
12 changes: 5 additions & 7 deletions src/flash/nor/esp32s2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "imp.h"
#include <target/xtensa_algorithm.h>
#include <target/esp_xtensa_apptrace.h>
#include <target/esp_xtensa.h>
#include <target/esp32s2.h>
#include <target/xtensa/xtensa_algorithm.h>
#include <target/espressif/esp_xtensa_apptrace.h>
#include <target/espressif/esp_xtensa.h>
#include <target/espressif/esp32s2.h>
#include "esp_xtensa.h"
#include "contrib/loaders/flash/esp/esp32s2/stub_flasher_image.h"

Expand Down
10 changes: 4 additions & 6 deletions src/flash/nor/esp32s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
Expand All @@ -24,9 +22,9 @@

#include "imp.h"
#include <target/smp.h>
#include <target/xtensa_algorithm.h>
#include <target/esp_xtensa_apptrace.h>
#include <target/esp32s3.h>
#include <target/xtensa/xtensa_algorithm.h>
#include <target/espressif/esp_xtensa_apptrace.h>
#include <target/espressif/esp32s3.h>
#include "esp_xtensa.h"
#include "contrib/loaders/flash/esp/esp32s3/stub_flasher_image.h"

Expand Down
6 changes: 2 additions & 4 deletions src/flash/nor/esp_flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifndef OPENOCD_FLASH_NOR_ESP_FLASH_H
#define OPENOCD_FLASH_NOR_ESP_FLASH_H

#include <target/target.h>
#include <helper/command.h>
#include <target/esp_algorithm.h>
#include <target/espressif/esp_algorithm.h>
#include <target/breakpoints.h>
#include <flash/nor/core.h>

Expand Down
9 changes: 4 additions & 5 deletions src/flash/nor/esp_riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "esp_riscv.h"
#include <target/esp_riscv_apptrace.h>
#include <target/esp_riscv_algorithm.h>
#include <target/espressif/esp_riscv_apptrace.h>
#include <target/espressif/esp_riscv_algorithm.h>

static const struct esp_flash_apptrace_hw s_esp_riscv_flash_apptrace_hw = {
.info_init = esp_riscv_apptrace_info_init,
Expand Down
10 changes: 4 additions & 6 deletions src/flash/nor/esp_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifndef FLASH_ESP_RISCV_H
#define FLASH_ESP_RISCV_H
#ifndef OPENOCD_FLASH_NOR_ESP_RISCV_H
#define OPENOCD_FLASH_NOR_ESP_RISCV_H

#include "esp_flash.h"

Expand All @@ -38,4 +36,4 @@ int esp_riscv_flash_init(struct esp_riscv_flash_bank *esp_info, uint32_t sec_sz,
const struct esp_flasher_stub_config *(*get_stub)(struct flash_bank *bank));


#endif /*FLASH_ESP_RISCV_H*/
#endif /* OPENOCD_FLASH_NOR_ESP_RISCV_H */
11 changes: 4 additions & 7 deletions src/flash/nor/esp_xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "esp_xtensa.h"
#include <target/esp_xtensa_apptrace.h>
#include <target/xtensa_algorithm.h>
#include <target/espressif/esp_xtensa_apptrace.h>
#include <target/xtensa/xtensa_algorithm.h>

#define ESP_XTENSA_FLASH_MIN_OFFSET 0x1000 /* protect secure boot digest data
**/
#define ESP_XTENSA_FLASH_MIN_OFFSET 0x1000 /* protect secure boot digest data */

static const struct esp_flash_apptrace_hw s_esp_xtensa_flash_apptrace_hw = {
.data_len_read = esp_xtensa_apptrace_data_len_read,
Expand Down
4 changes: 1 addition & 3 deletions src/flash/nor/esp_xtensa.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/

#ifndef OPENOCD_FLASH_NOR_ESP_XTENSA_H
Expand Down
22 changes: 22 additions & 0 deletions src/rtos/FreeRTOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,28 @@ static int freertos_get_tasks_details(struct target *target,
return ERROR_FAIL;
}
rtos->thread_details[index].exists = true;
const struct freertos_tls_info *tls_info =
rtos_freertos_get_tls_info(target);
if (tls_info &&
!rtos->thread_details[index].tls_addr) {
struct rtos_reg reg;
retval = freertos_get_thread_reg(rtos,
rtos->thread_details[index].threadid,
tls_info->tls_reg,
&reg);
if (retval == ERROR_OK &&
(reg.size / 8) <=
sizeof(rtos->thread_details[index].
tls_addr)) {
memcpy(
&rtos->thread_details[index].
tls_addr,
reg.value,
reg.size / 8);
rtos->thread_details[index].
tls_addr += tls_info->tls_align;
}
}

if (target->smp) {
struct target *current_target;
Expand Down
46 changes: 26 additions & 20 deletions src/rtos/rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
return rtos_detected;
}

int get_thread_number_by_id(struct target *target, threadid_t threadid) {
if ((target->rtos) && (target->rtos->thread_details)) {
for (int thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid &&
target->rtos->thread_details[thread_num].exists)
return thread_num;
}
}
return -1;
}

int rtos_thread_packet(struct connection *connection, char const *packet, int packet_size)
{
struct target *target = get_target_from_connection(connection);
Expand All @@ -333,18 +344,9 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
if ((target->rtos) && (target->rtos->thread_details) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);

if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
if (target->rtos->thread_details[thread_num].exists)
found = thread_num;
}
}
}
int found = get_thread_number_by_id(target, threadid);
if (found == -1) {
gdb_put_packet(connection, "E01", 3); /* thread not found */
return ERROR_OK;
Expand Down Expand Up @@ -416,6 +418,19 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
} else if (strncmp(packet, "qsThreadInfo", 12) == 0) {
gdb_put_packet(connection, "l", 1);
return ERROR_OK;
} else if (strncmp(packet, "qGetTLSAddr", 11) == 0) {
threadid_t threadid;
target_addr_t offset;
target_addr_t lm;
sscanf(packet, "qGetTLSAddr:%" SCNx64 ",%" SCNx64 ",%" SCNx64, &threadid, &offset, &lm);
int found = get_thread_number_by_id(target, threadid);
if (found == -1 || target->rtos->thread_details[found].tls_addr == 0)
return GDB_THREAD_PACKET_NOT_CONSUMED;
target_addr_t tlv_addr = target->rtos->thread_details[found].tls_addr + offset;
char answer[sizeof(tlv_addr) * 2 + 1] = {0}; // hex addr + '\0'
sprintf(answer, "%" PRIx64, tlv_addr);
gdb_put_packet(connection, answer, strlen(answer));
return ERROR_OK;
} else if (strncmp(packet, "qAttached", 9) == 0) {
gdb_put_packet(connection, "1", 1);
return ERROR_OK;
Expand All @@ -438,17 +453,8 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
return ERROR_OK;
} else if (packet[0] == 'T') { /* Is thread alive? */
threadid_t threadid;
int found = -1;
sscanf(packet, "T%" SCNx64, &threadid);
if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
if (target->rtos->thread_details[thread_num].exists)
found = thread_num;
}
}
}
int found = get_thread_number_by_id(target, threadid);
if (found != -1)
gdb_put_packet(connection, "OK", 2); /* thread alive */
else
Expand Down
1 change: 1 addition & 0 deletions src/rtos/rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct thread_detail {
bool exists;
char *thread_name_str;
char *extra_info_str;
target_addr_t tls_addr;
};

struct rtos {
Expand Down
Loading