Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32a59f4279 | ||
|
|
fc6bacdb94 | ||
|
|
680fd91de8 | ||
|
|
288cad1c2e | ||
|
|
4115aab13d | ||
|
|
fbdac811fc | ||
|
|
d15412a788 | ||
|
|
85fdbfb354 |
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
include config.mk
|
||||||
PREFIX?=/usr/local
|
PREFIX?=/usr/local
|
||||||
|
|
||||||
all: logot
|
all: logot
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
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
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
SPECS FOR TEH FIASCO FIRMWARE FILE FORMAT ffff!
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
These notes has not been taken properly and may be wrong. It must
|
||||||
|
be revised to fit the reality. But this is mostly a general idea:
|
||||||
|
|
||||||
|
|
||||||
|
FILE HEADER
|
||||||
|
|
||||||
|
1 byte = 0xb4 -- signature
|
||||||
|
4 bytes -- firmware name length (big endian)
|
||||||
|
6 bytes -- versioning info ( byte 4 is format version )
|
||||||
|
N-6 bytes -- firmware name (zero fill)
|
||||||
|
|
||||||
|
|
||||||
|
PIECE HEADER
|
||||||
|
|
||||||
|
1 byte = 0x54 -- piece signature
|
||||||
|
6 bytes -- unknown
|
||||||
|
2 bytes -- checksum for the piece contents (xorpair)
|
||||||
|
12 bytes -- piece name (first byte is FF if is the last)
|
||||||
|
4 bytes -- piece size (big endian)
|
||||||
|
4 bytes -- unknown
|
||||||
|
block {
|
||||||
|
1 byte -- if (value '1'-'9') { ..there's a comment.. }
|
||||||
|
1 byte -- length of comment
|
||||||
|
N bytes -- comment
|
||||||
|
}
|
||||||
|
N bytes -- piece data
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ Tablets (n770 and n800).
|
|||||||
- reboot de mother board
|
- reboot de mother board
|
||||||
- extract the current firmware pieces from the device (dump)
|
- extract the current firmware pieces from the device (dump)
|
||||||
- set the USB host/slave mode
|
- set the USB host/slave mode
|
||||||
|
- pack/unpack fiasco firmwares
|
||||||
- fine grained R&D flags support
|
- fine grained R&D flags support
|
||||||
- identify firmware pieces
|
- identify firmware pieces
|
||||||
- dump mtd partitions (embedded mtd-utils source code)
|
- dump mtd partitions (embedded mtd-utils source code)
|
||||||
@@ -19,27 +20,29 @@ Tablets (n770 and n800).
|
|||||||
This is the help message of the tool:
|
This is the help message of the tool:
|
||||||
<pre>
|
<pre>
|
||||||
<b>~$ 0xFFFF -h</b>
|
<b>~$ 0xFFFF -h</b>
|
||||||
0xFFFF v0.2 // The Free Fiasco Firmware Flasher
|
0xFFFF v0.3 // The Free Fiasco Firmware Flasher
|
||||||
-b [arg] boots the kernel with arguments
|
-b [arg] boots the kernel with arguments
|
||||||
-e [path] dump and extract pieces to path
|
|
||||||
-r [0|1] disable/enable R&D mode
|
|
||||||
-f <flags> set the given RD flags (see '-f help')
|
|
||||||
-p [[p%]file] piece-of-firmware % file-where-this-piece-is
|
|
||||||
-u [fiasco] unpack target fiasco image
|
|
||||||
-U [0|1] disable/enable the usb host mode
|
|
||||||
-s [serial] serial port console (minicom like terminal)
|
|
||||||
-C [/dev/mtd] check bad blocks on mtd
|
|
||||||
-c console prompt mode
|
-c console prompt mode
|
||||||
-h show this help message
|
-C [/dev/mtd] check bad blocks on mtd
|
||||||
-i show device information (let standby mode)
|
|
||||||
-I [piece] identify a firmware piece
|
|
||||||
-l list supported usb device ids
|
|
||||||
-d [vid:pid] injects a usb device into the supported list
|
-d [vid:pid] injects a usb device into the supported list
|
||||||
-D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)
|
-D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)
|
||||||
|
-e [path] dump and extract pieces to path
|
||||||
|
-f <flags> set the given RD flags (see '-f help')
|
||||||
|
-F [fiasco] flash a fiasco firmware image
|
||||||
|
-h show this help message
|
||||||
|
-H [file] calculate hash for file
|
||||||
|
-i show device information (let standby mode)
|
||||||
|
-I [piece] identify a firmware piece
|
||||||
|
-l, -L list supported usb device ids
|
||||||
|
-p [[p%]file] piece-of-firmware % file-where-this-piece-is
|
||||||
|
-r [0|1] disable/enable R&D mode
|
||||||
-R reboot the omap board
|
-R reboot the omap board
|
||||||
-x extract configuration entries from /dev/mtd1
|
-s [serial] serial port console (minicom like terminal)
|
||||||
|
-u [fiasco] unpack target fiasco image
|
||||||
|
-U [0|1] disable/enable the usb host mode
|
||||||
-v be verbose and noisy
|
-v be verbose and noisy
|
||||||
-V show 0xFFFF version information
|
-V show 0xFFFF version information
|
||||||
|
-x extract configuration entries from /dev/mtd1
|
||||||
Pieces are: xloader secondary kernel initfs rootfs omap-nand
|
Pieces are: xloader secondary kernel initfs rootfs omap-nand
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -1,8 +1,11 @@
|
|||||||
OBJ=main.o
|
OBJ=main.o
|
||||||
BIN=goxf
|
BIN=goxf
|
||||||
|
|
||||||
CFLAGS=`pkg-config gladeui-1.0 libglade-2.0 --cflags`
|
CFLAGS=`pkg-config gladeui-1.0 libglade-2.0 gmodule-2.0 --cflags`
|
||||||
LDFLAGS=`pkg-config gladeui-1.0 libglade-2.0 --libs`
|
LDFLAGS=`pkg-config gladeui-1.0 libglade-2.0 gmodule-2.0 --libs`
|
||||||
|
|
||||||
all: ${OBJ}
|
all: ${OBJ}
|
||||||
${CC} ${LDFLAGS} ${OBJ} -o ${BIN}
|
${CC} ${LDFLAGS} ${OBJ} -o ${BIN}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f ${BIN} ${OBJ}
|
||||||
+74
-18
@@ -21,7 +21,7 @@
|
|||||||
<widget class="GtkComboBox" id="combobox2">
|
<widget class="GtkComboBox" id="combobox2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="active">0</property>
|
<property name="active">0</property>
|
||||||
<property name="items" translatable="yes" context="yes">n770/n800
|
<property name="items" translatable="yes" context="yes">n770/n800/n810
|
||||||
HERMflasher</property>
|
HERMflasher</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -30,17 +30,7 @@ HERMflasher</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="gochange">
|
<placeholder/>
|
||||||
<property name="width_request">32</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="has_default">True</property>
|
|
||||||
<property name="label" translatable="yes" context="yes">></property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -55,10 +45,11 @@ HERMflasher</property>
|
|||||||
<child>
|
<child>
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTreeView" id="treeview1">
|
<widget class="GtkTreeView" id="tree">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
@@ -70,14 +61,14 @@ HERMflasher</property>
|
|||||||
<property name="border_width">3</property>
|
<property name="border_width">3</property>
|
||||||
<property name="spacing">2</property>
|
<property name="spacing">2</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkFileChooserButton" id="filechooserbutton2">
|
<widget class="GtkFileChooserButton" id="file">
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="combo1">
|
<widget class="GtkComboBox" id="piece">
|
||||||
<property name="row_span_column">0</property>
|
<property name="row_span_column">0</property>
|
||||||
<property name="column_span_column">0</property>
|
<property name="column_span_column">0</property>
|
||||||
<property name="active">0</property>
|
<property name="active">0</property>
|
||||||
@@ -100,12 +91,18 @@ xloader</property>
|
|||||||
<widget class="GtkButton" id="button2">
|
<widget class="GtkButton" id="button2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" context="yes">Remove</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>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="add">
|
<widget class="GtkButton" id="add">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" context="yes">Add</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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
@@ -118,9 +115,10 @@ xloader</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="checkbutton2">
|
<widget class="GtkCheckButton" id="usbhost">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes" context="yes">USB host mode</property>
|
<property name="label" translatable="yes" context="yes">USB host mode</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -130,9 +128,10 @@ xloader</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="checkbutton3">
|
<widget class="GtkCheckButton" id="rdmode">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes" context="yes">R&D mode</property>
|
<property name="label" translatable="yes" context="yes">R&D mode</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -145,6 +144,7 @@ xloader</property>
|
|||||||
<widget class="GtkCheckButton" id="reboot">
|
<widget class="GtkCheckButton" id="reboot">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes" context="yes">Reboot</property>
|
<property name="label" translatable="yes" context="yes">Reboot</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -171,7 +171,7 @@ xloader</property>
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkProgressBar" id="progressbar1">
|
<widget class="GtkProgressBar" id="pbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="show_text">True</property>
|
<property name="show_text">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -184,6 +184,9 @@ xloader</property>
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes" context="yes">gtk-dialog-info</property>
|
<property name="label" translatable="yes" context="yes">gtk-dialog-info</property>
|
||||||
<property name="use_stock">True</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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -195,6 +198,9 @@ xloader</property>
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes" context="yes">gtk-execute</property>
|
<property name="label" translatable="yes" context="yes">gtk-execute</property>
|
||||||
<property name="use_stock">True</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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -220,4 +226,54 @@ xloader</property>
|
|||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</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>
|
</glade-interface>
|
||||||
+29
-1
@@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#define U(x) printf("%d\n",x); fflush(stdout);
|
#define U(x) printf("%d\n",x); fflush(stdout);
|
||||||
|
|
||||||
|
GladeXML *xml;
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
GtkWidget *w;
|
GtkWidget *w;
|
||||||
GladeXML *xml;
|
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
@@ -40,6 +40,11 @@ int main(int argc, char **argv)
|
|||||||
w = glade_xml_get_widget(xml, "main_window");
|
w = glade_xml_get_widget(xml, "main_window");
|
||||||
gtk_signal_connect(GTK_OBJECT(w), "destroy",
|
gtk_signal_connect(GTK_OBJECT(w), "destroy",
|
||||||
GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
|
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_widget_show_all(w);
|
||||||
|
|
||||||
gtk_object_unref(GTK_OBJECT(xml));
|
gtk_object_unref(GTK_OBJECT(xml));
|
||||||
@@ -47,3 +52,26 @@ int main(int argc, char **argv)
|
|||||||
gtk_main();
|
gtk_main();
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
+5
-2
@@ -1,13 +1,16 @@
|
|||||||
VERSION=0.2
|
include ../config.mk
|
||||||
OBJ=main.o fiasco.o hexdump.o dump.o flash.o serial.o
|
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
|
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o console.o
|
||||||
BIN=0xFFFF
|
BIN=0xFFFF
|
||||||
|
#LIBS=`${HAVE_USB} && echo -- '-lusb'`
|
||||||
|
LIBS=`if [ "${HAVE_USB}" = 1 ]; then echo '-lusb'; fi`
|
||||||
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
|
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/error.o ../libusb/usb.o ../libusb/descriptors.o
|
||||||
USBOBJ+=../libusb/linux.o ## XXX not portable
|
USBOBJ+=../libusb/linux.o ## XXX not portable
|
||||||
|
|
||||||
all: ${OBJ}
|
all: ${OBJ}
|
||||||
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} -lusb
|
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${LIBS}
|
||||||
|
|
||||||
allusb: ${OBJ}
|
allusb: ${OBJ}
|
||||||
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${USBOBJ}
|
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${USBOBJ}
|
||||||
|
|||||||
+13
-7
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
* Copyright (C) 2007, 2008 pancake <pancake@youterm.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -45,6 +46,7 @@ void cmd_help(char *line)
|
|||||||
|
|
||||||
void cmd_info(char *line)
|
void cmd_info(char *line)
|
||||||
{
|
{
|
||||||
|
get_sw_version();
|
||||||
get_hw_revision(); // get hardware revision:
|
get_hw_revision(); // get hardware revision:
|
||||||
get_root_device(); // only for flashing
|
get_root_device(); // only for flashing
|
||||||
get_usb_mode();
|
get_usb_mode();
|
||||||
@@ -60,14 +62,17 @@ void cmd_nanddump(char *line)
|
|||||||
char out[128];
|
char out[128];
|
||||||
int ignbb;
|
int ignbb;
|
||||||
int ignoob = -1;
|
int ignoob = -1;
|
||||||
sscanf(line, "%127s 0x%x 0x%x %127s %d %d", &dev, &from, &length, &out, &ignbb, &ignoob);
|
|
||||||
|
sscanf(line, "%127s 0x%x 0x%x %127s %d %d",
|
||||||
|
(char *)&dev, (unsigned int*)&from, (unsigned int *)&length,
|
||||||
|
(char *)&out, (int*)&ignbb, (int *)&ignoob);
|
||||||
|
|
||||||
if (ignoob == -1) {
|
if (ignoob == -1) {
|
||||||
printf("Invalid arguments.\n");
|
eprintf("Invalid arguments.\n");
|
||||||
printf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
|
eprintf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
|
||||||
printf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
|
eprintf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
|
||||||
} else {
|
} else
|
||||||
nanddump(dev, from, length, out, ignbb, ignoob);
|
nanddump(dev, from, length, out, ignbb, ignoob);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_dump(char *line)
|
void cmd_dump(char *line)
|
||||||
@@ -161,3 +166,4 @@ int console_prompt()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
+4
-2
@@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
||||||
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
|
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
|
||||||
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
{ "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
|
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
@@ -56,7 +57,7 @@ int is_valid_device(struct usb_device_descriptor *udd)
|
|||||||
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
|
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
|
||||||
if ((udd->idVendor == ptr.vendor_id)
|
if ((udd->idVendor == ptr.vendor_id)
|
||||||
&& (udd->idProduct == ptr.product_id)) {
|
&& (udd->idProduct == ptr.product_id)) {
|
||||||
D printf("found %s\n", supported_devices[i]);
|
D printf("found %s\n", supported_devices[i].name);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,3 +117,4 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
+13
-9
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
#include <usb.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -81,8 +80,11 @@ __rf_extract_exit:
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <asm/types.h>
|
//#include <asm/types.h>
|
||||||
#include <mtd/mtd-user.h>
|
#include <mtd/mtd-user.h>
|
||||||
|
#ifndef loff_t
|
||||||
|
#define loff_t off_t
|
||||||
|
#endif
|
||||||
|
|
||||||
#define M_RDONLY 0x00000001
|
#define M_RDONLY 0x00000001
|
||||||
#define M_RDRW 0x00000002
|
#define M_RDRW 0x00000002
|
||||||
@@ -242,7 +244,8 @@ closeall:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl)
|
// XXX warning ioob is not used
|
||||||
|
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob)
|
||||||
{
|
{
|
||||||
unsigned char readbuf[2048];
|
unsigned char readbuf[2048];
|
||||||
int oobinfochanged = 0 ;
|
int oobinfochanged = 0 ;
|
||||||
@@ -379,6 +382,7 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
|
|||||||
|
|
||||||
/* Write out page data */
|
/* Write out page data */
|
||||||
//if (pretty_print) dump_bytes(readbuf, bs);
|
//if (pretty_print) dump_bytes(readbuf, bs);
|
||||||
|
write(ofd, readbuf, bs);
|
||||||
progressbar(ofs, end_addr);
|
progressbar(ofs, end_addr);
|
||||||
|
|
||||||
// OOB STUFF //
|
// OOB STUFF //
|
||||||
@@ -543,20 +547,20 @@ int reverse_extract_pieces(char *dir)
|
|||||||
// TODO: get values from /proc/mtd ???
|
// TODO: get values from /proc/mtd ???
|
||||||
|
|
||||||
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
|
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
|
||||||
nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1); // 0x3600 size?
|
nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1,0); // 0x3600 size?
|
||||||
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
|
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
|
||||||
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1);
|
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1,0);
|
||||||
nanddump("/dev/mtd1", 0, 0, "config.bin", 0);
|
nanddump("/dev/mtd1", 0, 0, "config.bin", 0,0);
|
||||||
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
|
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
|
||||||
nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0);
|
nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0,0);
|
||||||
//rf_extract("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
|
//rf_extract("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
|
||||||
nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0);
|
nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0,0);
|
||||||
|
|
||||||
printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
|
printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
|
||||||
read(0, &reply, 1);
|
read(0, &reply, 1);
|
||||||
if (reply=='y'||reply=='Y') {
|
if (reply=='y'||reply=='Y') {
|
||||||
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
|
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
|
||||||
nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0);
|
nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0,0);
|
||||||
} else printf("*** Ignoring rootfs\n");
|
} else printf("*** Ignoring rootfs\n");
|
||||||
|
|
||||||
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
|
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
|
||||||
|
|||||||
+249
-90
@@ -16,119 +16,278 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <arpa/inet.h>
|
||||||
|
#include "main.h"
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
#warning The FIASCO format is not yet fully implemented.
|
void (*fiasco_callback)(struct header_t *header) = NULL;
|
||||||
|
|
||||||
off_t piece_header_to_size(unsigned char *header)
|
int openfiasco(char *name)
|
||||||
{
|
{
|
||||||
off_t sz = 0;
|
struct header_t header;
|
||||||
sz += header[0x15+3];
|
unsigned char buf[128];
|
||||||
sz += header[0x15+2] << 8;
|
unsigned char data[128];
|
||||||
sz += header[0x15+1] << 16;
|
unsigned int namelen;
|
||||||
sz += header[0x15+0] << 24;
|
off_t off;
|
||||||
return sz;
|
int i;
|
||||||
}
|
header.fd = open(name, O_RDONLY);
|
||||||
|
|
||||||
int piece_header_is_valid(unsigned char *header)
|
if (header.fd == -1) {
|
||||||
{
|
fprintf(stderr, "Cannot open %s\n", name);
|
||||||
if (header[0]=='T' && header[1]=='\x02')
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read header */
|
||||||
|
read(header.fd, buf, 5);
|
||||||
|
if (buf[0] != 0xb4) {
|
||||||
|
printf("Invalid header\n");
|
||||||
|
return close(header.fd);
|
||||||
|
}
|
||||||
|
memcpy(&namelen,buf+1,4);
|
||||||
|
namelen = ntohl(namelen);
|
||||||
|
if (namelen>128) {
|
||||||
|
printf("Stupid length at header. Is this a joke?\n");
|
||||||
|
return close(header.fd);
|
||||||
|
}
|
||||||
|
memset(buf,'\0', 128);
|
||||||
|
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)
|
||||||
|
printf("Name: %s\n", buf+i);
|
||||||
|
|
||||||
|
/* walk the tree */
|
||||||
|
while(1) {
|
||||||
|
if (read(header.fd, buf, 9)<9)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (buf[0] != 0x54) { // 'T'
|
||||||
|
printf("unexpected header at 0x%x, found %02x %02x %02x\n",
|
||||||
|
((int)lseek(header.fd, 0, SEEK_CUR))-9,
|
||||||
|
buf[0], buf[1], buf[2]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
header.hash = buf[7]<<8|buf[8];
|
||||||
|
|
||||||
|
/* piece name */
|
||||||
|
memset(data, '\0', 13);
|
||||||
|
if (read(header.fd, data, 12)<12)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (data[0] == 0xff) {
|
||||||
|
printf(" [eof]\n");
|
||||||
|
break;
|
||||||
|
} else printf(" %s\n", data);
|
||||||
|
strcpy(header.name, (char *)data);
|
||||||
|
|
||||||
|
if (read(header.fd, buf, 9)<9)
|
||||||
|
break;
|
||||||
|
memcpy(&header.size, buf,4);
|
||||||
|
header.size = ntohl(header.size);
|
||||||
|
printf(" size: %d bytes\n", header.size);
|
||||||
|
printf(" hash: %04x\n", header.hash);
|
||||||
|
//printf("BYTE: %02x %02x %02x %02x %02x\n",
|
||||||
|
// buf[4], buf[5], buf[6], buf[7], buf[8]);
|
||||||
|
/* XXX this is not ok */
|
||||||
|
//printf("BUF8: %02x\n", buf[8]);
|
||||||
|
while (buf[8] && buf[8]>'0' && buf[8] < '9') {
|
||||||
|
if (read(header.fd, data, 1)<1)
|
||||||
|
break;
|
||||||
|
i = data[0];
|
||||||
|
if (read(header.fd, data, i)<i)
|
||||||
|
break;
|
||||||
|
if (data[0])
|
||||||
|
printf(" version: %s\n", data);
|
||||||
|
strcpy(header.version, (char *)data);
|
||||||
|
if (read(header.fd, buf+8, 1)<1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* callback */
|
||||||
|
off = lseek(header.fd, 0, SEEK_CUR);
|
||||||
|
if (fiasco_callback != NULL) {
|
||||||
|
fiasco_callback(&header);
|
||||||
|
free(header.data);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// XXX dup
|
||||||
|
lseek(header.fd, off, SEEK_SET);
|
||||||
|
lseek(header.fd, header.size, SEEK_CUR);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define piece_header_to_name(x) x+0x9;
|
void fiasco_data_read(struct header_t *header)
|
||||||
|
{
|
||||||
|
header->data = (unsigned char *)malloc(header->size);
|
||||||
|
if (header->data == NULL) {
|
||||||
|
printf("Cannot alloc %d bytes\n", header->size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
read(header->fd, header->data, header->size);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/* fiasco writer */
|
||||||
* Teh Fiasco firmware parser lives here!
|
int fiasco_new(const char *filename, const char *name)
|
||||||
*/
|
|
||||||
int fiasco_read_image(char *file)
|
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
unsigned char header[5];
|
//int len = htonl(strlen(name)+1+6+14);
|
||||||
unsigned char version[55];
|
|
||||||
char *version2;
|
|
||||||
|
|
||||||
fd = open(file, O_RDONLY);
|
fd = open(filename, O_RDWR|O_CREAT, 0644);
|
||||||
|
if (fd == -1)
|
||||||
printf("WARNING: Fiasco firmware is not yet fully supported. Don't relay on it ATM.\n");
|
|
||||||
|
|
||||||
if (fd == -1) {
|
|
||||||
printf("Cannot open fiasco image.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
|
#if 1
|
||||||
|
write(fd, "\xb4\x00\x00\x00\x14\x00\x00\x00\x01\xe8\x0e", 11);
|
||||||
|
write(fd, "OSSO UART+USB", 14);
|
||||||
|
#else
|
||||||
|
/* 2nd format doesnt works. atm stay with old one */
|
||||||
|
write(fd, "\xb4", 1);
|
||||||
|
write(fd, &len, 4);
|
||||||
|
/* version header */
|
||||||
|
write(fd, "\x00\x00\x00\x02\xe8\x0e", 6);
|
||||||
|
/* firmware type */
|
||||||
|
write(fd, "OSSO UART+USB", 14);
|
||||||
|
/* firmware name */
|
||||||
|
write(fd, name, strlen(name));
|
||||||
|
write(fd, "", 1);
|
||||||
|
#endif
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fiasco_add_eof(int fd)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
unsigned char buf[120];
|
||||||
|
if (fd == -1)
|
||||||
|
return -1;
|
||||||
|
memset(buf,'\xff', 120);
|
||||||
|
write(fd, buf, 120);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int fiasco_add(int fd, const char *name, const char *file, const char *version)
|
||||||
|
{
|
||||||
|
int gd,ret;
|
||||||
|
unsigned int sz;
|
||||||
|
unsigned char len;
|
||||||
|
unsigned short hash;
|
||||||
|
unsigned char *ptr = (unsigned char *)&hash;
|
||||||
|
char buf[4096];
|
||||||
|
char bname[32];
|
||||||
|
|
||||||
|
if (fd == -1)
|
||||||
|
return -1;
|
||||||
|
if (file == NULL)
|
||||||
|
return -1;
|
||||||
|
gd = open(file, O_RDONLY);
|
||||||
|
if (gd == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
sz = htonl((unsigned int) lseek(gd, 0, SEEK_END));
|
||||||
|
lseek(gd, 0, SEEK_SET);
|
||||||
|
// 4 bytes big endian
|
||||||
|
//write(fd, "T\x02\x2e\x19\x01\x01\x00", 7); // header?
|
||||||
|
write(fd, "T\x01\x2e\x19\x01\x01\x00", 7); // header (old piece format)
|
||||||
|
/* checksum */
|
||||||
|
hash = do_hash_file(file);
|
||||||
|
ptr[0]^=ptr[1]; ptr[1]=ptr[0]^ptr[1]; ptr[0]^=ptr[1];
|
||||||
|
write(fd, &hash, 2);
|
||||||
|
printf("hash: %04x\n", hash);
|
||||||
|
|
||||||
|
memset(bname, '\0', 13);
|
||||||
|
if (name == NULL)
|
||||||
|
name = fpid_file(file);
|
||||||
|
/* failback */
|
||||||
|
if (name == NULL)
|
||||||
|
name = file;
|
||||||
|
|
||||||
|
strncpy(bname, name, 12);
|
||||||
|
write(fd, bname, 12);
|
||||||
|
|
||||||
|
write(fd, &sz, 4);
|
||||||
|
if (version) {
|
||||||
|
/* append metadata */
|
||||||
|
write(fd, "\x00\x00\x00\x00\x31", 5);
|
||||||
|
len = strlen(version);
|
||||||
|
write(fd, &len, 1);
|
||||||
|
write(fd, version, len);
|
||||||
|
write(fd, "\x00\x9b", 2);
|
||||||
|
} else {
|
||||||
|
write(fd, "\x00\x00\x00\x00\x9b", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// b4 00 00 00 00 36
|
while(1) {
|
||||||
if (read(fd, header, 5) != 5) {
|
ret = read(gd, buf, 4096);
|
||||||
printf("Error reading fiasco header\n");
|
if (ret<1)
|
||||||
goto __fiasco_read_image_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header[0] != 0xb4) {
|
|
||||||
printf("Invalid fiasco signature.\n");
|
|
||||||
goto __fiasco_read_image_end;
|
|
||||||
}
|
|
||||||
// skip 6 bytes
|
|
||||||
read(fd, version, 6);
|
|
||||||
|
|
||||||
// print version header
|
|
||||||
if (read(fd, version, 55) != 55) {
|
|
||||||
printf("Error reading fiasco version.\n");
|
|
||||||
goto __fiasco_read_image_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("# Fiasco header information:\n");
|
|
||||||
printf("# ==========================\n");
|
|
||||||
printf("# firmware type: %s\n", version);
|
|
||||||
version2 = version+strlen((char *)version)+3;
|
|
||||||
if (*version2=='.')
|
|
||||||
printf("firmware version: (null) (old firmware? no version string found?)\n");
|
|
||||||
else printf("firmware version: %s\n", version2);
|
|
||||||
|
|
||||||
// pieces:
|
|
||||||
// after the version2 string starts the header-body loop love
|
|
||||||
lseek(fd, 0xf + strlen(version2) + strlen(version), SEEK_SET);
|
|
||||||
do {
|
|
||||||
char piece_header[30];
|
|
||||||
char description[256];
|
|
||||||
unsigned char desc_len;
|
|
||||||
char *name;
|
|
||||||
off_t size;
|
|
||||||
off_t tmp = lseek(fd, 0, SEEK_CUR);
|
|
||||||
|
|
||||||
size = read(fd, piece_header, 30);
|
|
||||||
if (size != 30) {
|
|
||||||
fprintf(stderr, "Unexpected end of file\n");
|
|
||||||
break;
|
break;
|
||||||
|
write(fd, buf, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fiasco_pack(int optind, char *argv[])
|
||||||
|
{
|
||||||
|
const char *file = argv[optind];
|
||||||
|
char *type;
|
||||||
|
int fd, ret;
|
||||||
|
|
||||||
|
fd = fiasco_new(file, file); // TODO use a format here
|
||||||
|
if (fd == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
printf("Package: %s\n", file);
|
||||||
|
while((file=argv[++optind])) {
|
||||||
|
type = (char *)fpid_file(file);
|
||||||
|
printf("Adding %s: %s..\n", type, file);
|
||||||
|
ret = fiasco_add(fd, type, file, NULL);
|
||||||
|
if (ret<0) {
|
||||||
|
printf("Error\n");
|
||||||
|
close(fd);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
dump_bytes(piece_header,30);
|
}
|
||||||
if (!piece_header_is_valid(piece_header)) {
|
fiasco_add_eof(fd);
|
||||||
fprintf(stderr, "Oops. Invalid piece header.\n");
|
printf("Done!\n");
|
||||||
break;
|
|
||||||
}
|
|
||||||
size = piece_header_to_size(piece_header);
|
|
||||||
name = piece_header_to_name(piece_header);
|
|
||||||
printf("# %s is %lld bytes\n", name, size);
|
|
||||||
|
|
||||||
read(fd, description, 255);
|
|
||||||
printf("# version: %s\n", description);
|
|
||||||
/* lseek foreach subimage */
|
|
||||||
lseek(fd, tmp, SEEK_SET);
|
|
||||||
lseek(fd, strlen(description) + 0x20, SEEK_CUR);
|
|
||||||
printf("rsc '%s' %lld '%s.bin' 0 %lld\n", file, lseek(fd,0,SEEK_CUR), name, size);
|
|
||||||
lseek(fd, size, SEEK_CUR);
|
|
||||||
} while(1);
|
|
||||||
|
|
||||||
//printf("Image '%s', size %d bytes.\n", image, size);
|
|
||||||
|
|
||||||
__fiasco_read_image_end:
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* local code */
|
||||||
|
#if 0
|
||||||
|
void my_callback(int fd, struct header_t *header)
|
||||||
|
{
|
||||||
|
fiasco_data_read(header);
|
||||||
|
//read(fd, buf, header->size);
|
||||||
|
printf("Dumping %s\n", header->name);
|
||||||
|
printf("DATA: %02x\n", header->data[0]);
|
||||||
|
fiasco_data_free(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc!=2) {
|
||||||
|
printf("Usage: unfiasco [file]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
fd = fiasco_new("myfiasco", "pancake-edition");
|
||||||
|
fiasco_add(fd, "kernel", "zImage", "2.6.22");
|
||||||
|
close(fd);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// fiasco_callback = &my_callback;
|
||||||
|
|
||||||
|
return openfiasco(argv[1]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+2
-1
@@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
#include <usb.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -195,3 +195,4 @@ void flash_image(char *filename, char *piece, char *version)
|
|||||||
}
|
}
|
||||||
printf("Flash done succesfully.\n");
|
printf("Flash done succesfully.\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
+2
-4
@@ -20,7 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char *fpid_file(char *filename)
|
const char *fpid_file(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@@ -45,11 +45,9 @@ char *fpid_file(char *filename)
|
|||||||
size = ftell(fd);
|
size = ftell(fd);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!memcmp(b+0x34, "2NDAPE", 6))
|
if (!memcmp(b+0x34, "2NDAPE", 6))
|
||||||
return PIECE_2ND;
|
return pieces[PIECE_2ND];
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
if (!memcmp(b+0x04, "NOLOScnd", 8))
|
if (!memcmp(b+0x04, "NOLOScnd", 8))
|
||||||
return pieces[PIECE_SECONDARY];
|
return pieces[PIECE_SECONDARY];
|
||||||
else
|
else
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ usho do_hash(usho *b, int len)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
usho do_hash_file(char *filename)
|
usho do_hash_file(const char *filename)
|
||||||
{
|
{
|
||||||
unsigned char buf[BSIZE];
|
unsigned char buf[BSIZE];
|
||||||
FILE *fd = fopen(filename, "r");
|
FILE *fd = fopen(filename, "r");
|
||||||
|
|||||||
+1
-1
@@ -5,6 +5,6 @@
|
|||||||
#define BSIZE 0x20000
|
#define BSIZE 0x20000
|
||||||
|
|
||||||
usho do_hash(usho *b, int len);
|
usho do_hash(usho *b, int len);
|
||||||
usho do_hash_file(char *filename);
|
usho do_hash_file(const char *filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+116
-67
@@ -24,8 +24,11 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
/* global pr0n */
|
/* global pr0n */
|
||||||
|
#if HAVE_USB
|
||||||
|
#include <usb.h>
|
||||||
struct usb_device *device = NULL;
|
struct usb_device *device = NULL;
|
||||||
struct usb_dev_handle *dev = NULL;
|
struct usb_dev_handle *dev = NULL;
|
||||||
|
#endif
|
||||||
char *fiasco_image = NULL;
|
char *fiasco_image = NULL;
|
||||||
char *boot_cmdline = NULL;
|
char *boot_cmdline = NULL;
|
||||||
char *reverseto = NULL;
|
char *reverseto = NULL;
|
||||||
@@ -35,32 +38,33 @@ 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 moboreboot = 0;
|
||||||
int unpack = 0;
|
int unpack = 0;
|
||||||
int info = 0;
|
int info = 0;
|
||||||
|
|
||||||
/* global structs */
|
/* global structs */
|
||||||
char *pieces[] = {
|
char *pieces[] = {
|
||||||
"xloader", // xloader.bin
|
"xloader", // xloader.bin
|
||||||
"secondary", // secondary.bin
|
"2nd", // 2nd
|
||||||
"kernel", // zImage
|
"secondary", // secondary.bin
|
||||||
"initfs", // jffs'd initfs
|
"kernel", // zImage
|
||||||
"rootfs", // 80mB of blob
|
"initfs", // jffs'd initfs
|
||||||
"omap-nand", // 8kB of food for the nand
|
"rootfs", // 80mB of blob
|
||||||
NULL
|
"omap-nand", // 8kB of food for the nand
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
char *modes[]={
|
char *modes[]={
|
||||||
"host",
|
"host",
|
||||||
"peripheral",
|
"peripheral",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
char *root_devices[] = {
|
char *root_devices[] = {
|
||||||
"flash",
|
"flash",
|
||||||
"mmc",
|
"mmc",
|
||||||
"usb",
|
"usb",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -73,27 +77,33 @@ void show_usage()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
show_title();
|
show_title();
|
||||||
|
#if HAVE_USB
|
||||||
printf(" -b [arg] boots the kernel with arguments\n");
|
printf("Over USB:\n");
|
||||||
printf(" -e [path] dump and extract pieces to path\n");
|
printf(" -b [arg] boots the kernel with arguments\n");
|
||||||
printf(" -r [0|1] disable/enable R&D mode\n");
|
printf(" -c console prompt mode\n");
|
||||||
printf(" -f <flags> set the given RD flags (see '-f help')\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(" -f <flags> set the given RD flags (see '-f help')\n");
|
||||||
|
printf(" -i show device information (let standby mode)\n");
|
||||||
|
printf(" -l list supported usb device ids\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(" -r [0|1] disable/enable R&D mode\n");
|
||||||
printf(" -U [0|1] disable/enable the usb host mode\n");
|
printf(" -R reboot the omap board\n");
|
||||||
printf(" -s [serial] serial port console (minicom like terminal)\n");
|
printf(" -U [0|1] disable/enable the usb host mode\n");
|
||||||
printf(" -C [/dev/mtd] check bad blocks on mtd\n");
|
#endif
|
||||||
printf(" -c console prompt mode\n");
|
printf("Local stuff:\n");
|
||||||
printf(" -h show this help message\n");
|
printf(" -s [serial] serial port console (minicom like terminal)\n");
|
||||||
printf(" -i show device information (let standby mode)\n");
|
printf(" -h show this help message\n");
|
||||||
printf(" -I [piece] identify a firmware piece\n");
|
printf(" -C [/dev/mtd] check bad blocks on mtd\n");
|
||||||
printf(" -l list supported usb device ids\n");
|
printf(" -e [path] dump and extract pieces to path\n");
|
||||||
printf(" -d [vid:pid] injects a usb device into the supported list\n");
|
printf(" -F [fiasco] flash a fiasco firmware image\n");
|
||||||
printf(" -D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)\n");
|
printf(" -H [file] calculate hash for file\n");
|
||||||
printf(" -R reboot the omap board\n");
|
printf(" -I [piece] identify a firmware piece\n");
|
||||||
printf(" -x extract configuration entries from /dev/mtd1\n");
|
printf(" -P [new-fiasco] creates a new fiasco package, pieces as arguments\n");
|
||||||
printf(" -v be verbose and noisy\n");
|
printf(" -u [fiasco] unpack target fiasco image\n");
|
||||||
printf(" -V show 0xFFFF version information\n");
|
printf(" -v be verbose and noisy\n");
|
||||||
|
printf(" -V show 0xFFFF version information\n");
|
||||||
|
printf(" -x extract configuration entries from /dev/mtd1\n");
|
||||||
printf("Pieces are: ");
|
printf("Pieces are: ");
|
||||||
for(i=0;pieces[i];i++) printf("%s ", pieces[i]); printf("\n");
|
for(i=0;pieces[i];i++) printf("%s ", pieces[i]); printf("\n");
|
||||||
// serial port support is not yet done (cold flash is for flashing the 8kB nand)
|
// serial port support is not yet done (cold flash is for flashing the 8kB nand)
|
||||||
@@ -102,12 +112,37 @@ void show_usage()
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpack_fiasco_image(char *file)
|
|
||||||
|
void unpack_callback(struct header_t *header)
|
||||||
{
|
{
|
||||||
fiasco_read_image(file);
|
FILE *fd = fopen(header->name, "wb");
|
||||||
// TODO
|
if (fd == NULL) {
|
||||||
|
printf("Cannot open file.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fiasco_data_read(header);
|
||||||
|
fwrite(header->data, header->size, 1, fd);
|
||||||
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unpack_fiasco_image(char *file)
|
||||||
|
{
|
||||||
|
printf("Dumping firmware pieces to disk.\n");
|
||||||
|
fiasco_callback = &unpack_callback;
|
||||||
|
openfiasco( file );
|
||||||
|
}
|
||||||
|
|
||||||
|
int fiasco_flash(char *file)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
fiasco_callback = NULL;
|
||||||
|
openfiasco( file );
|
||||||
|
|
||||||
|
printf("\nTODO: Implement the fiasco flashing here.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
int connect_via_usb()
|
int connect_via_usb()
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor udd;
|
struct usb_device_descriptor udd;
|
||||||
@@ -140,7 +175,8 @@ int connect_via_usb()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( usb_claim_interface(dev, 2) < 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");
|
D perror("usb_claim_interface");
|
||||||
|
|
||||||
// Something is broken if closing fails.
|
// Something is broken if closing fails.
|
||||||
@@ -155,7 +191,7 @@ int connect_via_usb()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usb_set_altinterface(dev, 1) < 0) {
|
if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
|
||||||
D perror("usb_set_altinterface");
|
D perror("usb_set_altinterface");
|
||||||
|
|
||||||
// Something is broken if closing fails.
|
// Something is broken if closing fails.
|
||||||
@@ -180,17 +216,30 @@ int connect_via_usb()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while((c = getopt(argc, argv, "C:cp:vVhRu:ib:U:r:e:ld:I:D:f:s:x")) != -1) {
|
while((c = getopt(argc, argv, "C:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
case 'H':
|
||||||
|
printf("xorpair: %04x\n", do_hash_file(optarg));
|
||||||
|
return 0;
|
||||||
case 'x':
|
case 'x':
|
||||||
return dump_config();
|
return dump_config();
|
||||||
|
#if HAVE_USB
|
||||||
case 'c':
|
case 'c':
|
||||||
return console_prompt();
|
return console_prompt();
|
||||||
|
case 'b':
|
||||||
|
boot_cmdline = optarg;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
usb_mode = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
return fiasco_flash(optarg);
|
||||||
case 'd':
|
case 'd':
|
||||||
sscanf(optarg, "%04hx:%04hx",
|
sscanf(optarg, "%04hx:%04hx",
|
||||||
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
||||||
@@ -200,11 +249,6 @@ int main(int argc, char **argv)
|
|||||||
case 'D':
|
case 'D':
|
||||||
root_device = atoi(optarg);
|
root_device = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
reverseto = optarg;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
return console(optarg);
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (!strcmp(optarg,"help")) {
|
if (!strcmp(optarg,"help")) {
|
||||||
printf("* Flags are composed of:\n");
|
printf("* Flags are composed of:\n");
|
||||||
@@ -216,34 +260,40 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
|
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
|
||||||
case 'U':
|
|
||||||
usb_mode = atoi(optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
rd_mode = atoi(optarg);
|
rd_mode = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'l':
|
||||||
boot_cmdline = optarg;
|
list_valid_devices();
|
||||||
|
return 0;
|
||||||
|
case 'p':
|
||||||
|
add_piece(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
info = 1;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
moboreboot = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case 'e':
|
||||||
|
reverseto = optarg;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
return console(optarg);
|
||||||
case 'u':
|
case 'u':
|
||||||
fiasco_image = optarg;
|
fiasco_image = optarg;
|
||||||
unpack = 1;
|
unpack = 1;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'P':
|
||||||
add_piece(optarg);
|
return fiasco_pack(optind, argv);
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
list_valid_devices();
|
|
||||||
return 0;
|
|
||||||
case 'I':
|
case 'I':
|
||||||
printf("%s: %s\n", fpid_file(optarg), optarg);
|
printf("%s: %s\n", fpid_file(optarg), optarg);
|
||||||
identify = 1;
|
identify = 1;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
return check_badblocks(optarg);
|
return check_badblocks(optarg);
|
||||||
case 'i':
|
|
||||||
info = 1;
|
|
||||||
break;
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
break;
|
break;
|
||||||
@@ -253,9 +303,6 @@ int main(int argc, char **argv)
|
|||||||
case 'V':
|
case 'V':
|
||||||
printf("%s\n", VERSION);
|
printf("%s\n", VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
case 'R':
|
|
||||||
reboot = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,13 +317,13 @@ int main(int argc, char **argv)
|
|||||||
&& (rd_flags == -1)
|
&& (rd_flags == -1)
|
||||||
&& (rd_mode == -1)
|
&& (rd_mode == -1)
|
||||||
&& (info == 0)
|
&& (info == 0)
|
||||||
&& (reboot == 0)
|
&& (moboreboot == 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("0xFFFF [-chilRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n");
|
||||||
printf(" [-b boot-args] [-I piece [-I ...]] [-u fiasco-image] [-x]\n");
|
printf(" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1]\n");
|
||||||
printf(" [-D 0|1|2] [-F rd flags] [-s serial-dev] [-c] [-C mtd-dev]\n");
|
printf(" [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +337,7 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
if (connect_via_usb()) {
|
if (connect_via_usb()) {
|
||||||
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -326,8 +374,9 @@ int main(int argc, char **argv)
|
|||||||
if (boot_cmdline)
|
if (boot_cmdline)
|
||||||
boot_board(boot_cmdline);
|
boot_board(boot_cmdline);
|
||||||
|
|
||||||
if (reboot)
|
if (moboreboot)
|
||||||
reboot_board();
|
reboot_board();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+35
-4
@@ -2,6 +2,9 @@
|
|||||||
#ifndef _INCLUDE_MAIN_H_
|
#ifndef _INCLUDE_MAIN_H_
|
||||||
#define _INCLUDE_MAIN_H_
|
#define _INCLUDE_MAIN_H_
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
#include "nolo.h"
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
@@ -15,9 +18,16 @@ void check_nolo_order();
|
|||||||
extern struct usb_dev_handle *dev;
|
extern struct usb_dev_handle *dev;
|
||||||
unsigned long get_file_size(char *file);
|
unsigned long get_file_size(char *file);
|
||||||
void progressbar(unsigned long long part, unsigned long long total);
|
void progressbar(unsigned long long part, unsigned long long total);
|
||||||
char *fpid_file(char *filename);
|
const char *fpid_file(const char *filename);
|
||||||
int add_piece(char *piece);
|
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>
|
#include <usb.h>
|
||||||
|
|
||||||
extern struct usb_device *device;
|
extern struct usb_device *device;
|
||||||
@@ -27,6 +37,8 @@ void list_valid_devices();
|
|||||||
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
|
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
|
||||||
int console(const char *device);
|
int console(const char *device);
|
||||||
int connect_via_usb();
|
int connect_via_usb();
|
||||||
|
#endif
|
||||||
|
|
||||||
int console_prompt();
|
int console_prompt();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -40,9 +52,6 @@ extern int verbose;
|
|||||||
#define CMD_WRITE 64
|
#define CMD_WRITE 64
|
||||||
#define CMD_QUERY 192
|
#define CMD_QUERY 192
|
||||||
|
|
||||||
#define NOLO_GET_STATUS 1
|
|
||||||
#define NOLO_GET_BOARD_ID 2
|
|
||||||
#define NOLO_GET_VERSION 3
|
|
||||||
|
|
||||||
struct piece_t {
|
struct piece_t {
|
||||||
char *name;
|
char *name;
|
||||||
@@ -65,6 +74,7 @@ extern struct piece_t pcs[10];
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PIECE_XLOADER = 0,
|
PIECE_XLOADER = 0,
|
||||||
|
PIECE_2ND,
|
||||||
PIECE_SECONDARY,
|
PIECE_SECONDARY,
|
||||||
PIECE_KERNEL,
|
PIECE_KERNEL,
|
||||||
PIECE_INITFS,
|
PIECE_INITFS,
|
||||||
@@ -73,8 +83,29 @@ enum {
|
|||||||
PIECE_LAST
|
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 *pieces[];
|
||||||
extern char *modes[];
|
extern char *modes[];
|
||||||
extern char *root_devices[];
|
extern char *root_devices[];
|
||||||
|
|
||||||
|
// fiasco
|
||||||
|
int openfiasco(char *name);
|
||||||
|
int fiasco_new(const char *filename, const char *name);
|
||||||
|
void fiasco_data_read(struct header_t *header);
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -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
|
||||||
+1
-1
@@ -55,7 +55,7 @@ int add_piece(char *piece)
|
|||||||
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
|
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
|
||||||
} else {
|
} else {
|
||||||
/*/ autodetect piece type */
|
/*/ autodetect piece type */
|
||||||
pcs[pcs_n].type = fpid_file(piece);
|
pcs[pcs_n].type = (char *)fpid_file(piece);
|
||||||
if (pcs[pcs_n].type == NULL) {
|
if (pcs[pcs_n].type == NULL) {
|
||||||
printf("Use -p [piece]:[file]\n");
|
printf("Use -p [piece]:[file]\n");
|
||||||
printf("Pieces: ");
|
printf("Pieces: ");
|
||||||
|
|||||||
+13
-8
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
* Copyright (C) 2007,2008 pancake <@youterm.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if HAVE_USB
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -116,7 +118,7 @@ int set_rd_mode(unsigned short mode)
|
|||||||
if (((short)mode)==-1)
|
if (((short)mode)==-1)
|
||||||
return 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");
|
fprintf(stderr, "Cannot set R&D flags.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -134,7 +136,8 @@ int get_hw_revision()
|
|||||||
unsigned char string[512];
|
unsigned char string[512];
|
||||||
int i = 0;
|
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");
|
fprintf(stderr, "Cannot query hw revision.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -157,7 +160,7 @@ int get_rd_mode()
|
|||||||
{
|
{
|
||||||
char isrd = 1;
|
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");
|
fprintf(stderr, "Cannot query rd mode.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -170,7 +173,7 @@ int get_root_device()
|
|||||||
{
|
{
|
||||||
unsigned char opcode;
|
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");
|
fprintf(stderr, "Cannot query root device\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -197,7 +200,7 @@ int set_root_device(unsigned short root_device)
|
|||||||
return -1;
|
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");
|
fprintf(stderr, "Cannot set root device\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -281,7 +284,7 @@ int get_rd_flags()
|
|||||||
{
|
{
|
||||||
unsigned short flags = 0;
|
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");
|
fprintf(stderr, "Cannot get rd flags\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -301,7 +304,7 @@ int get_nolo_version()
|
|||||||
unsigned int version; // ensure uint is at least 32 bits
|
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, 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");
|
fprintf(stderr, "Cannot query nolo version. Old bootloader version?\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -328,6 +331,7 @@ int get_sw_version()
|
|||||||
fprintf(stderr, "error: cannot write query 18\n");
|
fprintf(stderr, "error: cannot write query 18\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
bytes[0]='\0';
|
||||||
ret = usb_control_msg(dev, CMD_QUERY, 20, 0, 0, (char *)&bytes, 512, 2000);
|
ret = usb_control_msg(dev, CMD_QUERY, 20, 0, 0, (char *)&bytes, 512, 2000);
|
||||||
if (ret<0) {
|
if (ret<0) {
|
||||||
fprintf(stderr, "error: b0rken swversion read!\n");
|
fprintf(stderr, "error: b0rken swversion read!\n");
|
||||||
@@ -337,3 +341,4 @@ int get_sw_version()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+10
-1
@@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <usb.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
unsigned long get_file_size(char *file)
|
unsigned long get_file_size(char *file)
|
||||||
@@ -53,3 +53,12 @@ void progressbar(unsigned long long part, unsigned long long total)
|
|||||||
printf("]\r");
|
printf("]\r");
|
||||||
fflush(stdout);
|
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?!?!?
|
||||||
|
}
|
||||||
Reference in new issue
Block a user