Initial version
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
/************************************************************
|
||||
* Percepio Tracealyzer - ITM Trace Exporter for Keil uVision
|
||||
* Copyright (c) 2018, Percepio AB.
|
||||
* https://percepio.com
|
||||
************************************************************/
|
||||
|
||||
FUNC void tzSetEnable(int enable)
|
||||
{
|
||||
if (enable == 1)
|
||||
{
|
||||
printf("Starting Tracealyzer recorder\n");
|
||||
|
||||
// Forward the ITM data to file
|
||||
exec("ITMLOG 1 > .\\tracealyzer.psf");
|
||||
|
||||
// Send start command to Tracealyzer (not required if using vTraceEnable(TRC_START))
|
||||
exec("E CHAR tz_host_command_data = 1, 1, 0, 0, 0, 0, 0xFD, 0xFF");
|
||||
exec("tz_host_command_bytes_to_read = 8");
|
||||
}
|
||||
else if (enable == 0)
|
||||
{
|
||||
printf("Stopping Tracealyzer recorder...\n");
|
||||
|
||||
// Send stop command to Tracealyzer, to stop writing ITM data.
|
||||
exec("E CHAR tz_host_command_data = 1, 0, 0, 0, 0, 0, 0xFE, 0xFF");
|
||||
exec("tz_host_command_bytes_to_read = 8");
|
||||
|
||||
_sleep_(2000); // Wait a while to let all data be written the host file.
|
||||
|
||||
// Stop forwarding the ITM data to file and close the file.
|
||||
exec("ITMLOG 1 OFF");
|
||||
|
||||
printf("Tracealyzer recorder stopped.\n");
|
||||
|
||||
}
|
||||
else printf("Usage: tzSetEnable(0 or 1), where 0 is disable (stops recorder) and 1 enable (starts recording)");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The Tracealyzer ITM stream port for Keil µVision can be used in two ways.
|
||||
//
|
||||
// 1. Start tracing directly from startup.
|
||||
// Make sure tzSetEnable(1) is called below and vTraceEnable(TRC_START) in your target startup.
|
||||
//
|
||||
// 2. Start the trace manually, using the "Start Recording" button in Keil µVision.
|
||||
// In this case, comment out the below call to tzSetEnable and make sure you call vTraceEnable(TRC_INIT) in your target startup (not TRC_START).
|
||||
|
||||
tzSetEnable(1);
|
||||
|
||||
DEFINE BUTTON "Start Recording", "tzSetEnable(1)";
|
||||
DEFINE BUTTON "Stop Recording", "tzSetEnable(0)";
|
@ -0,0 +1,28 @@
|
||||
Tracealyzer Stream Port for ARM Cortex-M ITM
|
||||
--------------------------------------------
|
||||
2018-05-04
|
||||
|
||||
This directory contains a "stream port" for the Tracealyzer recorder library,
|
||||
i.e., the specific code needed to use a particular interface for streaming a
|
||||
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port targets ARM's ITM interface, which together with
|
||||
a fast debug probe such as a Keil ULINKpro or ULINKplus provides excellent
|
||||
performance. This stream port does not use any RAM buffer for the trace, but
|
||||
writes the data directly to the ITM registers. This is very fast.
|
||||
|
||||
To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus),
|
||||
see Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/
|
||||
|
||||
Learning more:
|
||||
- Tracealyzer User Manual (Help -> User Manual)
|
||||
- https://percepio.com/gettingstarted
|
||||
- Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/
|
||||
- About ITM trace, https://percepio.com/2016/06/09/arm-itm/
|
||||
- About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing
|
||||
|
||||
For questions, please contact support@percepio.com
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
@ -0,0 +1,91 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcStreamingPort.h
|
||||
*
|
||||
* The interface definitions for trace streaming ("stream ports").
|
||||
* This "stream port" sets up the recorder to use ARM ITM as streaming channel.
|
||||
*
|
||||
* Terms of Use
|
||||
* This file is part of the trace recorder library (RECORDER), which is the
|
||||
* intellectual property of Percepio AB (PERCEPIO) and provided under a
|
||||
* license as follows.
|
||||
* The RECORDER may be used free of charge for the purpose of recording data
|
||||
* intended for analysis in PERCEPIO products. It may not be used or modified
|
||||
* for other purposes without explicit permission from PERCEPIO.
|
||||
* You may distribute the RECORDER in its original source code form, assuming
|
||||
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
|
||||
* allowed to distribute the RECORDER with minor modifications intended for
|
||||
* configuration or porting of the RECORDER, e.g., to allow using it on a
|
||||
* specific processor, processor family or with a specific communication
|
||||
* interface. Any such modifications should be documented directly below
|
||||
* this comment block.
|
||||
*
|
||||
* Disclaimer
|
||||
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
|
||||
* as to its use or performance. PERCEPIO does not and cannot warrant the
|
||||
* performance or results you may obtain by using the RECORDER or documentation.
|
||||
* PERCEPIO make no warranties, express or implied, as to noninfringement of
|
||||
* third party rights, merchantability, or fitness for any particular purpose.
|
||||
* In no event will PERCEPIO, its technology partners, or distributors be liable
|
||||
* to you for any consequential, incidental or special damages, including any
|
||||
* lost profits or lost savings, even if a representative of PERCEPIO has been
|
||||
* advised of the possibility of such damages, or for any claim by any third
|
||||
* party. Some jurisdictions do not allow the exclusion or limitation of
|
||||
* incidental, consequential or special damages, or the exclusion of implied
|
||||
* warranties or limitations on how long an implied warranty may last, so the
|
||||
* above limitations may not apply to you.
|
||||
*
|
||||
* Tabs are used for indent in this file (1 tab = 4 spaces)
|
||||
*
|
||||
* Copyright Percepio AB, 2018.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRC_STREAMING_PORT_H
|
||||
#define TRC_STREAMING_PORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten);
|
||||
int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead);
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_CFG_ITM_PORT
|
||||
*
|
||||
* Possible values: 0 - 31
|
||||
*
|
||||
* What ITM port to use for the ITM software events. Make sure the IDE is
|
||||
* configured for the same channel.
|
||||
*
|
||||
* Default: 1 (0 is typically terminal output and 31 is used by Keil)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_ITM_PORT 1
|
||||
|
||||
#if (TRC_CFG_ITM_PORT < 0) || (TRC_CFG_ITM_PORT > 31)
|
||||
#error "Bad ITM port selected."
|
||||
#endif
|
||||
|
||||
// Not used for ITM - no RAM buffer...
|
||||
#define TRC_STREAM_PORT_ALLOCATE_FIELDS()
|
||||
|
||||
// Not used for ITM - assume the IDE configures the ITM setup
|
||||
#define TRC_STREAM_PORT_INIT()
|
||||
|
||||
/* Important for the ITM port - no RAM buffer, direct writes. In most other ports this can be skipped (default is 1) */
|
||||
#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0
|
||||
|
||||
#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) itm_write(_ptrData, _size, _ptrBytesWritten)
|
||||
|
||||
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) read_from_host(_ptrData, _size, _ptrBytesRead)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TRC_STREAMING_PORT_H */
|
@ -0,0 +1,71 @@
|
||||
|
||||
#include "trcRecorder.h"
|
||||
|
||||
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
|
||||
static void itm_write_32(uint32_t data);
|
||||
|
||||
volatile int32_t tz_host_command_bytes_to_read = 0; // This is set by the Tracealyzer host application (to the number of bytes written), after having written to tz_host_commands. Set to zero by the read function after the message in tz_host_commands has been read.
|
||||
volatile char tz_host_command_data[32];
|
||||
|
||||
/* This reads "command" data from a RAM buffer, written by a host macro in the debugger */
|
||||
int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead)
|
||||
{
|
||||
if ( tz_host_command_bytes_to_read > 0)
|
||||
{
|
||||
int i;
|
||||
uint8_t * bytesBuffer = (uint8_t*) ptrData;
|
||||
|
||||
if (ptrBytesRead != NULL)
|
||||
*ptrBytesRead = (int32_t)tz_host_command_bytes_to_read;
|
||||
|
||||
if (tz_host_command_bytes_to_read != size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=0; i < tz_host_command_bytes_to_read; i++)
|
||||
{
|
||||
bytesBuffer[i] = tz_host_command_data[i];
|
||||
}
|
||||
|
||||
tz_host_command_bytes_to_read = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void itm_write_32(uint32_t data)
|
||||
{
|
||||
if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && // Trace enabled
|
||||
(ITM->TCR & ITM_TCR_ITMENA_Msk) && // ITM enabled
|
||||
(ITM->TER & (1UL << TRC_CFG_ITM_PORT))) // ITM port enabled
|
||||
{
|
||||
while (ITM->PORT[TRC_CFG_ITM_PORT].u32 == 0); // Block until room in ITM FIFO - This stream port is always in "blocking mode", since intended for high-speed ITM!
|
||||
ITM->PORT[TRC_CFG_ITM_PORT].u32 = data; // Write the data
|
||||
}
|
||||
}
|
||||
|
||||
/* This is assumed to execute from within the recorder, with interrupts disabled */
|
||||
int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten)
|
||||
{
|
||||
uint32_t bytesWritten = 0;
|
||||
uint32_t* ptr32 = (uint32_t*)ptrData;
|
||||
|
||||
if (size % 4 != 0) return -2;
|
||||
|
||||
while(bytesWritten < size)
|
||||
{
|
||||
itm_write_32(*ptr32);
|
||||
ptr32++;
|
||||
bytesWritten += 4;
|
||||
}
|
||||
|
||||
*ptrBytesWritten = bytesWritten;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user