diff --git a/Inc/orbtraceIf.h b/Inc/orbtraceIf.h index 54015e1b..e6028d6b 100644 --- a/Inc/orbtraceIf.h +++ b/Inc/orbtraceIf.h @@ -160,7 +160,7 @@ bool OrbtraceSupportsOTAG( struct OrbtraceIf *o ); /* Device manipulation */ bool OrbtraceIfSetTraceWidth( struct OrbtraceIf *o, int width ); -bool OrbtraceIfSetTraceSWO( struct OrbtraceIf *o, bool isMANCH ); +bool OrbtraceIfSetTraceSWO( struct OrbtraceIf *o, bool isMANCH, bool useTPIU ); bool OrbtraceIfSetSWOBaudrate( struct OrbtraceIf *o, uint32_t speed ); bool OrbtraceIfVoltage( struct OrbtraceIf *o, enum Channel ch, int voltage ); diff --git a/Src/orbtrace.c b/Src/orbtrace.c index 6d3609f0..7fde082d 100644 --- a/Src/orbtrace.c +++ b/Src/orbtrace.c @@ -35,6 +35,8 @@ struct Options int traceWidth; /* Width to be used for communication */ bool swoMANCH; /* SWO Manchester output */ bool swoUART; /* SWO UART output */ + bool useTPIU; /* Decode TPIU on SWO */ + bool opJSON; /* Set output to JSON */ bool mono; /* Supress colour in output */ uint32_t serial_speed; /* Speed of serial communication via SWO */ @@ -141,7 +143,8 @@ static void _printHelp( const char *const progName ) genericsPrintf( " -h, --help:: This help" EOL ); genericsPrintf( " -l, --list: Show all OrbTrace devices attached to system" EOL ); genericsPrintf( " -M, --no-colour: Supress colour in output" EOL ); - genericsPrintf( " -T, --trace-format: Trace format; 1,2 or 4 bit parallel, m for Manchester SWO, u=UART SWO" EOL ); + genericsPrintf( " -T, --trace-format: Trace format; 1,2 or 4 bit parallel, m for Manchester SWO, u=UART SWO," EOL ); + genericsPrintf( " M for Manchester SWO with TPIU decode, U=UART SWO with TPIU decode" EOL ); genericsPrintf( " -n, --serial-number: any part of serial number to differentiate specific OrbTrace device" EOL ); genericsPrintf( " -p, --voltage: , Set voltage in V, Ch is vtref or vtpwr" EOL ); genericsPrintf( " -v, --verbose: Verbose mode 0(errors)..3(debug)" EOL ); @@ -312,17 +315,41 @@ static int _processOptions( struct RunTime *r, int argc, char *argv[] ) case 'T': /* Set tracewidth */ r->options->traceWidth = 0; - if ( ( *optarg == 'u' ) && ( !*( optarg + 1 ) ) ) - { - r->options->swoUART = true; - } - else if ( ( *optarg == 'm' ) && ( !*( optarg + 1 ) ) ) + if ( strlen( optarg ) != 1 ) { - r->options->swoMANCH = true; + *optarg = 0; } - else + + switch ( *optarg ) { - r->options->traceWidth = atoi( optarg ); + case 'u': + r->options->swoUART = true; + break; + + case 'm': + r->options->swoMANCH = true; + break; + + case 'U': + r->options->swoUART = true; + r->options->useTPIU = true; + break; + + case 'M': + r->options->swoMANCH = true; + r->options->useTPIU = true; + break; + + case '1': + case '2': + case '3': + case '4': + r->options->traceWidth = atoi( optarg ); + break; + + default: + genericsReport( V_ERROR, "Badly formatted tracewidth" EOL ); + return false; } _set_action( r, ACTION_SET_TRACE ); @@ -632,9 +659,9 @@ static int _performActions( struct RunTime *r ) } else if ( ( r->options->swoMANCH ) || ( r->options->swoUART ) ) { - genericsReport( V_INFO, "Setting SWO with %s encoding" EOL, r->options->swoMANCH ? "Manchester" : "UART" ); + genericsReport( V_INFO, "Setting SWO with %s encoding%s" EOL, r->options->swoMANCH ? "Manchester" : "UART", r->options->useTPIU ? " and TPIU decode" : "" ); - if ( OrbtraceIfSetTraceSWO( r->dev, r->options->swoMANCH ) ) + if ( OrbtraceIfSetTraceSWO( r->dev, r->options->swoMANCH, r->options->useTPIU ) ) { genericsReport( V_INFO, "OK" EOL ); } diff --git a/Src/orbtraceIf.c b/Src/orbtraceIf.c index f01dd3d6..078c756d 100644 --- a/Src/orbtraceIf.c +++ b/Src/orbtraceIf.c @@ -551,8 +551,8 @@ bool OrbtraceGetIfandEP( struct OrbtraceIf *o ) i->bInterfaceClass != 0xff || i->bInterfaceSubClass != 0x54 || ( i->bInterfaceProtocol != PROT_UNKNOWN && - i->bInterfaceProtocol != PROT_TPIU && - i->bInterfaceProtocol != PROT_OTAGV1_0 ) || + i->bInterfaceProtocol != PROT_TPIU && + i->bInterfaceProtocol != PROT_OTAGV1_0 ) || i->bNumEndpoints != 0x01 ) { /* Not the interface we're looking for */ @@ -564,7 +564,7 @@ bool OrbtraceGetIfandEP( struct OrbtraceIf *o ) altsetting = i->bAlternateSetting; num_altsetting = config->interface[if_num].num_altsetting; - o->supportsOTAG = ( i->bInterfaceProtocol == PROT_OTAGV1_0 ); + o->supportsOTAG = ( i->bInterfaceProtocol == PROT_OTAGV1_0 ); genericsReport( V_DEBUG, "Found interface %#x with altsetting %#x and ep %#x" EOL, o->iface, altsetting, o->ep ); interface_found = true; @@ -695,14 +695,14 @@ bool OrbtraceIfSetTraceWidth( struct OrbtraceIf *o, int width ) ); } // ==================================================================================================== -bool OrbtraceIfSetTraceSWO( struct OrbtraceIf *o, bool isMANCH ) +bool OrbtraceIfSetTraceSWO( struct OrbtraceIf *o, bool isMANCH, bool useTPIU ) { return _doInterfaceControlTransfer( o, OrbtraceIfGetTraceIF( o, OrbtraceIfGetActiveDevnum( o ) ), RQ_SET_TWIDTH, - isMANCH ? 0x10 : 0x12, + ( isMANCH ? 0x10 : 0x12 ) | ( useTPIU ? 0x01 : 0x00 ), 0, 0, NULL