A ready-to-use bootable SD card image for BeagleBone Black/Green with a fully preemptible Linux kernel (PREEMPT_RT) — includes a gpio-test program that mirrors an input signal to a GPIO output pin for measuring scheduler latency with an oscilloscope.
Oscilloscope view — yellow is the input signal, blue is the GPIO output. The phase difference indicates scheduler latency.
Thanks to Maxime Chevallier of Bootlin for providing the gpio-test demo utility during PREEMPT_RT training.
Setup diagram
Items needed
- BeagleBone Black or Green
- +5 V power adapter
- Micro SD card (1 GB or larger)
- Programmable signal generator board
- 2-channel oscilloscope
- Jumper wires
Instructions
- Prepare the setup as shown in the diagram (set signal generator to 100 Hz, 50% duty cycle)
- Download sdcard-beaglebone-preemptrt-demo.img.xz (~25 MB)
- Write the image to a micro SD card using Balena Etcher
- Insert the SD card into the BeagleBone and power on
- After boot, the oscilloscope shows two square waves with a phase difference — yellow (input) and blue (output from BeagleBone)
- The phase difference indicates the latency introduced by the scheduler while running the preemptrt-gpiotest program
On startup, /etc/init.d/S99PreemptrtGpioTester invokes:
chrt -r 99 /usr/sbin/preemptrt-gpiotest gpiochip0 28 gpiochip0 17 h p
This starts the gpio-test utility at real-time priority 99.
Measuring latency under load
The gpio-test program mirrors a GPIO input to an output — the phase difference between the two signals shows how fast the scheduler delivers context to your application. Jitter on the output signal (measured in oscilloscope persist mode) indicates the best and worst case scheduler latency under different load conditions (network traffic, interrupts, etc.).
For further details on PREEMPT_RT, see Bootlin's PREEMPT_RT training material.
Building from source
Detailed build instructions are available in the git repository. Cross-compile instructions for modifying and running a customized gpio-test utility are also available.
SOURCE CODE
github.com/hackboxguy/preemptrt-gpiotest — GPIO latency test program
github.com/hackboxguy/br-wrapper — Buildroot config and build instructions
sdcard-beaglebone-preemptrt-demo.img.xz — pre-built SD card image (~25 MB)
2 comments:
Great article! Is the response time just 3 kHz? What speed runs the cpu on?
Hello Albert,
That's a very neat article ! Thanks for the credit :)
You made my day :)
Maxime
Post a Comment