# FritzCard USB v2

## ahorn

EDIT: working now (thanks to massimo) for testing!!! 

fcusb2 for kernel 2.6.27 - http://ahorn.todesmut.org/fcusb2src-2.6.27.tar.gz

better is to use not the usb-kernel modul, maybe someone find out how

old entry:

hi forum,

```
  CC [M]  /var/tmp/portage/net-dialup/fcusb2-0.1-r1/work/fritz/src/tables.o

  CC [M]  /var/tmp/portage/net-dialup/fcusb2-0.1-r1/work/fritz/src/queue.o

  CC [M]  /var/tmp/portage/net-dialup/fcusb2-0.1-r1/work/fritz/src/lib.o

  LD [M]  /var/tmp/portage/net-dialup/fcusb2-0.1-r1/work/fritz/src/fcusb2.o

  Building modules, stage 2.

  MODPOST 1 modules

FATAL: modpost: GPL-incompatible module fcusb2.ko uses GPL-only symbol 'usb_kill_urb'

make[2]: *** [__modpost] Error 1

make[1]: *** [modules] Error 2

make[1]: Leaving directory `/usr/src/linux-2.6.25-gentoo-r7'

make: *** [fcusb2.o] Error 2

 *

 * ERROR: net-dialup/fcusb2-0.1-r1 failed.
```

that's it. i found this site http://opensuse.foehr-it.de/testing/2.6.25/fcusb2/ but now it seems to be offline.

there was a rpm-file with a 2.6.25 fcusb2 kernel modul but i never got it to use it because the rpm seems to be broken.

i'm going to upload the rpm file the next day. maybe someone have the same issue and can help or someone can open the rpm for me  :Smile: 

----------

## eccerr0r

Apologies: I don't own this hardware.

I guess the problem should be fairly apparent, but this is usually caused by a binary driver using a function call in the kernel, but then on a later kernel the call is considered 'sacred' and 'sacrilege' if a closed-source binary uses it, and thus barred.  Typically you can just remove the GPL-only flag in your kernel and recompile it, but don't expect the kernel developers to remove it due to these 'sacred' calls.

You could also just downgrade your kernel and see if there's one that works too.

Else yeah, will have to find a version of the driver that don't use the 'sacred' calls.

----------

## ahorn

the site is up again. can someone test to unpack the rpm please, maybe i missed a special rpm-unpacker?

----------

## olli.bo

Hi,

i have the same problem with Kernel 2.6.25. Could you solve it?

thx

olli

----------

## massimo

You need to modify main.c in fwlan's source folder:

```

-MODULE_LICENSE ("PROPRIETARY")

+MODULE_LICENSE ("GPL")

```

----------

## ahorn

don't know what i did anymore,

here is the modified src http://ahorn.todesmut.org/fritz.tar.gz

good luck!

----------

## olli.bo

Thanks very much massimo...

Changing the main.c solved my Problem...

----------

## ahorn

bumped to 2.6.27, the driver is borked again

any ideas?

----------

## massimo

It's working here with 2.6.27-zen3 (zen-sources).

----------

## ahorn

 *massimo wrote:*   

> It's working here with 2.6.27-zen3 (zen-sources).

 

fcusb2? please provide the source or tell me how to do it :_)

----------

## massimo

Oh, I'm sorry. I thought this was a post dealing with the USB WLAN device. Since I owe you a happy ending I tried to create a patch for you. What I did: I took the sources and applied all already existing patches (those coming with the sources and the one from the Gentoo Team). I took the result of that and applied my changes - the final result is the following patch (sorry, but I guess you find the difference anyhow) which can be applied to the untouched sources:

```

--- fritz/src/.tmp_versions/fcusb2.mod   1970-01-01 01:00:00.000000000 +0100

+++ fritz-2.6.27/src/.tmp_versions/fcusb2.mod   2008-12-16 22:16:54.000000000 +0100

@@ -0,0 +1,2 @@

+/tmp/fritz/src/fcusb2.ko

+/tmp/fritz/src/main.o /tmp/fritz/src/driver.o /tmp/fritz/src/tools.o /tmp/fritz/src/tables.o /tmp/fritz/src/queue.o /tmp/fritz/src/lib.o

diff -Naur fritz/src/driver.c fritz-2.6.27/src/driver.c

