December 12, 2013
Blink an LED using the PRU on a Beaglebone Black
I just finished setting up my BBB for PRU development, and
want to try some basic things.
I am still more or less following along with this well written tutorial:
Set up one of the demos in my own way
The demos that come with the 335x PRU development package are set up with what are
(to my mind) overly complicated Makefiles. Besides that, I have made the decision to
put the PRU tools into the normal system directories, and would like to try things
out in a way that would ensure that everything is working OK.
What I do is to copy the files for the PRU_memAccess_DDR_PRUsharedRAM demo into
the directory /home/tom/pru_demo, and then hack away on the Makefile.
The Makefile I finally arrived at is this:
CFLAGS+= -Wall -D__DEBUG -O2 -mtune=cortex-a8 -march=armv7-a
LDFLAGS+= -lprussdrv -lpthread
TARGET=PRU_memAccess_DDR_PRUsharedRAM
OBJ = $(TARGET).o
ASM = $(TARGET).p
all: $(TARGET) $(TARGET).bin
%.o: %.c
gcc $(CFLAGS) -c -o $@ $<
$(TARGET): $(OBJ)
gcc $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(TARGET).bin: $(ASM)
pasm -V3 -b $<
run: all
./$(TARGET)
.PHONY: clean
clean:
rm -rf *.o *~ $(TARGET) $(TARGET).bin
Note that I have added a "run" target, so I can type "make run".
This now works fine and I have a self contained directory full of files
that is independent of the 335x PRU development package distribution.
Modify this demo to blink the usr0 LED
The instructions for how to do this are provided in the link given above,
and I am following along. I change the names of the files to pru_blink.*
After this I have to edit pru_blink.c and change the name of the PRU
executable it tries to find and load. I also have to change the name
of the file included by pru_blink.p to be pru_blink.hp. After this
the demo builds and runs just like the original demo.
Now I add in the code from the link above.
The assembler complains about using the reserved word "LOOP"
as a label, so I change it to LLOOP and it is happy.
It runs and works like a champ.
Feedback? Questions?
Drop me a line!
Tom's Computer Info / tom@mmto.org