Coder Social home page Coder Social logo

panalyzer's Introduction

                                  Panalyzer

This is a Logic Analyzer that runs on the RaspberryPi.  The basic idea is that
it disables interrupts for a period, while sampling the GPIO pins once a
microsecond.  It then re-enables interupts and displays traces showing what the
relevant GPIO pins were doing.  Clearly the RaspberryPi is frozen while data is
being gathered, because interrupts are disabled, but a timeout is implemented
to avoid hanging for ever if a trigger word is not seen.

Panalyzer has features such as specifying trigger patterns, buffer depth, a
pair of cursors for measuring time periods on the trace, etc.  In the display
you can click and drag across part of the trace to zoom in on that section.

Not all features are implemented yet, and there is scope to improve
performance.  The UI may well be reworked as the idea develops.

Currently it expects you to use the following gpio pins:

Channel 0:  GPIO4   (P1-7)
Channel 1:  GPIO17  (P1-11)
Channel 2:  GPIO18  (P1-12)
Channel 3:  GPIO21  (P1-13)

Obviously you should be careful not to damage the RaspberryPi by feeding
signals above 3.3 volts to those pins.  Personally I added a 7417 open
collector buffer, driven from 5 volts, but with pullups on the outputs to 3.3
volts.  The idea being that I could then monitor 5 volt or 3.3 volt based
circuits safely.

While this project is in very early development, it has been tested monitoring
signals up to 250KHz, and capturing up to 2 seconds worth of data.  There is
obviously some sampling error at those speeds, as only it samples at 1000HKz.

Currently you cannot change the sampling frequency; it loops watching a 1MHz
counter in the processor, and takes a sample every time it changes.

The runtime comprises three files:

pandriver.ko is the kernel module that captures the data.
Panalyzer is the user space application that displays the data.
Panalyzer.ui is a Glade generated UI definition, and must be located in
the directory Panalyzer is invoked from.

As of June 16th 2014, the included module should load if you have recently
run rpi-update (and so are running kernel 3.12.22+).  Read the comments at the
top of pandriver.c for how to create the /dev/panalyzer file.  The included
Panalyzer binary uses gtk-3.0 and should run on Raspbian, at least.

Compiling:

To build the UI (Panalyzer) on Raspbian, you need to
"sudo apt-get install libgtk-3-dev", and the simply "make Panalyzer".

The Makefile is currently set up to cross-compile the kernel module; if you are
building natively remove the ARCH and CROSS_COMPILE settings.

Building the module can be painful because you need matching kernel headers.
Many people run Raspbian (as I do), and by default that ships a packaged kernel
with matching headers, but does not install it.  Instead, Raspbian runs a 
kernel from the RaspberryPi foundation, for which matching headers are not
available.  Also, to compile a kernel against which you can compile Panalyzer
(and get a module that will load), you need to have exactly the right kernel
source.

In theory you can short-circuit some of this process by running some "module
prepare" step rather thana full make, but I haven't had success with that.

In the past I have found that compiling the module on the Pi itself results
in a moduel that does not work; I presume that was due to some compiler bug,
but I've not investigated much, and I don't know if the issue has since been
fixed.  However, I cross-compile the module on an Ubuntu host, which avoids
that problem has is many times faster.

The best instructions I have found for compiling the correct kernel source
are here: <http://lnxpps.de/rpie/raspi-anleitung.txt>.  I have reproduced them
in full below (with a few extra [rgh] notes), in case that link goes away:


======================== http://lnxpps.de/rpie/raspi-anleitung.txt =============================


How to Build the Modules for adding an mcp251x to a Raspberry Pi
================================================================

Note: The examples shown here were run with Kernel 3.10.24+ from Raspbian 2013-12-20.

Chapter 1: Find your kernel hash and configuration (on the Pi)
--------------------------------------------------------------

- Find your kernel hash using either of the following methods:

