Picoscope oscilloscope drivers and mono application

Hey there,

I started some work on packaging the drivers and the mono based oscilloscope application for picotech’s products.

I didn’t really expect there to be many other nix users using these but since I found a fellow nix user in their support forum, I just want report the state of things so far here.

Here is the main derivation in my nixpkgs fork and can be built with nix-build -A picoscope[-mono4].

The mono oscilloscope application ist starting and you can work with the demo device. Also the drivers can be loaded and their dependencies are found. However even though the picoscope_usbtest correctly identifies the connected device, enumerating it fails with an obscure Error: IsMVFailed message, which i reported and which seems to be related to the different mono version (see my picotech thread and this older one).

Some remarks concerning the derivation:

  • autoPatchelfHook: I had to overwrite the hook’s autoPatchelfFile function because the runtimeDepencency entries are only added to the rpath for executables and not for libraries and also there was no easy way to add the derivation itself (runtimeDependencies = ["$out"]; does not get expanded). The drivers load one of the other driver files using dlOpen. This should probably be fixed in autoPatchelfHook if there is no reason against it. The first issue is easy, but I’m not sure how to solve the adding $out can be generically added. The alternative would be to not use autoPatchelfHook but run patchelf manually.
  • Originally every driver is packaged as its own dpkg package. I put them all in a single derivation for ease of development and because else you would need some “withDrivers” attribute to the derivation to add all the drivers to the wrapper. This could be remodularized later, once everything is working.

The branch also contains work in progress gnuradio sources for the digitizers building on @doronbehar’s gnuradio modularization work. Because this gnuradio module needs a very old boost and only works with gnuradio 3.7 there is a separate nixpkgs attribute nixpkgs.gnuradio3_7Full for it.

Great work, looking forward to it! Might be worth bumping things on your picoscope forum thread, or the older one so it doesn’t get lost in the noise.

Could also consider opening a WIP PR against nixpkgs to get some more visibility on this.

I wonder if it would be easier to get the Windows version running under Wine/Proton…

I didn’t look at the windows version at all as I’m more interested in using the drivers directly from the gnuradio module anyway. Packaging the GUI was more to verify that the drivers and things like device permissions are working correctly.

I’m not sure if WIP PRs are encouraged in nixpkgs, there is so much going on there already and I’m not sure when and if I will be able to finnish things up.
Ultimately my goal is to finally getting around to setting up a NUR repository for things like this.

Were you by any chance able to reproduce the problems with my picoscope build?

Annoyingly my scope is currently without a USB cable, so I could only reproduce it up to the demo scope working :). I’ll try to reproduce asap though.

I think WIP PRs are fine (one can mark them as WIP from the GitHub interface).

The Windows version didn’t work out of the box due to some unimplemented functionality in Wine, I suspect it might be troubled too if the software wants to install drivers.

Info: Trace opened 5/4/2021.
ApplicationInfo: Info: Application 'PicoScope 6 Beta' (version 6.14.17.544) starting.
ID: Info: 44B2E32B6B1AAE6D90435EE56A17BF8B
Environment: Info: User is not Guest
Environment: Info: No Administrator Privileges
Environment: Info: Failed to detect access rights
Environment: Info: Host Operating System - Linux
Environment: Info: OS Version - Unix 5.10.30.0
Environment: Info: .net Version - 4.0.30319.42000
Environment: Info: Running on Mono - True
Environment: Info: Mono Display Name - 5.20.1.27 (tarball Tue Dec 22 01:51:17 UTC 2020)
Environment: Info: Current Directory - /home/j/src/nixpkgs2
Info: Processor Count - 16
Environment: Info: 64Bit Operating System - True
Environment: Info: 64Bit Process - True
Environment: Info: Command Line - /nix/store/c60jk96dcjzq508mvbr4qj0wgy3rr348-picoscope-6.14.17-4r544/lib/PicoScope.GTK.exe
ApplicationInfo: Info: Settings file version - 11.3.1
ApplicationInfo: Info: Preferences file version - 2.0.0
ApplicationInfo: Info: Probes file version - 1.0.0
ApplicationInfo: Info: Data file binary header version - 1
Info: Using default culture: English (United States).
InitalDeviceLoadSequence: Info: Begin
Scanning for USB devices: Info: Begin
Scanning for USB devices: Info: Complete
Device: Info: Attempting to load ps2000.dll
Device: Info: ps2000.dll System.DllNotFoundException: ps2000.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps2000.dll
Device: Info: Attempting to load ps5000a.dll
Device: Info: ps5000a.dll System.DllNotFoundException: ps5000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x00021] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps5000a.dll
Device: Info: Attempting to load ps6000a.dll
Device: Info: ps6000a.dll System.DllNotFoundException: ps6000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps6000a.dll
Device: Info: Attempting to load ps6000a.dll
Device: Info: ps6000a.dll System.DllNotFoundException: ps6000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps6000a.dll
Device: Info: Attempting to load ps4000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps4000a.dll
Device: Info: Attempting to load ps3000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps3000a.dll
Device: Info: Attempting to load ps3000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps3000a.dll
Device: Info: Attempting to load ps4000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps4000a.dll
Device: Info: Attempting to load ps4000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps4000a.dll
Device: Info: Attempting to load ps4000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps4000a.dll
Device: Info: Attempting to load ps5000a.dll
Device: Info: ps5000a.dll System.DllNotFoundException: ps5000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x00021] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps5000a.dll
Device: Info: Attempting to load ps6000.dll
Error: IsMVFailed
Device: Info: Finished loading ps6000.dll
Device: Info: Attempting to load ps3000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps3000a.dll
Device: Info: Attempting to load ps2000a.dll
Device: Info: ps2000a.dll System.DllNotFoundException: ps2000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps2000a.dll
Device: Info: Attempting to load ps3000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps3000a.dll
Device: Info: Attempting to load usbdrdaq.dll
Error: IsMVFailed
Device: Info: Finished loading usbdrdaq.dll
Device: Info: Attempting to load pl1000.dll
Device: Info: pl1000.dll System.DllNotFoundException: pl1000.dll
  at (wrapper managed-to-native) Pico.+.(int16,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading pl1000.dll
Device: Info: Attempting to load ps6000.dll
Error: IsMVFailed
Device: Info: Finished loading ps6000.dll
Device: Info: Attempting to load ps4000.dll
Device: Info: ps4000.dll System.DllNotFoundException: ps4000.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps4000.dll
Device: Info: Attempting to load ps5000.dll
Device: Info: ps5000.dll System.DllNotFoundException: ps5000.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps5000.dll
Device: Info: Attempting to load ps3000.dll
Device: Info: ps3000.dll System.DllNotFoundException: ps3000.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x0000c] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps3000.dll
Device: Info: Attempting to load ps5000a.dll
Device: Info: ps5000a.dll System.DllNotFoundException: ps5000a.dll
  at (wrapper managed-to-native) Pico.+.(int,int16)
  at Pico.. () [0x00021] in <bbec0400c3f6465d8e2acfec9a88945f>:0
  at Pico.. () [0x00031] in <bbec0400c3f6465d8e2acfec9a88945f>:0
