Jump to content
OMRON Forums

Compiling and installing a custom kernel driver for Power PMAC


Sina.Sattari

Recommended Posts

I had to compile a driver for a Tektronix AFG1022 signal generator in order to be able to use the SCPI (Standard Commands for Programmable Instruments) standard interface provided on this device.

 

The driver in question required for this device is called: USBTMC. The USBTMC support under GNU/Linux systems is provided in two ways: native support in the Linux kernel and the legacy USBTMC kernel module developed by Agilent. Since the kernel 2.6.28-11 the native module is not working properly, although we are trying to solve this issue, the best solution for now is to use the module provided by Agilent (download here). This procedure is supported for kernel 2.6.28-11 only, since tests in newer versions didn't work.

 

Since the kernel compilers are not installed on Power PMAC for storage space considerations, the cross compiler included in IDE installation can be used for this purpose. This means the driver will be compiled under Windows environment and then transferred and installed under Power PMAC.

 

First, download the source code of the module here

 

Unzip the contents into a folder on your Windows computer. In this example, we use C:\usbtmc folder.

 

The makefile provided with the package is missing essential parts for compilation on a cross compiler, which is why we will use a makefile template from IDE. The makefile needed for the kernel driver compilation is the same as the makefile IDE uses for compilation of realtime routines with a bit of modification. You can obtain a copy of this makefile, by openning a new project under Power PMAC IDE, selecting build action of "Compile" under properties for usercode.c file under "C Language\Realtime Routines" folder of the Project and selecting "Build" from the context menu of project. Once the build is completed, using windows explorer, browse to location which the empty project is saved and copy the make file to C:\usbtmc folder.

 

Make the following modifications in the make file:

 

Under obj-m parameter only include the object name we want to compile:

 

Original code:

obj-m	+= usralgo.o
usralgo-objs := usralgomain.o \
usrcode.o

 

should be changed to:

obj-m	+= usbtmc.o

 

Also under "all:" section make the following changes:

Original code:

all::
cp -f /usr/local/usralgo/usralgomain.c $(PWD)
$(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules
mv -f usralgo.ko ../../bin/Debug/

 

should be changed to:

all::

$(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules

 

Once these changes are done, save the makefile and exit the editor.

 

Go to Environment Variables for windows (Windows 7: Control Panel>System>Advanced system settings>Environment Variables)

Under System Variables, find DTBUILDPATH variable and copy its value to clipboard. This is required for next step.

 

Open a command prompt (Start>Accessories>Command Prompt)

send the following command:

 

path=C:\DeltaTau\Power PMAC IDE\compilers\bin;C:\DeltaTau\Power PMAC IDE\compilers\usr\local\bin"

The path value shown above is the save value copied into clipboard from System variable DTBUILDPATH in previous step.

 

In command prompt, change directory to "C:\usbtmc":

 

cd c:\usbtmc

 

execute the following command and the compilers pointed to by the newly defined path system variable will take the default Makefile, which we modified earlier and generate the usbtmc.ko file.

 

make

 

Once the usbtmc.ko file is compiled, transfer the file to ftp://[your_power_pmac_ip_here]/gather folder using Windows Explorer.

 

From this point on, we are executing the command on a CLI from Power PMAC using SSH or Telnet terminal:

Now we have to move the file to non-volatile memory and make it load upon each boot. To do this lets make the non-volatile memory write-enabled:

mount -o remout,rw /

 

Lets copy the file from its temporary location to its permanent location:

cp /var/ftp/gather/usbtmc.ko /lib/modules/3.2.21-powerpmac-smp/kernel/drivers/usb/

 

Note that your kernel on Power PMAC may be different from what us shown here. Please adjust the folder name accordingly.

 

Now we have to make a start-up script for loading this driver upon boot. Use nano text editor to create this shell script:

 

nano /.readonly/etc/init.d/usbtmc

 

Paste the following code in the editor:

 

#!/bin/sh
### BEGIN INIT INFO
# Provides:          usbtmc
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start:     2
# Default-Stop:
# Short-Description: Adds usbtmc driver to kernel
# Description:       Adds USBTMC driver to kernel for Tektronix Units
### END INIT INFO



case "$1" in
 start|"")
       insmod /lib/modules/3.2.21-powerpmac-smp/kernel/drivers/usb/usbtmc.ko
       ;;
 restart|reload|force-reload)
       echo "Error: argument '$1' not supported" >&2
       exit 3
       ;;
 stop)
       # No-op
       rmmod usbtmc
       ;;
 *)
       echo "Usage:  deltatau-startup [start|stop]" >&2
       exit 3
       ;;
