From 32a59f4279e1d72abc2b60f08d6e32e2a0b32478 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 18 Feb 2008 01:25:00 +0100 Subject: * Initial support for n810 - Fix set_altinterface workaround which seems to be checked by nolo 1.7 - n810 has the same USBID than n770 * Define some nolo commands used in query.c in nolo.h * Get SW version with -i too --- src/console.c | 3 ++- src/devices.c | 2 +- src/main.c | 6 +++--- src/main.h | 4 +--- src/nolo.h | 7 +++++++ src/query.c | 16 +++++++++------- 6 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 src/nolo.h diff --git a/src/console.c b/src/console.c index d03343c..3206903 100644 --- a/src/console.c +++ b/src/console.c @@ -1,6 +1,6 @@ /* * 0xFFFF - Open Free Fiasco Firmware Flasher - * Copyright (C) 2007 pancake + * Copyright (C) 2007, 2008 pancake * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +46,7 @@ void cmd_help(char *line) void cmd_info(char *line) { + get_sw_version(); get_hw_revision(); // get hardware revision: get_root_device(); // only for flashing get_usb_mode(); diff --git a/src/devices.c b/src/devices.c index 203c300..2691770 100644 --- a/src/devices.c +++ b/src/devices.c @@ -37,7 +37,7 @@ struct devices supported_devices[SUPPORTED_DEVICES] = { { "FFFF", 0x000, 0x0000, 0x0000 }, // dummy { "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board - { "n770", 0x421, 0x0105, 0x0001 }, // my n770 + { "n770/n810", 0x421, 0x0105, 0x0001 }, // my n770 { "n800", 0x421, 0x04c3, 0x0001 }, // a n800 { 0 }, { 0 } diff --git a/src/main.c b/src/main.c index ba9f3b5..adec9f8 100644 --- a/src/main.c +++ b/src/main.c @@ -175,8 +175,8 @@ int connect_via_usb() return 1; } - if ( usb_claim_interface(dev, - device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0 + if ( usb_claim_interface(dev, 2) < 0) { + //device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0 D perror("usb_claim_interface"); // Something is broken if closing fails. @@ -191,7 +191,7 @@ int connect_via_usb() continue; } - if (usb_set_altinterface(dev, device->config->interface->altsetting->bAlternateSetting) < 0) { + if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) { D perror("usb_set_altinterface"); // Something is broken if closing fails. diff --git a/src/main.h b/src/main.h index 72ad491..541b4fa 100644 --- a/src/main.h +++ b/src/main.h @@ -3,6 +3,7 @@ #define _INCLUDE_MAIN_H_ #include "hash.h" +#include "nolo.h" #define _FILE_OFFSET_BITS 64 #define _GNU_SOURCE @@ -51,9 +52,6 @@ extern int verbose; #define CMD_WRITE 64 #define CMD_QUERY 192 -#define NOLO_GET_STATUS 1 -#define NOLO_GET_BOARD_ID 2 -#define NOLO_GET_VERSION 3 struct piece_t { char *name; diff --git a/src/nolo.h b/src/nolo.h new file mode 100644 index 0000000..f0a71a4 --- /dev/null +++ b/src/nolo.h @@ -0,0 +1,7 @@ + +#define NOLO_GET_STATUS 1 +#define NOLO_GET_BOARD_ID 2 +#define NOLO_GET_VERSION 3 +#define NOLO_GET_HWVERSION 4 +#define NOLO_SET_RDFLAGS 16 +#define NOLO_GET_RDFLAGS 17 diff --git a/src/query.c b/src/query.c index 72b5b0f..6709fd2 100644 --- a/src/query.c +++ b/src/query.c @@ -118,7 +118,7 @@ int set_rd_mode(unsigned short mode) if (((short)mode)==-1) return 1; - if (usb_control_msg(dev, CMD_WRITE, 16, mode, 0, 0, 0, 2000) == -1) { + if (usb_control_msg(dev, CMD_WRITE, NOLO_SET_RDFLAGS, mode, 0, 0, 0, 2000) == -1) { fprintf(stderr, "Cannot set R&D flags.\n"); return 1; } @@ -136,7 +136,8 @@ int get_hw_revision() unsigned char string[512]; int i = 0; - if (usb_control_msg(dev, CMD_QUERY, 4, 0, 0, (char *)string, 512, 2000) == -1) { + memset(string,'\0',512); + if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_HWVERSION, 0, 0, (char *)string, 512, 2000) == -1) { fprintf(stderr, "Cannot query hw revision.\n"); return -1; } @@ -159,7 +160,7 @@ int get_rd_mode() { char isrd = 1; - if (usb_control_msg(dev, CMD_QUERY, 17, 0, 0, (char *)&isrd, 1, 2000) == -1) { + if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 0, (char *)&isrd, 1, 2000) == -1) { fprintf(stderr, "Cannot query rd mode.\n"); return -1; } @@ -172,7 +173,7 @@ int get_root_device() { unsigned char opcode; - if (usb_control_msg(dev, CMD_QUERY, 17, 0, 1, (char *)&opcode, 1, 2000) < 0) { + if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 1, (char *)&opcode, 1, 2000) < 0) { fprintf(stderr, "Cannot query root device\n"); return -1; } @@ -199,7 +200,7 @@ int set_root_device(unsigned short root_device) return -1; } - if (usb_control_msg(dev, CMD_WRITE, 16, root_device, 1, 0, 0, 2000) == -1) { + if (usb_control_msg(dev, CMD_WRITE, NOLO_SET_RDFLAGS, root_device, 1, 0, 0, 2000) == -1) { fprintf(stderr, "Cannot set root device\n"); return -1; } @@ -283,7 +284,7 @@ int get_rd_flags() { unsigned short flags = 0; - if (usb_control_msg(dev, CMD_QUERY, 17, 0, 3, (void *) &flags, sizeof(flags), 2000) == -1) { + if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 3, (void *) &flags, sizeof(flags), 2000) == -1) { fprintf(stderr, "Cannot get rd flags\n"); return -1; } @@ -303,7 +304,7 @@ int get_nolo_version() unsigned int version; // ensure uint is at least 32 bits //if (usb_control_msg(dev, CMD_QUERY, 3, 0, 1, (char *)&version, 4 , 2000) < 0) { - if (usb_control_msg(dev, CMD_QUERY, 3, 0, 0, (char *)&version, 4 , 2000) < 0) { + if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_VERSION, 0, 0, (char *)&version, 4 , 2000) < 0) { fprintf(stderr, "Cannot query nolo version. Old bootloader version?\n"); exit(1); } @@ -330,6 +331,7 @@ int get_sw_version() fprintf(stderr, "error: cannot write query 18\n"); return 0; } + bytes[0]='\0'; ret = usb_control_msg(dev, CMD_QUERY, 20, 0, 0, (char *)&bytes, 512, 2000); if (ret<0) { fprintf(stderr, "error: b0rken swversion read!\n"); -- cgit v1.2.3