Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[refactor] - split more cleanly into driver/ and pb_utils/
This is really 2 projects in one repository.
  • Loading branch information
Richard Neill committed Sep 17, 2013
1 parent a20a73a commit 149693c
Show file tree
Hide file tree
Showing 27 changed files with 237 additions and 58 deletions.
55 changes: 9 additions & 46 deletions Makefile
Expand Up @@ -10,40 +10,17 @@ WWW_DIR = pulseblaster
all :: compile

compile:
@[ -d /usr/src/*`uname -r` ] || (echo "Error: please install the kernel sources"; exit 1)
cd kernel; make -C /lib/modules/`uname -r`/build M=`pwd` ; cd -
pod2man pb_ctl/pb_ctl -c "User Commands" | bzip2 > man/pb_ctl.1.bz2
bzip2 -kf man/pulseblaster.1
bzip2 -kf man/pb_driver-load.1
bzip2 -kf man/pb_test-flash-2Hz.1
ln -sf pb_test-flash-2Hz.1.bz2 man/pb_test-flash-fastest-5.55MHz.1.bz2
ln -sf pb_test-flash-2Hz.1.bz2 man/pb_test-identify-output.1.bz2
ln -sf pb_driver-load.1.bz2 man/pb_driver-unload.1.bz2
make -C driver
make -C pb_utils
bzip2 -kf man/pulseblaster.1

install:
@[ `whoami` = root ] || (echo "Error, please be root"; exit 1)
@#Kernel module
mkdir -p /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
cp kernel/pulseblaster.ko /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
gzip -f /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster/pulseblaster.ko
depmod -A

@#PAM permissions.
echo '<console> 0660 /sys/class/pulseblaster/pulseblaster*/* 660 root.usb' > /etc/security/console.perms.d/90-pulseblaster.perms
@#Do it
modprobe pulseblaster; pam_console_apply

mkdir -p $(BINDIR) $(MAN1DIR) $(DOCDIR)
install pb_ctl/pb_ctl $(BINDIR)
install pb_ctl/pb_driver-load.sh $(BINDIR)/pb_driver-load
install pb_ctl/pb_driver-unload.sh $(BINDIR)/pb_driver-unload
install pb_ctl/pb_test-flash-2Hz.sh $(BINDIR)/pb_test-flash-2Hz
install pb_ctl/pb_test-flash-fastest-5.55MHz.sh $(BINDIR)/pb_test-flash-fastest-5.55MHz
install pb_ctl/pb_test-identify-output.sh $(BINDIR)/pb_test-identify-output
install -m644 README.txt LICENSE.txt doc/* $(DOCDIR)
install -m644 man/*.1.bz2 $(MAN1DIR)
make -C driver install
make -C pb_utils install
mkdir -p $(BINDIR) $(MAN1DIR) $(DOCDIR)
install -m644 README.txt LICENSE.txt index.html $(DOCDIR)
install -m644 man/*.1.bz2 $(MAN1DIR)

.PHONY: www
www:
Expand All @@ -61,28 +38,14 @@ www:
@echo "Now, upload www/$(WWW_DIR)/ and link to www/$(WWW_DIR)/index.html"

clean:
rm -f kernel/*.o kernel/*.ko
rm -f man/*.bz2 man/*.html
make -C driver clean
make -C pb_utils clean
rm -f man/*.bz2 man/*.html
rm -rf www

uninstall:
@[ `whoami` = root ] || (echo "Error, please be root"; exit 1)
rm -rf /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
depmod -A
rm -f /etc/security/console.perms.d/90-pulseblaster.perms
rm -f $(BINDIR)/pb_ctl
rm -f $(BINDIR)/pb_driver-load
rm -f $(BINDIR)/pb_driver-unload
rm -f $(BINDIR)/pb_test-flash-2Hz
rm -f $(BINDIR)/pb_test-flash-fastest-5.55MHz
rm -f $(BINDIR)/pb_test-identify-output
rm -f $(MAN1DIR)/pulseblaster.1.bz2
rm -f $(MAN1DIR)/pb_ctl.1.bz2
rm -f $(MAN1DIR)/pb_driver-load.1.bz2
rm -f $(MAN1DIR)/pb_driver-unload.1.bz2
rm -f $(MAN1DIR)/pb_test-flash-2Hz.1.bz2
rm -f $(MAN1DIR)/pb_test-flash-fastest-5.55MHz.1.bz2
rm -f $(MAN1DIR)/pb_test-identify_output.1.bz2
rm -rf $(DOCDIR)
make -C driver uninstall
make -C pb_utils uninstall
8 changes: 4 additions & 4 deletions README.txt
Expand Up @@ -6,11 +6,11 @@ See: http://spincore.com/products/PulseBlaster/PulseBlaster-Programmable-Pulse-G
It consists of:


kernel/
driver/
kernel/
The driver. This builds on kernel 3.8.
It creates entries in /sys, under /sys/class/pulseblaster/

pb_ctl/
pb_ctl/
A simple control script and some debugging/diagnostic utilities.

pb_utils/
Expand Down Expand Up @@ -99,7 +99,7 @@ pb_utils/ comprises:
pb_check - check lspci for the pulseblaster hardware being present.

For debugging, use:
pb_test-identify-output.sh - identify a particular output in the hardware by flashing its bit.
pb_identify_output.sh - identify a particular output in the hardware by flashing its bit.
pb_freq_gen.sh - generate a square wave of a desired frequency on selected bits.
pb_manual - manually, interactively, control the pulseblaster outputs. This is actually quite useful!

Expand Down
3 changes: 3 additions & 0 deletions driver/LICENSE.txt
@@ -0,0 +1,3 @@
This is all Free Software, licensed under the GNU GPL.
Copyright 2010 - 2013, Michael Brown and Richard Neill.
License version is "v3 or later", except for the kernel driver which is "v2".
64 changes: 64 additions & 0 deletions driver/Makefile
@@ -0,0 +1,64 @@
PREFIX = $(DESTDIR)/usr/local
BINDIR = $(PREFIX)/bin
DATAROOTDIR = $(PREFIX)/share
DOCDIR = $(DATAROOTDIR)/doc/pb_driver
MANDIR = $(DATAROOTDIR)/man
MAN1DIR = $(MANDIR)/man1

all :: compile

compile:
@[ -d /usr/src/*`uname -r` ] || (echo "Error: please install the kernel sources"; exit 1)
cd kernel; make -C /lib/modules/`uname -r`/build M=`pwd` ; cd -
pod2man pb_ctl/pb_ctl -c "User Commands" | bzip2 > man/pb_ctl.1.bz2
bzip2 -kf man/pb_driver-load.1
bzip2 -kf man/pb_test-flash-2Hz.1
ln -sf pb_test-flash-2Hz.1.bz2 man/pb_test-flash-fastest-5.55MHz.1.bz2
ln -sf pb_test-flash-2Hz.1.bz2 man/pb_test-identify-output.1.bz2
ln -sf pb_driver-load.1.bz2 man/pb_driver-unload.1.bz2

install:
@[ `whoami` = root ] || (echo "Error, please be root"; exit 1)
@#Kernel module
mkdir -p /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
cp kernel/pulseblaster.ko /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
gzip -f /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster/pulseblaster.ko
depmod -A

@#PAM permissions.
echo '<console> 0660 /sys/class/pulseblaster/pulseblaster*/* 660 root.usb' > /etc/security/console.perms.d/90-pulseblaster.perms
@#Do it
modprobe pulseblaster; pam_console_apply

mkdir -p $(BINDIR) $(MAN1DIR) $(DOCDIR)
install pb_ctl/pb_ctl $(BINDIR)
install pb_ctl/pb_driver-load.sh $(BINDIR)/pb_driver-load
install pb_ctl/pb_driver-unload.sh $(BINDIR)/pb_driver-unload
install pb_ctl/pb_test-flash-2Hz.sh $(BINDIR)/pb_test-flash-2Hz
install pb_ctl/pb_test-flash-fastest-5.55MHz.sh $(BINDIR)/pb_test-flash-fastest-5.55MHz
install pb_ctl/pb_test-identify-output.sh $(BINDIR)/pb_test-identify-output
install -m644 README.txt LICENSE.txt doc/* $(DOCDIR)
install -m644 man/*.1.bz2 $(MAN1DIR)

clean:
rm -f kernel/*.o kernel/*.ko
rm -f man/*.bz2 man/*.html

uninstall:
@[ `whoami` = root ] || (echo "Error, please be root"; exit 1)
rm -rf /lib/modules/`uname -r`/kernel/3rdparty/pulseblaster
depmod -A
rm -f /etc/security/console.perms.d/90-pulseblaster.perms
rm -f $(BINDIR)/pb_ctl
rm -f $(BINDIR)/pb_driver-load
rm -f $(BINDIR)/pb_driver-unload
rm -f $(BINDIR)/pb_test-flash-2Hz
rm -f $(BINDIR)/pb_test-flash-fastest-5.55MHz
rm -f $(BINDIR)/pb_test-identify-output
rm -f $(MAN1DIR)/pb_ctl.1.bz2
rm -f $(MAN1DIR)/pb_driver-load.1.bz2
rm -f $(MAN1DIR)/pb_driver-unload.1.bz2
rm -f $(MAN1DIR)/pb_test-flash-2Hz.1.bz2
rm -f $(MAN1DIR)/pb_test-flash-fastest-5.55MHz.1.bz2
rm -f $(MAN1DIR)/pb_test-identify_output.1.bz2
rm -rf $(DOCDIR)
58 changes: 58 additions & 0 deletions driver/README.txt
@@ -0,0 +1,58 @@
INTRODUCTION
------------

This is a GPL'd Linux driver for the SpinCore PulseBlaster PCI Digital Timing card:

kernel/
The driver. This builds on kernel 3.8.
It creates entries in /sys, under /sys/class/pulseblaster/

pb_ctl/
A simple control script and some low-level debugging/diagnostic utilities.


MODULE LOADING
--------------

insmod ./pulseblaster.ko ; rmmod pulseblaster

Loading the module will create entries within /sys/class/pulseblaster,
typically /sys/class/pulseblaster/pulseblaster0/*

After running make install, this will happen automatically on reboot, and pam_console_apply
will automatically grant permissions the the logged-in user. Or use pb_driver-load.


USERSPACE
---------

It's possible to just write directly to the /sys interface.

Eg: doc/flash.bin is a pulseblaster executable to flash all the outputs at 2Hz

To program it:
cat doc/flash.bin > /sys/class/pulseblaster/pulseblaster0/program
To start the program:
echo 1 > /sys/class/pulseblaster/pulseblaster0/start


Identify specific outputs with pb_test-identify-output.sh
(this generates simple PB programs).


DISTRIBUTION
------------

Once the driver becomes part of the kernel, there's no need to install pb_ctl/*.
Just use pb_utils.


SEE ALSO
--------

* pb_utils - PulseBlaster control and assembler.

* pb_parse - High-level compiler.

* GIT tree at: http://git.ipxe.org/people/rjn/pulseblaster.git

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -27,7 +27,7 @@ <h2>Installation</h2>

<ul>
<li>To install, simply: <tt>make && sudo make install</tt>. Then run, for example <tt>pb_freq_gen</tt>
<li>Consider also installing <a href="../pb_parse/index.html">pb_parse</a>.
<li>It is also recommended to install <a href="../pb_parse/index.html">pb_parse</a>.
<li>This is Free Software released under the GNU GPL v3+ (except the kernel driver which is v2). Please feel free to take it, modify it, package it etc.
<li>Authors: Richard Neill and Michael Brown. Do ask if you would like further information and assistance.
</ul>
Expand All @@ -41,7 +41,7 @@ <h2>pb_utils</h2>
<li><tt>pb_init</tt>, <tt>pb_zero</tt> &nbsp;-&nbsp; directly set the PulseBlaster's outputs.
<li><tt>pb_vliw</tt> &nbsp;-&nbsp; generates an example/demo VLIW file. (see also <tt>vliw&nbsp;(5)</tt>)
<li><tt>pb_check</tt> &nbsp;-&nbsp; check <tt>lspci</tt> for the PulseBlaster hardware.
<li><tt>pb_test-identify-output</tt> &nbsp;-&nbsp; identify a particular hardware output and check phase.
<li><tt>pb_identify_output</tt> &nbsp;-&nbsp; identify a particular hardware output and check phase.
<li><tt>pb_freq_gen.sh</tt> &nbsp;-&nbsp; generate a square wave of a desired frequency on selected bits.
<li><tt>pb_manual</tt> &nbsp;-&nbsp; manually, interactively, control the PulseBlaster outputs. Useful for debugging whatever it's connected to.
</ul>
Expand Down
4 changes: 4 additions & 0 deletions pb_utils/Makefile
Expand Up @@ -60,6 +60,7 @@ manpages:
bash man/pb_utils.1.sh
bash man/vliw.5.sh
bash man/pb_freq_gen.1.sh
bash man/pb_identify_output.1.sh
bash man/pb_manual.1.sh
bash man/pb_serial_trigger.1.sh
bash man/pb_serial_trigger_check.1.sh
Expand Down Expand Up @@ -108,6 +109,7 @@ install:
install src/pb_vliw $(BINDIR)
install src/pb_print_config $(BINDIR)
install src/pb_check.sh $(BINDIR)/pb_check
install src/pb_identify_output.sh $(BINDIR)/pb_identify_output
install src/pb_freq_gen.sh $(BINDIR)/pb_freq_gen
install src/pb_manual.sh $(BINDIR)/pb_manual
install src/pb_serial_trigger $(BINDIR)
Expand Down Expand Up @@ -149,6 +151,7 @@ uninstall:

rm -f $(BINDIR)/pb_test-pbinit-counter
rm -f $(BINDIR)/pb_test-vliw-walk4
rm -f $(BINDIR)/pb_identify_output
rm -f $(BINDIR)/pb_freq_gen
rm -f $(BINDIR)/pb_manual

Expand All @@ -169,6 +172,7 @@ uninstall:
rm -f $(MAN1DIR)/pb_vliw.1.bz2
rm -f $(MAN1DIR)/pb_print_config.1.bz2
rm -f $(MAN1DIR)/pb_check.1.bz2
rm -f $(MAN1DIR)/pb_identify_output.1.bz2
rm -f $(MAN1DIR)/pb_freq_gen.1.bz2
rm -f $(MAN1DIR)/pb_manual.1.bz2
rm -f $(MAN1DIR)/pb_serial_trigger.1.bz2
Expand Down
8 changes: 8 additions & 0 deletions pb_utils/README.txt
Expand Up @@ -66,6 +66,9 @@ src/


Helper programs:
pb_identify_output
Control the PB to flash one (specified) bit, asymmetrically, to identify it and check phase.

pb_freq_gen
Control the PB to output a square wave of a given frequency on a given set of output bits.

Expand Down Expand Up @@ -121,3 +124,8 @@ Makefile
README.txt, LICENSE.txt
This readme, and the GPL License.


See also:
* This was written as part of my PhD InfraRed Camera system: http://www.richardneill.org/phd
* There is a GIT tree at: http://git.ipxe.org/people/rjn/pulseblaster.git
* There is also a parser, pb_parse in a parallel project.
2 changes: 1 addition & 1 deletion pb_utils/man/pb_freq_gen.1.sh
Expand Up @@ -23,7 +23,7 @@ SOURCE="IR Camera System"
DATE="July 2012"
#See also. Array, Each manpage with its section.
SEE_ALSO=( "pb_utils (1)" "ni4462_system_clock_calibrate (1)" )
SEE_ALSO=( "pb_utils (1)" "ni4462_system_clock_calibrate (1)" "pb_manual (1)" "pb_identify_output (1)" )
#Prefix each line with a leading space? Prevent paragraphs from being line-wrapped. true/false
LEADING_SPACE=true
Expand Down
@@ -1,13 +1,13 @@
#Generate manpage from command's output. Invoke with "sh", -h for help.

#Program name.
NAME="pb_freq_out"
NAME="pb_identify_output"

#The binary, (relative path to this script). Invoked with "-h" for help text (stdout or stderr)
BINARY=../src/pb_freq_out.sh
BINARY=../src/pb_identify_output.sh

#Description: brief string for the start of the man page.
DESCRIPTION="output a square wave from the pulseblaster"
DESCRIPTION="identify a given output of the pulseblaster, and check phase"

#Synopsis text, or leave blank to omit. Add leading spaces to avoid automatic paragraph formatting.
SYNOPSIS=`cat <<-EOT
Expand All @@ -23,7 +23,7 @@ SOURCE="IR Camera System"
DATE="July 2012"
#See also. Array, Each manpage with its section.
SEE_ALSO=( "pb_utils (1)" "ni4462_system_clock_calibrate (1)" )
SEE_ALSO=( "pb_utils (1)" "pb_freq_gen (1)" "pb_manual (1)" )
#Prefix each line with a leading space? Prevent paragraphs from being line-wrapped. true/false
LEADING_SPACE=true
Expand Down
2 changes: 1 addition & 1 deletion pb_utils/man/pb_manual.1.sh
Expand Up @@ -23,7 +23,7 @@ SOURCE="IR Camera System"
DATE="July 2012"
#See also. Array, Each manpage with its section.
SEE_ALSO=( "pb_utils (1)" )
SEE_ALSO=( "pb_utils (1)" "pb_freq_gen (1)" "pb_identify_output (1)" )
#Prefix each line with a leading space? Prevent paragraphs from being line-wrapped. true/false
LEADING_SPACE=true
Expand Down

0 comments on commit 149693c

Please sign in to comment.