Permalink
Browse files

o First Beaglebone PRU boilerplate stuff

  • Loading branch information...
hzeller committed Jan 2, 2017
1 parent 8446bbd commit cb52d97491372a817c8ba8760c1aa0c362c2262f
View
@@ -1,2 +1,6 @@
*~
.compiler-flags
*.o
*.o.d
*-pru_bin.h
ldgraphy
View
@@ -0,0 +1,3 @@
[submodule "am335x_pru_package"]
path = am335x_pru_package
url = https://github.com/hzeller/am335x_pru_package.git
View
@@ -1,6 +1,8 @@
LDgraphy - Laser Direct Lithography
===================================
(work in progress, nothing to see here yet)
Simple implementation of direct photo resist exposure using a 405nm laser.
Uses
@@ -9,6 +11,10 @@ Uses
* stepper motor
* Beaglebone Black to control it all.
Build
-----
git clone --recursive https://github.com/hzeller/ldgraphy.git
----
Polygon scanner mirror
NBC3111
Submodule am335x_pru_package added at 7e2aea
Binary file not shown.
View
@@ -0,0 +1,56 @@
/*
* Based on github.com/jadonk/validation-scripts/tree/master/test-capemgr
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Purpose License Version 2 as
* published by the Free Software Foundation
*
* To create the binary representation that the device manager can handle, run
* make LDGraphy-00A0.dtbo
* (The binary fill is checked into github, so this is only needed if you are
* modifying this file)
*/
/dts-v1/;
/plugin/;
/{
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
part-number = "LDGraphy";
version = "00A0";
exclusive-use = "pruss", // Programmable realtime unit
"P9.18", "P9.17";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
beagleg_gpio_pins: LDGraphy_Pins {
pinctrl-single,pins = <
0x158 0x07 /* GPIO0[4] ; Polygon Mirror Clock */
0x15c 0x07 /* GPIO0[5] ; Laser Data */
>;
};
};
};
fragment@1 {
target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&beagleg_gpio_pins>;
status = "okay";
};
};
};
fragment@2{
target = <&pruss>;
__overlay__ {
status = "okay";
};
};
};
View
@@ -0,0 +1,6 @@
all : LDGraphy-00A0.dtbo
# Making a binary devicetree
%-00A0.dtbo: %.dts
dtc -I dts -O dtb -o $@ -b 0 -@ $^
@@ -0,0 +1,78 @@
#!/bin/bash
# This requires bb-customizations be installed
# sudo apt-get install bb-customizations
#
# Essentially what we are doing is to embed the DTBO file in the initrd file, so that it
# is available right away on boot-up. That is the quickest way to enable the cape at boot-up
# short of compiling the device-tree file into the kernel.
##
set -e
DT_VERSION=00A0
UENV_FILE=/boot/uEnv.txt
usage() {
echo "Usage: $0 <dts-file>"
echo "Available:"
for f in $(ls `dirname $0`/*/*.dts) ; do
echo " $f"
done
exit 1
}
if [ $# -ne 1 ] ; then
usage
fi
DTS_FILE=$1
if [[ ! $DTS_FILE =~ \.dts$ ]] ; then
echo "This does not seem to be a *.dts file".
usage
fi
# ... there must be a simpler way to extract this...
CAPE_NAME=$(sed 's/.*part-number\s*=\s*"\([^"]*\)".*/\1/p;d' < $DTS_FILE)
if [ -z "$CAPE_NAME" ] ; then
echo "Didn't find any part-number in $DTS_FILE ?"
exit
fi
DTBO_FILE=$(echo "$DTS_FILE" | sed "s/.dts$/-$DT_VERSION.dtbo/")
make $DTBO_FILE
if [ $? -ne 0 ] ; then
echo "Failed to produce $DTBO_FILE"
fi
# The initramfs script will pick up dtbos from /lib/firmware.
# Let's put it there.
cp $DTBO_FILE /lib/firmware
if uname -r | grep -q "^4" ; then
MAGIC_ENABLE=cape_enable=bone_capemgr.enable_partno=
else
MAGIC_ENABLE=cape_enable=capemgr.enable_partno=
fi
# First: set up UENV_FILE.
echo "* Setting up $UENV_FILE"
# Note, this only works properly if optargs is not set yet.
if grep "^${MAGIC_ENABLE}.*${CAPE_NAME}" $UENV_FILE > /dev/null ; then
echo " * Already configured in $UENV_FILE"
else
if grep "^$MAGIC_ENABLE" $UENV_FILE > /dev/null ; then
echo " * Adding $CAPE_NAME to cape-enable line in $UENV_FILE"
sed -i "s/^${MAGIC_ENABLE}.*/\0,${CAPE_NAME}/g" $UENV_FILE
else
echo " * Adding cape-enable line to $UENV_FILE"
echo "${MAGIC_ENABLE}${CAPE_NAME}" >> $UENV_FILE
fi
fi
update-initramfs -tu -k `uname -r`
sync
echo "Now reboot for the cape to be initialized at boot time"
@@ -0,0 +1,78 @@
#!/bin/bash
# Run as root.
# What is happening here is well explained in Derek Molloy's excellent
# video http://www.youtube.com/watch?v=wui_wU1AeQc
##
VERBOSE=0
DT_VERSION=00A0
usage() {
echo "Usage: $0 <dts-file>"
echo "Available:"
for f in $(ls `dirname $0`/*.dts) ; do
echo " $f"
done
exit 1
}
if [ $# -ne 1 ] ; then
usage
fi
DTS_FILE=$1
if [[ ! $DTS_FILE =~ \.dts$ ]] ; then
echo "This does not seem to be a *.dts file".
usage
fi
# ... there must be a simpler way to extract this...
CAPE_NAME=$(sed 's/.*part-number\s*=\s*"\([^"]*\)".*/\1/p;d' < $DTS_FILE)
if [ -z "$CAPE_NAME" ] ; then
echo "Didn't find any part-number in $DTS_FILE ?"
exit
fi
DTBO_FILE=$(echo "$DTS_FILE" | sed "s/.dts$/-$DT_VERSION.dtbo/")
make $DTBO_FILE
if [ $? -ne 0 ] ; then
echo "Failed to produce $DTBO_FILE"
fi
PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins
if [ -e /sys/devices/platform/bone_capemgr/slots ] ; then
SLOTS=/sys/devices/platform/bone_capemgr/slots
else
# 3.x way of doing things.
SLOTS=/sys/devices/bone_capemgr.*/slots
fi
# Some dance around minimal tools available on the system. We get the offsets
# and add 44e10800 to it, so that we can grep these in the $PINS
OFFSETS_800=$(for f in $(cat $DTS_FILE | grep "^\s*0x" | awk '{print $1}') ; do \
printf "%0d" $f | awk '{printf("44e10%03x\n", $1 + 2048)}'; \
done)
if [ $VERBOSE -ne 0 ] ; then
echo "This is how these pins look before."
for f in $OFFSETS_800 ; do
grep $f $PINS
done
fi
cp $DTBO_FILE /lib/firmware
echo
echo "Adding $CAPE_NAME overlay"
echo "$CAPE_NAME" > $SLOTS
cat $SLOTS
if [ $VERBOSE -ne 0 ] ; then
echo
echo "This is how these pins look afterwards."
for f in $OFFSETS_800 ; do
grep $f $PINS
done
fi
View
@@ -0,0 +1,72 @@
# (c) 2017 h.zeller@acm.org
# This is free software. License: GNU 3.0
# In case you cross compile this on a different architecture, uncomment this
# and set the prefix. Or simply set the environment variable.
#CROSS_COMPILE?=arm-arago-linux-gnueabi-
# Tuning options for ARM CPU. Unset this in an environment variable if compiled
# on a different system.
ARM_COMPILE_FLAGS?=-mtune=cortex-a8 -march=armv7-a
# Location of am335x package https://github.com/beagleboard/am335x_pru_package
# We check this out in a local git submodule.
AM335_BASE=../am335x_pru_package
PASM=$(AM335_BASE)/pru_sw/utils/pasm
LIBDIR_APP_LOADER?=$(AM335_BASE)/pru_sw/app_loader/lib
INCDIR_APP_LOADER?=$(AM335_BASE)/pru_sw/app_loader/include
CAPE_INCLUDE=../hardware/$(LDGRAPHY_HARDWARE_TARGET)
# Optmization flags. Typically, that should be -O3 for regluar use, but for
# debugging and development "-g -O0" can be more helpful. Overridable by
# environment variable.
LDGRAPHY_OPT_CFLAGS?=-O3
CFLAGS+=-Wall -I$(INCDIR_APP_LOADER) -I$(CAPE_INCLUDE) -D_XOPEN_SOURCE=500 $(ARM_COMPILE_FLAGS) $(LDGRAPHY_OPT_CFLAGS) -DCAPE_NAME='"$(LDGRAPHY_HARDWARE_TARGET)"'
# We use c++11, but it looks like that even the latest
# bone-debian-7.11-lxde-4gb-armhf-2016-06-16-4gb image has an ancient 4.6.3
# compiler that still referred to that standard as c++0x
export CXXFLAGS+=-std=c++0x $(CFLAGS)
export CXX?=g++
LDFLAGS+=-lpthread -lm
PRUSS_LIBS=$(LIBDIR_APP_LOADER)/libprussdrv.a
# Assembled binary from *.p file.
PRU_BIN=laser-scribe-pru_bin.h
OBJECTS=uio-pruss-interface.o
MAIN_OBJECTS=main.o
TARGETS=ldgraphy
DEPENDENCY_RULES=$(OBJECTS:=.d)
all : $(TARGETS)
ldgraphy: main.o $(OBJECTS)
$(CROSS_COMPILE)$(CXX) -o $@ $^ $(LDFLAGS) $(PRUSS_LIBS)
%.o: %.cc .compiler-flags
$(CROSS_COMPILE)$(CXX) $(CXXFLAGS) -c $< -o $@
@$(CROSS_COMPILE)$(CXX) $(CXXFLAGS) -MM $< > $@.d
%_bin.h : %.p $(PASM)
$(PASM) -I$(CAPE_INCLUDE) -V3 -c $<
$(PASM):
make -C $(AM335_BASE)
main.o : laser-scribe-pru_bin.h
# Auto generated dependencies
-include $(DEPENDENCY_RULES)
clean:
rm -rf $(TARGETS) $(MAIN_OBJECTS) $(OBJECTS) $(PRU_BIN) $(DEPENDENCY_RULES)
.compiler-flags: FORCE
@echo '$(CXX) $(CXXFLAGS) $(GTEST_INCLUDE)' | cmp -s - $@ || echo '$(CXX) $(CXXFLAGS) $(GTEST_INCLUDE)' > $@
.PHONY: FORCE
Oops, something went wrong.

0 comments on commit cb52d97

Please sign in to comment.