--- fritz/src/driver.c   2005-07-07 00:00:00.000000000 +0200

+++ fritz-2.6.27/src/driver.c   2008-12-16 22:15:40.000000000 +0100

@@ -92,8 +92,12 @@

 static DECLARE_WAIT_QUEUE_HEAD(capi_wait);

 static DECLARE_WAIT_QUEUE_HEAD(tx_wait);

 static DECLARE_WAIT_QUEUE_HEAD(rx_wait);

+static DECLARE_COMPLETION(hotplug); /* New DECLARE, <arnd.feldmueller@web.de> */

+static DECLARE_COMPLETION(notify);  /* New DECLARE, <arnd.feldmueller@web.de> */

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))

 static DECLARE_MUTEX_LOCKED(hotplug);

 static DECLARE_MUTEX_LOCKED(notify);

+#endif

 

 #define   SCHED_WAKEUP_CAPI   { atomic_set (&thread_capi_flag, 1); wake_up_interruptible (&capi_wait); }

 #define   SCHED_WAKEUP      { atomic_set (&got_kicked, 1); wake_up_interruptible (&wait); }

@@ -189,10 +193,9 @@

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

-static void select_completion (struct urb * purb, struct pt_regs * ptr) {

+static void select_completion (struct urb * purb) {

    struct usb_ctrlrequest   * req;

 

-   UNUSED_ARG (ptr);

    assert (NULL != purb);

    req = (struct usb_ctrlrequest *) purb->context;

    LOG(

@@ -258,10 +261,9 @@

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

-static void reset_completion (struct urb * purb, struct pt_regs * ptr) {

+static void reset_completion (struct urb * purb) {

    struct usb_ctrlrequest *   req;

 

-   UNUSED_ARG (ptr);

    assert (NULL != purb);

    info (purb->status == 0);

 

@@ -693,7 +695,7 @@

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

 static void closing_worker (void * ctx) {

-   card_p   card = (card_p) ctx;

+   card_p   card = capi_card;

 

    DECLARE_WAIT_QUEUE_HEAD(close_wait);

 

@@ -789,7 +791,7 @@

    close_func = func;

    close_data = data;

 

-   INIT_WORK (&closing_work, closing_worker, capi_card);

+   INIT_WORK (&closing_work, (work_func_t)closing_worker);

    schedule_work (&closing_work);

    LOG("Worker scheduled.\n");

 } /* start_closing_worker */

@@ -985,19 +987,17 @@

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/ 

-static void usb_write_completion (struct urb * purb, struct pt_regs * ptr) {

+static void usb_write_completion (struct urb * purb) {

 

    UNUSED_ARG (purb);

-   UNUSED_ARG (ptr);

    tasklet_schedule (&tx_tasklet);

 } /* usb_write_completion */

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/ 

-static void usb_read_completion (struct urb * purb, struct pt_regs * ptr) {

+static void usb_read_completion (struct urb * purb) {

 

    UNUSED_ARG (purb);

-   UNUSED_ARG (ptr);

    tasklet_schedule (&rx_tasklet);

 } /* usb_read_completion */

 

@@ -1215,7 +1215,10 @@

       }

    }

    LOG("Scheduler thread stopped.\n");

+   complete(&hotplug); /* Complete Thread Sync here <arnd.feldmueller@web.de> */

+   #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))

    up (&hotplug);

+   #endif

    return 0;

 } /* scheduler */

 

@@ -1241,7 +1244,7 @@

 

    if (thread_pid != -1) {

       atomic_set (&thread_run_flag, 0);

-      if (NULL == find_task_by_pid (thread_pid)) {

+      if (NULL == find_task_by_pid_ns (thread_pid, &init_pid_ns)) {

          LOG("Thread[%d] has died before!\n", thread_pid);

       } else {

          if (!atomic_read (&thread_capi_flag)) {

@@ -1250,7 +1253,10 @@

             SCHED_WAKEUP;

          }

          LOG("Scheduler thread signalled, waiting...\n");

+         wait_for_completion(&hotplug); /* Wait for complete Thread Sync <arnd.feldmueller@web.de> */

+         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))

          down (&hotplug);

+         #endif

          LOG("Scheduler thread[%d] terminated.\n", thread_pid);

       }

       thread_pid = -1;

diff -Naur fritz/src/driver.h fritz-2.6.27/src/driver.h

--- fritz/src/driver.h   2005-07-07 00:00:00.000000000 +0200

+++ fritz-2.6.27/src/driver.h   2008-12-16 22:19:47.000000000 +0100

@@ -23,9 +23,7 @@

 #ifndef __have_driver_h__

 #define __have_driver_h__

 

-#include <asm/semaphore.h>

 #include <asm/atomic.h>

-#include <linux/config.h>

 #include <linux/skbuff.h>

 #include <linux/capi.h>

 #include <linux/isdn/capilli.h>

diff -Naur fritz/src/main.c fritz-2.6.27/src/main.c

--- fritz/src/main.c   2005-07-07 00:00:00.000000000 +0200

+++ fritz-2.6.27/src/main.c   2008-12-16 22:16:51.000000000 +0100

@@ -61,7 +61,7 @@

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

-MODULE_LICENSE ("Proprietary");

+MODULE_LICENSE ("GPL");

 MODULE_DESCRIPTION ("CAPI4Linux: Driver for " PRODUCT_LOGO);

 

 /*---------------------------------------------------------------------------*\

@@ -82,7 +82,6 @@

 

 struct usb_driver usb_driver = {

 

-   .owner =   THIS_MODULE,

    .name =      TARGET,

    .id_table =   usb_id_table,

    .probe =   usb_probe,

diff -Naur fritz/src/modules.order fritz-2.6.27/src/modules.order

--- fritz/src/modules.order   1970-01-01 01:00:00.000000000 +0100

+++ fritz-2.6.27/src/modules.order   2008-12-16 22:16:54.000000000 +0100

@@ -0,0 +1 @@

+kernel//tmp/fritz/src/fcusb2.ko

diff -Naur fritz/src/tools.h fritz-2.6.27/src/tools.h

--- fritz/src/tools.h   2005-07-07 00:00:00.000000000 +0200

+++ fritz-2.6.27/src/tools.h   2008-12-16 22:07:00.000000000 +0100

@@ -71,13 +71,14 @@

 

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

+#ifndef atomic_xchg

 static inline unsigned long atomic_xchg (

    volatile atomic_t *   v, 

    unsigned      value

 ) {

    return __xchg (value, &v->counter, sizeof (unsigned));

 } /* atomic_xchg */

-

+#endif

 /*---------------------------------------------------------------------------*\

 \*---------------------------------------------------------------------------*/

 #ifndef NDEBUG

```

----------

## ahorn

1st thank you for your help

the patch didn't apply

```
patching file fritz/src/.tmp_versions/fcusb2.mod

patching file fritz/src/driver.c

Hunk #1 FAILED at 92.

Hunk #2 FAILED at 193.

Hunk #3 FAILED at 261.

Hunk #4 FAILED at 695.

Hunk #5 FAILED at 791.

Hunk #6 FAILED at 987.

Hunk #7 FAILED at 1215.

Hunk #8 FAILED at 1244.

Hunk #9 FAILED at 1253.

9 out of 9 hunks FAILED -- saving rejects to file fritz/src/driver.c.rej

patching file fritz/src/driver.h

Hunk #1 FAILED at 23.

1 out of 1 hunk FAILED -- saving rejects to file fritz/src/driver.h.rej

patching file fritz/src/main.c

Hunk #1 FAILED at 61.

Hunk #2 FAILED at 82.

2 out of 2 hunks FAILED -- saving rejects to file fritz/src/main.c.rej

patching file fritz/src/modules.order

patching file fritz/src/tools.h

Hunk #1 FAILED at 71.

1 out of 1 hunk FAILED -- saving rejects to file fritz/src/tools.h.rej

```

i tried with these sources http://download.avm.de/cardware/fritzcrdusb.v20/linux/suse.93/fcusb2-suse93-3.11-07.tar.gz

i guess you used other sources?

btw: asm/semaphore.h changed to linux/semaphore.h and linux/config.h to linux/autoconf.h

----------

## massimo

This is used by the ebuild: http://opensuse.foehr-it.de/rpms/10_3/src/fcusb2-0.1-0.src.rpm

----------

## ahorn

ok, it works now. your patch still didn't work with patch. but i did it by hand and included the src here: 

http://ahorn.todesmut.org/fcusb2src-2.6.27.tar.gz

----------

## massimo

At least it's working ;)

----------

