mbuesch / razer

Razer device library and tools
http://bues.ch/h/razercfg
GNU General Public License v2.0
253 stars 50 forks source link

[Taipan] Failed to read firmware version #4

Closed Fragan closed 10 years ago

Fragan commented 10 years ago

Hello,

Thanks to you to provide Razer mice support for Linux.

Today, I have installed the latest version of razercfg on Ubuntu 13.10 (3.11.0-12-generic x86_64) for my Razer Taipan.

The installation went smoothly, but when I start razerd I have the following error message:

$ sudo razerd
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: razer-taipan: Failed to read firmware version

I would be happy to provide you any helping information.

Regards, Fragan.

messani commented 10 years ago

Hello, I have Taipan mouse and it works for me. I think that there could be problem with the firmware version. I need more info for fixing it. Can you add line

razer_debug("err=%d, ver=%d\n", err, ver);

to the file hw_taipan.c to the line 166 (function taipan_read_fw_ver)? It should look like this:

... cmd.request = cpu_to_be16(0x8100); err = taipan_send_command(priv, &cmd); ver = be16_to_cpu((be16_t)cmd.value0); razer_debug("err=%d, ver=%d\n", err, ver); // <<-- NEW LINE if (!err && (ver & 0xFF00) != 0) ...

After recompiling run razerd and you should see something like this:

Razer device service daemon [razerd debug]: librazer: err=0, ver=256 <-- NEW LINE [razerd debug]: librazer: profile emulation: Committed active profile ...

Send me please your output. If you can't see new message, you will need to change logging level by parameter -l to 3.

If you want to skip firware version test, you can comment out part of the condition like this:

... ver = be16_to_cpu((be16_t)cmd.value0); razer_debug("err=%d, ver=%d\n", err, ver); if (!err) // <<---- MODIFIED LINE return ver;

But it is only ugly way to find out if firmware version test fix can help.

Fragan commented 10 years ago

Hi,

Thank you for help and sorry for the response time, I don't have much time in week.

I have modified the hw_taipan.c file as you mentioned. The razer_debug function shows nothing. After remove the second condition in the if statement, I was able to use the below command:

$ razercfg -V
Mouse:Taipan:USB-001-004:1532-0034-0: Firmware version 0.00

Using razer_error rather than razer_debug, shows me the below lines:

$ sudo razerd
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: err=0, ver=0

Regards, Fragan.

Edit:

For the debug, i forgot to use command to increase logging level (sudo razerd -l 3) This is the 'stacktrace':

$ sudo razerd -l 3
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: err=0, ver=0
[razerd debug]: librazer: profile emulation: Committed active profile
[razerd debug]: librazer: Mouse profile emulation initialized for Mouse:Taipan:USB-001-004:1532-0034-0
[razerd debug]: librazer: Allocated and initialized new mouse "Mouse:Taipan:USB-001-004:1532-0034-0"
Fragan commented 10 years ago

Without (ver & 0xFF00) != 0 condition in the if statement, I can configure my Taipan.

qrazercfg

Thanks for this workaround.

PS: If you have a fix, I can test it.

mbuesch commented 10 years ago

On Sun, 02 Mar 2014 08:02:55 -0800 Fragan notifications@github.com wrote:

Without (ver & 0xFF00) != 0 condition in the if statement, I can configure my Taipan.

PS: If you have a fix, I can test it.

What does the debug statement print, if you do not remove the condition?

Michael.

Fragan commented 10 years ago

With the statement if (!err && (ver & 0xFF00) != 0), I have this print:

$ sudo razerd -l 3
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: razer-taipan: Failed to read firmware version
mbuesch commented 10 years ago

On Sun, 02 Mar 2014 09:44:48 -0800 Fragan notifications@github.com wrote:

With the statement if (!err && (ver & 0xFF00) != 0), I have this print:

$ sudo razerd -l 3
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: razer-taipan: Failed to read firmware version

hm. What if you increase the loop count?

