faster firmware development with freertos and tracealyzer

24
Faster Firmware Development with Tracealyzer Faster Firmware Development with Tracealyzer Dr. Johan Kraft, CEO/CTO/Founder, Percepio AB [email protected]

Upload: mike-skrtic

Post on 25-Jan-2017

221 views

Category:

Devices & Hardware


7 download

TRANSCRIPT

Page 1: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Faster Firmware Development with Tracealyzer

Dr. Johan Kraft, CEO/CTO/Founder, Percepio [email protected]

Page 2: Faster firmware development with FreeRTOS and Tracealyzer

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?

Page 3: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Software Tracing

Software-defined TracingRecorder module + instrumentationrecords RTOS and application logging.

Page 4: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Trace Visualization – See the Runtime World

Page 5: Faster firmware development with FreeRTOS and Tracealyzer

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.

Page 6: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Main Trace ViewVertical time-line- Task scheduling- Preemptions- Interrupts- RTOS API calls- Blocking- Resumes- Timeouts- RTOS Tick- User Events

Page 7: Faster firmware development with FreeRTOS and Tracealyzer

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.

Page 8: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with TracealyzerSummary of task and ISR communications via kernel objects (queues, …)

Communication Flow

Page 9: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with TracealyzerCPU Load Graph: Use of processor cycles, per task and ISR.Kernel Object Utilization: Size of queues over time.

Page 10: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with TracealyzerUser Event Signal Plot: Any data logged as ”User Events”

Page 11: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Customer Case 1

Page 12: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Case 1 – Timing variations

Task should execute every 5 ms, but random variations of 1-2 ms!

Page 13: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Compare with the Task Trace...

Something delays the activation of SamplerTask, probably ControlTask!

Page 14: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Why delayed preemption? Looking closer...

ControlTask seems to disable interrupts!

No OS Ticks for 2.5 ms

Page 15: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Showing all logged events...

ServerTask also logged ”Updating file”, but uses a Mutex instead!

Page 16: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

When using a Mutex instead of disabling interrupts...

Now perfect 5 ms periodicity!

Page 17: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Customer Case 2

Page 18: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Watchdog reset? User events added…

Page 19: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Why doesn’t SamplerTask reset the Watchdog?

Page 20: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

Why is ControlQueue blocking?

Page 21: Faster firmware development with FreeRTOS and Tracealyzer

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!

Page 22: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

With swapped task priorities – problem solved!

Page 23: Faster firmware development with FreeRTOS and Tracealyzer

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

Page 24: Faster firmware development with FreeRTOS and Tracealyzer

Faster Firmware Development with Tracealyzer

[email protected]

Evaluate Tracealyzer!http://percepio.com/download