# HG changeset patch # User Michael Spacefalcon # Date 1383608111 0 # Node ID 3b5c3f3646fbbb84ad2841f8361175144cd329a7 # Parent e4257294102bdbdefbe9ad49e85ea2fedbe18997 RV bring-up: lack of timer ticks fixed, still investigating the lack of "system time" messages from the RVT task diff -r e4257294102b -r 3b5c3f3646fb nuc-fw/bsp/init_target.c --- a/nuc-fw/bsp/init_target.c Sun Nov 03 00:14:40 2013 +0000 +++ b/nuc-fw/bsp/init_target.c Mon Nov 04 23:35:11 2013 +0000 @@ -364,6 +364,7 @@ #if !CONFIG_GSM Dtimer2_Init_cntl (1875, 1, 0, 1); + Dtimer2_Start (1); #endif #endif /* (OP_L1_STANDALONE == 0) */ diff -r e4257294102b -r 3b5c3f3646fb nuc-fw/riviera/init/create_RVtasks.c --- a/nuc-fw/riviera/init/create_RVtasks.c Sun Nov 03 00:14:40 2013 +0000 +++ b/nuc-fw/riviera/init/create_RVtasks.c Mon Nov 04 23:35:11 2013 +0000 @@ -47,7 +47,6 @@ #include #include - #define START_TASK_ID (MAX_RVF_TASKS-1) #define RV_START_TASK_PRIO (249) @@ -570,7 +569,7 @@ #if 1 //(CHIPSET!=15) || (REMU==0) /* dump the Riviera memory state */ rvf_delay (RVF_MS_TO_TICKS (300)) ; - rvf_dump_mem (); + rvf_dump_mem (); rvf_dump_pool(); rvf_dump_tasks(); #endif diff -r e4257294102b -r 3b5c3f3646fb nuc-fw/riviera/rvt/rvt_task.c --- a/nuc-fw/riviera/rvt/rvt_task.c Sun Nov 03 00:14:40 2013 +0000 +++ b/nuc-fw/riviera/rvt/rvt_task.c Mon Nov 04 23:35:11 2013 +0000 @@ -66,182 +66,191 @@ /********************************************************************************/ T_RVM_RETURN rvt_task_core (void) { - UINT16 event = 0; - UINT32 nb_bytes_sent = 0; + UINT16 event = 0; + UINT32 nb_bytes_sent = 0; + + #ifdef FRAMING_PROTOCOL - #ifdef FRAMING_PROTOCOL + // Request for the level of filtering, as well as the 32-bit + // mask related to the software entities to be monitored. + { + UINT8 trace_level_request[] = {RVM_INVALID_USE_ID, 0, 0, 0, 0, + (RV_TRACE_LEVEL_ERROR - 1), 0, 0, 0, 0}; + + // Note that the level is defined as invalid + trace_level_request[0] = (char) rv_trace_user_id; - // Request for the level of filtering, as well as the 32-bit - // mask related to the software entities to be monitored. + // Transmit an 'empty' message + nb_bytes_sent = 0; + while (nb_bytes_sent < sizeof (trace_level_request)) { - UINT8 trace_level_request[] = {RVM_INVALID_USE_ID, 0, 0, 0, 0, (RV_TRACE_LEVEL_ERROR - 1), 0, 0, 0, 0}; + nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, + trace_level_request + nb_bytes_sent, + sizeof (trace_level_request) - + nb_bytes_sent); + } + } + + // Start the 'Alive Polling Timer' + #if (OP_WCP == 0) + rvf_start_timer (RVF_TIMER_0, + RVT_ALIVE_POLLING_TIME, + TRUE); + #endif - // Note that the level is defined as invalid - trace_level_request[0] = (char) rv_trace_user_id; + for (; ; ) + { + // Infinite wait on 'Trace Task' mailbox or timer events + event = rvf_wait ((1 << RVT_TRACE_MAILBOX) | (RVF_TIMER_0_EVT_MASK), + 0); + + // Check for some messages lost + if (((rvt_lost_msg_cpt.bit_mask).count >= RVT_MAX_LOST_TRACE_MSG) + && (p_rvt_lost_msg)) + { + INT8 count = 0; + UINT8 lost_msg_length = RVT_HDR_LENGTH + RVT_LOST_MSG_LENGTH; + UINT32 lost_msg_cpt = rvt_lost_msg_cpt.overall_value; - // Transmit an 'empty' message - nb_bytes_sent = 0; - while (nb_bytes_sent < sizeof (trace_level_request)) - { - nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, - trace_level_request + nb_bytes_sent, - sizeof (trace_level_request) - nb_bytes_sent); - } + // Append with the number of messages lost + rvt_lost_msg_cpt.overall_value = 0; + for (count = 0; + count < RVT_HEX_VALUE_LENGTH; + count++) + { + p_rvt_lost_msg[lost_msg_length + count] = + Num2Char[(UINT8) ((lost_msg_cpt << (count << 2)) >> 28)]; + } + lost_msg_length += RVT_HEX_VALUE_LENGTH; + + // Send message to the UART with byte stuffing + nb_bytes_sent = 0; + while (nb_bytes_sent < lost_msg_length) + { + nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, + (UINT8 *) p_rvt_lost_msg + nb_bytes_sent, + lost_msg_length - nb_bytes_sent); } - // Start the 'Alive Polling Timer' - #if (OP_WCP == 0) - rvf_start_timer (RVF_TIMER_0, - RVT_ALIVE_POLLING_TIME, - TRUE); - #endif + } // End of if ((rvt_lost_msg_cpt.bit_mask).count >= RVT_MAX_LOST_TRACE_MSG) + + if (event & EVENT_MASK (RVT_TRACE_MAILBOX)) + { + T_RV_HDR *msg = NULL; - for (; - ; - ) + // Read the message from the mailbox + if ((msg = (T_RV_HDR *) rvf_read_mbox (RVT_TRACE_MAILBOX)) + != NULL) { - // Infinite wait on 'Trace Task' mailbox or timer events - event = rvf_wait ((1 << RVT_TRACE_MAILBOX) | (RVF_TIMER_0_EVT_MASK), - 0); + if (msg->msg_id == RVT_TRACE_RQST_ID) + { + UINT8 msg_format = 0; + UINT32 msg_length = 0; + + // Get the length + msg_length = ((T_RVT_TRACE_RQST *) msg)->msg_length; + + // Get the format + msg_format = ((T_RVT_TRACE_RQST *) msg)->format; - // Check for some messages lost - if (((rvt_lost_msg_cpt.bit_mask).count >= RVT_MAX_LOST_TRACE_MSG) && (p_rvt_lost_msg)) - { - INT8 count = 0; - UINT8 lost_msg_length = RVT_HDR_LENGTH + RVT_LOST_MSG_LENGTH; - UINT32 lost_msg_cpt = rvt_lost_msg_cpt.overall_value; + // Copy the 'User ID' + ((UINT8 *) msg + RVT_HEADER_SIZE - 1)[0] = + ((T_RVT_TRACE_RQST *) msg)->user_id; + msg_length++; - // Append with the number of messages lost - rvt_lost_msg_cpt.overall_value = 0; - for (count = 0; - count < RVT_HEX_VALUE_LENGTH; - count++) + switch (msg_format) + { + case RVT_ASCII_FORMAT: + { + // Send message to the UART without byte stuffing + nb_bytes_sent = 0; + while (nb_bytes_sent < msg_length) { - p_rvt_lost_msg[lost_msg_length + count] = Num2Char[(UINT8) ((lost_msg_cpt << (count << 2)) >> 28)]; + nb_bytes_sent += SER_tr_EncapsulateNChars + (SER_LAYER_1, + (char *) msg + RVT_HEADER_SIZE - 1 + + nb_bytes_sent, + msg_length - nb_bytes_sent); } - lost_msg_length += RVT_HEX_VALUE_LENGTH; - + break; + } + case RVT_BINARY_FORMAT: + { // Send message to the UART with byte stuffing nb_bytes_sent = 0; - while (nb_bytes_sent < lost_msg_length) + while (nb_bytes_sent < msg_length) { - nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, - (UINT8 *) p_rvt_lost_msg + nb_bytes_sent, - lost_msg_length - nb_bytes_sent); + nb_bytes_sent += SER_tr_WriteNBytes + (SER_LAYER_1, + (UINT8 *) msg + RVT_HEADER_SIZE + - 1 + nb_bytes_sent, + msg_length - nb_bytes_sent); } - - } // End of if ((rvt_lost_msg_cpt.bit_mask).count >= RVT_MAX_LOST_TRACE_MSG) - - if (event & EVENT_MASK (RVT_TRACE_MAILBOX)) - { - T_RV_HDR *msg = NULL; + break; + } + default: + { + // Increment the number of messages lost. + // Is the buffer corrupted? + (rvt_lost_msg_cpt.bit_mask).count++; + (rvt_lost_msg_cpt.bit_mask).unknown_format = 1; + break; + } + } - // Read the message from the mailbox - if ((msg = (T_RV_HDR *) rvf_read_mbox (RVT_TRACE_MAILBOX)) != NULL) - { - if (msg->msg_id == RVT_TRACE_RQST_ID) - { - UINT8 msg_format = 0; - UINT32 msg_length = 0; + // Deallocate the buffer + rvf_free_buf (msg); - // Get the length - msg_length = ((T_RVT_TRACE_RQST *) msg)->msg_length; - - // Get the format - msg_format = ((T_RVT_TRACE_RQST *) msg)->format; - - // Copy the 'User ID' - ((UINT8 *) msg + RVT_HEADER_SIZE - 1)[0] = ((T_RVT_TRACE_RQST *) msg)->user_id; - msg_length++; + } // End of if (msg->msg_id == RVT_TRACE_RQST_ID) + else + { + // Increment the number of messages lost. Is the buffer + // corrupted? + (rvt_lost_msg_cpt.bit_mask).count++; + (rvt_lost_msg_cpt.bit_mask).unknown_request = 1; + } - switch (msg_format) - { - case RVT_ASCII_FORMAT: - { - // Send message to the UART without byte stuffing - nb_bytes_sent = 0; - while (nb_bytes_sent < msg_length) - { - nb_bytes_sent += SER_tr_EncapsulateNChars (SER_LAYER_1, - (char *) msg + RVT_HEADER_SIZE - 1 + nb_bytes_sent, - msg_length - nb_bytes_sent); - } - break; - } - case RVT_BINARY_FORMAT: - { - // Send message to the UART with byte stuffing - nb_bytes_sent = 0; - while (nb_bytes_sent < msg_length) - { - nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, - (UINT8 *) msg + RVT_HEADER_SIZE - 1 + nb_bytes_sent, - msg_length - nb_bytes_sent); - } - break; - } - default: - { - // Increment the number of messages lost. - // Is the buffer corrupted? - (rvt_lost_msg_cpt.bit_mask).count++; - (rvt_lost_msg_cpt.bit_mask).unknown_format = 1; - break; - } - } + } // End of if (msg != NULL) + else + { + // Increment the number of messages lost. Is the buffer + // corrupted? + (rvt_lost_msg_cpt.bit_mask).count++; + (rvt_lost_msg_cpt.bit_mask).message_empty = 1; + } - // Deallocate the buffer - rvf_free_buf (msg); + } // End of if (event & EVENT_MASK (RVT_TRACE_MAILBOX)) - } // End of if (msg->msg_id == RVT_TRACE_RQST_ID) + if ((event & (RVF_TIMER_0_EVT_MASK)) && (p_rvt_sys_time)) + { + UINT8 count = 0; + UINT8 sys_time_length = RVT_HDR_LENGTH + RVT_SYS_TIME_LENGTH; + UINT32 current_time = rvf_get_tick_count (); - else - { - // Increment the number of messages lost. Is the buffer - // corrupted? - (rvt_lost_msg_cpt.bit_mask).count++; - (rvt_lost_msg_cpt.bit_mask).unknown_request = 1; - } - - } // End of if (msg != NULL) - - else - { - // Increment the number of messages lost. Is the buffer - // corrupted? - (rvt_lost_msg_cpt.bit_mask).count++; - (rvt_lost_msg_cpt.bit_mask).message_empty = 1; - } - - } // End of if (event & EVENT_MASK (RVT_TRACE_MAILBOX)) + // Append with the system time + for (count = 0; + count < RVT_HEX_VALUE_LENGTH; + count++) + { + p_rvt_sys_time[sys_time_length + count] = + Num2Char[(UINT8) ((current_time << (count << 2)) >> 28)]; + } + sys_time_length += RVT_HEX_VALUE_LENGTH; - if ((event & (RVF_TIMER_0_EVT_MASK)) && (p_rvt_sys_time)) - { - UINT8 count = 0; - UINT8 sys_time_length = RVT_HDR_LENGTH + RVT_SYS_TIME_LENGTH; - UINT32 current_time = rvf_get_tick_count (); + // Send message to the UART with byte stuffing + nb_bytes_sent = 0; + while (nb_bytes_sent < sys_time_length) + { + nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, + (UINT8 *) p_rvt_sys_time + nb_bytes_sent, + sys_time_length - nb_bytes_sent); + } - // Append with the system time - for (count = 0; - count < RVT_HEX_VALUE_LENGTH; - count++) - { - p_rvt_sys_time[sys_time_length + count] = Num2Char[(UINT8) ((current_time << (count << 2)) >> 28)]; - } - sys_time_length += RVT_HEX_VALUE_LENGTH; + } // End of if (event & (RVF_TIMER_0_EVT_MASK)) + //freecalypso_lldbg_intinfo(); + } - // Send message to the UART with byte stuffing - nb_bytes_sent = 0; - while (nb_bytes_sent < sys_time_length) - { - nb_bytes_sent += SER_tr_WriteNBytes (SER_LAYER_1, - (UINT8 *) p_rvt_sys_time + nb_bytes_sent, - sys_time_length - nb_bytes_sent); - } - - } // End of if (event & (RVF_TIMER_0_EVT_MASK)) - } - #else + #else // Start the 'Alive Polling Timer' #if (OP_WCP == 0) @@ -411,6 +420,13 @@ UINT32 bytesRead; static UINT8 inBuffer[255]; + rvf_send_trace("Ser RX", 6, rvf_get_tick_count(), + RV_TRACE_LEVEL_DEBUG_HIGH, RVT_USE_ID); +/* + freecalypso_raw_dbgout("*Ser_RX"); + freecalypso_lldbg_intinfo(); +*/ + #ifdef FRAMING_PROTOCOL BOOL eof = 0; static UINT8 rcv_state = RVT_WAIT_FOR_HEADER; diff -r e4257294102b -r 3b5c3f3646fb nuc-fw/serial/Makefile --- a/nuc-fw/serial/Makefile Sun Nov 03 00:14:40 2013 +0000 +++ b/nuc-fw/serial/Makefile Mon Nov 04 23:35:11 2013 +0000 @@ -2,7 +2,7 @@ CFLAGS= -O2 -fno-builtin -mthumb-interwork -mthumb LD= arm-elf-ld -OBJS= init.o serialswitch.o uart.o +OBJS= debug.o init.o serialswitch.o uart.o HDRS= faxdata.h serialswitch.h traceswitch.h uart.h uartfax.h diff -r e4257294102b -r 3b5c3f3646fb nuc-fw/serial/debug.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nuc-fw/serial/debug.c Mon Nov 04 23:35:11 2013 +0000 @@ -0,0 +1,47 @@ +/* + * This module is a FreeCalypso addition for very low-level debugging. + * The functions implemented in this module produce "forced" serial output + * on the RVTMUX UART without going through the normal RV trace mechanism. + * Calls to these FC debug functions should be added during difficult + * debug sessions, but should never remain in stable checked-in code: + * these functions are too disruptive to be used in "production" fw images. + */ + +#include "../include/config.h" +#include "../include/sys_types.h" + +#include "serialswitch.h" + +#include + +freecalypso_raw_dbgout(char *string) +{ + char *p; + int l, cc; + + p = string; + l = strlen(p); + while (l) { + cc = SER_tr_WriteNBytes(SER_LAYER_1, p, l); + p += cc; + l -= cc; + } +} + +freecalypso_lldbg_intinfo() +{ + char strbuf[128]; + extern unsigned IQ_TimerCount2; + extern unsigned TMD_System_Clock; + extern unsigned INT_Check_IRQ_Mask(); + + sprintf(strbuf, "*CPSR=%08x, IQ_TimerCount2=%u, TMD_System_Clock=%u", + INT_Check_IRQ_Mask(), IQ_TimerCount2, TMD_System_Clock); + freecalypso_raw_dbgout(strbuf); +} + +freecalypso_nucidle_dbghook() +{ + freecalypso_raw_dbgout("*In Nucleus idle loop"); + freecalypso_lldbg_intinfo(); +}