1 Commits
Author SHA1 Message Date
pancake a215967e38 Import version 0.3 from tarball 0xFFFF-0.3.tar.gz 2007-10-20 02:32:24 +02:00
19 changed files with 109 additions and 268 deletions

No files matched your search

-1
View File
@@ -1,4 +1,3 @@
include config.mk
PREFIX?=/usr/local
all: logot
-8
View File
@@ -1,8 +0,0 @@
VERSION=0.3.2
PREFIX=/usr
# NetBSD stuff
CFLAGS+=-I/usr/pkg/include
LDFLAGS+=-L/usr/pkg/lib -Wl,-R/usr/pkg/lib
HAVE_USB=1
+2 -5
View File
@@ -1,11 +1,8 @@
OBJ=main.o
BIN=goxf
CFLAGS=`pkg-config gladeui-1.0 libglade-2.0 gmodule-2.0 --cflags`
LDFLAGS=`pkg-config gladeui-1.0 libglade-2.0 gmodule-2.0 --libs`
CFLAGS=`pkg-config libgladeui-1.0 libglade-2.0 --cflags`
LDFLAGS=`pkg-config libgladeui-1.0 libglade-2.0 --libs`
all: ${OBJ}
${CC} ${LDFLAGS} ${OBJ} -o ${BIN}
clean:
-rm -f ${BIN} ${OBJ}
+18 -74
View File
@@ -21,7 +21,7 @@
<widget class="GtkComboBox" id="combobox2">
<property name="visible">True</property>
<property name="active">0</property>
<property name="items" translatable="yes" context="yes">n770/n800/n810
<property name="items" translatable="yes" context="yes">n770/n800
HERMflasher</property>
</widget>
<packing>
@@ -30,7 +30,17 @@ HERMflasher</property>
</packing>
</child>
<child>
<placeholder/>
<widget class="GtkButton" id="gochange">
<property name="width_request">32</property>
<property name="visible">True</property>
<property name="has_default">True</property>
<property name="label" translatable="yes" context="yes">&gt;</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
@@ -45,11 +55,10 @@ HERMflasher</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkTreeView" id="tree">
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
</widget>
</child>
@@ -61,14 +70,14 @@ HERMflasher</property>
<property name="border_width">3</property>
<property name="spacing">2</property>
<child>
<widget class="GtkFileChooserButton" id="file">
<widget class="GtkFileChooserButton" id="filechooserbutton2">
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="piece">
<widget class="GtkComboBox" id="combo1">
<property name="row_span_column">0</property>
<property name="column_span_column">0</property>
<property name="active">0</property>
@@ -91,18 +100,12 @@ xloader</property>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="label" context="yes">Remove</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gui_remove"/>
<signal name="activate" handler="gui_remove"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="add">
<property name="visible">True</property>
<property name="label" context="yes">Add</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gui_add"/>
<signal name="activate" handler="gui_add"/>
</widget>
<packing>
<property name="position">1</property>
@@ -115,10 +118,9 @@ xloader</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="usbhost">
<widget class="GtkCheckButton" id="checkbutton2">
<property name="visible">True</property>
<property name="label" translatable="yes" context="yes">USB host mode</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -128,10 +130,9 @@ xloader</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="rdmode">
<widget class="GtkCheckButton" id="checkbutton3">
<property name="visible">True</property>
<property name="label" translatable="yes" context="yes">R&amp;D mode</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -144,7 +145,6 @@ xloader</property>
<widget class="GtkCheckButton" id="reboot">
<property name="visible">True</property>
<property name="label" translatable="yes" context="yes">Reboot</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -171,7 +171,7 @@ xloader</property>
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkProgressBar" id="pbar">
<widget class="GtkProgressBar" id="progressbar1">
<property name="visible">True</property>
<property name="show_text">True</property>
</widget>
@@ -184,9 +184,6 @@ xloader</property>
<property name="visible">True</property>
<property name="label" translatable="yes" context="yes">gtk-dialog-info</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gui_information" object="main_window"/>
<signal name="activate" handler="gui_information" object="main_window"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -198,9 +195,6 @@ xloader</property>
<property name="visible">True</property>
<property name="label" translatable="yes" context="yes">gtk-execute</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gui_run"/>
<signal name="activate" handler="gui_run"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -226,54 +220,4 @@ xloader</property>
</widget>
</child>
</widget>
<widget class="GtkAboutDialog" id="information">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes" context="yes">About Glade</property>
<property name="resizable">False</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<property name="program_name">Glade</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="pixels_below_lines">2</property>
<property name="editable">False</property>
<property name="cursor_visible">False</property>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
+1 -29
View File
@@ -21,10 +21,10 @@
#define U(x) printf("%d\n",x); fflush(stdout);
GladeXML *xml;
int main(int argc, char **argv)
{
GtkWidget *w;
GladeXML *xml;
gtk_init(&argc, &argv);
@@ -40,11 +40,6 @@ int main(int argc, char **argv)
w = glade_xml_get_widget(xml, "main_window");
gtk_signal_connect(GTK_OBJECT(w), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
{
GtkComboBox *piece = GTK_COMBO_BOX(glade_xml_get_widget(xml, "piece"));
gtk_combo_box_set_active(piece, 0);
}
gtk_widget_show_all(w);
gtk_object_unref(GTK_OBJECT(xml));
@@ -52,26 +47,3 @@ int main(int argc, char **argv)
gtk_main();
return 0;
}
extern void gui_run();
extern void gui_run()
{
printf("run\n");
}
extern void gui_add();
extern void gui_add()
{
GtkTreeView *tree = glade_xml_get_widget(xml, "tree");
GtkFileChooser *file = GTK_FILE_CHOOSER(glade_xml_get_widget(xml, "file"));
GtkComboBox *piece = GTK_COMBO_BOX(glade_xml_get_widget(xml, "piece"));
printf("ADD %s\n", gtk_file_chooser_get_filename(file));
printf("ADD %d\n", gtk_combo_box_get_active(piece));
}
extern void gui_information();
void gui_information()
{
printf("FUCKMENOT!\n");
fflush(stdout);
}
+2 -5
View File
@@ -1,16 +1,13 @@
include ../config.mk
VERSION=0.3
OBJ=main.o fiasco.o hexdump.o dump.o flash.o serial.o
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o console.o
BIN=0xFFFF
#LIBS=`${HAVE_USB} && echo -- '-lusb'`
LIBS=`if [ "${HAVE_USB}" = 1 ]; then echo '-lusb'; fi`
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
CFLAGS+=-pedantic -std=c99 -DHAVE_USB=${HAVE_USB}
USBOBJ=../libusb/error.o ../libusb/usb.o ../libusb/descriptors.o
USBOBJ+=../libusb/linux.o ## XXX not portable
all: ${OBJ}
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${LIBS}
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} -lusb
allusb: ${OBJ}
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${USBOBJ}
+7 -13
View File
@@ -1,6 +1,6 @@
/*
* 0xFFFF - Open Free Fiasco Firmware Flasher
* Copyright (C) 2007, 2008 pancake <pancake@youterm.com>
* Copyright (C) 2007 pancake <pancake@youterm.com>
*
* 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
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_USB
#include "main.h"
#include "query.h"
#include <stdio.h>
@@ -46,7 +45,6 @@ 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();
@@ -62,17 +60,14 @@ void cmd_nanddump(char *line)
char out[128];
int ignbb;
int ignoob = -1;
sscanf(line, "%127s 0x%x 0x%x %127s %d %d",
(char *)&dev, (unsigned int*)&from, (unsigned int *)&length,
(char *)&out, (int*)&ignbb, (int *)&ignoob);
sscanf(line, "%127s 0x%x 0x%x %127s %d %d", &dev, &from, &length, &out, &ignbb, &ignoob);
if (ignoob == -1) {
eprintf("Invalid arguments.\n");
eprintf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
eprintf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
} else
printf("Invalid arguments.\n");
printf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
printf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
} else {
nanddump(dev, from, length, out, ignbb, ignoob);
}
}
void cmd_dump(char *line)
@@ -166,4 +161,3 @@ int console_prompt()
return 0;
}
#endif
+2 -4
View File
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_USB
#include "main.h"
#include <stdio.h>
#include <string.h>
@@ -37,7 +36,7 @@
struct devices supported_devices[SUPPORTED_DEVICES] = {
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
{ "n770/n810", 0x421, 0x0105, 0x0001 }, // my n770
{ "n770", 0x421, 0x0105, 0x0001 }, // my n770
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
{ 0 },
{ 0 }
@@ -57,7 +56,7 @@ int is_valid_device(struct usb_device_descriptor *udd)
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
if ((udd->idVendor == ptr.vendor_id)
&& (udd->idProduct == ptr.product_id)) {
D printf("found %s\n", supported_devices[i].name);
D printf("found %s\n", supported_devices[i]);
return i;
}
@@ -117,4 +116,3 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
return 0;
}
#endif
+9 -13
View File
@@ -18,6 +18,7 @@
#include "main.h"
#include "hexdump.h"
#include <usb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -80,11 +81,8 @@ __rf_extract_exit:
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
//#include <asm/types.h>
#include <asm/types.h>
#include <mtd/mtd-user.h>
#ifndef loff_t
#define loff_t off_t
#endif
#define M_RDONLY 0x00000001
#define M_RDRW 0x00000002
@@ -244,8 +242,7 @@ closeall:
return 1;
}
// XXX warning ioob is not used
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob)
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl)
{
unsigned char readbuf[2048];
int oobinfochanged = 0 ;
@@ -382,7 +379,6 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
/* Write out page data */
//if (pretty_print) dump_bytes(readbuf, bs);
write(ofd, readbuf, bs);
progressbar(ofs, end_addr);
// OOB STUFF //
@@ -547,20 +543,20 @@ int reverse_extract_pieces(char *dir)
// TODO: get values from /proc/mtd ???
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1,0); // 0x3600 size?
nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1); // 0x3600 size?
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1,0);
nanddump("/dev/mtd1", 0, 0, "config.bin", 0,0);
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1);
nanddump("/dev/mtd1", 0, 0, "config.bin", 0);
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0,0);
nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0);
//rf_extract("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0,0);
nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0);
printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
read(0, &reply, 1);
if (reply=='y'||reply=='Y') {
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0,0);
nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0);
} else printf("*** Ignoring rootfs\n");
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
+5 -5
View File
@@ -60,8 +60,8 @@ int openfiasco(char *name)
read(header.fd, buf, namelen);
printf("Fiasco version: %2d\n", buf[3]);
strcpy(header.fwname, (char *)buf+6);
for(i=6;i<namelen;i+=strlen((char *)(buf+i))+1)
strcpy(header.fwname, buf+6);
for(i=6;i<namelen;i+=strlen(buf+i)+1)
printf("Name: %s\n", buf+i);
/* walk the tree */
@@ -86,7 +86,7 @@ int openfiasco(char *name)
printf(" [eof]\n");
break;
} else printf(" %s\n", data);
strcpy(header.name, (char *)data);
strcpy(header.name, data);
if (read(header.fd, buf, 9)<9)
break;
@@ -106,7 +106,7 @@ int openfiasco(char *name)
break;
if (data[0])
printf(" version: %s\n", data);
strcpy(header.version, (char *)data);
strcpy(header.version, data);
if (read(header.fd, buf+8, 1)<1)
break;
}
@@ -126,7 +126,7 @@ int openfiasco(char *name)
void fiasco_data_read(struct header_t *header)
{
header->data = (unsigned char *)malloc(header->size);
header->data = (char *)malloc(header->size);
if (header->data == NULL) {
printf("Cannot alloc %d bytes\n", header->size);
return;
+1 -2
View File
@@ -16,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_USB
#include "main.h"
#include "hash.h"
#include "hexdump.h"
#include <usb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -195,4 +195,3 @@ void flash_image(char *filename, char *piece, char *version)
}
printf("Flash done succesfully.\n");
}
#endif
+1 -1
View File
@@ -27,7 +27,7 @@ usho do_hash(usho *b, int len)
return result;
}
usho do_hash_file(const char *filename)
usho do_hash_file(char *filename)
{
unsigned char buf[BSIZE];
FILE *fd = fopen(filename, "r");
+1 -1
View File
@@ -5,6 +5,6 @@
#define BSIZE 0x20000
usho do_hash(usho *b, int len);
usho do_hash_file(const char *filename);
usho do_hash_file(char *filename);
#endif
+38 -53
View File
@@ -24,11 +24,8 @@
#include <getopt.h>
/* global pr0n */
#if HAVE_USB
#include <usb.h>
struct usb_device *device = NULL;
struct usb_dev_handle *dev = NULL;
#endif
char *fiasco_image = NULL;
char *boot_cmdline = NULL;
char *reverseto = NULL;
@@ -38,7 +35,7 @@ int usb_mode = -1;
int root_device = -1;
int verbose = 0;
int identify = 0;
int moboreboot = 0;
int reboot = 0;
int unpack = 0;
int info = 0;
@@ -77,30 +74,26 @@ void show_usage()
{
int i;
show_title();
#if HAVE_USB
printf("Over USB:\n");
printf(" -b [arg] boots the kernel with arguments\n");
printf(" -c console prompt mode\n");
printf(" -C [/dev/mtd] check bad blocks on mtd\n");
printf(" -d [vid:pid] injects a usb device into the supported list\n");
printf(" -D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)\n");
printf(" -e [path] dump and extract pieces to path\n");
printf(" -f <flags> set the given RD flags (see '-f help')\n");
printf(" -F [fiasco] flash a fiasco firmware image\n");
printf(" -h show this help message\n");
printf(" -H [file] calculate hash for file\n");
printf(" -i show device information (let standby mode)\n");
printf(" -l list supported usb device ids\n");
printf(" -I [piece] identify a firmware piece\n");
printf(" -l, -L list supported usb device ids\n");
printf(" -p [[p%%]file] piece-of-firmware %% file-where-this-piece-is\n");
printf(" -P [new-fiasco] creates a new fiasco package, pieces as arguments\n");
printf(" -r [0|1] disable/enable R&D mode\n");
printf(" -R reboot the omap board\n");
printf(" -U [0|1] disable/enable the usb host mode\n");
#endif
printf("Local stuff:\n");
printf(" -s [serial] serial port console (minicom like terminal)\n");
printf(" -h show this help message\n");
printf(" -C [/dev/mtd] check bad blocks on mtd\n");
printf(" -e [path] dump and extract pieces to path\n");
printf(" -F [fiasco] flash a fiasco firmware image\n");
printf(" -H [file] calculate hash for file\n");
printf(" -I [piece] identify a firmware piece\n");
printf(" -P [new-fiasco] creates a new fiasco package, pieces as arguments\n");
printf(" -u [fiasco] unpack target fiasco image\n");
printf(" -U [0|1] disable/enable the usb host mode\n");
printf(" -v be verbose and noisy\n");
printf(" -V show 0xFFFF version information\n");
printf(" -x extract configuration entries from /dev/mtd1\n");
@@ -139,10 +132,8 @@ int fiasco_flash(char *file)
openfiasco( file );
printf("\nTODO: Implement the fiasco flashing here.\n");
return -1;
}
#if HAVE_USB
int connect_via_usb()
{
struct usb_device_descriptor udd;
@@ -175,8 +166,7 @@ int connect_via_usb()
return 1;
}
if ( usb_claim_interface(dev, 2) < 0) {
//device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0
if ( usb_claim_interface(dev, 2) < 0) { // 2 or 0
D perror("usb_claim_interface");
// Something is broken if closing fails.
@@ -191,7 +181,7 @@ int connect_via_usb()
continue;
}
if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
if (usb_set_altinterface(dev, 1) < 0) {
D perror("usb_set_altinterface");
// Something is broken if closing fails.
@@ -216,28 +206,20 @@ int connect_via_usb()
return 0;
}
#endif
int main(int argc, char **argv)
{
int c;
while((c = getopt(argc, argv, "C:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:")) != -1) {
while((c = getopt(argc, argv, "C:cp:PvVhRu:ib:U:r:e:Lld:I:D:f:F:s:xH:")) != -1) {
switch(c) {
case 'H':
printf("xorpair: %04x\n", do_hash_file(optarg));
return 0;
case 'x':
return dump_config();
#if HAVE_USB
case 'c':
return console_prompt();
case 'b':
boot_cmdline = optarg;
break;
case 'U':
usb_mode = atoi(optarg);
break;
case 'F':
return fiasco_flash(optarg);
case 'd':
@@ -249,6 +231,11 @@ int main(int argc, char **argv)
case 'D':
root_device = atoi(optarg);
break;
case 'e':
reverseto = optarg;
break;
case 's':
return console(optarg);
case 'f':
if (!strcmp(optarg,"help")) {
printf("* Flags are composed of:\n");
@@ -260,40 +247,37 @@ int main(int argc, char **argv)
exit(1);
}
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
case 'U':
usb_mode = atoi(optarg);
break;
case 'r':
rd_mode = atoi(optarg);
break;
case 'l':
list_valid_devices();
return 0;
case 'p':
add_piece(optarg);
case 'b':
boot_cmdline = optarg;
break;
case 'i':
info = 1;
break;
case 'R':
moboreboot = 1;
break;
#endif
case 'e':
reverseto = optarg;
break;
case 's':
return console(optarg);
case 'u':
fiasco_image = optarg;
unpack = 1;
break;
case 'p':
add_piece(optarg);
break;
case 'P':
return fiasco_pack(optind, argv);
case 'L':
case 'l':
list_valid_devices();
return 0;
case 'I':
printf("%s: %s\n", fpid_file(optarg), optarg);
identify = 1;
break;
case 'C':
return check_badblocks(optarg);
case 'i':
info = 1;
break;
case 'v':
verbose = 1;
break;
@@ -303,6 +287,9 @@ int main(int argc, char **argv)
case 'V':
printf("%s\n", VERSION);
return 0;
case 'R':
reboot = 1;
break;
}
}
@@ -317,11 +304,11 @@ int main(int argc, char **argv)
&& (rd_flags == -1)
&& (rd_mode == -1)
&& (info == 0)
&& (moboreboot == 0)
&& (reboot == 0)
&& (usb_mode == -1)
&& (root_device == -1))
{
printf("0xFFFF [-chilRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n");
printf("0xFFFF [-chiLRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n");
printf(" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1]\n");
printf(" [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
return 1;
@@ -337,7 +324,6 @@ int main(int argc, char **argv)
return 0;
}
#if HAVE_USB
if (connect_via_usb()) {
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
return 0;
@@ -374,9 +360,8 @@ int main(int argc, char **argv)
if (boot_cmdline)
boot_board(boot_cmdline);
if (moboreboot)
if (reboot)
reboot_board();
#endif
return 0;
}
+12 -23
View File
@@ -2,9 +2,6 @@
#ifndef _INCLUDE_MAIN_H_
#define _INCLUDE_MAIN_H_
#include "hash.h"
#include "nolo.h"
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
@@ -20,14 +17,7 @@ unsigned long get_file_size(char *file);
void progressbar(unsigned long long part, unsigned long long total);
const char *fpid_file(const char *filename);
int add_piece(char *piece);
void eprintf(const char *format, ...);
#include <limits.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#if HAVE_USB
#include <usb.h>
extern struct usb_device *device;
@@ -37,8 +27,6 @@ void list_valid_devices();
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
int console(const char *device);
int connect_via_usb();
#endif
int console_prompt();
//
@@ -52,6 +40,9 @@ 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;
@@ -83,16 +74,6 @@ enum {
PIECE_LAST
};
struct header_t {
int fd;
char fwname[128];
char name[128];
char version[128];
unsigned short hash;
unsigned int size;
unsigned char *data;
};
extern char *pieces[];
extern char *modes[];
extern char *root_devices[];
@@ -105,7 +86,15 @@ int fiasco_add_eof(int fd);
extern void (*fiasco_callback)(struct header_t *header);
int fiasco_add(int fd, const char *name, const char *file, const char *version);
int fiasco_pack(int optind, char *argv[]);
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob);
struct header_t {
int fd;
char fwname[128];
char name[128];
char version[128];
unsigned short hash;
unsigned int size;
unsigned char *data;
};
#endif
-7
View File
@@ -1,7 +0,0 @@
#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
+1 -1
View File
@@ -55,7 +55,7 @@ int add_piece(char *piece)
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
} else {
/*/ autodetect piece type */
pcs[pcs_n].type = (char *)fpid_file(piece);
pcs[pcs_n].type = fpid_file(piece);
if (pcs[pcs_n].type == NULL) {
printf("Use -p [piece]:[file]\n");
printf("Pieces: ");
+8 -13
View File
@@ -1,6 +1,6 @@
/*
* 0xFFFF - Open Free Fiasco Firmware Flasher
* Copyright (C) 2007,2008 pancake <@youterm.com>
* Copyright (C) 2007 pancake <pancake@youterm.com>
*
* 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
@@ -16,8 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_USB
#include "main.h"
#include <stdio.h>
#include <string.h>
@@ -118,7 +116,7 @@ int set_rd_mode(unsigned short mode)
if (((short)mode)==-1)
return 1;
if (usb_control_msg(dev, CMD_WRITE, NOLO_SET_RDFLAGS, mode, 0, 0, 0, 2000) == -1) {
if (usb_control_msg(dev, CMD_WRITE, 16, mode, 0, 0, 0, 2000) == -1) {
fprintf(stderr, "Cannot set R&D flags.\n");
return 1;
}
@@ -136,8 +134,7 @@ int get_hw_revision()
unsigned char string[512];
int i = 0;
memset(string,'\0',512);
if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_HWVERSION, 0, 0, (char *)string, 512, 2000) == -1) {
if (usb_control_msg(dev, CMD_QUERY, 4, 0, 0, (char *)string, 512, 2000) == -1) {
fprintf(stderr, "Cannot query hw revision.\n");
return -1;
}
@@ -160,7 +157,7 @@ int get_rd_mode()
{
char isrd = 1;
if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 0, (char *)&isrd, 1, 2000) == -1) {
if (usb_control_msg(dev, CMD_QUERY, 17, 0, 0, (char *)&isrd, 1, 2000) == -1) {
fprintf(stderr, "Cannot query rd mode.\n");
return -1;
}
@@ -173,7 +170,7 @@ int get_root_device()
{
unsigned char opcode;
if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 1, (char *)&opcode, 1, 2000) < 0) {
if (usb_control_msg(dev, CMD_QUERY, 17, 0, 1, (char *)&opcode, 1, 2000) < 0) {
fprintf(stderr, "Cannot query root device\n");
return -1;
}
@@ -200,7 +197,7 @@ int set_root_device(unsigned short root_device)
return -1;
}
if (usb_control_msg(dev, CMD_WRITE, NOLO_SET_RDFLAGS, root_device, 1, 0, 0, 2000) == -1) {
if (usb_control_msg(dev, CMD_WRITE, 16, root_device, 1, 0, 0, 2000) == -1) {
fprintf(stderr, "Cannot set root device\n");
return -1;
}
@@ -284,7 +281,7 @@ int get_rd_flags()
{
unsigned short flags = 0;
if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_RDFLAGS, 0, 3, (void *) &flags, sizeof(flags), 2000) == -1) {
if (usb_control_msg(dev, CMD_QUERY, 17, 0, 3, (void *) &flags, sizeof(flags), 2000) == -1) {
fprintf(stderr, "Cannot get rd flags\n");
return -1;
}
@@ -304,7 +301,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, NOLO_GET_VERSION, 0, 0, (char *)&version, 4 , 2000) < 0) {
if (usb_control_msg(dev, CMD_QUERY, 3, 0, 0, (char *)&version, 4 , 2000) < 0) {
fprintf(stderr, "Cannot query nolo version. Old bootloader version?\n");
exit(1);
}
@@ -331,7 +328,6 @@ 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");
@@ -341,4 +337,3 @@ int get_sw_version()
return 1;
}
#endif
+1 -10
View File
@@ -17,9 +17,9 @@
*/
#include "main.h"
#include <usb.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
unsigned long get_file_size(char *file)
@@ -53,12 +53,3 @@ void progressbar(unsigned long long part, unsigned long long total)
printf("]\r");
fflush(stdout);
}
void eprintf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
//fflush(stderr); // XXX CRASH?!? stdin here?!?!?
}