libusb20と格闘

as11loader by libusb20

ugenとlibusb20のギャップに挫折して、:-P
recfriioの前に、naobsdに転進中。
as11loader.cはできた?のかどうか、とりあえず ugen3.2: なデバイスが生えました。
こんな環境。

FreeBSD 8.0-CURRENT #2: Fri Feb  6 00:45:49 JST 2009

CPU: Intel(R) Atom(TM) CPU  230   @ 1.60GHz (1599.29-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x106c2  Stepping = 2
  Features=0xbfe9fbff
  Features2=0x40e31d>
  AMD Features=0x20100000
  AMD Features2=0x1
  TSC: P-state invariant
  Logical CPUs per core: 2
real memory  = 1063649280 (1014 MB)
avail memory = 1027399680 (979 MB)
ACPI APIC Table: 

uhci0:  port 0x3060-0x307f irq 23 at device 29.0 on pci0
uhci0: [ITHREAD]
uhci0: LegSup = 0x0f10
usbus0:  on uhci0
uhci1:  port 0x3040-0x305f irq 19 at device 29.1 on pci0
uhci1: [ITHREAD]
uhci1: LegSup = 0x0f10
usbus1:  on uhci1
uhci2:  port 0x3020-0x303f irq 16 at device 29.3 on pci0
uhci2: [ITHREAD]
uhci2: LegSup = 0x0f10
usbus2:  on uhci2
ehci0:  mem 0x503c4000-0x503c43ff irq 23 at device 2
9.7 on pci0
ehci0: [ITHREAD]
usbus3: EHCI version 1.0
usbus3:  on ehci0

使用前。

pansy# usbconfig -u 3 -a 2 dump_curr_config_desc
ugen3.2:  at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON


 Configuration index 0

    bLength = 0x0009
    bDescriptorType = 0x0002
    wTotalLength = 0x0019
    bNumInterfaces = 0x0001
    bConfigurationValue = 0x0001
    iConfiguration = 0x0030  
    bmAttributes = 0x0080
    bMaxPower = 0x00f9

    Interface 0
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0000
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x00ff
      bInterfaceSubClass = 0x00ff
      bInterfaceProtocol = 0x00ff
      iInterface = 0x0040  

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0001
        bmAttributes = 0x0002
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

使用後。SKNET_AS11Loader.sysは、MTVHDU_080701_Drvのもの。

Feb 11 16:00:17 pansy kernel: ugen3.2:  at usbus3 (disconnected)
Feb 11 16:00:20 pansy kernel: ugen3.2:  at usbus3

pansy# usbconfig -u 3 -a 2 dump_curr_config_desc
ugen3.2:  at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON


 Configuration index 0

    bLength = 0x0009
    bDescriptorType = 0x0002
    wTotalLength = 0x0030
    bNumInterfaces = 0x0002
    bConfigurationValue = 0x0001
    iConfiguration = 0x0030  
    bmAttributes = 0x0080
    bMaxPower = 0x00f9

    Interface 0
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0000
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0002
      bInterfaceClass = 0x00ff
      bInterfaceSubClass = 0x00ff
      bInterfaceProtocol = 0x00ff
      iInterface = 0x0020  


     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0081
        bmAttributes = 0x0002
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

     Endpoint 1
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0082
        bmAttributes = 0x0002
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000


    Interface 1
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0001
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x00ff
      bInterfaceSubClass = 0x00ff
      bInterfaceProtocol = 0x00ff
      iInterface = 0x0040  

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0083
        bmAttributes = 0x0001
        wMaxPacketSize = 0x0000
        bInterval = 0x0001
        bRefresh = 0x0000
        bSynchAddress = 0x0000

当然、FreeBSD-7でugenの時と変わらんのですが、libusb20で動いたという自己満足。
ソースは。。。ここに貼るのもなあ。xor.cがなんとかなったら、合わせてどこかに置きます。
ああ、カードリーダも調達せんと。内蔵が使えればなあ。

車輪再発明

いただいたコメントから試してみたところ、「旧基板を *BSD で動かすソースをLinuxに移植したソース」が、ほとんどそのままコンパイル通るやんか。。。動くかどうかは別として。

  • の代わりに、をinclude
  • -lusbの代わりに、-lusb20をリンク
  • usb_detach_kernel_driver_np()のブロックをコメントアウト

でもこのup120って、naobsdのそれと、微妙に違う。。。

  • かたやhdusctlでチューニングと読み込み+xorでデコード、かたやhdusctlでチューニング+xorで読み込みとデコード
  • hdusctlが、sendctl()で送っているデータが違う

なんだ、通るのか?と思って、recfriior4もmakeしてみた。

  • をinclude
  • Makefileをちょこちょこ修正

usbdevfs_ctrltransferとusbdevfs_urbがErrorになる以外は、ほとんどコンパイル通った。。。あとは、USBDEVFSなioctlを、libusb20に変えていけばいいのか?