mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
refactor(apptrace): format apptrace component with astyle
This commit is contained in:
@@ -52,7 +52,6 @@ const static char *TAG = "esp_apptrace";
|
|||||||
|
|
||||||
static uint32_t esp_apptrace_membufs_down_buffer_write_nolock(esp_apptrace_membufs_proto_data_t *proto, uint8_t *data, uint32_t size);
|
static uint32_t esp_apptrace_membufs_down_buffer_write_nolock(esp_apptrace_membufs_proto_data_t *proto, uint8_t *data, uint32_t size);
|
||||||
|
|
||||||
|
|
||||||
esp_err_t esp_apptrace_membufs_init(esp_apptrace_membufs_proto_data_t *proto, const esp_apptrace_mem_block_t blocks_cfg[2])
|
esp_err_t esp_apptrace_membufs_init(esp_apptrace_membufs_proto_data_t *proto, const esp_apptrace_mem_block_t blocks_cfg[2])
|
||||||
{
|
{
|
||||||
// disabled by default
|
// disabled by default
|
||||||
@@ -66,7 +65,7 @@ esp_err_t esp_apptrace_membufs_init(esp_apptrace_membufs_proto_data_t *proto, co
|
|||||||
proto->state.in_block = 0;
|
proto->state.in_block = 0;
|
||||||
#if CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX > 0
|
#if CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX > 0
|
||||||
esp_apptrace_rb_init(&proto->rb_pend, proto->pending_data,
|
esp_apptrace_rb_init(&proto->rb_pend, proto->pending_data,
|
||||||
sizeof(proto->pending_data));
|
sizeof(proto->pending_data));
|
||||||
#endif
|
#endif
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -101,13 +100,13 @@ static esp_err_t esp_apptrace_membufs_swap(esp_apptrace_membufs_proto_data_t *pr
|
|||||||
// TODO: add support for multiple blocks from host, currently there is no need for that
|
// TODO: add support for multiple blocks from host, currently there is no need for that
|
||||||
uint8_t *p = proto->blocks[new_block_num].start + proto->blocks[new_block_num].sz;
|
uint8_t *p = proto->blocks[new_block_num].start + proto->blocks[new_block_num].sz;
|
||||||
ESP_APPTRACE_LOGD("Recvd %" PRIu16 " bytes from host (@ %p) [%x %x %x %x %x %x %x %x .. %x %x %x %x %x %x %x %x]",
|
ESP_APPTRACE_LOGD("Recvd %" PRIu16 " bytes from host (@ %p) [%x %x %x %x %x %x %x %x .. %x %x %x %x %x %x %x %x]",
|
||||||
hdr->block_sz, proto->blocks[new_block_num].start,
|
hdr->block_sz, proto->blocks[new_block_num].start,
|
||||||
*(proto->blocks[new_block_num].start+0), *(proto->blocks[new_block_num].start+1),
|
*(proto->blocks[new_block_num].start + 0), *(proto->blocks[new_block_num].start + 1),
|
||||||
*(proto->blocks[new_block_num].start+2), *(proto->blocks[new_block_num].start+3),
|
*(proto->blocks[new_block_num].start + 2), *(proto->blocks[new_block_num].start + 3),
|
||||||
*(proto->blocks[new_block_num].start+4), *(proto->blocks[new_block_num].start+5),
|
*(proto->blocks[new_block_num].start + 4), *(proto->blocks[new_block_num].start + 5),
|
||||||
*(proto->blocks[new_block_num].start+6), *(proto->blocks[new_block_num].start+7),
|
*(proto->blocks[new_block_num].start + 6), *(proto->blocks[new_block_num].start + 7),
|
||||||
*(p-8), *(p-7), *(p-6), *(p-5), *(p-4), *(p-3), *(p-2), *(p-1));
|
*(p - 8), *(p - 7), *(p - 6), *(p - 5), *(p - 4), *(p - 3), *(p - 2), *(p - 1));
|
||||||
uint32_t sz = esp_apptrace_membufs_down_buffer_write_nolock(proto, (uint8_t *)(hdr+1), hdr->block_sz);
|
uint32_t sz = esp_apptrace_membufs_down_buffer_write_nolock(proto, (uint8_t *)(hdr + 1), hdr->block_sz);
|
||||||
if (sz != hdr->block_sz) {
|
if (sz != hdr->block_sz) {
|
||||||
ESP_APPTRACE_LOGE("Failed to write %" PRIu32 " bytes to down buffer (%" PRIu16 " %" PRIu32 ")!", hdr->block_sz - sz, hdr->block_sz, sz);
|
ESP_APPTRACE_LOGE("Failed to write %" PRIu32 " bytes to down buffer (%" PRIu16 " %" PRIu32 ")!", hdr->block_sz - sz, hdr->block_sz, sz);
|
||||||
}
|
}
|
||||||
@@ -129,8 +128,8 @@ static esp_err_t esp_apptrace_membufs_swap(esp_apptrace_membufs_proto_data_t *pr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ESP_APPTRACE_LOGD("Pump %d pend bytes [%x %x %x %x : %x %x %x %x : %x %x %x %x : %x %x...%x %x]",
|
ESP_APPTRACE_LOGD("Pump %d pend bytes [%x %x %x %x : %x %x %x %x : %x %x %x %x : %x %x...%x %x]",
|
||||||
read_sz, *(ptr+0), *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
|
read_sz, *(ptr + 0), *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4),
|
||||||
*(ptr+5), *(ptr+6), *(ptr+7), *(ptr+8), *(ptr+9), *(ptr+10), *(ptr+11), *(ptr+12), *(ptr+13), *(ptr+read_sz-2), *(ptr+read_sz-1));
|
*(ptr + 5), *(ptr + 6), *(ptr + 7), *(ptr + 8), *(ptr + 9), *(ptr + 10), *(ptr + 11), *(ptr + 12), *(ptr + 13), *(ptr + read_sz - 2), *(ptr + read_sz - 1));
|
||||||
memcpy(proto->blocks[new_block_num].start + proto->state.markers[new_block_num], ptr, read_sz);
|
memcpy(proto->blocks[new_block_num].start + proto->state.markers[new_block_num], ptr, read_sz);
|
||||||
proto->state.markers[new_block_num] += read_sz;
|
proto->state.markers[new_block_num] += read_sz;
|
||||||
}
|
}
|
||||||
@@ -209,7 +208,7 @@ static uint32_t esp_apptrace_membufs_down_buffer_write_nolock(esp_apptrace_membu
|
|||||||
|
|
||||||
while (total_sz < size) {
|
while (total_sz < size) {
|
||||||
ESP_APPTRACE_LOGD("esp_apptrace_trax_down_buffer_write_nolock WRS %" PRIu32 "-%" PRIu32 "-%" PRIu32 " %" PRIu32, proto->rb_down.wr, proto->rb_down.rd,
|
ESP_APPTRACE_LOGD("esp_apptrace_trax_down_buffer_write_nolock WRS %" PRIu32 "-%" PRIu32 "-%" PRIu32 " %" PRIu32, proto->rb_down.wr, proto->rb_down.rd,
|
||||||
proto->rb_down.cur_size, size);
|
proto->rb_down.cur_size, size);
|
||||||
uint32_t wr_sz = esp_apptrace_rb_write_size_get(&proto->rb_down);
|
uint32_t wr_sz = esp_apptrace_rb_write_size_get(&proto->rb_down);
|
||||||
if (wr_sz == 0) {
|
if (wr_sz == 0) {
|
||||||
break;
|
break;
|
||||||
@@ -319,10 +318,10 @@ uint8_t *esp_apptrace_membufs_up_buffer_get(esp_apptrace_membufs_proto_data_t *p
|
|||||||
if (1) {
|
if (1) {
|
||||||
#endif
|
#endif
|
||||||
if (ESP_APPTRACE_INBLOCK_MARKER(proto) + ESP_APPTRACE_USR_BLOCK_RAW_SZ(size) > ESP_APPTRACE_INBLOCK(proto)->sz) {
|
if (ESP_APPTRACE_INBLOCK_MARKER(proto) + ESP_APPTRACE_USR_BLOCK_RAW_SZ(size) > ESP_APPTRACE_INBLOCK(proto)->sz) {
|
||||||
#if CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX > 0
|
#if CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX > 0
|
||||||
ESP_APPTRACE_LOGD("Block full. Get %" PRIu32 " bytes from PEND buffer", size);
|
ESP_APPTRACE_LOGD("Block full. Get %" PRIu32 " bytes from PEND buffer", size);
|
||||||
buf_ptr = esp_apptrace_rb_produce(&proto->rb_pend, ESP_APPTRACE_USR_BLOCK_RAW_SZ(size));
|
buf_ptr = esp_apptrace_rb_produce(&proto->rb_pend, ESP_APPTRACE_USR_BLOCK_RAW_SZ(size));
|
||||||
#endif
|
#endif
|
||||||
if (buf_ptr == NULL) {
|
if (buf_ptr == NULL) {
|
||||||
int pended_buf;
|
int pended_buf;
|
||||||
ESP_APPTRACE_LOGD(" full. Get %" PRIu32 " bytes from pend buffer", size);
|
ESP_APPTRACE_LOGD(" full. Get %" PRIu32 " bytes from pend buffer", size);
|
||||||
@@ -372,10 +371,11 @@ esp_err_t esp_apptrace_membufs_flush_nolock(esp_apptrace_membufs_proto_data_t *p
|
|||||||
ESP_APPTRACE_LOGD("Try to flush %" PRIu32 " bytes", ESP_APPTRACE_INBLOCK_MARKER(proto));
|
ESP_APPTRACE_LOGD("Try to flush %" PRIu32 " bytes", ESP_APPTRACE_INBLOCK_MARKER(proto));
|
||||||
res = esp_apptrace_membufs_swap_waitus(proto, tmo);
|
res = esp_apptrace_membufs_swap_waitus(proto, tmo);
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
if (res == ESP_ERR_TIMEOUT)
|
if (res == ESP_ERR_TIMEOUT) {
|
||||||
ESP_APPTRACE_LOGW("Failed to switch to another block in %" PRIi32 " us!", (int32_t)tmo->elapsed);
|
ESP_APPTRACE_LOGW("Failed to switch to another block in %" PRIi32 " us!", (int32_t)tmo->elapsed);
|
||||||
else
|
} else {
|
||||||
ESP_APPTRACE_LOGE("Failed to switch to another block, res: %d", res);
|
ESP_APPTRACE_LOGE("Failed to switch to another block, res: %d", res);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ void esp_apptrace_log_unlock(void)
|
|||||||
|
|
||||||
esp_err_t esp_apptrace_tmo_check(esp_apptrace_tmo_t *tmo)
|
esp_err_t esp_apptrace_tmo_check(esp_apptrace_tmo_t *tmo)
|
||||||
{
|
{
|
||||||
if (tmo->tmo != (int64_t)-1) {
|
if (tmo->tmo != (int64_t) -1) {
|
||||||
tmo->elapsed = esp_timer_get_time() - tmo->start;
|
tmo->elapsed = esp_timer_get_time() - tmo->start;
|
||||||
if (tmo->elapsed >= tmo->tmo) {
|
if (tmo->elapsed >= tmo->tmo) {
|
||||||
return ESP_ERR_TIMEOUT;
|
return ESP_ERR_TIMEOUT;
|
||||||
|
@@ -73,7 +73,7 @@ void gcov_create_task(void *arg)
|
|||||||
{
|
{
|
||||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||||
xTaskCreatePinnedToCore(&gcov_dump_task, "gcov_dump_task", CONFIG_APPTRACE_GCOV_DUMP_TASK_STACK_SIZE,
|
xTaskCreatePinnedToCore(&gcov_dump_task, "gcov_dump_task", CONFIG_APPTRACE_GCOV_DUMP_TASK_STACK_SIZE,
|
||||||
(void *)&s_gcov_task_running, configMAX_PRIORITIES - 1, NULL, 0);
|
(void *)&s_gcov_task_running, configMAX_PRIORITIES - 1, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IRAM_ATTR
|
static IRAM_ATTR
|
||||||
@@ -180,7 +180,7 @@ int gcov_rtio_feof(void *stream)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gcov_rtio_setbuf(void *arg1 __attribute__ ((unused)), void *arg2 __attribute__ ((unused)))
|
void gcov_rtio_setbuf(void *arg1 __attribute__((unused)), void *arg2 __attribute__((unused)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ esp_err_t heap_trace_init_tohost(void)
|
|||||||
esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
|
esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
|
||||||
{
|
{
|
||||||
#if CONFIG_APPTRACE_SV_ENABLE
|
#if CONFIG_APPTRACE_SV_ENABLE
|
||||||
esp_err_t ret = esp_sysview_heap_trace_start((uint32_t)-1);
|
esp_err_t ret = esp_sysview_heap_trace_start((uint32_t) -1);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -152,7 +152,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
|||||||
cmd_args.mode_len = strlen(mode) + 1;
|
cmd_args.mode_len = strlen(mode) + 1;
|
||||||
|
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FOPEN, esp_apptrace_fopen_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FOPEN, esp_apptrace_fopen_args_prepare,
|
||||||
&cmd_args, cmd_args.path_len+cmd_args.mode_len);
|
&cmd_args, cmd_args.path_len + cmd_args.mode_len);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -182,7 +182,7 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream)
|
|||||||
|
|
||||||
cmd_args.file = stream;
|
cmd_args.file = stream;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FCLOSE, esp_apptrace_fclose_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FCLOSE, esp_apptrace_fclose_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args));
|
&cmd_args, sizeof(cmd_args));
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return EOF;
|
return EOF;
|
||||||
@@ -211,7 +211,7 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
|||||||
{
|
{
|
||||||
esp_apptrace_fwrite_args_t cmd_args;
|
esp_apptrace_fwrite_args_t cmd_args;
|
||||||
|
|
||||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fwrite f %p l %d", stream, size*nmemb);
|
ESP_EARLY_LOGV(TAG, "esp_apptrace_fwrite f %p l %d", stream, size * nmemb);
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -221,7 +221,7 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
|||||||
cmd_args.size = size * nmemb;
|
cmd_args.size = size * nmemb;
|
||||||
cmd_args.file = stream;
|
cmd_args.file = stream;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FWRITE, esp_apptrace_fwrite_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FWRITE, esp_apptrace_fwrite_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args.file)+cmd_args.size);
|
&cmd_args, sizeof(cmd_args.file) + cmd_args.size);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -253,7 +253,7 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
|||||||
{
|
{
|
||||||
esp_apptrace_fread_args_t cmd_args;
|
esp_apptrace_fread_args_t cmd_args;
|
||||||
|
|
||||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fread f %p l %d", stream, size*nmemb);
|
ESP_EARLY_LOGV(TAG, "esp_apptrace_fread f %p l %d", stream, size * nmemb);
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -262,7 +262,7 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
|||||||
cmd_args.size = size * nmemb;
|
cmd_args.size = size * nmemb;
|
||||||
cmd_args.file = stream;
|
cmd_args.file = stream;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FREAD, esp_apptrace_fread_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FREAD, esp_apptrace_fread_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args));
|
&cmd_args, sizeof(cmd_args));
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -288,7 +288,7 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
|||||||
* fread(buf, 1 ,size, file);
|
* fread(buf, 1 ,size, file);
|
||||||
* So, total read bytes count returns
|
* So, total read bytes count returns
|
||||||
*/
|
*/
|
||||||
return resp/size; // return the number of items read
|
return resp / size; // return the number of items read
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esp_apptrace_fseek_args_prepare(uint8_t *buf, void *priv)
|
static void esp_apptrace_fseek_args_prepare(uint8_t *buf, void *priv)
|
||||||
@@ -310,7 +310,7 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
|||||||
cmd_args.offset = offset;
|
cmd_args.offset = offset;
|
||||||
cmd_args.whence = whence;
|
cmd_args.whence = whence;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FSEEK, esp_apptrace_fseek_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FSEEK, esp_apptrace_fseek_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args));
|
&cmd_args, sizeof(cmd_args));
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -340,7 +340,7 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
|||||||
|
|
||||||
cmd_args.file = stream;
|
cmd_args.file = stream;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FTELL, esp_apptrace_ftell_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FTELL, esp_apptrace_ftell_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args));
|
&cmd_args, sizeof(cmd_args));
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -380,7 +380,7 @@ int esp_apptrace_feof(esp_apptrace_dest_t dest, void *stream)
|
|||||||
|
|
||||||
cmd_args.file = stream;
|
cmd_args.file = stream;
|
||||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FEOF, esp_apptrace_feof_args_prepare,
|
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FEOF, esp_apptrace_feof_args_prepare,
|
||||||
&cmd_args, sizeof(cmd_args));
|
&cmd_args, sizeof(cmd_args));
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||||
return EOF;
|
return EOF;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -19,9 +19,9 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESP_APPTRACE_DEST_JTAG = 1, ///< JTAG destination
|
ESP_APPTRACE_DEST_JTAG = 1, ///< JTAG destination
|
||||||
ESP_APPTRACE_DEST_TRAX = ESP_APPTRACE_DEST_JTAG, ///< xxx_TRAX name is obsolete, use more common xxx_JTAG
|
ESP_APPTRACE_DEST_TRAX = ESP_APPTRACE_DEST_JTAG, ///< xxx_TRAX name is obsolete, use more common xxx_JTAG
|
||||||
ESP_APPTRACE_DEST_UART, ///< UART destination
|
ESP_APPTRACE_DEST_UART, ///< UART destination
|
||||||
ESP_APPTRACE_DEST_MAX = ESP_APPTRACE_DEST_UART+1,
|
ESP_APPTRACE_DEST_MAX = ESP_APPTRACE_DEST_UART + 1,
|
||||||
ESP_APPTRACE_DEST_NUM
|
ESP_APPTRACE_DEST_NUM
|
||||||
} esp_apptrace_dest_t;
|
} esp_apptrace_dest_t;
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ bool esp_apptrace_host_is_connected(esp_apptrace_dest_t dest);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Opens file on host.
|
* @brief Opens file on host.
|
||||||
* This function has the same semantic as 'fopen' except for the first argument.
|
* This function has the same semantic as 'fopen' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param path Path to file.
|
* @param path Path to file.
|
||||||
@@ -183,7 +183,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Closes file on host.
|
* @brief Closes file on host.
|
||||||
* This function has the same semantic as 'fclose' except for the first argument.
|
* This function has the same semantic as 'fclose' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
@@ -194,11 +194,11 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes to file on host.
|
* @brief Writes to file on host.
|
||||||
* This function has the same semantic as 'fwrite' except for the first argument.
|
* This function has the same semantic as 'fwrite' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param ptr Address of data to write.
|
* @param ptr Address of data to write.
|
||||||
* @param size Size of an item.
|
* @param size Size of an item.
|
||||||
* @param nmemb Number of items to write.
|
* @param nmemb Number of items to write.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
*
|
*
|
||||||
@@ -208,11 +208,11 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read file on host.
|
* @brief Read file on host.
|
||||||
* This function has the same semantic as 'fread' except for the first argument.
|
* This function has the same semantic as 'fread' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param ptr Address to store read data.
|
* @param ptr Address to store read data.
|
||||||
* @param size Size of an item.
|
* @param size Size of an item.
|
||||||
* @param nmemb Number of items to read.
|
* @param nmemb Number of items to read.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
*
|
*
|
||||||
@@ -222,7 +222,7 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set position indicator in file on host.
|
* @brief Set position indicator in file on host.
|
||||||
* This function has the same semantic as 'fseek' except for the first argument.
|
* This function has the same semantic as 'fseek' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
@@ -235,7 +235,7 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get current position indicator for file on host.
|
* @brief Get current position indicator for file on host.
|
||||||
* This function has the same semantic as 'ftell' except for the first argument.
|
* This function has the same semantic as 'ftell' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
@@ -246,8 +246,8 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Indicates to the host that all file operations are complete.
|
* @brief Indicates to the host that all file operations are complete.
|
||||||
* This function should be called after all file operations are finished and
|
* This function should be called after all file operations are finished and
|
||||||
* indicate to the host that it can perform cleanup operations (close open files etc.).
|
* indicate to the host that it can perform cleanup operations (close open files etc.).
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
*
|
*
|
||||||
@@ -257,7 +257,7 @@ int esp_apptrace_fstop(esp_apptrace_dest_t dest);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Test end-of-file indicator on a stream.
|
* @brief Test end-of-file indicator on a stream.
|
||||||
* This function has the same semantic as 'feof' except for the first argument.
|
* This function has the same semantic as 'feof' except for the first argument.
|
||||||
*
|
*
|
||||||
* @param dest Indicates HW interface to use.
|
* @param dest Indicates HW interface to use.
|
||||||
* @param stream File handle returned by esp_apptrace_fopen.
|
* @param stream File handle returned by esp_apptrace_fopen.
|
||||||
@@ -268,7 +268,7 @@ int esp_apptrace_feof(esp_apptrace_dest_t dest, void *stream);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Triggers gcov info dump.
|
* @brief Triggers gcov info dump.
|
||||||
* This function waits for the host to connect to target before dumping data.
|
* This function waits for the host to connect to target before dumping data.
|
||||||
*/
|
*/
|
||||||
void esp_gcov_dump(void);
|
void esp_gcov_dump(void);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -32,12 +32,12 @@ typedef struct {
|
|||||||
* @brief Initializes timeout structure.
|
* @brief Initializes timeout structure.
|
||||||
*
|
*
|
||||||
* @param tmo Pointer to timeout structure to be initialized.
|
* @param tmo Pointer to timeout structure to be initialized.
|
||||||
* @param user_tmo Timeout value (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
|
* @param user_tmo Timeout value (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
|
||||||
*/
|
*/
|
||||||
static inline void esp_apptrace_tmo_init(esp_apptrace_tmo_t *tmo, uint32_t user_tmo)
|
static inline void esp_apptrace_tmo_init(esp_apptrace_tmo_t *tmo, uint32_t user_tmo)
|
||||||
{
|
{
|
||||||
tmo->start = esp_timer_get_time();
|
tmo->start = esp_timer_get_time();
|
||||||
tmo->tmo = user_tmo == ESP_APPTRACE_TMO_INFINITE ? (int64_t)-1 : (int64_t)user_tmo;
|
tmo->tmo = user_tmo == ESP_APPTRACE_TMO_INFINITE ? (int64_t) -1 : (int64_t)user_tmo;
|
||||||
tmo->elapsed = 0;
|
tmo->elapsed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ esp_err_t esp_apptrace_tmo_check(esp_apptrace_tmo_t *tmo);
|
|||||||
|
|
||||||
static inline uint32_t esp_apptrace_tmo_remaining_us(esp_apptrace_tmo_t *tmo)
|
static inline uint32_t esp_apptrace_tmo_remaining_us(esp_apptrace_tmo_t *tmo)
|
||||||
{
|
{
|
||||||
return tmo->tmo != (int64_t)-1 ? (tmo->elapsed - tmo->tmo) : ESP_APPTRACE_TMO_INFINITE;
|
return tmo->tmo != (int64_t) -1 ? (tmo->elapsed - tmo->tmo) : ESP_APPTRACE_TMO_INFINITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tracing module synchronization lock */
|
/** Tracing module synchronization lock */
|
||||||
@@ -94,7 +94,7 @@ esp_err_t esp_apptrace_lock_give(esp_apptrace_lock_t *lock);
|
|||||||
/** Ring buffer control structure.
|
/** Ring buffer control structure.
|
||||||
*
|
*
|
||||||
* @note For purposes of application tracing module if there is no enough space for user data and write pointer can be wrapped
|
* @note For purposes of application tracing module if there is no enough space for user data and write pointer can be wrapped
|
||||||
* current ring buffer size can be temporarily shrinked in order to provide buffer with requested size.
|
* current ring buffer size can be temporarily shrunk in order to provide buffer with requested size.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *data; ///< pointer to data storage
|
uint8_t *data; ///< pointer to data storage
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
|
|
||||||
#define APPTRACE_DEST_UART (CONFIG_APPTRACE_DEST_UART0 | CONFIG_APPTRACE_DEST_UART1 | CONFIG_APPTRACE_DEST_UART2)
|
#define APPTRACE_DEST_UART (CONFIG_APPTRACE_DEST_UART0 | CONFIG_APPTRACE_DEST_UART1 | CONFIG_APPTRACE_DEST_UART2)
|
||||||
|
|
||||||
#define APP_TRACE_MAX_TX_BUFF_UART CONFIG_APPTRACE_UART_TX_BUFF_SIZE
|
#define APP_TRACE_MAX_TX_BUFF_UART CONFIG_APPTRACE_UART_TX_BUFF_SIZE
|
||||||
@@ -59,7 +58,7 @@ const static char *TAG = "esp_apptrace_uart";
|
|||||||
|
|
||||||
esp_apptrace_hw_t *esp_apptrace_uart_hw_get(int num, void **data)
|
esp_apptrace_hw_t *esp_apptrace_uart_hw_get(int num, void **data)
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG,"esp_apptrace_uart_hw_get - %i", num);
|
ESP_LOGD(TAG, "esp_apptrace_uart_hw_get - %i", num);
|
||||||
#if APPTRACE_DEST_UART
|
#if APPTRACE_DEST_UART
|
||||||
static esp_apptrace_uart_data_t s_uart_hw_data = {
|
static esp_apptrace_uart_data_t s_uart_hw_data = {
|
||||||
};
|
};
|
||||||
@@ -69,7 +68,7 @@ esp_apptrace_hw_t *esp_apptrace_uart_hw_get(int num, void **data)
|
|||||||
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_up_buffer_put,
|
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_up_buffer_put,
|
||||||
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_uart_flush_nolock,
|
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_uart_flush_nolock,
|
||||||
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_uart_flush,
|
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_uart_flush,
|
||||||
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t ))esp_apptrace_uart_down_buffer_config,
|
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t))esp_apptrace_uart_down_buffer_config,
|
||||||
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_down_buffer_get,
|
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_down_buffer_get,
|
||||||
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_down_buffer_put,
|
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_uart_down_buffer_put,
|
||||||
.host_is_connected = (bool (*)(void *))esp_apptrace_uart_host_is_connected,
|
.host_is_connected = (bool (*)(void *))esp_apptrace_uart_host_is_connected,
|
||||||
@@ -109,7 +108,6 @@ static inline void esp_apptrace_uart_hw_init(void)
|
|||||||
ESP_APPTRACE_LOGI("Initialized UART on CPU%d", esp_cpu_get_core_id());
|
ESP_APPTRACE_LOGI("Initialized UART on CPU%d", esp_cpu_get_core_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
/***************************** Apptrace HW iface *****************************************/
|
/***************************** Apptrace HW iface *****************************************/
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
@@ -128,9 +126,8 @@ static esp_err_t esp_apptrace_send_uart_data(esp_apptrace_uart_data_t *hw_data,
|
|||||||
len_free = out_position - hw_data->tx_data_buff_in;
|
len_free = out_position - hw_data->tx_data_buff_in;
|
||||||
}
|
}
|
||||||
int check_len = APP_TRACE_MAX_TX_BUFF_UART - hw_data->tx_data_buff_in;
|
int check_len = APP_TRACE_MAX_TX_BUFF_UART - hw_data->tx_data_buff_in;
|
||||||
if (size <= len_free)
|
if (size <= len_free) {
|
||||||
{
|
if (check_len >= size) {
|
||||||
if ( check_len >= size) {
|
|
||||||
memcpy(&hw_data->tx_data_buff[hw_data->tx_data_buff_in], data, size);
|
memcpy(&hw_data->tx_data_buff[hw_data->tx_data_buff_in], data, size);
|
||||||
hw_data->tx_data_buff_in += size;
|
hw_data->tx_data_buff_in += size;
|
||||||
} else {
|
} else {
|
||||||
@@ -183,13 +180,11 @@ static void esp_apptrace_send_uart_tx_task(void *arg)
|
|||||||
while (1) {
|
while (1) {
|
||||||
send_buff_data(hw_data, &tmo);
|
send_buff_data(hw_data, &tmo);
|
||||||
vTaskDelay(10);
|
vTaskDelay(10);
|
||||||
if (hw_data->circular_buff_overflow == true)
|
if (hw_data->circular_buff_overflow == true) {
|
||||||
{
|
|
||||||
hw_data->circular_buff_overflow = false;
|
hw_data->circular_buff_overflow = false;
|
||||||
ESP_LOGE(TAG, "Buffer overflow. Please increase UART baudrate, or increase UART TX ring buffer size in menuconfig.");
|
ESP_LOGE(TAG, "Buffer overflow. Please increase UART baudrate, or increase UART TX ring buffer size in menuconfig.");
|
||||||
}
|
}
|
||||||
if (hw_data->message_buff_overflow == true)
|
if (hw_data->message_buff_overflow == true) {
|
||||||
{
|
|
||||||
hw_data->message_buff_overflow = false;
|
hw_data->message_buff_overflow = false;
|
||||||
ESP_LOGE(TAG, "Message size more then message buffer!");
|
ESP_LOGE(TAG, "Message size more then message buffer!");
|
||||||
}
|
}
|
||||||
@@ -202,15 +197,14 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data)
|
|||||||
{
|
{
|
||||||
int core_id = esp_cpu_get_core_id();
|
int core_id = esp_cpu_get_core_id();
|
||||||
if (core_id == 0) {
|
if (core_id == 0) {
|
||||||
hw_data->tx_data_buff = (uint8_t *)heap_caps_malloc(APP_TRACE_MAX_TX_BUFF_UART, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
hw_data->tx_data_buff = (uint8_t *)heap_caps_malloc(APP_TRACE_MAX_TX_BUFF_UART, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||||
if (hw_data->tx_data_buff == NULL){
|
if (hw_data->tx_data_buff == NULL) {
|
||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
hw_data->tx_data_buff_in = 0;
|
hw_data->tx_data_buff_in = 0;
|
||||||
hw_data->tx_data_buff_out = 0;
|
hw_data->tx_data_buff_out = 0;
|
||||||
hw_data->tx_msg_buff = (uint8_t *)heap_caps_malloc(APP_TRACE_MAX_TX_MSG_UART, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
hw_data->tx_msg_buff = (uint8_t *)heap_caps_malloc(APP_TRACE_MAX_TX_MSG_UART, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||||
if (hw_data->tx_msg_buff == NULL)
|
if (hw_data->tx_msg_buff == NULL) {
|
||||||
{
|
|
||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
hw_data->tx_msg_buff_size = 0;
|
hw_data->tx_msg_buff_size = 0;
|
||||||
@@ -222,8 +216,9 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data)
|
|||||||
|
|
||||||
int source_clk = UART_SCLK_DEFAULT;
|
int source_clk = UART_SCLK_DEFAULT;
|
||||||
#if SOC_UART_LP_NUM > 0
|
#if SOC_UART_LP_NUM > 0
|
||||||
if (hw_data->port_num >= SOC_UART_HP_NUM)
|
if (hw_data->port_num >= SOC_UART_HP_NUM) {
|
||||||
source_clk = LP_UART_SCLK_DEFAULT;
|
source_clk = LP_UART_SCLK_DEFAULT;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const uart_config_t uart_config = {
|
const uart_config_t uart_config = {
|
||||||
@@ -244,7 +239,9 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data)
|
|||||||
assert((err == ESP_OK) && "Not possible to configure UART RX/TX pins. Please check and change menuconfig parameters!");
|
assert((err == ESP_OK) && "Not possible to configure UART RX/TX pins. Please check and change menuconfig parameters!");
|
||||||
|
|
||||||
int uart_prio = CONFIG_APPTRACE_UART_TASK_PRIO;
|
int uart_prio = CONFIG_APPTRACE_UART_TASK_PRIO;
|
||||||
if (uart_prio >= (configMAX_PRIORITIES-1)) uart_prio = configMAX_PRIORITIES - 1;
|
if (uart_prio >= (configMAX_PRIORITIES - 1)) {
|
||||||
|
uart_prio = configMAX_PRIORITIES - 1;
|
||||||
|
}
|
||||||
err = xTaskCreate(esp_apptrace_send_uart_tx_task, "app_trace_uart_tx_task", 2500, hw_data, uart_prio, NULL);
|
err = xTaskCreate(esp_apptrace_send_uart_tx_task, "app_trace_uart_tx_task", 2500, hw_data, uart_prio, NULL);
|
||||||
assert((err == pdPASS) && "Not possible to configure UART. Not possible to create task!");
|
assert((err == pdPASS) && "Not possible to configure UART. Not possible to create task!");
|
||||||
|
|
||||||
@@ -266,8 +263,7 @@ static uint8_t *esp_apptrace_uart_up_buffer_get(esp_apptrace_uart_data_t *hw_dat
|
|||||||
hw_data->message_buff_overflow = true;
|
hw_data->message_buff_overflow = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (hw_data->tx_msg_buff_size != 0)
|
if (hw_data->tx_msg_buff_size != 0) {
|
||||||
{
|
|
||||||
// A previous message was not sent.
|
// A previous message was not sent.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -296,7 +292,7 @@ static esp_err_t esp_apptrace_uart_up_buffer_put(esp_apptrace_uart_data_t *hw_da
|
|||||||
static void esp_apptrace_uart_down_buffer_config(esp_apptrace_uart_data_t *hw_data, uint8_t *buf, uint32_t size)
|
static void esp_apptrace_uart_down_buffer_config(esp_apptrace_uart_data_t *hw_data, uint8_t *buf, uint32_t size)
|
||||||
{
|
{
|
||||||
hw_data->down_buffer = (uint8_t *)malloc(size);
|
hw_data->down_buffer = (uint8_t *)malloc(size);
|
||||||
if (hw_data->down_buffer == NULL){
|
if (hw_data->down_buffer == NULL) {
|
||||||
assert(false && "Failed to allocate apptrace uart down buffer!");
|
assert(false && "Failed to allocate apptrace uart down buffer!");
|
||||||
}
|
}
|
||||||
hw_data->down_buffer_size = size;
|
hw_data->down_buffer_size = size;
|
||||||
@@ -323,7 +319,7 @@ static uint8_t *esp_apptrace_uart_down_buffer_get(esp_apptrace_uart_data_t *hw_d
|
|||||||
}
|
}
|
||||||
*size = uart_fifolen;
|
*size = uart_fifolen;
|
||||||
ptr = hw_data->down_buffer;
|
ptr = hw_data->down_buffer;
|
||||||
*size =uart_read_bytes(hw_data->port_num, ptr, uart_fifolen, 0);
|
*size = uart_read_bytes(hw_data->port_num, ptr, uart_fifolen, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esp_apptrace_uart_unlock(hw_data) != ESP_OK) {
|
if (esp_apptrace_uart_unlock(hw_data) != ESP_OK) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
*/
|
*/
|
||||||
@@ -54,7 +54,6 @@ static esp_err_t esp_apptrace_riscv_buffer_swap(uint32_t new_block_id, uint32_t
|
|||||||
static esp_err_t esp_apptrace_riscv_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
|
static esp_err_t esp_apptrace_riscv_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
|
||||||
static bool esp_apptrace_riscv_host_data_pending(void);
|
static bool esp_apptrace_riscv_host_data_pending(void);
|
||||||
|
|
||||||
|
|
||||||
const static char *TAG = "esp_apptrace";
|
const static char *TAG = "esp_apptrace";
|
||||||
|
|
||||||
#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
|
#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
|
||||||
@@ -85,7 +84,7 @@ esp_apptrace_hw_t *esp_apptrace_jtag_hw_get(void **data)
|
|||||||
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_up_buffer_put,
|
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_up_buffer_put,
|
||||||
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_riscv_flush_nolock,
|
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_riscv_flush_nolock,
|
||||||
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_riscv_flush,
|
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_riscv_flush,
|
||||||
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t ))esp_apptrace_riscv_down_buffer_config,
|
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t))esp_apptrace_riscv_down_buffer_config,
|
||||||
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_down_buffer_get,
|
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_down_buffer_get,
|
||||||
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_down_buffer_put,
|
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_riscv_down_buffer_put,
|
||||||
.host_is_connected = (bool (*)(void *))esp_apptrace_riscv_host_is_connected,
|
.host_is_connected = (bool (*)(void *))esp_apptrace_riscv_host_is_connected,
|
||||||
@@ -166,8 +165,8 @@ static esp_err_t esp_apptrace_riscv_init(esp_apptrace_riscv_data_t *hw_data)
|
|||||||
s_tracing_ctrl[core_id].mem_blocks = hw_data->membufs.blocks;
|
s_tracing_ctrl[core_id].mem_blocks = hw_data->membufs.blocks;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
ESP_APPTRACE_LOGD("Mem buf[%d] %" PRIu32 " bytes @ %p (%p/%p)", i,
|
ESP_APPTRACE_LOGD("Mem buf[%d] %" PRIu32 " bytes @ %p (%p/%p)", i,
|
||||||
s_tracing_ctrl[core_id].mem_blocks[i].sz, s_tracing_ctrl[core_id].mem_blocks[i].start,
|
s_tracing_ctrl[core_id].mem_blocks[i].sz, s_tracing_ctrl[core_id].mem_blocks[i].start,
|
||||||
&(s_tracing_ctrl[core_id].mem_blocks[i].start), &(s_tracing_ctrl[core_id].mem_blocks[i].sz));
|
&(s_tracing_ctrl[core_id].mem_blocks[i].start), &(s_tracing_ctrl[core_id].mem_blocks[i].sz));
|
||||||
}
|
}
|
||||||
// notify host about control block address
|
// notify host about control block address
|
||||||
int res = esp_apptrace_advertise_ctrl_block(&s_tracing_ctrl[core_id]);
|
int res = esp_apptrace_advertise_ctrl_block(&s_tracing_ctrl[core_id]);
|
||||||
@@ -314,7 +313,7 @@ static __attribute__((noinline)) void esp_apptrace_riscv_buffer_swap_unlock(void
|
|||||||
s_tracing_ctrl[esp_cpu_get_core_id()].stat = 0;
|
s_tracing_ctrl[esp_cpu_get_core_id()].stat = 0;
|
||||||
// TODO: currently host sets breakpoint, use break instruction to stop;
|
// TODO: currently host sets breakpoint, use break instruction to stop;
|
||||||
// it will allow to use ESP_APPTRACE_RISCV_STAT_REG for other purposes
|
// it will allow to use ESP_APPTRACE_RISCV_STAT_REG for other purposes
|
||||||
asm volatile (
|
asm volatile(
|
||||||
" .global __esp_apptrace_riscv_updated\n"
|
" .global __esp_apptrace_riscv_updated\n"
|
||||||
"__esp_apptrace_riscv_updated:\n"); // host will set bp here to resolve collision at streaming start
|
"__esp_apptrace_riscv_updated:\n"); // host will set bp here to resolve collision at streaming start
|
||||||
}
|
}
|
||||||
@@ -332,7 +331,7 @@ static esp_err_t esp_apptrace_riscv_buffer_swap_start(uint32_t curr_block_id)
|
|||||||
uint32_t host_to_read = ESP_APPTRACE_RISCV_BLOCK_LEN_GET(ctrl_reg);
|
uint32_t host_to_read = ESP_APPTRACE_RISCV_BLOCK_LEN_GET(ctrl_reg);
|
||||||
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_RISCV_BLOCK_ID_MSK)) {
|
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_RISCV_BLOCK_ID_MSK)) {
|
||||||
ESP_APPTRACE_LOGD("[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32, esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
ESP_APPTRACE_LOGD("[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32, esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
||||||
curr_block_id & ESP_APPTRACE_RISCV_BLOCK_ID_MSK, curr_block_id);
|
curr_block_id & ESP_APPTRACE_RISCV_BLOCK_ID_MSK, curr_block_id);
|
||||||
res = ESP_ERR_NO_MEM;
|
res = ESP_ERR_NO_MEM;
|
||||||
goto _on_err;
|
goto _on_err;
|
||||||
}
|
}
|
||||||
@@ -348,7 +347,7 @@ static esp_err_t esp_apptrace_riscv_buffer_swap_end(uint32_t new_block_id, uint3
|
|||||||
uint32_t ctrl_reg = s_tracing_ctrl[esp_cpu_get_core_id()].ctrl;
|
uint32_t ctrl_reg = s_tracing_ctrl[esp_cpu_get_core_id()].ctrl;
|
||||||
uint32_t host_connected = ESP_APPTRACE_RISCV_HOST_CONNECT & ctrl_reg;
|
uint32_t host_connected = ESP_APPTRACE_RISCV_HOST_CONNECT & ctrl_reg;
|
||||||
s_tracing_ctrl[esp_cpu_get_core_id()].ctrl = ESP_APPTRACE_RISCV_BLOCK_ID(new_block_id) |
|
s_tracing_ctrl[esp_cpu_get_core_id()].ctrl = ESP_APPTRACE_RISCV_BLOCK_ID(new_block_id) |
|
||||||
host_connected | ESP_APPTRACE_RISCV_BLOCK_LEN(prev_block_len);
|
host_connected | ESP_APPTRACE_RISCV_BLOCK_LEN(prev_block_len);
|
||||||
esp_apptrace_riscv_buffer_swap_unlock();
|
esp_apptrace_riscv_buffer_swap_unlock();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -197,7 +197,6 @@ typedef struct {
|
|||||||
esp_apptrace_membufs_proto_data_t membufs;
|
esp_apptrace_membufs_proto_data_t membufs;
|
||||||
} esp_apptrace_trax_data_t;
|
} esp_apptrace_trax_data_t;
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t esp_apptrace_trax_init(esp_apptrace_trax_data_t *hw_data);
|
static esp_err_t esp_apptrace_trax_init(esp_apptrace_trax_data_t *hw_data);
|
||||||
static esp_err_t esp_apptrace_trax_flush(esp_apptrace_trax_data_t *hw_data, esp_apptrace_tmo_t *tmo);
|
static esp_err_t esp_apptrace_trax_flush(esp_apptrace_trax_data_t *hw_data, esp_apptrace_tmo_t *tmo);
|
||||||
static esp_err_t esp_apptrace_trax_flush_nolock(esp_apptrace_trax_data_t *hw_data, uint32_t min_sz, esp_apptrace_tmo_t *tmo);
|
static esp_err_t esp_apptrace_trax_flush_nolock(esp_apptrace_trax_data_t *hw_data, uint32_t min_sz, esp_apptrace_tmo_t *tmo);
|
||||||
@@ -212,7 +211,6 @@ static esp_err_t esp_apptrace_trax_buffer_swap(uint32_t new_block_id, uint32_t p
|
|||||||
static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
|
static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
|
||||||
static bool esp_apptrace_trax_host_data_pending(void);
|
static bool esp_apptrace_trax_host_data_pending(void);
|
||||||
|
|
||||||
|
|
||||||
const static char *TAG = "esp_apptrace";
|
const static char *TAG = "esp_apptrace";
|
||||||
|
|
||||||
static uint8_t * const s_trax_blocks[] = {
|
static uint8_t * const s_trax_blocks[] = {
|
||||||
@@ -240,7 +238,7 @@ esp_apptrace_hw_t *esp_apptrace_jtag_hw_get(void **data)
|
|||||||
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_up_buffer_put,
|
.put_up_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_up_buffer_put,
|
||||||
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_trax_flush_nolock,
|
.flush_up_buffer_nolock = (esp_err_t (*)(void *, uint32_t, esp_apptrace_tmo_t *))esp_apptrace_trax_flush_nolock,
|
||||||
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_trax_flush,
|
.flush_up_buffer = (esp_err_t (*)(void *, esp_apptrace_tmo_t *))esp_apptrace_trax_flush,
|
||||||
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t ))esp_apptrace_trax_down_buffer_config,
|
.down_buffer_config = (void (*)(void *, uint8_t *, uint32_t))esp_apptrace_trax_down_buffer_config,
|
||||||
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_down_buffer_get,
|
.get_down_buffer = (uint8_t *(*)(void *, uint32_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_down_buffer_get,
|
||||||
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_down_buffer_put,
|
.put_down_buffer = (esp_err_t (*)(void *, uint8_t *, esp_apptrace_tmo_t *))esp_apptrace_trax_down_buffer_put,
|
||||||
.host_is_connected = (bool (*)(void *))esp_apptrace_trax_host_is_connected,
|
.host_is_connected = (bool (*)(void *))esp_apptrace_trax_host_is_connected,
|
||||||
@@ -291,13 +289,13 @@ static inline void esp_apptrace_trax_select_memory_block(int block_num)
|
|||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
DPORT_WRITE_PERI_REG(DPORT_TRACEMEM_MUX_MODE_REG, block_num ? TRACEMEM_MUX_BLK0_ONLY : TRACEMEM_MUX_BLK1_ONLY);
|
DPORT_WRITE_PERI_REG(DPORT_TRACEMEM_MUX_MODE_REG, block_num ? TRACEMEM_MUX_BLK0_ONLY : TRACEMEM_MUX_BLK1_ONLY);
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
WRITE_PERI_REG(DPORT_PMS_OCCUPY_3_REG, block_num ? BIT(TRACEMEM_MUX_BLK0_NUM-4) : BIT(TRACEMEM_MUX_BLK1_NUM-4));
|
WRITE_PERI_REG(DPORT_PMS_OCCUPY_3_REG, block_num ? BIT(TRACEMEM_MUX_BLK0_NUM - 4) : BIT(TRACEMEM_MUX_BLK1_NUM - 4));
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
// select memory block to be exposed to the TRAX module (accessed by host)
|
// select memory block to be exposed to the TRAX module (accessed by host)
|
||||||
uint32_t block_bits = block_num ? TRACEMEM_CORE0_MUX_BLK_BITS(TRACEMEM_MUX_BLK0_NUM)
|
uint32_t block_bits = block_num ? TRACEMEM_CORE0_MUX_BLK_BITS(TRACEMEM_MUX_BLK0_NUM)
|
||||||
: TRACEMEM_CORE0_MUX_BLK_BITS(TRACEMEM_MUX_BLK1_NUM);
|
: TRACEMEM_CORE0_MUX_BLK_BITS(TRACEMEM_MUX_BLK1_NUM);
|
||||||
block_bits |= block_num ? TRACEMEM_CORE1_MUX_BLK_BITS(TRACEMEM_MUX_BLK0_NUM)
|
block_bits |= block_num ? TRACEMEM_CORE1_MUX_BLK_BITS(TRACEMEM_MUX_BLK0_NUM)
|
||||||
: TRACEMEM_CORE1_MUX_BLK_BITS(TRACEMEM_MUX_BLK1_NUM);
|
: TRACEMEM_CORE1_MUX_BLK_BITS(TRACEMEM_MUX_BLK1_NUM);
|
||||||
ESP_EARLY_LOGV(TAG, "Select block %d @ %p (bits 0x%" PRIx32 ")", block_num, s_trax_blocks[block_num], block_bits);
|
ESP_EARLY_LOGV(TAG, "Select block %d @ %p (bits 0x%" PRIx32 ")", block_num, s_trax_blocks[block_num], block_bits);
|
||||||
DPORT_WRITE_PERI_REG(SENSITIVE_INTERNAL_SRAM_USAGE_2_REG, block_bits);
|
DPORT_WRITE_PERI_REG(SENSITIVE_INTERNAL_SRAM_USAGE_2_REG, block_bits);
|
||||||
#endif
|
#endif
|
||||||
@@ -306,11 +304,11 @@ static inline void esp_apptrace_trax_select_memory_block(int block_num)
|
|||||||
static inline void esp_apptrace_trax_memory_enable(void)
|
static inline void esp_apptrace_trax_memory_enable(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
/* Enable trace memory on PRO CPU */
|
/* Enable trace memory on PRO CPU */
|
||||||
DPORT_WRITE_PERI_REG(DPORT_PRO_TRACEMEM_ENA_REG, DPORT_PRO_TRACEMEM_ENA_M);
|
DPORT_WRITE_PERI_REG(DPORT_PRO_TRACEMEM_ENA_REG, DPORT_PRO_TRACEMEM_ENA_M);
|
||||||
#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE == 0
|
#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE == 0
|
||||||
/* Enable trace memory on APP CPU */
|
/* Enable trace memory on APP CPU */
|
||||||
DPORT_WRITE_PERI_REG(DPORT_APP_TRACEMEM_ENA_REG, DPORT_APP_TRACEMEM_ENA_M);
|
DPORT_WRITE_PERI_REG(DPORT_APP_TRACEMEM_ENA_REG, DPORT_APP_TRACEMEM_ENA_M);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -491,7 +489,7 @@ static __attribute__((noinline)) void esp_apptrace_trax_buffer_swap_unlock(void)
|
|||||||
eri_write(ESP_APPTRACE_TRAX_STAT_REG, 0x0);
|
eri_write(ESP_APPTRACE_TRAX_STAT_REG, 0x0);
|
||||||
// TODO: currently host sets breakpoint, use break instruction to stop;
|
// TODO: currently host sets breakpoint, use break instruction to stop;
|
||||||
// it will allow to use ESP_APPTRACE_TRAX_STAT_REG for other purposes
|
// it will allow to use ESP_APPTRACE_TRAX_STAT_REG for other purposes
|
||||||
asm volatile (
|
asm volatile(
|
||||||
" .global __esp_apptrace_trax_eri_updated\n"
|
" .global __esp_apptrace_trax_eri_updated\n"
|
||||||
"__esp_apptrace_trax_eri_updated:\n"); // host will set bp here to resolve collision at streaming start
|
"__esp_apptrace_trax_eri_updated:\n"); // host will set bp here to resolve collision at streaming start
|
||||||
}
|
}
|
||||||
@@ -509,8 +507,8 @@ static esp_err_t esp_apptrace_trax_buffer_swap_start(uint32_t curr_block_id)
|
|||||||
uint32_t host_to_read = ESP_APPTRACE_TRAX_BLOCK_LEN_GET(ctrl_reg);
|
uint32_t host_to_read = ESP_APPTRACE_TRAX_BLOCK_LEN_GET(ctrl_reg);
|
||||||
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK)) {
|
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK)) {
|
||||||
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32,
|
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32,
|
||||||
esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
||||||
curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK, curr_block_id);
|
curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK, curr_block_id);
|
||||||
res = ESP_ERR_NO_MEM;
|
res = ESP_ERR_NO_MEM;
|
||||||
goto _on_err;
|
goto _on_err;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +61,7 @@ static uint8_t s_down_buf[SYSVIEW_DOWN_BUF_SIZE];
|
|||||||
*
|
*
|
||||||
* Parameters
|
* Parameters
|
||||||
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. TRAX destinations only.
|
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. TRAX destinations only.
|
||||||
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
|
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
|
||||||
*
|
*
|
||||||
* Return value
|
* Return value
|
||||||
* None.
|
* None.
|
||||||
@@ -70,15 +70,15 @@ void SEGGER_RTT_ESP_FlushNoLock(unsigned long min_sz, unsigned long tmo)
|
|||||||
{
|
{
|
||||||
esp_err_t res;
|
esp_err_t res;
|
||||||
if (s_events_buf_filled > 0) {
|
if (s_events_buf_filled > 0) {
|
||||||
res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, s_events_buf, s_events_buf_filled, tmo);
|
res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, s_events_buf, s_events_buf_filled, tmo);
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to flush buffered events (%d)!", res);
|
ESP_LOGE(TAG, "Failed to flush buffered events (%d)!", res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// flush even if we failed to write buffered events, because no new events will be sent after STOP
|
// flush even if we failed to write buffered events, because no new events will be sent after STOP
|
||||||
res = esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_SYSVIEW, min_sz, tmo);
|
res = esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_SYSVIEW, min_sz, tmo);
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to flush apptrace data (%d)!", res);
|
ESP_LOGE(TAG, "Failed to flush apptrace data (%d)!", res);
|
||||||
}
|
}
|
||||||
s_events_buf_filled = 0;
|
s_events_buf_filled = 0;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ void SEGGER_RTT_ESP_FlushNoLock(unsigned long min_sz, unsigned long tmo)
|
|||||||
*
|
*
|
||||||
* Parameters
|
* Parameters
|
||||||
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. TRAX destinations only.
|
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. TRAX destinations only.
|
||||||
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
|
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
|
||||||
*
|
*
|
||||||
* Return value
|
* Return value
|
||||||
* None.
|
* None.
|
||||||
@@ -121,13 +121,14 @@ void SEGGER_RTT_ESP_Flush(unsigned long min_sz, unsigned long tmo)
|
|||||||
* Return value
|
* Return value
|
||||||
* Number of bytes that have been read.
|
* Number of bytes that have been read.
|
||||||
*/
|
*/
|
||||||
unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize) {
|
unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize)
|
||||||
uint32_t size = BufferSize;
|
{
|
||||||
esp_err_t res = esp_apptrace_read(ESP_APPTRACE_DEST_SYSVIEW, pData, &size, 0);
|
uint32_t size = BufferSize;
|
||||||
if (res != ESP_OK) {
|
esp_err_t res = esp_apptrace_read(ESP_APPTRACE_DEST_SYSVIEW, pData, &size, 0);
|
||||||
return 0;
|
if (res != ESP_OK) {
|
||||||
}
|
return 0;
|
||||||
return size;
|
}
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -154,80 +155,79 @@ unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned Buffe
|
|||||||
* and may only be called after RTT has been initialized.
|
* and may only be called after RTT has been initialized.
|
||||||
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
|
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
|
||||||
*/
|
*/
|
||||||
unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
|
unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes)
|
||||||
uint8_t *pbuf = (uint8_t *)pBuffer;
|
{
|
||||||
uint8_t event_id = *pbuf;
|
uint8_t *pbuf = (uint8_t *)pBuffer;
|
||||||
|
uint8_t event_id = *pbuf;
|
||||||
#if CONFIG_APPTRACE_SV_DEST_UART
|
#if CONFIG_APPTRACE_SV_DEST_UART
|
||||||
if (
|
if (
|
||||||
(APPTRACE_SV_DEST_CPU != esp_cpu_get_core_id()) &&
|
(APPTRACE_SV_DEST_CPU != esp_cpu_get_core_id()) &&
|
||||||
(
|
(
|
||||||
(event_id == SYSVIEW_EVTID_ISR_ENTER) ||
|
(event_id == SYSVIEW_EVTID_ISR_ENTER) ||
|
||||||
(event_id == SYSVIEW_EVTID_ISR_EXIT) ||
|
(event_id == SYSVIEW_EVTID_ISR_EXIT) ||
|
||||||
(event_id == SYSVIEW_EVTID_TASK_START_EXEC) ||
|
(event_id == SYSVIEW_EVTID_TASK_START_EXEC) ||
|
||||||
(event_id == SYSVIEW_EVTID_TASK_STOP_EXEC) ||
|
(event_id == SYSVIEW_EVTID_TASK_STOP_EXEC) ||
|
||||||
(event_id == SYSVIEW_EVTID_TASK_START_READY) ||
|
(event_id == SYSVIEW_EVTID_TASK_START_READY) ||
|
||||||
(event_id == SYSVIEW_EVTID_TASK_STOP_READY) ||
|
(event_id == SYSVIEW_EVTID_TASK_STOP_READY) ||
|
||||||
(event_id == SYSVIEW_EVTID_MARK_START) ||
|
(event_id == SYSVIEW_EVTID_MARK_START) ||
|
||||||
(event_id == SYSVIEW_EVTID_MARK_STOP) ||
|
(event_id == SYSVIEW_EVTID_MARK_STOP) ||
|
||||||
(event_id == SYSVIEW_EVTID_TIMER_ENTER) ||
|
(event_id == SYSVIEW_EVTID_TIMER_ENTER) ||
|
||||||
(event_id == SYSVIEW_EVTID_TIMER_EXIT) ||
|
(event_id == SYSVIEW_EVTID_TIMER_EXIT) ||
|
||||||
(event_id == SYSVIEW_EVTID_STACK_INFO) ||
|
(event_id == SYSVIEW_EVTID_STACK_INFO) ||
|
||||||
(event_id == SYSVIEW_EVTID_MODULEDESC)
|
(event_id == SYSVIEW_EVTID_MODULEDESC)
|
||||||
)
|
)
|
||||||
){
|
) {
|
||||||
return NumBytes;
|
return NumBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is workaround for SystemView!
|
// This is workaround for SystemView!
|
||||||
// Without this line SystemView will hangs on when heap tracing enabled.
|
// Without this line SystemView will hangs on when heap tracing enabled.
|
||||||
if(event_id == SYSVIEW_EVTID_MODULEDESC){
|
if (event_id == SYSVIEW_EVTID_MODULEDESC) {
|
||||||
return NumBytes;
|
return NumBytes;
|
||||||
}
|
}
|
||||||
#endif // CONFIG_APPTRACE_SV_DEST_UART
|
#endif // CONFIG_APPTRACE_SV_DEST_UART
|
||||||
|
|
||||||
if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
|
if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
|
||||||
ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes);
|
ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if CONFIG_APPTRACE_SV_DEST_JTAG
|
#if CONFIG_APPTRACE_SV_DEST_JTAG
|
||||||
if (esp_cpu_get_core_id()) { // dual core specific code
|
if (esp_cpu_get_core_id()) { // dual core specific code
|
||||||
// use the highest - 1 bit of event ID to indicate core ID
|
// use the highest - 1 bit of event ID to indicate core ID
|
||||||
// the highest bit can not be used due to event ID encoding method
|
// the highest bit can not be used due to event ID encoding method
|
||||||
// this reduces supported ID range to [0..63] (for 1 byte IDs) plus [128..16383] (for 2 bytes IDs)
|
// this reduces supported ID range to [0..63] (for 1 byte IDs) plus [128..16383] (for 2 bytes IDs)
|
||||||
if (*pbuf & 0x80) { // 2 bytes ID
|
if (*pbuf & 0x80) { // 2 bytes ID
|
||||||
*(pbuf + 1) |= (1 << 6);
|
*(pbuf + 1) |= (1 << 6);
|
||||||
} else if (NumBytes != 10 || *pbuf != 0) { // ignore sync sequence
|
} else if (NumBytes != 10 || *pbuf != 0) { // ignore sync sequence
|
||||||
*pbuf |= (1 << 6);
|
*pbuf |= (1 << 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif // CONFIG_APPTRACE_SV_DEST_JTAG
|
#endif // CONFIG_APPTRACE_SV_DEST_JTAG
|
||||||
#if CONFIG_APPTRACE_SV_DEST_JTAG
|
#if CONFIG_APPTRACE_SV_DEST_JTAG
|
||||||
if (s_events_buf_filled + NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
|
if (s_events_buf_filled + NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
|
||||||
|
|
||||||
esp_err_t res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, s_events_buf, s_events_buf_filled, SEGGER_HOST_WAIT_TMO);
|
esp_err_t res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, s_events_buf, s_events_buf_filled, SEGGER_HOST_WAIT_TMO);
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
return 0; // skip current data buffer only, accumulated events are kept
|
return 0; // skip current data buffer only, accumulated events are kept
|
||||||
|
}
|
||||||
|
s_events_buf_filled = 0;
|
||||||
}
|
}
|
||||||
s_events_buf_filled = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
memcpy(&s_events_buf[s_events_buf_filled], pBuffer, NumBytes);
|
memcpy(&s_events_buf[s_events_buf_filled], pBuffer, NumBytes);
|
||||||
s_events_buf_filled += NumBytes;
|
s_events_buf_filled += NumBytes;
|
||||||
|
|
||||||
#if CONFIG_APPTRACE_SV_DEST_UART
|
#if CONFIG_APPTRACE_SV_DEST_UART
|
||||||
esp_err_t res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, pBuffer, NumBytes, SEGGER_HOST_WAIT_TMO);
|
esp_err_t res = esp_apptrace_write(ESP_APPTRACE_DEST_SYSVIEW, pBuffer, NumBytes, SEGGER_HOST_WAIT_TMO);
|
||||||
if (res != ESP_OK)
|
if (res != ESP_OK) {
|
||||||
{
|
return 0; // skip current data buffer only, accumulated events are kept
|
||||||
return 0; // skip current data buffer only, accumulated events are kept
|
}
|
||||||
}
|
s_events_buf_filled = 0;
|
||||||
s_events_buf_filled = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (event_id == SYSVIEW_EVTID_TRACE_STOP)
|
if (event_id == SYSVIEW_EVTID_TRACE_STOP) {
|
||||||
{
|
SEGGER_RTT_ESP_FlushNoLock(0, SEGGER_STOP_WAIT_TMO);
|
||||||
SEGGER_RTT_ESP_FlushNoLock(0, SEGGER_STOP_WAIT_TMO);
|
}
|
||||||
}
|
return NumBytes;
|
||||||
return NumBytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -255,9 +255,10 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u
|
|||||||
* May only be called once per buffer.
|
* May only be called once per buffer.
|
||||||
* Buffer name and flags can be reconfigured using the appropriate functions.
|
* Buffer name and flags can be reconfigured using the appropriate functions.
|
||||||
*/
|
*/
|
||||||
int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
|
int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags)
|
||||||
s_events_buf_filled = 0;
|
{
|
||||||
return 0;
|
s_events_buf_filled = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -285,9 +286,10 @@ int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBu
|
|||||||
* May only be called once per buffer.
|
* May only be called once per buffer.
|
||||||
* Buffer name and flags can be reconfigured using the appropriate functions.
|
* Buffer name and flags can be reconfigured using the appropriate functions.
|
||||||
*/
|
*/
|
||||||
int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
|
int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags)
|
||||||
esp_apptrace_down_buffer_config(s_down_buf, sizeof(s_down_buf));
|
{
|
||||||
return 0;
|
esp_apptrace_down_buffer_config(s_down_buf, sizeof(s_down_buf));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************** Init hook ****************************
|
/*************************** Init hook ****************************
|
||||||
@@ -302,5 +304,4 @@ ESP_SYSTEM_INIT_FN(sysview_init, SECONDARY, BIT(0), 120)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************** End of file ****************************/
|
/*************************** End of file ****************************/
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -27,14 +27,13 @@ static SEGGER_SYSVIEW_MODULE s_esp_sysview_heap_module = {
|
|||||||
|
|
||||||
static bool s_mod_registered;
|
static bool s_mod_registered;
|
||||||
|
|
||||||
|
|
||||||
esp_err_t esp_sysview_heap_trace_start(uint32_t tmo)
|
esp_err_t esp_sysview_heap_trace_start(uint32_t tmo)
|
||||||
{
|
{
|
||||||
uint32_t tmo_ticks = tmo/(1000*portTICK_PERIOD_MS);
|
uint32_t tmo_ticks = tmo / (1000 * portTICK_PERIOD_MS);
|
||||||
|
|
||||||
ESP_EARLY_LOGV(TAG, "%s", __func__);
|
ESP_EARLY_LOGV(TAG, "%s", __func__);
|
||||||
do {
|
do {
|
||||||
if (tmo != (uint32_t)-1) {
|
if (tmo != (uint32_t) -1) {
|
||||||
// Currently timeout implementation is simple and has granularity of 1 OS tick,
|
// Currently timeout implementation is simple and has granularity of 1 OS tick,
|
||||||
// so just count down the number of times to call vTaskDelay
|
// so just count down the number of times to call vTaskDelay
|
||||||
if (tmo_ticks-- == 0) {
|
if (tmo_ticks-- == 0) {
|
||||||
@@ -42,7 +41,7 @@ esp_err_t esp_sysview_heap_trace_start(uint32_t tmo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
} while(!SEGGER_SYSVIEW_Started());
|
} while (!SEGGER_SYSVIEW_Started());
|
||||||
|
|
||||||
SEGGER_SYSVIEW_RegisterModule(&s_esp_sysview_heap_module);
|
SEGGER_SYSVIEW_RegisterModule(&s_esp_sysview_heap_module);
|
||||||
s_mod_registered = true;
|
s_mod_registered = true;
|
||||||
@@ -58,7 +57,7 @@ esp_err_t esp_sysview_heap_trace_stop(void)
|
|||||||
|
|
||||||
void esp_sysview_heap_trace_alloc(const void *addr, uint32_t size, const void *callers)
|
void esp_sysview_heap_trace_alloc(const void *addr, uint32_t size, const void *callers)
|
||||||
{
|
{
|
||||||
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (2+CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
|
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (2 + CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
|
||||||
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
|
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
|
||||||
U32 *calls = (U32 *)callers;
|
U32 *calls = (U32 *)callers;
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ void esp_sysview_heap_trace_alloc(const void *addr, uint32_t size, const void *c
|
|||||||
|
|
||||||
void esp_sysview_heap_trace_free(const void *addr, const void *callers)
|
void esp_sysview_heap_trace_free(const void *addr, const void *callers)
|
||||||
{
|
{
|
||||||
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (1+CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
|
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (1 + CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
|
||||||
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
|
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
|
||||||
U32 *calls = (U32 *)callers;
|
U32 *calls = (U32 *)callers;
|
||||||
|
|
||||||
|
@@ -43,7 +43,6 @@ components_not_formatted_temporary:
|
|||||||
# 2. If no, move it to 'components_not_formatted_permanent' section below.
|
# 2. If no, move it to 'components_not_formatted_permanent' section below.
|
||||||
check: false
|
check: false
|
||||||
include:
|
include:
|
||||||
- "/components/app_trace/"
|
|
||||||
- "/components/app_update/"
|
- "/components/app_update/"
|
||||||
- "/components/bootloader_support/"
|
- "/components/bootloader_support/"
|
||||||
- "/components/bootloader/"
|
- "/components/bootloader/"
|
||||||
|
Reference in New Issue
Block a user