> FIRMWARE_HASH=$(zgrep "* firmware as of" /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 | awk '{ print $5 }')
> KERNEL_HASH=$(wget https://raw.github.com/raspberrypi/firmware/$FIRMWARE_HASH/extra/git_hash -O -)
> echo $KERNEL_HASH
4bbea92eae6c0792e85a4ba079d367ac6aa77fb5

or, if you got your kernel via rpi-update (scroll down): raspberrypi/linux#486

- Get the configuration of your running kernel:

> cp /proc/config.gz ~


Chapter 2: Setup your build environment (on a different, *very* fast machine)
-----------------------------------------------------------------------------

See http://elinux.org/RPi_Kernel_Compilation for additional basic information.

- Setup a Linux System or VM
- make a folder for compilation:

> mkdir ~/raspi; export BASEDIR=~/raspi; cd $BASEDIR

- Get the kernel sources:

[rgh: --depth 100 below was not enough for me; I used --depth 200]

> cd $BASEDIR
> git clone --depth 100 https://github.com/raspberrypi/linux.git
> export KERNEL_SRC=$BASEDIR/linux
> cd $KERNEL_SRC
> git checkout 4bbea92eae6c0792e85a4ba079d367ac6aa77fb5

[rgh: If that gives you some error about "is not a tree", you probably need a larger --depth value above]
[rgh: I needed a "git pull" after that last "git checkout <hash>"]

Note that the hash value for git checkout is the one you got in Chapter 1.

- Get the Compiler

[rgh: I run Ubuntu, so just installed the cross compiler from their repositories, as per http://elinux.org/RPi_Kernel_Compilation]

> cd $BASEDIR
> git clone git://github.com/raspberrypi/tools.git
> export CCDIR=$BASEDIR/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin
> export CCPREFIX=$CCDIR/arm-bcm2708-linux-gnueabi-

Chapter 3: Compile the Kernel modules
-------------------------------------

- Prime the Kernel sources with the old configuration

> cd $BASEDIR
> scp pi@raspberry:config.gz .
> cd $KERNEL_SRC
> zcat $BASEDIR/config.gz > .config
> ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfig

[rgh: You can skip the menuconfig command below]

- Add the CAN modules and drivers to the configuration.

> ARCH=arm CROSS_COMPILE=${CCPREFIX} make menuconfig

For what options to select, see http://elinux.org/RPi_CANBus
Note that when an option is selected to be compiled into the kernel (shows a *), you do *not* need to change that to module!

- Compile the kernel

> ARCH=arm CROSS_COMPILE=${CCPREFIX} make

This will take a while. If you have multiple cores available in your VM, speed up compilation by using "-j <numcors+1>". So for my VM with 3 cores available, I use

> ARCH=arm CROSS_COMPILE=${CCPREFIX} make -j 4

[rgh: At this point fix the path in Panalyzer/Makefile to point at your kernel, and "make pandriver.ko".  Job done.]

- Create a directory to temporarily deploy the modules in

> mkdir $BASEDIR/modules
> export MODULES_TEMP=$BASEDIR/modules

- Deploy the modules:

> ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make modules_install

- Get the source for the spi-config module

> cd $BASEDIR
> git clone https://github.com/msperl/spi-config
> cd spi-config

- Build the spi-config module

> ARCH=arm CROSS_COMPILE=${CCPREFIX} make KDIR=$KERNEL_SRC

- Deploy the spi-config module

> ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make KDIR=$KERNEL_SRC install

- Pack all necessary modules into one tar file:

> cd $MODULES_TEMP
> tar -cjf rpi-can-modules.tar.bz2 \
lib/modules/3.10.24+/kernel/net/can/can.ko \
lib/modules/3.10.24+/kernel/net/can/can-raw.ko \
lib/modules/3.10.24+/kernel/net/can/can-gw.ko \
lib/modules/3.10.24+/kernel/net/can/can-bcm.ko \
lib/modules/3.10.24+/kernel/drivers/net/can/mcp251x.ko \
lib/modules/3.10.24+/kernel/drivers/net/can/can-dev.ko \
lib/modules/3.10.24+/kernel/drivers/spi/spi-bcm2708.ko \
lib/modules/3.10.24+/extra/spi-config.ko

- Copy the resulting archive to the Pi

> scp rpi-can-modules.tar.bz2 pi@raspberrypi:

Chapter 4: Deploy the modules on the Pi (on the Pi, obviously)
--------------------------------------------------------------

- Exctract the modules

> cd /
> sudo tar -xjf ~/rpi-can-modules.tar.bz2
> sudo depmod -a

- Test-load the modules

> sudo modprobe spi-bcm2708
> sudo modprobe can
> sudo modprobe can-dev
> sudo modprobe can-raw
> sudo modprobe can-bcm
> sudo modprobe spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release

If you see "mcp251x spi0.0: probed", it worked.

================== End of http://lnxpps.de/rpie/raspi-anleitung.txt =========================



Feedback welcome.

Richard Hirst <[email protected]>  June 16th 2014

['rgh' on the RaspberryPi forum]


panalyzer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panalyzer's Issues

building in 2015

Just FYI. I tried to build this under Raspbian/Jessie:

$ uname -a
Linux scope 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux

I think I finally managed to track down all of the changes to the kernel tree that affected include paths, and had to take some code out of drivers/dma/bcm2835-dma.c and paste it into pandriver-dma.c and got the compiles working. However, the Makefile is then trying to build Linux kernel modules...

root@scope:~/Panalyzer# !mak
make all
make -C /root/raspi/linux M=/root/Panalyzer modules
make[1]: Entering directory '/root/raspi/linux'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 2 modules
/bin/sh: 1: scripts/mod/modpost: not found
scripts/Makefile.modpost:90: recipe for target '__modpost' failed
make[2]: *** [__modpost] Error 127
Makefile:1387: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
make[1]: Leaving directory '/root/raspi/linux'
Makefile:9: recipe for target 'pandriver.ko' failed
make: *** [pandriver.ko] Error 2

And this is the point where I'm giving up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.