Eakins Camera hackery pokery and the legend of MeasureTwice

After picking up an auto focus Eakins camera for PCB inspection and so on. I adapted my test app MeasureTwice which came from a history of wanting to measure where two holes were for a CNC operation the app grew as they do into my catchall app for inspection work.

I’ve wanted to add an XY table to it so i can capture a PCB or item larger than the view and within the workable ROI of the lense and be sharp, I finally got around to adding the X stage with a stepper on a screw and  track then added a USB control for it, ported in the control code to MT so that it can move the track back and forth.

 

image

Since the camera has autofocus , auto exposure etc. it’s desirable to control them from my MT app so i can fix them before starting a scan.

First things first is to pop open the camera and take a look, there’s a 3 pin connector internally that is a 3.3V Serial port called J50

image

popped out the board, 8 screws, slide out the assembly disconnect the fpc/ffc’s, Soldered in 3 wires (i cut up an old Samsung usb cable since they’re nicely made) added a zip tie as a strain relief

image

image

Serial port J50 looks like this square pad, round, round

[]- RX

O –TX

O – GND

The square pad I’d usually expect to see as ground, but there we go.

image

image

We used the power LED hole to pass the cable back through

image

and remounted the camera

image

Next step is to connect it to a USB 3.3V serial adapter

popping that open at 115Kbaud gives us a u-boot and log of the Linux boot.

U-Boot 2010.06 (Nov 22 2016 – 16:36:06)

NAND:  Check nand flash controller v610. found
Special NAND id table Version 1.36
Nand ID: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
No NAND device found!!!
0 MiB
Check spi flash controller v350… Found
Spi(cs1) ID: 0xC2 0x20 0x19 0xC2 0x20 0x19
Spi(cs1): Block:64KB Chip:32MB Name:”MX25L 256/257 35 E/F”
*** Warning – bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
USB:   scanning bus for devices… 2 USB Device(s) found
0 Storage Device(s) found
32768 KiB hi_sfc at 0:0 is now current device

## Booting kernel from Legacy Image at 82000000 …
   Image Name:   Linux-3.4.35
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2986672 Bytes = 2.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Loading Kernel Image … OK
OK

Starting kernel …

Uncompressing Linux… done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.4.35 (root@linux-5w9i) (gcc version 4.8.3 20131202 (prerelease) (Hisilicon_v300) ) #2 Fri Jan 13 17:00:54 CST 2017
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: hi3516a
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: mem=128M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),3M(kernel),26M(rootfs)
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 124028k/124028k available, 7044k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 – 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 – 0xfffe0000   ( 896 kB)
    vmalloc : 0xc8800000 – 0xff000000   ( 872 MB)
    lowmem  : 0xc0000000 – 0xc8000000   ( 128 MB)
    modules : 0xbf000000 – 0xc0000000   (  16 MB)
      .text : 0xc0008000 – 0xc054a000   (5384 kB)
      .init : 0xc054a000 – 0xc056c434   ( 138 kB)
      .data : 0xc056e000 – 0xc059d800   ( 190 kB)
       .bss : 0xc059d824 – 0xc05bc9f8   ( 125 kB)
SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:128
sched_clock: 32 bits at 49MHz, resolution 20ns, wraps every 86767ms
Console: colour dummy device 80×30
Calibrating delay loop… 1196.85 BogoMIPS (lpj=5984256)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys freezer
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x8041e4a8 – 0x8041e500
dummy:
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
uart:0: ttyAMA0 at MMIO 0x20080000 (irq = 40) is a PL011 rev2
console [ttyAMA0] enabled
uart:1: ttyAMA1 at MMIO 0x20090000 (irq = 41) is a PL011 rev2
bio: create slab <bio-0> at 0
SCSI subsystem initialized
hi-spi-master hi-spi-master.0: with 1 chip select slaves attached
hi-spi-master hi-spi-master.1: with 3 chip select slaves attached
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource timer0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
NFS: Registering the id_resolver key type
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
fuse init (API version 7.18)
SGI XFS with security attributes, large block/inode numbers, no debug enabled
msgmni has been set to 242
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered (default)
io scheduler cfq registered
brd: module loaded
Spi id table Version 1.22
Spi(cs1) ID: 0xC2 0x20 0x19 0xC2 0x20 0x19
SPI nor flash boot mode is 3 Bytes
Spi(cs1):
Block:64KB
Chip:32MB
Name:”MX25L(256/257)35(E/F)”
spi size: 32MB
chip num: 1
3 cmdlinepart partitions found on MTD device hi_sfc
3 cmdlinepart partitions found on MTD device hi_sfc
Creating 3 MTD partitions on “hi_sfc”:
0x000000000000-0x000000100000 : “boot”
0x000000100000-0x000000400000 : “kernel”
0x000000400000-0x000001e00000 : “rootfs”
Found Nand Flash Controller V610.
Nand ID: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
No NAND device found
Higmac dma_sg_phy: 0x87a00000
higmac_mdio_bus: probed
PHY mdio0:01 not found
ETH0: rgmii, phy_addr=1, mii_name=mdio0
ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
hiusb-ehci hiusb-ehci.0: HIUSB EHCI
hiusb-ehci hiusb-ehci.0: new USB bus registered, assigned bus number 1
hiusb-ehci hiusb-ehci.0: irq 53, io mem 0x100b0000
hiusb-ehci hiusb-ehci.0: USB 0.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
hiusb-ohci hiusb-ohci.0: HIUSB OHCI
hiusb-ohci hiusb-ohci.0: new USB bus registered, assigned bus number 2
hiusb-ohci hiusb-ohci.0: irq 54, io mem 0x100a0000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver…
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
hisi_i2c hisi_i2c.0: Hisilicon [i2c-0] probed!
hisi_i2c hisi_i2c.1: Hisilicon [i2c-1] probed!
hisi_i2c hisi_i2c.2: Hisilicon [i2c-2] probed!
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
NET: Registered protocol family 15
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
mmc0: new high speed SDXC card at address aaaa
mmcblk0: mmc0:aaaa SE64G 59.4 GiB
mmcblk0: p1
VFS: Mounted root (jffs2 filesystem) on device 31:2.
Freeing init memory: 136K
usb 2-1: new low-speed USB device number 2 using hiusb-ohci
input: Dell Dell USB Optical Mouse as /devices/platform/hiusb-ohci.0/usb2/2-1/2-1:1.0/input/input0
generic-usb 0003:413C:3012.0001: input: USB HID v1.11 Mouse [Dell Dell USB Optical Mouse] on usb-hiusb-ohci-1/input0
[RCS]: /etc/init.d/S00devs
[RCS]: /etc/init.d/S01udev
Not recognise ACTION:change
Not recognise ACTION:change
Not recognise ACTION:change
[RCS]: /etc/init.d/S80network
[RCS]: /etc/init.d/S90hibernate
Password for ‘root’ changed
Auto login as root …
Jan  1 00:00:02 login[905]: root login on ‘ttyS000’

Welcome to HiLinux.
None of nfsroot found in cmdline.
His3516a_LoadDrivers Start…..!
~ # Hisilicon Media Memory Zone Manager
Module himedia: init ok
hi3516a_base: module license ‘Proprietary’ taints kernel.
Disabling lock debugging due to kernel taint
load sys.ko for Hi3516A…OK!
load tde.ko …OK!
load region.ko ….OK!
load vgs.ko for Hi3516A…OK!
ISP Mod init!
load viu.ko for Hi3516A…OK!
load vpss.ko ….OK!
load vou.ko ….OK!
load hifb.ko OK!
load rc.ko for Hi3516A…OK!
load venc.ko for Hi3516A…OK!
load chnl.ko for Hi3516A…OK!
load h264e.ko for Hi3516A…OK!
load h265e.ko for Hi3516A…OK!
load jpege.ko for Hi3516A…OK!
load vda.ko ….OK!
load ive.ko for Hi3516A…OK!
hi3516a_io driver init start
hi3516a_io driver init successful!
af pi level:0
af move steps:330
af move steps:320 10
insmod: can’t insert ‘/komod/extdrv/wdt.ko’: No such file or directory
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f0050: 0x00000000 –> 0x00000001
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f0054: 0x00000000 –> 0x00000001
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f0058: 0x00000000 –> 0x00000001
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x200f005c: 0x00000000 –> 0x00000001
[END]
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:166}cmdstr:himm
0x2003002c: 0x00090007 –> 0x00090007
[END]
mipi_init
init phy power successful!
load hi_mipi driver successful!
hi3516a_io driver init start
His3516a_LoadDrivers Finish…..!
***COPYRIGHT 2016 tagye technology****
software:v2.3.1
DATE:Nov  1 2018,TIME:16:36:05
************************************
linear mode
–IMX290 1080P 60fps LINE Init OK!—-
Entering the cmos_fps_set!
vout start finish
Entering the cmos_fps_set!
open success:fd0 ===== 3
FBIOPUT_VSCREENINFO over !!!
hi_i2c_wait_txfifo_notfull->260:
transmit error, int_raw_status: 0x750!

hi_i2c_wait_txfifo_notfull->262:
tx_abrt_cause is 1.

we can see the camera sensor model, iMX290 and the hi3516a processor, the tagye tech guys seem to have a patent on microscope digital zooming so they may supply the software.

no root password needed, though in the /mm.sh script it changes the password for root at every boot

#!/bin/sh

#ifconfig eth0 192.168.1.247
#mount -t nfs -o nolock -o tcp 192.168.1.100:/nfs  /mnt

echo “root:tagye1207” | chpasswd

ulimit -c 9999
ulimit -c 9999

mount -t vfat /dev/mmcblk0p1  /mnt/sdcard

export HOME=’/root’
export LD_LIBRARY_PATH=’/usr/local/lib:/usr/lib:/qt_lib’
export LOGNAME=’root’
export OLDPWD=’/qt_lib’
export PATH=’/usr/bin:/usr/sbin:/bin:/sbin’
export PWD=’/opt’
export QT_PLUGIN_PATH=’/qt_lib/plugins’
export QT_QWS_FONTDIR=’/qt_lib/fonts’
export QWS_DISPLAY=’LinuxFb:/dev/fb0′
export TERM=’vt100′
export USER=’root’

/opt/3516a_proc &
/opt/myTest_8.17 -qws -fn DejaVuSans.ttf &

so now there is a shell, there isn’t a lot going on there are two apps running one is handling the im290 setup and auto focus, the other handles the gui for the mouse. unfortunately there are no network usb driver .ko’s so sticking with serial at the moment.

the dev board for the 3516 has a gmac on it, so that is likely what the dev is using with the commented out ifconfig


/opt/3516a_proc &
/opt/myTest_8.17 -qws -fn DejaVuSans.ttf &

i pop on a arm7l version of  strace and  can now see the myTest app talking to a local socket at /tmp/UNIX.domain and /tmp/UNIX.domain1

connect(15, {sa_family=AF_LOCAL, sun_path=”/tmp/UNIX.domain1″}, 110) = 0
connect(16, {sa_family=AF_LOCAL, sun_path=”/tmp/UNIX.domain”}, 110) = 0

clicking buttons shows a write to socket 16, /tmp/UNIX.domain

write(16, “\7\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100
write(16, “\7\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100

write(16, “\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100
write(16, “\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100

 

3516a_proc is the one that controls the camera which looks like via i2c , the other mrTest is a QT app that does the overlay and then communicates with the 3516 app  with an AF_LOCAL IPC socket.

so instead of going back and forth with a fiddly sdcard, i grabbed lrsrz source code setup an ARM7L cross compiler on a lightsail instance and built it, transferred it to the sdcard and booted up the camera, now i can just use TeraTerm to ZMODEM upload over the serial console.

/mnt/sdcard # lrz -b -Z –c -y
lrz waiting to receive.**B0100000023be50

binary, zmodem with checksum and overwrite(clobber)

it is now slightly less of a hassle to transfer files to and from the camera, building the .ko for a usb ethernet adapter I’ll tackle later

pop up the camera UI set AF mode

image

from the strace before i believe \7 is the MF command

next is a very quick test app

#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>

#define SOCK_CLOEXEC 02000000UL

int main()
{
        struct sockaddr_un tolog;
        int sock = socket(AF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0);
        tolog.sun_family = AF_UNIX;
        strcpy(tolog.sun_path, “/tmp/UNIX.domain”);
        connect(sock, (struct sockaddr*)&tolog, sizeof(struct sockaddr_un));
        write(sock,”\7\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″,100);
        close(sock);
        return 0;
}

compile it, pass it over to the serial app vi lxz and ,kill the mYtest app, then run our test app

socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path=”/tmp/UNIX.domain”}, 110) = 0
write(3, “\7\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100
close(3)                                = 0
exit_group(-1093076012)                 = ?

re-run the myTest app

/opt/myTest_8.17 -qws -fn DejaVuSans.ttf

make sure you set the exports from the /mm.sh script first or the app will complain.

image

and it has changed to manual focus mode, neat!

ok lets double check with something else

image

might as well try to change it to B&W mode, so lets strace the command

this seems like a good candidate

write(16, “\36\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100

next to modify the test app (add \36 to the start of the buffer, compile, upload,and strace it

socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path=”/tmp/UNIX.domain”}, 110) = 0
write(3, “\36\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100
close(3)                                = 0
exit_group(-1091580860)                 = ?

and yup it switches to B&W mode

image

ok so it seems like we’re going the right way so far. not everything in the GUI works like this I don’t believe, but if i can get AE/MF up and down focus control, and AE off and on it’ll be a good start. if its all just one or two bytes to set modes, it’d be trivial to adapt the app to just pass in the command on the argv and poke at it.

Leaving the myTest app running there is no problem with multiple applications talking to that local IPC socket, other than if you manage to write multiple things at once that conflict and the GUI will get  out of sync if you change things programmatically that are toggles, since the GUI is unaware of what you did.


next step is to catalogue the commands, then later start looking at the main application.

and on to add more features to the always growing MeasureTwice app…

Sometimes i’ll add the strace, others just the first byte

(these are out of date now use the github link https://github.com/charlie-x/eakins-camera )

Auto Focus

write(16, “\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100

Click focus

\6

Manual Focus

write(16, “\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100

B&W on

\36

ROI Set

write(15, “\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.000826>

AWB

write(15, “\f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.006507>

MWB

write(15, “\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0″…, 100) = 100 <0.001343>

click Capture

write(15, “\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.000385>

Flip

write(15, “\31\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.000899>

Mirror

write(15, “\32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.000908>

Clicking HDR

write(15, “\23\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0″…, 100) = 100 <0.001058>

Sliding MF slider in MF mode, so write \10and then a position ( i changed strace to dump in hex here)

write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xeb\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002519>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.007700>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.007004>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002271>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.008654>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002378>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.003269>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002288>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002283>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002493>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.006618>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002643>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.015587>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002530>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002634>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x54\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002608>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002951>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.003195>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.007897>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.010341>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002574>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002904>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x83\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.027182>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002345>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.007582>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x91\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.005741>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002418>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002833>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.014942>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.116899>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xea\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002403>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.010266>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.014076>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002584>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.024927>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.007165>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002472>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x46\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.120134>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.002780>
write(15, “\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x77\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.105966>

clicking 50/60Hz

Entering the cmos_fps_set!
write(15, “\x1b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″…, 100) = 100 <0.000859>

A bit of the old Heath Robinson going on but its a start,  also planning to add a Y stage.

image

If you wanted to rewrite the GUI app its just doing the above with a straight up  /dev/fb0 and QT and then overlaying the crosshairs etc.

/dev/fb0 is a hardware overlay over the cameras sensor, copying urandom onto /dev/fb0 , moving mouse around erases the fb0, but the background stays regardless

image

now that i can control the camera i can do a focus stack capture, which just means controlling the focus of the camera either by mocing it up and down or by moving the AF motor, so lets do that.

first figure out the range that the object is in focus at near and far plane. in my case 140 to 155

step from 140 to 155 and capture image each step.

serial in to the shell, add the talk app , insert an sd-card

for var in `seq 140 155`; do ./talk p $var ; ./talk C ; done

https://www.youtube.com/watch?v=tRmd8nV61Ds&feature=youtu.be

quick focus stack result with 15 steps
from

some results

camera view

after focus stack

before/after





test apps and source at

https://github.com/charlie-x/eakins-camera

Created a .ko for the r8152 USB to ethernet adapter, and it works.

/mnt/sdcard # insmod ./r8152.ko
usbcore: registered new interface driver r8152
/mnt/sdcard #
/mnt/sdcard # usb 1-1: reset high-speed USB device number 3 using hiusb-ehci
r8152 1-1:1.0: eth0: v2.12.0 (2019/04/29)
r8152 1-1:1.0: eth0: This product is covered by one or more of the following patents:
                US6,570,884, US6,115,776, and US6,327,625.

 

/mnt/sdcard # ifconfig
eth0      Link encap:Ethernet  HWaddr 70:88:6B:86:3F:97
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1540 (1.5 KiB)  TX bytes:0 (0.0 B)

 

ifconfig eth0 192.168.1.160 netmask 255.255.255.0

 

/mnt/sdcard # ifconfig
eth0      Link encap:Ethernet  HWaddr 70:88:6B:86:3F:97
          inet addr:192.168.1.160  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:135 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
           RX bytes:12590 (12.2 KiB)  TX bytes:0 (0.0 B)

 

[C:\Program Files\JPSoft\TCMD17x64]ping 192.168.1.160

 

Pinging 192.168.1.160 with 32 bytes of data:
Reply from 192.168.1.160: bytes=32 time=1ms TTL=64
Reply from 192.168.1.160: bytes=32 time=1ms TTL=64

image

Just started to add an Eagle BRD overlay, load the BRD in and it’ll draw the tracks/vias etc.

image_thumb.png

 

10 thoughts on “Eakins Camera hackery pokery and the legend of MeasureTwice

  1. Hi, is it possible have a dump of your camera system or a zip file with directory?…..my camera have a new software V 2.3.9 that doesn’t have a autofocus ….

  2. I tried to run ./talk with all args, they all work except the autofocus and the Roi setting, when I try the autofocus everything freezes and I have to turn off the camera by unplugging the cable….
    is it possible to have a copy of the files in your room?
    maybe some files are different, or missing…

    I tried with Ida Pro to reverse the qt_app and 3516a_proc files and they seem to include Autofocus functions…

    I think that my cam has been deliberately blocked by the possibility of having autofocus, in addition I noticed that the system recognizes it as IMX185
    Hope you see my message

      1. Many Thanks!!!!!,
        I just noticed that there is no mm.sh file and some folder like root….

        maybe mine is a different version …. cmq thanks will investigate

    1. i notice the tar didn’t pick up / so there is an mm.sh

      drwxr-xr-x 24 root root 0 Jan 1 1970 .
      drwxr-xr-x 24 root root 0 Jan 1 1970 ..
      drwx—— 2 1002 100 0 Feb 14 2017 bin
      drwx—— 2 1002 100 0 Feb 14 2017 boot
      drwxrwxrwt 7 root root 3500 Jan 1 1970 dev
      drwx—— 4 1002 100 0 Jan 1 1970 etc
      drwx—— 2 1002 100 0 Feb 14 2017 home
      lrwxrwxrwx 1 1002 100 9 Feb 14 2017 init -> sbin/init
      drwx—— 3 1002 100 0 Feb 14 2017 komod
      -rw-r–r– 1 root root 1 Feb 27 05:06 language.txt
      drwx—— 2 1002 100 0 Feb 14 2017 lib
      -rw-r–r– 1 root root 48 Sep 16 08:24 linecolor.txt
      lrwxrwxrwx 1 1002 100 11 Feb 14 2017 linuxrc -> bin/busybox
      drwx—— 2 1002 100 0 Feb 14 2017 lost+found
      -rwx—— 1 1002 100 1341 Feb 14 2017 mkimg.rootfs
      -rwx—— 1 1002 100 431 Feb 14 2017 mknod_console
      -rwx—— 1 1002 100 843 Sep 21 08:56 mm.sh
      drwxr-xr-x 2 root root 0 Jan 5 2020 mmc
      drwx—— 3 1002 100 0 Nov 30 2016 mnt
      drwx—— 2 1002 100 0 Feb 14 2017 nfsroot
      drwx—— 2 1002 100 0 Nov 6 2018 opt
      dr-xr-xr-x 59 root root 0 Jan 1 1970 proc
      drwx—— 4 1002 100 0 Feb 14 2017 qt_lib
      drwx—— 2 1002 100 0 Sep 21 08:48 root
      drwx—— 2 1002 100 0 Feb 14 2017 sbin
      drwx—— 2 1002 100 0 Feb 14 2017 share
      dr-xr-xr-x 12 root root 0 Jan 1 1970 sys
      drwx—— 3 1002 100 0 Feb 27 05:06 tmp
      drwx—— 6 1002 100 0 Feb 14 2017 usr
      drwx—— 3 1002 100 0 Feb 14 2017 var
      / #
      #!/bin/sh
      insmod /root/r8152.ko

      echo insmod serial
      insmod /root/usbserial.ko
      insmod /root/ftdi_sio.ko

      ifconfig eth0 192.168.1.160 netmask 255.255.255.0

      route add default gw 192.168.1.1

      setserial /dev/ttyUSB0

      #ifconfig eth0 192.168.1.247
      #mount -t nfs -o nolock -o tcp 192.168.1.100:/nfs /mnt

      stty -F /dev/ttyUSB0 115200

      echo “root:tagye1207” | chpasswd

      ulimit -c 9999
      ulimit -c 9999

      mount -t vfat /dev/mmcblk0p1 /mnt/sdcard

      export HOME=’/root’
      export LD_LIBRARY_PATH=’/usr/local/lib:/usr/lib:/qt_lib’
      export LOGNAME=’root’
      export OLDPWD=’/qt_lib’
      export PATH=’/usr/bin:/usr/sbin:/bin:/sbin’
      export PWD=’/opt’
      export QT_PLUGIN_PATH=’/qt_lib/plugins’
      export QT_QWS_FONTDIR=’/qt_lib/fonts’
      export QWS_DISPLAY=’LinuxFb:/dev/fb0′
      export TERM=’vt100′
      export USER=’root’

      /opt/3516a_proc &
      /opt/myTest_8.17 -qws -fn DejaVuSans.ttf &

      1. Yes ,
        some error during extract your last tar file …
        “x usr/lib/libncurses.so.6.1: Truncated tar archive
        tar: Error exit delayed from previous errors.”

        there should also be a setting.ini file
        (maybe yours is more complete)
        mine :

        [HCrossLine]
        0=@Variant(\0\0\0\x17\xff\xff\xffj\0\0\x2\x1c\0\0\b\x16\0\0\x2\x1c)
        1=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        2=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        3=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        4=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        5=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        6=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        7=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        8=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        9=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)

        [HCrossLineColor]
        0=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        1=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        2=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        3=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        4=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        5=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        6=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        7=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        8=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        9=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)

        [Hide]
        hide=false

        [Name]
        name=true

        [VCrossLine]
        0=@Variant(\0\0\0\x17\0\0\x3\xc0\xff\xff\xfd\xc6\0\0\x3\xc0\0\0\x6r)
        1=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        2=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        3=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        4=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        5=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        6=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        7=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        8=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
        9=@Variant(\0\0\0\x17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)

        [VCrossLineColor]
        0=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        1=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        2=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        3=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
        4=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        5=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        6=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        7=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        8=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        9=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)

        [crossNum]
        HCrossNum=1
        VCrossNum=1

        [setting]
        crosscolor=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\xff\xff\0\0)
        fitcolor=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        fitwidth=21417912
        lineColor=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        lineenable=false
        linemove=false
        linewidth=1
        textcolor=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
        textlabel=false
        textlength=-1097613352
        textsize=12

        [unit]
        value=2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.