* Move usb-dev related code to devices.c from main.c
* Create a root Makefile to build the flasher, logotool and install * Clean some warning messages
This commit is contained in:
1 parent
3e13254858
commit
d0f9d78335
6 files changed
+137
-90
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
PREFIX?=/usr/local
|
||||||
|
|
||||||
|
all:
|
||||||
|
cd src && ${MAKE} all
|
||||||
|
cd logotool && ${MAKE} all
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cd src && ${MAKE} clean
|
||||||
|
cd logotool && ${MAKE} clean
|
||||||
|
|
||||||
|
install:
|
||||||
|
cp src/0xFFFF ${PREFIX}/bin
|
||||||
|
cp logotool/logotool ${PREFIX}/bin
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
int uncompress_image(char *srcf, char *dstf);
|
int uncompress_image(char *srcf, char *dstf);
|
||||||
int compress_image(char *srcf, char *dstf, int w, int h);
|
int compress_image(char *srcf, char *dstf, int w, int h);
|
||||||
|
int rgb2yuv(char *from, char *to, int width, int height);
|
||||||
|
|
||||||
static int show_usage()
|
static int show_usage()
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
VERSION=0.2
|
VERSION=0.2
|
||||||
OBJ=main.o fiasco.o hexdump.o dump.o flash.o
|
OBJ=main.o fiasco.o hexdump.o dump.o flash.o
|
||||||
OBJ+=hash.o fpid.o query.o pieces.o utils.o
|
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o
|
||||||
BIN=0xFFFF
|
BIN=0xFFFF
|
||||||
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g
|
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g
|
||||||
|
|
||||||
main: ${OBJ}
|
all: ${OBJ}
|
||||||
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} -lusb
|
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} -lusb
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007
|
||||||
|
* pancake <pancake@youterm.com>
|
||||||
|
*
|
||||||
|
* 0xFFFF is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 0xFFFF is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with 0xFFFF; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
||||||
|
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
||||||
|
{ "n770", 0x421, 0x0105, 0x0001 }, // my n770
|
||||||
|
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
||||||
|
{ 0 },
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
int is_valid_device(struct usb_device_descriptor *udd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct devices ptr = supported_devices[0];
|
||||||
|
|
||||||
|
for(i=0 ; ptr.vendor_id; ptr = supported_devices[++i])
|
||||||
|
if ((udd->idVendor == ptr.vendor_id)
|
||||||
|
&& (udd->idProduct == ptr.product_id)) {
|
||||||
|
printf("found %s (%04x:%04x)\n",
|
||||||
|
ptr.name, ptr.vendor_id, ptr.product_id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void list_valid_devices()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct devices ptr = supported_devices[0];
|
||||||
|
|
||||||
|
for(i=0; ptr.vendor_id; ptr = supported_devices[++i])
|
||||||
|
printf("%04x:%04x %s\n", ptr.vendor_id, ptr.product_id, ptr.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int usb_device_found(struct usb_device_descriptor *udd)
|
||||||
|
{
|
||||||
|
if (usb_find_busses() < 0) {
|
||||||
|
fprintf(stderr, "error: no usb busses found.\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
if (usb_find_devices() < 0) {
|
||||||
|
fprintf(stderr, "error: no devices found.\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
struct usb_bus *bus;
|
||||||
|
for (bus = usb_busses; bus; bus = bus->next) {
|
||||||
|
struct usb_device *dev = bus->devices;
|
||||||
|
D printf("bus: \n");
|
||||||
|
for (; dev; dev = dev->next) {
|
||||||
|
*udd = dev->descriptor;
|
||||||
|
D printf(" dev (%s) - ", dev->filename);
|
||||||
|
D printf("vendor: %04x product: %04x\n", udd->idVendor, udd->idProduct);
|
||||||
|
|
||||||
|
if (is_valid_device(udd)) {
|
||||||
|
device = dev;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+14
-88
@@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
#include <usb.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -30,18 +28,18 @@
|
|||||||
/* global pr0n */
|
/* global pr0n */
|
||||||
struct usb_device *device = NULL;
|
struct usb_device *device = NULL;
|
||||||
struct usb_dev_handle *dev = NULL;
|
struct usb_dev_handle *dev = NULL;
|
||||||
char *fiasco_image = NULL;
|
char *fiasco_image = NULL;
|
||||||
char *boot_cmdline = NULL;
|
char *boot_cmdline = NULL;
|
||||||
char *reverseto = NULL;
|
char *reverseto = NULL;
|
||||||
int rd_mode = -1;
|
int rd_mode = -1;
|
||||||
int rd_flags = -1;
|
int rd_flags = -1;
|
||||||
int usb_mode = -1;
|
int usb_mode = -1;
|
||||||
int root_device = -1;
|
int root_device = -1;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int identify = 0;
|
int identify = 0;
|
||||||
int reboot = 0;
|
int reboot = 0;
|
||||||
int unpack = 0;
|
int unpack = 0;
|
||||||
int info = 0;
|
int info = 0;
|
||||||
|
|
||||||
/* global structs */
|
/* global structs */
|
||||||
char *pieces[] = {
|
char *pieces[] = {
|
||||||
@@ -67,78 +65,6 @@ char *root_devices[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
struct devices {
|
|
||||||
char *name;
|
|
||||||
unsigned short vendor_id;
|
|
||||||
unsigned short product_id;
|
|
||||||
unsigned short flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SUPPORTED_DEVICES 5
|
|
||||||
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
|
||||||
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
|
||||||
{ "n770", 0x421, 0x0105, 0x0001 }, // my n770
|
|
||||||
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
|
||||||
{ 0 },
|
|
||||||
{ 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
int is_valid_device(struct usb_device_descriptor *udd)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct devices ptr = supported_devices[0];
|
|
||||||
|
|
||||||
for(i=0 ; ptr.vendor_id; ptr = supported_devices[++i])
|
|
||||||
if ((udd->idVendor == ptr.vendor_id)
|
|
||||||
&& (udd->idProduct == ptr.product_id)) {
|
|
||||||
printf("found %s (%04x:%04x)\n",
|
|
||||||
ptr.name, ptr.vendor_id, ptr.product_id);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void list_valid_devices()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct devices ptr = supported_devices[0];
|
|
||||||
|
|
||||||
for(i=0; ptr.vendor_id; ptr = supported_devices[++i])
|
|
||||||
printf("%04x:%04x %s\n", ptr.vendor_id, ptr.product_id, ptr.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int usb_device_found(struct usb_device_descriptor *udd)
|
|
||||||
{
|
|
||||||
if (usb_find_busses() < 0) {
|
|
||||||
fprintf(stderr, "error: no usb busses found.\n");
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
if (usb_find_devices() < 0) {
|
|
||||||
fprintf(stderr, "error: no devices found.\n");
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
struct usb_bus *bus;
|
|
||||||
for (bus = usb_busses; bus; bus = bus->next) {
|
|
||||||
struct usb_device *dev = bus->devices;
|
|
||||||
D printf("bus: \n");
|
|
||||||
for (; dev; dev = dev->next) {
|
|
||||||
*udd = dev->descriptor;
|
|
||||||
D printf(" dev (%s) - ", dev->filename);
|
|
||||||
D printf("vendor: %04x product: %04x\n", udd->idVendor, udd->idProduct);
|
|
||||||
|
|
||||||
if (is_valid_device(udd)) {
|
|
||||||
device = dev;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*------------- devices -----------------------*/
|
|
||||||
|
|
||||||
void show_title()
|
void show_title()
|
||||||
{
|
{
|
||||||
@@ -153,7 +79,7 @@ void show_usage()
|
|||||||
printf(" -b [arg] boots the kernel with arguments\n");
|
printf(" -b [arg] boots the kernel with arguments\n");
|
||||||
printf(" -e [path] dump and extract pieces to path\n");
|
printf(" -e [path] dump and extract pieces to path\n");
|
||||||
printf(" -r [0|1] disable/enable R&D mode\n");
|
printf(" -r [0|1] disable/enable R&D mode\n");
|
||||||
printf(" -f <flags> set the given RD flags (see 'Flasher_tool_usage' in maemo wiki)\n");
|
printf(" -f <flags> set the given RD flags (see '-f help' or 'Flasher_tool_usage' in maemo wiki)\n");
|
||||||
printf(" -p [[p%%]file] piece-of-firmware %% file-where-this-piece-is\n");
|
printf(" -p [[p%%]file] piece-of-firmware %% file-where-this-piece-is\n");
|
||||||
printf(" -u [fiasco] unpack target fiasco image\n");
|
printf(" -u [fiasco] unpack target fiasco image\n");
|
||||||
printf(" -U [0|1] disable/enable the usb host mode\n");
|
printf(" -U [0|1] disable/enable the usb host mode\n");
|
||||||
@@ -263,7 +189,7 @@ int main(int argc, char **argv)
|
|||||||
&& (rd_mode == -1)
|
&& (rd_mode == -1)
|
||||||
&& (info == 0)
|
&& (info == 0)
|
||||||
&& (reboot == 0)
|
&& (reboot == 0)
|
||||||
&& (usb_mode == -1)
|
&& (usb_mode == -1)
|
||||||
&& (root_device == -1))
|
&& (root_device == -1))
|
||||||
{
|
{
|
||||||
printf("Usage: 0xFFFF [-hvVRi] [-e path] [-U 0|1] [-p [piece%%]file [-p ...]]\n");
|
printf("Usage: 0xFFFF [-hvVRi] [-e path] [-U 0|1] [-p [piece%%]file [-p ...]]\n");
|
||||||
|
|||||||
+19
@@ -5,6 +5,7 @@
|
|||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
|
||||||
int reverse_extract_pieces(char *dir);
|
int reverse_extract_pieces(char *dir);
|
||||||
void flash_image(char *filename, char *piece, char *version);
|
void flash_image(char *filename, char *piece, char *version);
|
||||||
int fiasco_read_image(char *file);
|
int fiasco_read_image(char *file);
|
||||||
@@ -15,6 +16,15 @@ void progressbar(unsigned long long part, unsigned long long total);
|
|||||||
char *fpid_file(char *filename);
|
char *fpid_file(char *filename);
|
||||||
int add_piece(char *piece);
|
int add_piece(char *piece);
|
||||||
|
|
||||||
|
#include <usb.h>
|
||||||
|
|
||||||
|
extern struct usb_device *device;
|
||||||
|
extern struct usb_dev_handle *dev;
|
||||||
|
int is_valid_device(struct usb_device_descriptor *udd);
|
||||||
|
void list_valid_devices();
|
||||||
|
int usb_device_found(struct usb_device_descriptor *udd);
|
||||||
|
|
||||||
|
extern int verbose;
|
||||||
#define D if (verbose)
|
#define D if (verbose)
|
||||||
|
|
||||||
#define CMD_WRITE 64
|
#define CMD_WRITE 64
|
||||||
@@ -30,6 +40,15 @@ struct piece_t {
|
|||||||
char *vers;
|
char *vers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct devices {
|
||||||
|
char *name;
|
||||||
|
unsigned short vendor_id;
|
||||||
|
unsigned short product_id;
|
||||||
|
unsigned short flags;
|
||||||
|
};
|
||||||
|
#define SUPPORTED_DEVICES 5
|
||||||
|
extern struct devices supported_devices[SUPPORTED_DEVICES];
|
||||||
|
|
||||||
extern int pcs_n;
|
extern int pcs_n;
|
||||||
extern struct piece_t pcs[10];
|
extern struct piece_t pcs[10];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user