refactor(apptrace): format apptrace component with astyle

This commit is contained in:
Erhan Kurubas
2024-05-19 12:08:30 +02:00
parent 2bb1ae8729
commit a0ef187d10
13 changed files with 178 additions and 186 deletions

View File

@@ -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
@@ -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;
} }
} }

View File

@@ -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
*/ */

View File

@@ -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
*/ */

View File

@@ -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,7 +32,7 @@ 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)
{ {
@@ -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

View File

@@ -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
@@ -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,8 +126,7 @@ 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;
@@ -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!");
} }
@@ -209,8 +204,7 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data)
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;
} }

View File

@@ -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

View File

@@ -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[] = {

View File

@@ -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.
@@ -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,7 +121,8 @@ 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; uint32_t size = BufferSize;
esp_err_t res = esp_apptrace_read(ESP_APPTRACE_DEST_SYSVIEW, pData, &size, 0); esp_err_t res = esp_apptrace_read(ESP_APPTRACE_DEST_SYSVIEW, pData, &size, 0);
if (res != ESP_OK) { if (res != ESP_OK) {
@@ -154,7 +155,8 @@ 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 *pbuf = (uint8_t *)pBuffer;
uint8_t event_id = *pbuf; uint8_t event_id = *pbuf;
#if CONFIG_APPTRACE_SV_DEST_UART #if CONFIG_APPTRACE_SV_DEST_UART
@@ -216,15 +218,13 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u
#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,7 +255,8 @@ 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; s_events_buf_filled = 0;
return 0; return 0;
} }
@@ -285,7 +286,8 @@ 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)); esp_apptrace_down_buffer_config(s_down_buf, sizeof(s_down_buf));
return 0; return 0;
} }
@@ -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 ****************************/

View 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,7 +27,6 @@ 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);

View File

@@ -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/"