Device: Info: Finished loading ps5000a.dll
Device: Info: Attempting to load ps4000a.dll
Error: IsMVFailed
Device: Info: Finished loading ps4000a.dll
Device: Info: No of Devices Found: 0
InitalDeviceLoadSequence: Info: Complete
Info: GlobalDeviceManager.Close()

Here’s the log from my run with a 2206B-MSO. Looks like the main problem is failing to load the driver shared object.

Ah, I see that the 2000 series drivers aren’t on your branch.

Also the .deb files do some editing to picoscope.conf detailing the locations of shared objects, something like that.

Thanks for testing. The dll not found errors are due to the fact that the mono application looks for them in multiple places (you can see this if you run the application with LD_DEBUG=files ...). For the attempts where the dll loading succeeds you also get the IsMVFailed error, on which I couldn’t find anything except this one thread which fixed it by using a different mono version which didn’t help.

ah yeah, sorry about that, I was lazy and only packaged the scopes that we have available.

hahah, no worries :slight_smile: Do you happen to know the difference between the 2000 and 2000a packages?

FWIW I tried with the latest packages and the dependencies it specifies, as well as the exact version of mono used in Ubuntu 18.04 to no avail.

Very sadly also the scope doesn’t seem to work in a Windows VM :confused:

Have emailed PS with my info, not really sure what to expect.

I guess my next try would be to run it in an FSH user env or via steamRun. I’ve also rebased my branch to nixpkgs-unstable. Thanks for sharing your progress :+1:

I tried a fhs env to no avail already actually :confused:

Not sure where the error comes from, but stracing shows that nothing (external) happens between reading the shared object and printing the error message.

Thanks for rebasing, I also did the same yesterday :slight_smile: I’ve also updated the debs to the latest version and dependencies, will share that today.

1 Like

@wirew0rm, got it working, it seems to require a special version of mono supplied by PS :frowning:

PR here: picoscope: init at 6.14.44-4r5870 by expipiplus1 · Pull Request #122160 · NixOS/nixpkgs · GitHub

This version of mono has heaps of references to /opt and whatnot in its config files, so I opted for a FHS wrapper.

I’ve tested this on my 2006B MSO and basic functionality at least seems to work. The font scaling is a bit whack though, but that’s a common complaint on the PS forums dating back years, so I don’t think it’s an artifact of this packaging.

1 Like

Hey, sorry just saw this now, great news. Just tried it with a “3403D MSO” (but couldn’t plug in any signals or the other scopes from home). But everything seems to work and for me the fonts look fine, so that seems unrelated to the packaging.

Looking at this comment in @yorickvP’s version linked in the PR the ominous “IsMVFailed” error message could well have been picotech’s signature verification failure message m(.

Hi! The ominous IsMVFailed error is a signature check on the loaded libraries. I had to disassemble the binary to find out. Let’s merge @expipiplus1’s PR and then see if we can incorporate some changes later so we can use the mono from nixpkgs.

1 Like