Skip to content

Commit

Permalink
Add control functions to enable TPIU decode in-probe for SWO streams
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Aug 12, 2024
1 parent 90413b4 commit fdb43d6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Inc/orbtraceIf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
49 changes: 38 additions & 11 deletions Src/orbtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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: <x> Trace format; 1,2 or 4 bit parallel, m for Manchester SWO, u=UART SWO" EOL );
genericsPrintf( " -T, --trace-format: <x> 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: <Serial> any part of serial number to differentiate specific OrbTrace device" EOL );
genericsPrintf( " -p, --voltage: <Ch>,<Voltage> Set voltage in V, Ch is vtref or vtpwr" EOL );
genericsPrintf( " -v, --verbose: <level> Verbose mode 0(errors)..3(debug)" EOL );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down
10 changes: 5 additions & 5 deletions Src/orbtraceIf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fdb43d6

Please sign in to comment.