Change the line for (i = 0; i < 5; i++) { to for (i = 0; i < 50; i++) { for example.

I'll change the error condition to be nonfatal for the time being, until a better fix is found.

Fragan commented 10 years ago

No changes:

$ sudo razerd -l 3
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring.
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: err=0, ver=0
librazer: razer-taipan: Failed to read firmware version

The same with 200 iterations.

mbuesch commented 10 years ago

On Sun, 02 Mar 2014 10:01:48 -0800 Fragan notifications@github.com wrote:

librazer: err=0, ver=0 librazer: razer-taipan: Failed to read firmware version The same with 200 iterations.

Ok, thanks for testing. I'll apply the workaround. If somebody has a real fix, I'd be happy to apply that, though.

messani commented 10 years ago

I would like to know if there is a way to find out version of the firmware. I am not able to find it. http://www.razerzone.com/gaming-mice/razer-taipan There is a sentence about automatic firmware updates. I updated Razer Synapse, but my mouse is still working. Do you know if the mouse has old or new firmware?

Variable "ver" has value 256 in my case. The question is if the "ver" variable really means firmware version.

We can compare content of the cmd struct. In my case the content is this:

Breakpoint 1, taipan_read_fw_ver (priv=<optimized out>) at /home/tibor/devel/razer/librazer/hw_taipan.c:167
167         if (!err && (ver & 0xFF00) != 0)
(gdb) p cmd
$1 = {
  status = 1 '\001', 
  padding0 = "\000\000\000", 
  command = 2, 
  request = 385, 
  value0 = 1, 
  value1 = 0, 
  padding1 = '\000' <repeats 74 times>, 
  checksum = 131 '\203', 
  padding2 = 0 '\000'
}

I think it would be interesting to know what is in variable "value1". Can you modify line with logging to this:

razer_debug("err=%d, ver=%d, value0=%d, value1=%d\n", err, ver, cmd.value0, cmd.value1);

mbuesch commented 10 years ago

Closing this issue, as the workaround should do its job until a better solution is found.

electrojustin commented 10 years ago

Hey, I know this is an old thread, but I found this bug and fixed it for my local copy months and months ago and didn't find this thread until just now (I just assumed my mouse was weird), and I see from the commit logs that a proper solution still hasn't been found.

Way back when I was trying to fix this bug in my local copy, I assumed that 0x8100 was the wrong request for getting firmware and tried to find the correct request. A little trial and error revealed that my mouse replies with 50 when the request is changed to 0x8300. The command itself is completely irrelevant apparently, I removed it and nothing bad happened. I don't know if 50 is correct or if there is even any way to check if that's correct, but it seemed plausible-ish and didn't brick my mouse.

mbuesch commented 10 years ago

So do you have an actual patch that improves the situation?

electrojustin commented 10 years ago

I do have a patch. Will it improve the situation? Maybe...I will have to see if I can get a proper version number (possibly using the Razer's own software?) and compare that to 50.

--- razer/librazer/hw_taipan.c  2014-08-24 15:55:45.351239181 -0400
+++ razercfg-0.20/librazer/hw_taipan.c  2014-01-11 16:33:25.509996046 -0500
@@ -151,16 +151,14 @@
 static int taipan_read_fw_ver(struct taipan_private *priv)
 {
    struct taipan_command cmd;
-   uint16_t ver;
+   uint16_t ver = 1;
    int err;
    unsigned int i;
-
    /* Poke the device several times until it responds with a
     * valid version number */
    for (i = 0; i < 5; i++) {
        taipan_command_init(&cmd);
-       cmd.command = cpu_to_be16(0x0200);
-       cmd.request = cpu_to_be16(0x8100);
+       cmd.request = cpu_to_be16(0x8300);
        err = taipan_send_command(priv, &cmd);
        ver = be16_to_cpu((be16_t)cmd.value0);
        if (!err && (ver & 0xFF00) != 0)
@@ -169,10 +167,7 @@
    }
    razer_error("razer-taipan: Failed to read firmware version\n");

-   /* FIXME: Ignore the error and return 0 until we find out
-    *        why some mice fail to return a valid version number.
-    */
-   return 0;
+   return 2;
 }

 static int taipan_do_commit(struct taipan_private *priv)
messani commented 10 years ago

I have mouse that works well with current version. I hope that I will have oportunity to test it this week. I don't have the mouse now.

Thank you.

Fragan commented 10 years ago

Hi,

This patch fix the problem for my mouse.

[razer]>> ./ui/razercfg -V
Mouse:Taipan:USB-001-004:1532-0034-0: Firmware version 50.00
[razer]>> sudo ./razerd/razerd -l 3
Razer device service daemon
librazer: No config file /etc/razer.conf present. Ignoring
[razerd debug]: librazer: profile emulation: Committed active profile
[razerd debug]: librazer: Mouse profile emulation initialized for Mouse:Taipan:USB-001-004:1532-0034-0
[razerd debug]: librazer: Allocated and initialized new mouse "Mouse:Taipan:USB-001-004:1532-0034-0"

I have sent a PR https://github.com/mbuesch/razer/pull/23

messani commented 10 years ago

I tested it and it worked for me. Thank you.

mbuesch commented 10 years ago

messani, does it display the correct firmware version for you?

messani commented 10 years ago

Sorry for late reply. I can see firmware version 50 too (in razercfg). But I don't know, how to find out real firmware version (In Razer Synapse). So I don't know if value 50 is correct...

note89 commented 9 years ago

So i did my installation with yaourt can i still apply this fix ? cant open the program and have a similar issue as descibed above.