esac

:

 

Save the contents by issuing a CTRL+O and confirming file name.

Exit editor by issuing a CTRL+X.

 

Make the shell script executable:

chmod +x usbtmc

 

Now we need to add a symbolic link to this file to make it load automatically upon boot:

 

cd /.readonly/etc/rc2.d/
ln -s ../init.d/usbtmc S99usbtmc

 

make the non-volatile memory write protected:

 

mount -o remount,ro /

 

And that's it!

 

Now you can test the driver. install the driver manually if you don't want to restart the Power PMAC yet.

 

/etc/init.d/usbtmc

 

plug in the AFG1022 to the Power PMAC USB port and list the installed modules:

 

lsmod

 

Here is what I get:

root@192.168.0.200:/# lsmod
Module                  Size  Used by
usbtmc                  9724  0
ec_r8169               52519  0
ec_master             260832  1 ec_r8169
rtpmac                237640  0
libppmac              230512  1 rtpmac
ppmachw                 1511  1 rtpmac
root@192.168.0.200:/# 

 

As you can see the usbtmc module is loaded.

 

We can also testing the communication to the unit using the echo command:

 

echo "*IDN?" > /dev/usbtmc0
cat /dev/usbtmc0

 

for which I get the response:

TEKTRONIX,AFG1022,1511253,SCPI:99.0 FV:V1.1.0

 

 

Note:

The following pages were very helpful in getting this driver working:

https://code.google.com/p/scte/wiki/USBTMC

Link to comment
Share on other sites

  • 4 months later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Edit: The problem was that I had to restart the cygwin terminal because it gets the paths when you run it as a bash shell and I added the paths in the terminal when cygwin was already running

 

 

 

I tried this way to get the cross compiler to work for compiling a user servo. When I used cygwin to do te make all command, I still got the error:

 

 make[1]: powerpc-405-linux-gnu-gcc: Command not found

 

After that I checked the bin folder in compilers, and there wasn't te powerpc-405-linux-gnu-gcc compiler. The search function in explorer can't find the compiler anywhere on my harddisk. Does anyone know where it is located and how I can create a correct path to it to use the makefile?

 

Go to Environment Variables for windows (Windows 7: Control Panel>System>Advanced system settings>Environment Variables)

Under System Variables, find DTBUILDPATH variable and copy its value to clipboard. This is required for next step.

 

Open a command prompt (Start>Accessories>Command Prompt)

send the following command:

 

path=C:\DeltaTau\Power PMAC IDE\compilers\bin;C:\DeltaTau\Power PMAC IDE\compilers\usr\local\bin"

The path value shown above is the save value copied into clipboard from System variable DTBUILDPATH in previous step.

 

In command prompt, change directory to "C:\usbtmc":

 

cd c:\usbtmc

 

execute the following command and the compilers pointed to by the newly defined path system variable will take the default Makefile, which we modified earlier and generate the usbtmc.ko file.

 

make

Link to comment
Share on other sites

My "C:\DeltaTau\Power PMAC IDE\compilers\usr\local\bin" folder contains "powerpc-405-linux-gnu-gcc.exe". From an install of IDE 2.0.3.40.

 

I did have a problem once where that folder got corrupted and I found the compilers reside in "C:\DeltaTau\Power PMAC IDE\compilers.tar.gz" and there is a program which appears to repair them called "C:\DeltaTau\Power PMAC IDE\CompilerExtractProgress.exe".

 

My system appears to be working after doing this but you might want an official DT response...

 

Older IDEs installed in program files if memory serves...

Link to comment
Share on other sites

The windows search funtions was not working correctly so I didn't see it appear there. When I went to the folder manually, I found it there. The problem why it was not working for me was that I didn't think about restarting cygwin after adding the paths. The paths were correctly added but not correctly passed to cygwin, which happend when I restarted it.
Link to comment
Share on other sites

I know this is an old posting but I wanted to point out that I've used an IEEE-488 to USB adapter to send SCPI commands to some data acquisiton equipment and power supplies using a product from a company called Prologix, LLC (I was using windows embedded 7).

 

One main feature of this product is that it uses a USB to serial port driver. I can't say for sure if it would attach to the power PMAC but it would be worth a try since other popular USB-serial drivers do work.

 

I don't know if that would solve the original problem mentioned in this post but I thought I'd pass this information on.

 

KEJR

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...