faster firmware development with freertos and tracealyzer
TRANSCRIPT
Faster Firmware Development with Tracealyzer
Faster Firmware Development with Tracealyzer
Dr. Johan Kraft, CEO/CTO/Founder, Percepio [email protected]
Faster Firmware Development with Tracealyzer
?
Source code - not the full picture!
Software behavior depends on timing
Interrupts? Critical Sections? Execution times? Dynamic memory allocation?RTOS Scheduling? Timeouts? Priorities? Blocking? Triggering?
CPU usage? Response times? Periodicities?
What is actually going on in the runtime system?
Faster Firmware Development with Tracealyzer
Software Tracing
Software-defined TracingRecorder module + instrumentationrecords RTOS and application logging.
Faster Firmware Development with Tracealyzer
Trace Visualization – See the Runtime World
Faster Firmware Development with Tracealyzer
Improves Development Efficiency and Quality
ValidationCode running as intended?
DebuggingRTOS and timing issues
ProfilingRAM and CPU usage per
task?
DocumentationVisualize designs or issues
TrainingRTOS and other APIs
“Tracealyzer has doubled our development speed. Problems that otherwise would take days to solve are obvious with this tool and just a quick fix.”Alex Pabouctisids, Lead Firmware Engineer, Flyability.
“In less than 5 days from running the tool, we improved the performance of our graphic rendering engine by 3x!”Terry West, CEO, Serious Integrated Inc.
Faster Firmware Development with Tracealyzer
Main Trace ViewVertical time-line- Task scheduling- Preemptions- Interrupts- RTOS API calls- Blocking- Resumes- Timeouts- RTOS Tick- User Events
Faster Firmware Development with Tracealyzer
Kernel Object HistoryDouble-click on a queue, semaphore or mutex label to see all operations and states of the selected kernel object.
Track queue messages between send and receive or vice versa. Double-click showsthe event in main trace view.
Faster Firmware Development with TracealyzerSummary of task and ISR communications via kernel objects (queues, …)
Communication Flow
Faster Firmware Development with TracealyzerCPU Load Graph: Use of processor cycles, per task and ISR.Kernel Object Utilization: Size of queues over time.
Faster Firmware Development with TracealyzerUser Event Signal Plot: Any data logged as ”User Events”
Faster Firmware Development with Tracealyzer
Customer Case 1
Faster Firmware Development with Tracealyzer
Case 1 – Timing variations
Task should execute every 5 ms, but random variations of 1-2 ms!
Faster Firmware Development with Tracealyzer
Compare with the Task Trace...
Something delays the activation of SamplerTask, probably ControlTask!
Faster Firmware Development with Tracealyzer
Why delayed preemption? Looking closer...
ControlTask seems to disable interrupts!
No OS Ticks for 2.5 ms
Faster Firmware Development with Tracealyzer
Showing all logged events...
ServerTask also logged ”Updating file”, but uses a Mutex instead!
Faster Firmware Development with Tracealyzer
When using a Mutex instead of disabling interrupts...
Now perfect 5 ms periodicity!
Faster Firmware Development with Tracealyzer
Customer Case 2
Faster Firmware Development with Tracealyzer
Watchdog reset? User events added…
Faster Firmware Development with Tracealyzer
Why doesn’t SamplerTask reset the Watchdog?
Faster Firmware Development with Tracealyzer
Why is ControlQueue blocking?
Faster Firmware Development with Tracealyzer
So the queue gets full... Why is ControlTask is not reading the queue fast enough?
ServerTask has higher priority than ControlTask, does not leave enough cycles when high load!
Faster Firmware Development with Tracealyzer
With swapped task priorities – problem solved!
Faster Firmware Development with Tracealyzer
Integrating the Recorder Library
• RTOS events is traced automatically via Percepio’s ”instrumentation layer” for the supported RTOS– For FreeRTOS:
• Enable ”useTRACE_FACILITY” in FreeRTOSConfig.h• Include ”trcKernelPort.h” in FreeRTOSConfig.h.• Call the recorder’s init function early in main().• Start and stop the recorder when desired.
– Similar for Micrium, SafeRTOS and embOS.• Accurate hardware timestamping ”out-of-the-box” for
most MCUs (see trcHardwarePort.h)– ARM Cortex-M, Renesas RX, Microchip PIC32, …– Easy to implement new ports via macros.
• See http://percepio.com/gettingstarted
Faster Firmware Development with Tracealyzer
Evaluate Tracealyzer!http://percepio.com/download