diff options
author | pancake <pancake@pluna> | 2008-01-14 11:25:08 +0100 |
---|---|---|
committer | pancake <pancake@pluna> | 2008-01-14 11:25:08 +0100 |
commit | 288cad1c2e401e5dfbd029b95f62ca05c85d3d61 (patch) | |
tree | ac2652d1998dc9e641d49e367b3a853b2728b6c8 | |
parent | 4115aab13d70bbe8300562bcd789cc5bc27c8ded (diff) | |
download | 0xFFFF-288cad1c2e401e5dfbd029b95f62ca05c85d3d61.tar.bz2 |
* Up to 0.3.2
* Add HAVE_USB to config.mk
- Now is possible to build a usb-less version of the flasher
(only for unpacking and so, offline operations)
* Refactor varname. Avoid portability problems:
- reboot -> moboreboot
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | config.mk | 8 | ||||
-rw-r--r-- | src/Makefile | 8 | ||||
-rw-r--r-- | src/console.c | 2 | ||||
-rw-r--r-- | src/devices.c | 2 | ||||
-rw-r--r-- | src/dump.c | 7 | ||||
-rw-r--r-- | src/flash.c | 3 | ||||
-rw-r--r-- | src/main.c | 85 | ||||
-rw-r--r-- | src/main.h | 4 | ||||
-rw-r--r-- | src/query.c | 5 | ||||
-rw-r--r-- | src/utils.c | 1 |
11 files changed, 82 insertions, 44 deletions
@@ -1,3 +1,4 @@ +include config.mk PREFIX?=/usr/local all: logot diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..a8d435c --- /dev/null +++ b/config.mk @@ -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 diff --git a/src/Makefile b/src/Makefile index 1ac4058..de2ba2e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,14 +1,16 @@ -VERSION=0.3 +include ../config.mk 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 +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} -lusb + ${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${LIBS} allusb: ${OBJ} ${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${USBOBJ} diff --git a/src/console.c b/src/console.c index 3aa406c..d03343c 100644 --- a/src/console.c +++ b/src/console.c @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#if HAVE_USB #include "main.h" #include "query.h" #include <stdio.h> @@ -164,3 +165,4 @@ int console_prompt() return 0; } +#endif diff --git a/src/devices.c b/src/devices.c index 6bfe624..203c300 100644 --- a/src/devices.c +++ b/src/devices.c @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#if HAVE_USB #include "main.h" #include <stdio.h> #include <string.h> @@ -116,3 +117,4 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic return 0; } +#endif @@ -18,7 +18,6 @@ #include "main.h" #include "hexdump.h" -#include <usb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -81,8 +80,11 @@ __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 @@ -380,6 +382,7 @@ 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 // diff --git a/src/flash.c b/src/flash.c index 7414afa..e135e53 100644 --- a/src/flash.c +++ b/src/flash.c @@ -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,3 +195,4 @@ void flash_image(char *filename, char *piece, char *version) } printf("Flash done succesfully.\n"); } +#endif @@ -24,8 +24,11 @@ #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; @@ -35,7 +38,7 @@ int usb_mode = -1; int root_device = -1; int verbose = 0; int identify = 0; -int reboot = 0; +int moboreboot = 0; int unpack = 0; int info = 0; @@ -74,26 +77,30 @@ 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(" -I [piece] identify a firmware piece\n"); - printf(" -l, -L list supported usb device ids\n"); + printf(" -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"); @@ -135,6 +142,7 @@ int fiasco_flash(char *file) return -1; } +#if HAVE_USB int connect_via_usb() { struct usb_device_descriptor udd; @@ -207,20 +215,28 @@ 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:Lld:I:D:f:F:s:xH:")) != -1) { + while((c = getopt(argc, argv, "C:cp:PvVhRu:ib:U:r:e:ld: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': @@ -232,11 +248,6 @@ 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"); @@ -248,37 +259,40 @@ 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 'b': - boot_cmdline = optarg; + case 'l': + list_valid_devices(); + return 0; + case 'p': + add_piece(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; @@ -288,9 +302,6 @@ int main(int argc, char **argv) case 'V': printf("%s\n", VERSION); return 0; - case 'R': - reboot = 1; - break; } } @@ -305,11 +316,11 @@ int main(int argc, char **argv) && (rd_flags == -1) && (rd_mode == -1) && (info == 0) - && (reboot == 0) + && (moboreboot == 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; @@ -325,6 +336,7 @@ 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; @@ -361,8 +373,9 @@ int main(int argc, char **argv) if (boot_cmdline) boot_board(boot_cmdline); - if (reboot) + if (moboreboot) reboot_board(); +#endif return 0; } @@ -25,6 +25,8 @@ void eprintf(const char *format, ...); #ifndef PATH_MAX #define PATH_MAX 4096 #endif + +#if HAVE_USB #include <usb.h> extern struct usb_device *device; @@ -34,6 +36,8 @@ 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(); // diff --git a/src/query.c b/src/query.c index 3decf94..72b5b0f 100644 --- a/src/query.c +++ b/src/query.c @@ -1,6 +1,6 @@ /* * 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 * 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/>. */ +#if HAVE_USB + #include "main.h" #include <stdio.h> #include <string.h> @@ -337,3 +339,4 @@ int get_sw_version() return 1; } +#endif diff --git a/src/utils.c b/src/utils.c index e694a0f..4803a50 100644 --- a/src/utils.c +++ b/src/utils.c @@ -17,7 +17,6 @@ */ #include "main.h" -#include <usb.h> #include <stdio.h> #include <string.h> #include <stdarg.h> |