worlickwerx / sbig-util

Linux utility for Santa Barbara Instrument Group cameras for astronomy
GNU General Public License v3.0
5 stars 2 forks source link

make parallel cameras work #11

Closed garlick closed 7 years ago

garlick commented 9 years ago

In theory one could set device to LPT1, LPT2, or LPT3 and use a parallel port camera with sbig-utils. This is untested so far.

garlick commented 8 years ago

Source for a specialized kernel driver for sbig parallel port cameras has been checked in on the parallel_port_cameras branch, and a port from linux 2.4 begun. Let's use this issue to track progress.

callumjpotter commented 8 years ago

When building the module, I got three errors, first was about __muldf3 undefined and the other two also related to floating point arithmetic. I narrowed this down to two lines in ksbiglpt.c which are both // Set nibbleTimeout to 300 ms. nibbleTimeout = 0.3 * gLptHz;

changing to

nibbleTimeout = gLptHz / 3;

got the module to build properly, and load ok using insmod

garlick commented 7 years ago

Back to this after a long break(!) and reproduced @callumjpotter's floating point compile issue:

make
make -C /lib/modules/4.10.0-21-generic/build M=/home/garlick/proj/sbig-util/lpt_drv modules
make[1]: Entering directory '/usr/src/linux-headers-4.10.0-21-generic'
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglptmain.o
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglptd0.o
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglptd1.o
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglptd2.o
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglpthw.o
  CC [M]  /home/garlick/proj/sbig-util/lpt_drv/ksbiglpt.o
  LD [M]  /home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "__muldf3" [/home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.ko] undefined!
WARNING: "__floatunsidf" [/home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.ko] undefined!
WARNING: "__fixunsdfsi" [/home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.ko] undefined!
  CC      /home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.mod.o
  LD [M]  /home/garlick/proj/sbig-util/lpt_drv/sbiglptmod.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-21-generic'
garlick commented 7 years ago

I missed one of the two lines he pointed out - just pushed a fix to parallel_port_cameras branch.

garlick commented 7 years ago

Keeping some notes here. Testing on Dell Optiplex 755 with 2G RAM and Ubuntu 17.04:

[   18.757838] lp: driver loaded but no devices found
[   18.761805] ppdev: user-space parallel port driver
[   18.765682] parport_pc 00:02: reported by Plug and Play ACPI
[   18.765742] parport0: PC-style at 0x378 (0x778), irq 7, using FIFO [PCSPP,TRISTATE,COMPAT,EPP,ECP]
[   18.864100] lp0: using parport0 (interrupt-driven).

These modules must be blacklisted (later revisit whether we can acquire access through parport)

$ lsmod|grep par
parport_pc             32768  1
parport                45056  3 lp,parport_pc,ppdev

by creating /etc/modprobe.d/blacklist-parport.conf with contents:

blacklist parport
blacklist parport_pc
blacklist lp
blacklist ppdev

Reboot, then attempt to load module:

$ sudo insmod sbiglptmod.ko
$ dmesg|tail
[  162.677459] sbiglptmod: loading out-of-tree module taints kernel.
[  162.677461] sbiglptmod: module license 'unspecified' taints kernel.
[  162.677462] Disabling lock debugging due to kernel taint
[  162.677510] sbiglptmod: module verification failed: signature and/or required key missing - tainting kernel
$ find /dev -name \*sbiglpt\*
$ sudo rmmod sbiglpt
$
garlick commented 7 years ago

Based on spelunking of ksbiglpt.c and hints from this sbig cable appnote, it would seem that sbig are using the parallel data port (base+0) as a 3-bit register select + 4-bit data out + 1 bit strobe, and the status port (base+1) as a 4-bit data in + 1 bit inverted "data valid" indicator as noted below.

One implication is that we may be able to use the parport and parport_pc modules to claim the port in SPP mode and access it with port->ops->write_data() and port->ops->read_status(), instead of the direct outb() calls, thereby playing nicely with the driver stack. Writing to the data port in this way might wiggle the pin 1 strobe, but since sbig is not using that...

img_20170604_112506

garlick commented 7 years ago

Oooh, some success with changes just pushed to parallel_port_cameras branch (3d704d88c3e8ef5c93b3b3228eab861eea3bf947)

After loading module and chmod 666 /dev/sbiglpt0:

./sbig --device LPT1 info ccd imaging
sbig-info: firmware-version: 1.08
sbig-info: camera-type:      ST9
sbig-info: name:             SBIG ST-9 Dual CCD Camera
sbig-info: readout-modes:
sbig-info:  0:  512 x 512  2.40 e-/ADU 20.00 x 20.00 microns
sbig-info:  1:  256 x 256  2.40 e-/ADU 40.00 x 40.00 microns
sbig-info:  2:  170 x 170  2.40 e-/ADU 60.00 x 60.00 microns
sbig-info:  3:  512 x 0    2.40 e-/ADU 20.00 x 20.00 microns
sbig-info:  4:  256 x 0    2.40 e-/ADU 40.00 x 20.00 microns
sbig-info:  5:  170 x 0    2.40 e-/ADU 60.00 x 20.00 microns
sbig-info:  6:  512 x 512  2.40 e-/ADU 20.00 x 20.00 microns
sbig-info:  7:  256 x 256  2.40 e-/ADU 40.00 x 40.00 microns
sbig-info:  8:  170 x 170  2.40 e-/ADU 60.00 x 60.00 microns
sbig-info:  9:   56 x 56   2.40 e-/ADU 99.99 x 99.99 microns
sbig-info: bad columns:       0
sbig-info: ABG:               no
sbig-info: serial-number:     910107330
sbig-info: ccd-type:          full frame
sbig-info: electronic-shutter:no
sbig-info: remote-guide-port: no
sbig-info: biorad-tdi-mode:   no
sbig-info: AO8-detected:      no
sbig-info: frame-buffer:      no

which looks more or less correct for the camera I've got hooked up!

garlick commented 7 years ago

So far, everything I've tried seems to be working. Here's a full frame image. It did come out flipped in y

./sbig --device LPT1 snap -t 0.5 --no-cooler --force
sbig-snap: warning - cannot load /home/garlick/.sbig/config.ini
sbig-snap: Device open
sbig-snap: Link established to ST9
sbig-snap: [0]exposure: DF (0.50s)
sbig-snap: [0]readout: DF
sbig-snap: [0]exposure: LF (0.50s)
sbig-snap: [0]readout: LF (subtracted)
sbig-snap: wrote /tmp/LF_2017-06-05T03:55:59.fits
sbig-snap: Device closed

ds9

garlick commented 7 years ago

Scope trace of sbig info ccd imaging starting up scope_1

garlick commented 7 years ago

One more scope trace during image capture from windows a few days ago, for the record.

scope_0

garlick commented 7 years ago

Working I guess, so closing this.