fix: preserve current runtime debug state
This commit is contained in:
@@ -45,7 +45,7 @@ void debug_log_write(const char *msg)
|
||||
|
||||
void debug_log_printf(const char *fmt, ...)
|
||||
{
|
||||
char buffer[192];
|
||||
char buffer[128];
|
||||
va_list args;
|
||||
int len;
|
||||
|
||||
|
||||
+50
-156
@@ -29,86 +29,6 @@ volatile int32_t g_netif_set_default_err = 0x7FFFFFFF;
|
||||
volatile int32_t g_netif_set_link_down_err = 0x7FFFFFFF;
|
||||
volatile int32_t g_netif_set_up_err = 0x7FFFFFFF;
|
||||
volatile int32_t g_netif_init_ok = 0;
|
||||
volatile uint32_t g_eth_poll_count = 0u;
|
||||
volatile uint32_t g_eth_isr_pr_count = 0u;
|
||||
volatile uint32_t g_eth_rx_count = 0u;
|
||||
volatile uint32_t g_eth_rx_drop_count = 0u;
|
||||
volatile uint32_t g_eth_tx_count = 0u;
|
||||
volatile uint32_t g_eth_link_up_count = 0u;
|
||||
volatile uint32_t g_eth_link_down_count = 0u;
|
||||
volatile uint32_t g_eth_last_isr = 0u;
|
||||
volatile uint32_t g_eth_last_nsr = 0u;
|
||||
volatile uint32_t g_eth_last_mrcmdx = 0u;
|
||||
volatile uint32_t g_eth_last_mrcmdx1 = 0u;
|
||||
volatile uint32_t g_eth_last_mrrl = 0u;
|
||||
volatile uint32_t g_eth_last_mrrh = 0u;
|
||||
volatile uint32_t g_eth_last_bcastcr = 0u;
|
||||
volatile uint32_t g_eth_last_mar7 = 0u;
|
||||
volatile uint32_t g_eth_last_nsr_rxrdy = 0u;
|
||||
volatile uint32_t g_eth_last_rx_ready = 0u;
|
||||
volatile uint32_t g_eth_last_rx_status = 0u;
|
||||
volatile uint32_t g_eth_last_rx_len = 0u;
|
||||
volatile uint32_t g_eth_last_rx_head0 = 0u;
|
||||
volatile uint32_t g_eth_last_rx_head1 = 0u;
|
||||
volatile uint32_t g_eth_last_rx_head2 = 0u;
|
||||
volatile uint32_t g_eth_last_rx_head3 = 0u;
|
||||
volatile uint32_t g_eth_last_rx_fail_stage = 0u;
|
||||
volatile uint32_t g_eth_rx_gate_ok_count = 0u;
|
||||
volatile uint32_t g_eth_rx_fallback_ok_count = 0u;
|
||||
volatile uint32_t g_eth_rx_fallback_reject_count = 0u;
|
||||
volatile uint32_t g_eth_probe_attempted = 0u;
|
||||
volatile uint32_t g_eth_probe_head0 = 0u;
|
||||
volatile uint32_t g_eth_probe_head1 = 0u;
|
||||
volatile uint32_t g_eth_probe_head2 = 0u;
|
||||
volatile uint32_t g_eth_probe_head3 = 0u;
|
||||
volatile uint32_t g_eth_probe_rx_status = 0u;
|
||||
volatile uint32_t g_eth_probe_rx_len = 0u;
|
||||
volatile uint8_t g_eth_probe_dump[32] = {0u};
|
||||
volatile uint32_t g_eth_probe_drop_count = 0u;
|
||||
volatile uint32_t g_eth_reprobe_head0 = 0u;
|
||||
volatile uint32_t g_eth_reprobe_head1 = 0u;
|
||||
volatile uint32_t g_eth_reprobe_head2 = 0u;
|
||||
volatile uint32_t g_eth_reprobe_head3 = 0u;
|
||||
volatile uint32_t g_eth_reprobe_rx_status = 0u;
|
||||
volatile uint32_t g_eth_reprobe_rx_len = 0u;
|
||||
volatile uint32_t g_eth_input_ok_count = 0u;
|
||||
volatile uint32_t g_eth_input_err_count = 0u;
|
||||
volatile int32_t g_eth_last_input_err = 0;
|
||||
volatile uint32_t g_eth_last_frame_len = 0u;
|
||||
volatile uint8_t g_eth_last_frame_head[14] = {0u};
|
||||
volatile uint32_t g_eth_tx_probe_count = 0u;
|
||||
volatile uint32_t g_eth_last_tx_len = 0u;
|
||||
volatile uint8_t g_eth_last_tx_head[14] = {0u};
|
||||
volatile uint32_t g_eth_last_tcr_after = 0u;
|
||||
volatile uint32_t g_eth_last_nsr_after = 0u;
|
||||
volatile uint32_t g_eth_last_tsra = 0u;
|
||||
volatile uint32_t g_eth_last_tsrb = 0u;
|
||||
volatile uint32_t g_eth_last_txpll_rb = 0u;
|
||||
volatile uint32_t g_eth_last_txplh_rb = 0u;
|
||||
volatile uint32_t g_eth_arp_rx_count = 0u;
|
||||
volatile uint32_t g_eth_arp_tx_count = 0u;
|
||||
volatile uint32_t g_eth_arp_rx_op = 0u;
|
||||
volatile uint32_t g_eth_arp_tx_op = 0u;
|
||||
volatile uint8_t g_eth_local_ip[4] = {0u};
|
||||
volatile uint8_t g_eth_local_mac[6] = {0u};
|
||||
volatile uint8_t g_eth_arp_rx_sha[6] = {0u};
|
||||
volatile uint8_t g_eth_arp_rx_spa[4] = {0u};
|
||||
volatile uint8_t g_eth_arp_rx_tha[6] = {0u};
|
||||
volatile uint8_t g_eth_arp_rx_tpa[4] = {0u};
|
||||
volatile uint8_t g_eth_arp_tx_sha[6] = {0u};
|
||||
volatile uint8_t g_eth_arp_tx_spa[4] = {0u};
|
||||
volatile uint8_t g_eth_arp_tx_tha[6] = {0u};
|
||||
volatile uint8_t g_eth_arp_tx_tpa[4] = {0u};
|
||||
volatile uint32_t g_eth_lwip_arp_seen_count = 0u;
|
||||
volatile uint32_t g_eth_lwip_arp_opcode = 0u;
|
||||
volatile uint32_t g_eth_lwip_arp_for_us = 0u;
|
||||
volatile uint32_t g_eth_lwip_arp_from_us = 0u;
|
||||
volatile uint8_t g_eth_lwip_arp_sip[4] = {0u};
|
||||
volatile uint8_t g_eth_lwip_arp_dip[4] = {0u};
|
||||
volatile uint32_t g_eth_lwip_eth_seen_count = 0u;
|
||||
volatile uint32_t g_eth_lwip_eth_last_type = 0u;
|
||||
volatile uint32_t g_eth_lwip_eth_last_len = 0u;
|
||||
volatile uint32_t g_eth_lwip_eth_arp_case_count = 0u;
|
||||
|
||||
static TaskHandle_t xNetPollTaskHandle = NULL;
|
||||
static TaskHandle_t xTcpSrvTaskS1Handle = NULL;
|
||||
@@ -117,6 +37,54 @@ static TaskHandle_t xTcpCliTaskC1Handle = NULL;
|
||||
static TaskHandle_t xTcpCliTaskC2Handle = NULL;
|
||||
static TaskHandle_t xDefaultTaskHandle = NULL;
|
||||
|
||||
void app_start_network_tasks(void)
|
||||
{
|
||||
#if !DIAG_TASK_ISOLATION
|
||||
BaseType_t rc;
|
||||
|
||||
if (xTcpSrvTaskS1Handle != NULL) {
|
||||
debug_log_write("[NET] start-network-tasks already\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
debug_log_printf("[NET] start-network-tasks enter free=%lu min=%lu\r\n",
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
|
||||
rc = xTaskCreate(TcpSrvTask_S1, "TcpSrvS1", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS1Handle);
|
||||
debug_log_printf("[NET] create TcpSrvS1 rc=%ld free=%lu min=%lu\r\n",
|
||||
(long)rc,
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
configASSERT(rc == pdPASS);
|
||||
|
||||
rc = xTaskCreate(TcpSrvTask_S2, "TcpSrvS2", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS2Handle);
|
||||
debug_log_printf("[NET] create TcpSrvS2 rc=%ld free=%lu min=%lu\r\n",
|
||||
(long)rc,
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
configASSERT(rc == pdPASS);
|
||||
|
||||
rc = xTaskCreate(TcpCliTask_C1, "TcpCliC1", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC1Handle);
|
||||
debug_log_printf("[NET] create TcpCliC1 rc=%ld free=%lu min=%lu\r\n",
|
||||
(long)rc,
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
configASSERT(rc == pdPASS);
|
||||
|
||||
rc = xTaskCreate(TcpCliTask_C2, "TcpCliC2", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC2Handle);
|
||||
debug_log_printf("[NET] create TcpCliC2 rc=%ld free=%lu min=%lu\r\n",
|
||||
(long)rc,
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
configASSERT(rc == pdPASS);
|
||||
|
||||
debug_log_printf("[NET] start-network-tasks exit free=%lu min=%lu\r\n",
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
#endif
|
||||
}
|
||||
|
||||
static void StartDefaultTask(void *argument)
|
||||
{
|
||||
TickType_t last_snapshot = xTaskGetTickCount();
|
||||
@@ -145,76 +113,6 @@ static void StartDefaultTask(void *argument)
|
||||
(unsigned long)g_netif_phase,
|
||||
(unsigned long)uxTaskGetStackHighWaterMark(xNetPollTaskHandle));
|
||||
}
|
||||
debug_log_printf("[ARP] poll=%lu isr=0x%02lX pr=%lu rx=%lu drop=%lu tx=%lu lup=%lu ldn=%lu\r\n",
|
||||
(unsigned long)g_eth_poll_count,
|
||||
(unsigned long)g_eth_last_isr,
|
||||
(unsigned long)g_eth_isr_pr_count,
|
||||
(unsigned long)g_eth_rx_count,
|
||||
(unsigned long)g_eth_rx_drop_count,
|
||||
(unsigned long)g_eth_tx_count,
|
||||
(unsigned long)g_eth_link_up_count,
|
||||
(unsigned long)g_eth_link_down_count);
|
||||
debug_log_printf("[ARP] txp=%lu tlen=%lu\r\n",
|
||||
(unsigned long)g_eth_tx_probe_count,
|
||||
(unsigned long)g_eth_last_tx_len);
|
||||
debug_log_printf("[ARP] txr tcr=0x%02lX nsr=0x%02lX tsra=0x%02lX tsrb=0x%02lX pll=0x%02lX plh=0x%02lX\r\n",
|
||||
(unsigned long)g_eth_last_tcr_after,
|
||||
(unsigned long)g_eth_last_nsr_after,
|
||||
(unsigned long)g_eth_last_tsra,
|
||||
(unsigned long)g_eth_last_tsrb,
|
||||
(unsigned long)g_eth_last_txpll_rb,
|
||||
(unsigned long)g_eth_last_txplh_rb);
|
||||
debug_log_printf("[ARP] local ip=%lu.%lu.%lu.%lu mac=%02lX:%02lX:%02lX:%02lX:%02lX:%02lX\r\n",
|
||||
(unsigned long)g_eth_local_ip[0],
|
||||
(unsigned long)g_eth_local_ip[1],
|
||||
(unsigned long)g_eth_local_ip[2],
|
||||
(unsigned long)g_eth_local_ip[3],
|
||||
(unsigned long)g_eth_local_mac[0],
|
||||
(unsigned long)g_eth_local_mac[1],
|
||||
(unsigned long)g_eth_local_mac[2],
|
||||
(unsigned long)g_eth_local_mac[3],
|
||||
(unsigned long)g_eth_local_mac[4],
|
||||
(unsigned long)g_eth_local_mac[5]);
|
||||
debug_log_printf("[ARP] rxarp c=%lu op=%lu spa=%lu.%lu.%lu.%lu tpa=%lu.%lu.%lu.%lu\r\n",
|
||||
(unsigned long)g_eth_arp_rx_count,
|
||||
(unsigned long)g_eth_arp_rx_op,
|
||||
(unsigned long)g_eth_arp_rx_spa[0],
|
||||
(unsigned long)g_eth_arp_rx_spa[1],
|
||||
(unsigned long)g_eth_arp_rx_spa[2],
|
||||
(unsigned long)g_eth_arp_rx_spa[3],
|
||||
(unsigned long)g_eth_arp_rx_tpa[0],
|
||||
(unsigned long)g_eth_arp_rx_tpa[1],
|
||||
(unsigned long)g_eth_arp_rx_tpa[2],
|
||||
(unsigned long)g_eth_arp_rx_tpa[3]);
|
||||
debug_log_printf("[ARP] txarp c=%lu op=%lu spa=%lu.%lu.%lu.%lu tpa=%lu.%lu.%lu.%lu\r\n",
|
||||
(unsigned long)g_eth_arp_tx_count,
|
||||
(unsigned long)g_eth_arp_tx_op,
|
||||
(unsigned long)g_eth_arp_tx_spa[0],
|
||||
(unsigned long)g_eth_arp_tx_spa[1],
|
||||
(unsigned long)g_eth_arp_tx_spa[2],
|
||||
(unsigned long)g_eth_arp_tx_spa[3],
|
||||
(unsigned long)g_eth_arp_tx_tpa[0],
|
||||
(unsigned long)g_eth_arp_tx_tpa[1],
|
||||
(unsigned long)g_eth_arp_tx_tpa[2],
|
||||
(unsigned long)g_eth_arp_tx_tpa[3]);
|
||||
debug_log_printf("[ARP] lwip c=%lu op=%lu fu=%lu mu=%lu sip=%lu.%lu.%lu.%lu dip=%lu.%lu.%lu.%lu\r\n",
|
||||
(unsigned long)g_eth_lwip_arp_seen_count,
|
||||
(unsigned long)g_eth_lwip_arp_opcode,
|
||||
(unsigned long)g_eth_lwip_arp_for_us,
|
||||
(unsigned long)g_eth_lwip_arp_from_us,
|
||||
(unsigned long)g_eth_lwip_arp_sip[0],
|
||||
(unsigned long)g_eth_lwip_arp_sip[1],
|
||||
(unsigned long)g_eth_lwip_arp_sip[2],
|
||||
(unsigned long)g_eth_lwip_arp_sip[3],
|
||||
(unsigned long)g_eth_lwip_arp_dip[0],
|
||||
(unsigned long)g_eth_lwip_arp_dip[1],
|
||||
(unsigned long)g_eth_lwip_arp_dip[2],
|
||||
(unsigned long)g_eth_lwip_arp_dip[3]);
|
||||
debug_log_printf("[ARP] edmx c=%lu type=0x%04lX len=%lu arpc=%lu\r\n",
|
||||
(unsigned long)g_eth_lwip_eth_seen_count,
|
||||
(unsigned long)g_eth_lwip_eth_last_type,
|
||||
(unsigned long)g_eth_lwip_eth_last_len,
|
||||
(unsigned long)g_eth_lwip_eth_arp_case_count);
|
||||
last_snapshot = xTaskGetTickCount();
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
@@ -230,8 +128,8 @@ void MX_FREERTOS_Init(void)
|
||||
debug_log_boot("uart-trans-init");
|
||||
|
||||
xNetSemaphore = xSemaphoreCreateBinary();
|
||||
xTcpRxQueue = xQueueCreate(8, sizeof(route_msg_t *));
|
||||
xConfigQueue = xQueueCreate(4, sizeof(route_msg_t *));
|
||||
xTcpRxQueue = xQueueCreate(6, sizeof(route_msg_t *));
|
||||
xConfigQueue = xQueueCreate(2, sizeof(route_msg_t *));
|
||||
for (i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||
xLinkTxQueues[i] = xQueueCreate(4, sizeof(route_msg_t *));
|
||||
}
|
||||
@@ -247,10 +145,6 @@ void MX_FREERTOS_Init(void)
|
||||
|
||||
configASSERT(xTaskCreate(NetPollTask, "NetPoll", TASK_STACK_NET_POLL, NULL, TASK_PRIORITY_NET_POLL, &xNetPollTaskHandle) == pdPASS);
|
||||
#if !DIAG_TASK_ISOLATION
|
||||
configASSERT(xTaskCreate(TcpSrvTask_S1, "TcpSrvS1", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS1Handle) == pdPASS);
|
||||
configASSERT(xTaskCreate(TcpSrvTask_S2, "TcpSrvS2", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS2Handle) == pdPASS);
|
||||
configASSERT(xTaskCreate(TcpCliTask_C1, "TcpCliC1", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC1Handle) == pdPASS);
|
||||
configASSERT(xTaskCreate(TcpCliTask_C2, "TcpCliC2", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC2Handle) == pdPASS);
|
||||
configASSERT(xTaskCreate(UartRxTask, "UartRx", TASK_STACK_UART_RX, NULL, TASK_PRIORITY_UART_RX, &xUartRxTaskHandle) == pdPASS);
|
||||
configASSERT(xTaskCreate(ConfigTask, "Config", TASK_STACK_CONFIG, NULL, TASK_PRIORITY_CONFIG, &xConfigTaskHandle) == pdPASS);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user