🛠 Programmer les cores PRU : le clignotement temps réel déterministe

BeagleBone Black (TI Sitara AM3358) · avance · Schéma : IMG-beaglebone-black-avance-2-pru-blink-cores-temps-reel.svg — schéma bloc du PRU-ICSS de l'AM335x (2 cores 200 MHz, 8 Ko de mémoire d'instructions chacun, RAM partagée 12 Ko) relié directement aux broches d'entrée-sortie, Linux tournant à côté sans y toucher.

Objectives

The real power of the AM335x: two 32-bit PRU-ICSS cores running at 200 MHz, wired directly to the I/O pins, capable of bit-banging and deterministic control loops while Linux runs alongside. You will assemble a PRU blink program in assembly, load it via the mainline remoteproc driver, and measure period stability. As the SRM reminds us: TI never supported this chain on this platform — it is the community ecosystem (am335x_pru_package) that carries the subject.

Hardware

Complete Code

; blink.pasm — bascule la broche PRU0 R30.7 (à muxer vers une broche
; de nappe via un overlay gpmux)
        .origin 0
        .cinit
INIT    SET     R30, 0              ; efface le registre de sortie
LOOP    SET     R30.t7              ; bit 7 haut -> broche haute
        CALL    DELAY
        CLR     R30.t7              ; bit 7 bas  -> broche basse
        CALL    DELAY
        JMP     LOOP
DELAY   MOV     R0, 200000000       ; ~1 s à l'horloge 200 MHz du PRU
WAIT    SUB     R0, R0, 1
        QBEQ    DONE, R0, 0
        JMP     WAIT
DONE    HALT
# Assemblage avec la toolchain communautaire
git clone https://github.com/beagleboard/am335x_pru_package
cd am335x_pru_package && make -C pru_sw/app_loader && cd ..
export PATH=$PWD/pru_sw/utils:$PATH
clpr blink.pasm && link_pru blink.obj blink_out
sudo cp blink_out /lib/firmware/am335x-pru0-fw

# Chargement via remoteproc mainline (les noms exacts varient selon le noyau)
ls /sys/class/remoteproc/
echo start | sudo tee /sys/class/remoteproc/remoteproc0/state
cat /sys/class/remoteproc/remoteproc0/state    # attendu : running

Expected Verification

The remoteproc state transitions to running, and the oscilloscope shows a perfectly regular square wave: the period does NOT depend on the Linux load (test with stress-ng --cpu 1 running alongside: the square wave does not shift by a single cycle). This demonstrates the real-time coprocessor.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials