22 December 2012

298. Hantek DSO 2250 USB with Openhantek on Debian Testing/Wheezy /Linux

Update 23 May 2013: Updated as per Peter Jeffris' suggestion (see below)/

UPDATE: this has been updated as per the developer's (Oliver Haag) recommendations (see first comment)

Original post:
I wanted to get Hantek DSO-2250 USB running on debian. I first tried openhantek 0.2.0 but it doesn't support the DSO-2250, so I ended up using the development version. I had to get the configure and Makefile.in files from another source though (see below).

I finally got the scope to work as shown below -- I primarily needed it for some work on NMR probes I did two years ago, but better late than never.

Probe set to X1

Probe set to X10


Before installing anything, on plugging in the oscilloscope we get:
dmesg
[10885.993061] usb 2-2: USB disconnect, device number 3
[10894.913984] usb 1-2: new high-speed USB device number 9 using ehci_hcd
[10895.046104] usb 1-2: New USB device found, idVendor=04b4, idProduct=2250
[10895.046117] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[10895.398887] usb 1-2: USB disconnect, device number 9
[10895.668190] usb 1-2: new high-speed USB device number 10 using ehci_hcd
[10895.800317] usb 1-2: New USB device found, idVendor=04b4, idProduct=2250
[10895.800330] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0

lsusb
Bus 001 Device 010: ID 04b4:2250 Cypress Semiconductor Corp.

Openhantek

sudo apt-get install subversion autoconf automake build-essential unrar
cd ~/tmp
svn checkout http://svn.code.sf.net/p/openhantek/code/trunk openhantek-code
cd openhantek-code/
sudo apt-get install libqt4-dev libfftw3-dev qt4-qmake fxload libusb-1.0-0-dev libbfd-dev
cd openhantek/
qmake
make
sudo make install
cd ../openhantek-extractfw/
aclocal && autoconf && automake
./configure
make
wget http://www.hantek.com.cn/Product/32Driver/2250/Driver.rar
unrar x Driver.rar
UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal Extracting from Driver.rar Creating Driver OK Extracting Driver/DSO22501.sys OK Extracting Driver/DSO22502.sys OK Extracting Driver/dso2250usb.inf OK All OK
./openhantek-extractfw Driver/DSO22501.sys
BFD: Driver/DSO22501.sys: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section .text BFD: Driver/DSO22501.sys: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section .data Section .data found (starting at 0x08a0, 9504 bytes) Symbol _firmware found (offset 0x0000, 8184 bytes) Symbol _loader found (offset 0x1ff8, 1320 bytes) Saving firmware as Driver/dso2250-firmware.hex Saving loader as Driver/dso2250-loader.hex
sudo mkdir -p /usr/local/share/hantek sudo cp Driver/*.hex /usr/local/share/hantek/

While tempting (the ID shows up as 04b4 above), do NOT change the part marked in red in 90-hantek.rules since changing it requires you to run as root. It works fine as user if you leave it alone.
 13 # Hantek DSO-2250
 14 SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="4b4/2250/*", RUN+="/sbin/fxload -t fx2 -I /usr/local/share/hantek/dso2250-firmware.hex -s /usr/local/share/hantek/dso2250-loader.hex -D $env{DEVNAME}"
 15 SYSFS{idVendor}=="04b5", SYSFS{idProduct}=="2250", MODE="0660", GROUP="plugdev"
sudo cp 90-hantek.rules /etc/udev/rules.d/
sudo service udev restart
sudo usermod -a -G plugdev $USER

Plug in your oscilloscope:
[ 4216.277235] udevd[23240]: starting version 175
[ 4246.532221] usb 2-2: new high-speed USB device number 5 using ehci_hcd
[ 4246.664559] usb 2-2: New USB device found, idVendor=04b4, idProduct=2250
[ 4246.664570] usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 4246.718694] usb 2-2: USB disconnect, device number 5
[ 4248.492214] usb 2-2: new high-speed USB device number 6 using ehci_hcd
[ 4248.625224] usb 2-2: New USB device found, idVendor=04b5, idProduct=2250
[ 4248.625238] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4248.625246] usb 2-2: Product: DSO-2250 
[ 4248.625252] usb 2-2: Manufacturer: ODM

At this point the light on the oscilloscope was blinking red.
openhantek

Check the 'show spectrum' thingy (I'm running this with the probe on CH1 connected to the square wave cal at the back of the scope).

Done.

21 December 2012

297. WakeOnLan with etherwake, ethtool -- working with onboard NIC

I've looked at this on and off during the past two years and never managed to get it to work -- until today. I leaned heavily on https://wiki.debian.org/WakeOnLan to get it to work.

Not sure what made the difference -- probably the ethernet-wol g line -- but here's what I did:


First activate wake on lan in the bios on whatever computer you're using. In an ideal world that'd just be a matter of changing 'Wake On Lan' to enabled, but it's not always that easy. Typically, you'll be looking under power options.

On Optiplex 990, go to power options, and enable Wake On Lan.
On Gigabyte 990-fxa-d3 there's no such option. Just make sure that ErP support is NOT enabled.
On Biostar N68S3+, just enable Wake On Lan and you'll be fine.

On none of these could I boot using the PCI/PCIe NIC devices i.e. only the onboard NICs worked.


Next on each computer which you wish to boot, install ethtool.
Then edit /etc/network/interfaces and add ethernet-wol g for each IF that you want to boot with:

auto eth0
iface eth0 inet dhcp
ethernet-wol g

auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1
ethernet-wol g

Finally, on the computer you wish to boot from, install etherwake from the repos. Then do
sudo etherwake -i eth3 78:2b:cb:b3:a4:a5
where eth3 is the interface on the local computer that is on the same LAN as the interface on the remote computer that you wish to boot, and 78:2b:cb:b3:a4:a5 is the MAC address of the remote computer's interface.

I've tried this successfully on:
* Optiplex 990 -- onboard NIC only
* gigabyte 990-fxa-d3 -- onboard NIC only
* Biostar N68S3+. Bios: American Megatrends 08/26/2010. On-board NIC only.


19 December 2012

296. Building Wine 1.5.19 on Debian (Wheezy/Testing) without errors

UPDATE 16 May 2013: See here for Wine 1.5.30: http://verahill.blogspot.com.au/2013/05/416-wine-1530-in-chroot.html

UPDATE (10th Jan 2013): See here for Wine 1.5.21 using the multiarch approach: http://verahill.blogspot.com.au/2013/01/308-compiling-wine-1521-on-debian.html

This time we'll be cheating and using the carbon-dev.org debian rules to build wine 1.5.19, which works amazingly well with a tiny bit of editing. In spite of what it looks like, this build is easy.



This is also my first encounter with multiarch since libgsm was causing issues (think it's moved out of ia32). Ultimately, multiarch will be the proper way to build 32-bit wine anyway, but I'll deal with that some other day.

Interesting fact: if you try to build with ... 1>build.log 2> build.err the build will fail since files are changing in the main directory during build. Make sure that you do e.g. .. 1> ../build.log 2> ../build.err if you want to track the build.

Finally, I've also built wine 1.5.18 this way, in addition to wine 1.5.19.

The build starts here:

Here's my current best guess at dependencies (Note that multiarch on ubuntu is a little bit different from Debian.):
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install ia32-libs ia32-libs-dev bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev opencl-dev lib32opencl1 oss4-dev gettext lib32v4l-dev lib32ncurses5-dev lib32asound2-dev libtiff4-dev libgphoto2-2-dev libxkbfile-dev libxxf86dga-dev freeglut3-dev unixodbc-dev gcc-multilib
sudo apt-get install libgsm1:i386
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: gcc-4.7-base:i386 libc6:i386 libc6-i686:i386 libgcc1:i386 Suggested packages: glibc-doc:i386 locales:i386 The following NEW packages will be installed: gcc-4.7-base:i386 libc6:i386 libc6-i686:i386 libgcc1:i386 libgsm1:i386 0 upgraded, 5 newly installed, 0 to remove and 2 not upgraded. Need to get 5,412 kB of archives. After this operation, 11.9 MB of additional disk space will be used. [..]
Once you've got that sorted, it is time to download the sources:
mkdir -p ~/tmp/wine_1.5.19_carbon/
cd ~/tmp/wine_1.5.19_carbon/
wget http://mirrors.ibiblio.org/wine/source/1.5/wine-1.5.19.tar.bz2 -O wine-unstable_1.5.19.orig.tar.bz2
tar xvf wine-unstable_1.5.19.orig.tar.bz2
cd wine-1.5.19/
wget http://dev.carbon-project.org/debian/wine-unstable/wine-unstable_1.5.5-0.1.debian.tar.bz2
tar xvf wine-unstable_1.5.5-0.1.debian.tar.bz2
rm wine-unstable_1.5.5-0.1.debian.tar.bz2

We could do the editing the proper way, or the quick way. Since I'm not really that familiar with build debian packages the right way (I cheat using checkinstall) we're doing this the quick and dirty way:
sed -i 's/1.5.5/1.5.19/g' debian/changelog
sed -i 's/\-4.5//g' debian/rules
sed -i 's/\-4.5//g' debian/control
sed -i 's/\-4.5//g' debian/control.in

Next, edit debian/patches/series and change it from
  1 debian-changes-from-1.1.32-1.patch
  2 readd_xpm.patch
  3 function_grep.patch
  4 Bug#29669_proposed-fix.patch
  5 fix-winegcc-paths.patch
  6 Bug#28898_squashed-proposed-patches.patch
  7 Bug#28201_proposed-fix-modified.patch
to
  1 debian-changes-from-1.1.32-1.patch
  2 readd_xpm.patch
  3 function_grep.patch

And build:
time dpkg-buildpackage -uc -us

The entire build takes about 40 minutes and gives the following files:
../libwine-alsa-unstable_1.5.19-0.1_amd64.deb
../libwine-dbg-unstable_1.5.19-0.1_amd64.deb
../libwine-ldap-unstable_1.5.19-0.1_amd64.deb
../libwine-sane-unstable_1.5.19-0.1_amd64.deb
../libwine-bin-unstable_1.5.19-0.1_amd64.deb
../libwine-dev-unstable_1.5.19-0.1_amd64.deb
../libwine-openal-unstable_1.5.19-0.1_amd64.deb
../libwine-unstable_1.5.19-0.1_amd64.deb
../libwine-capi-unstable_1.5.19-0.1_amd64.deb
../libwine-gl-unstable_1.5.19-0.1_amd64.deb
../libwine-oss-unstable_1.5.19-0.1_amd64.deb
../wine-bin-unstable_1.5.19-0.1_amd64.deb
../libwine-cms-unstable_1.5.19-0.1_amd64.deb
../libwine-gphoto2-unstable_1.5.19-0.1_amd64.deb
../libwine-print-unstable_1.5.19-0.1_amd64.deb
../wine-unstable_1.5.19-0.1_amd64.deb

To install,
cd ../
sudo dpkg -i *.deb

And you're done.
To confirm what version you're using (and get a screenshot like above) do
winecfg
and click on 'about'.

Links to this post:
http://www.debian-srbija.iz.rs/p/kako-da.html