4 Commits
Author SHA1 Message Date
pancake 3a1053b29e * Oops missing up
* Added fixups for make install/deinstall
* HAVE_GUI is now enabled by default
* New 'stop' button for goxf GUI
* Fix lil bug in squeue.c
* Initial .desktop icon for freedesktop environments (GNOME)
2008-12-14 03:05:19 +01:00
pancake fc3a613276 * Minor stetical fixups
* Cut 0.4 release :)
2008-12-14 01:40:49 +01:00
pancake 5a96158322 * Implement and test direct file FIASCO flash - openfiasco receives options for grepping for pieces and be verbose - fixed flashing order using grep options xloader, secondary, kernel, initfs, rootfs - Tested and working - Added parser for the hw revision string
* Autodetect device hw revision and setup the subversion string
  on the fly.
2008-12-08 18:13:36 +01:00
pancake 3d427bfd77 * Added -n flag to do not write to disk or flash (simulation)
* Added -S flag to specify subversion id manually while flashing or dumping
* Fixed support for the last fiasco image
  - Skip paddings
  - More verbose output while parsing FIASCO headers
* Initial implementation of the full direct FIASCO flasher
  - No need to dump manually before flashing
* Some warnings and code cleanup
* Fix building issue
* Add HAVE_GUI directive in config.mk
* Up to version 0.4
2008-12-08 00:21:05 +01:00
19 changed files with 295 additions and 104 deletions

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Name=0xFFFF
Comment=Free flasher for the Nokia internet tablets
Exec=gnome-terminal -e goxf
Icon=gnome-terminal.png
Terminal=false
Type=Application
Categories=GTK;Application;Utility;
+12 -5
View File
@@ -1,5 +1,6 @@
include config.mk
PREFIX?=/usr/local
DESTDIR?=
all: logot frontend
cd src && ${MAKE} all
@@ -10,6 +11,7 @@ frontend:
static: logot
cd libusb && ${MAKE} all
cd src && ${MAKE} static
cd logotool && ${MAKE} static
allusb: logot
cd libusb && ${MAKE} all
@@ -23,10 +25,15 @@ clean:
cd logotool && ${MAKE} clean
install:
cp src/0xFFFF ${PREFIX}/bin
-cp src/gui/goxf ${PREFIX}/bin
cp logotool/logotool ${PREFIX}/bin
mkdir -p ${DESTDIR}${PREFIX}/bin
mkdir -p ${DESTDIR}${PREFIX}/share/applications/
cp src/0xFFFF ${DESTDIR}${PREFIX}/bin
-cp src/gui/goxf ${DESTDIR}${PREFIX}/bin
cp logotool/logotool ${DESTDIR}${PREFIX}/bin
cp 0xFFFF.desktop ${DESTDIR}${PREFIX}/share/applications/
deinstall:
rm -f ${PREFIX}/bin/0xFFFF
rm -f ${PREFIX}/bin/logotool
rm -f ${DESTDIR}${PREFIX}/bin/0xFFFF
rm -f ${DESTDIR}${PREFIX}/bin/logotool
rm -f ${DESTDIR}${PREFIX}/bin/goxf
rm ${DESTDIR}${PREFIX}/share/applications/0xFFFF.desktop
+9 -2
View File
@@ -27,8 +27,15 @@ Feel free to join to the mailing list and visit the homepage for more info:
0xffff@lists.nopcode.org
http://www.nopcode.org/0xFFFF
-----------8<---------------------------------------------------------------
Build:
$ make
To install: (by default is /usr/local)
$ make install PREFIX=/usr DESTDIR=/
Have phun!
--pancake
+4 -2
View File
@@ -1,8 +1,10 @@
VERSION=0.3.9
VERSION=0.4.0
PREFIX=/usr
# NetBSD stuff
CFLAGS+=-I/usr/pkg/include
CFLAGS+=-I/usr/pkg/include -O2
LDFLAGS+=-L/usr/pkg/lib -Wl,-R/usr/pkg/lib
HAVE_USB=1
HAVE_GUI=1
+8 -2
View File
@@ -1,8 +1,14 @@
OBJ=logotool.o compress.o uncompress.o rgb2yuv.o
CFLAGS=-Wall -g
#CFLAGS=-Wall -g
BIN=logotool
all: ${OBJ}
all: ${BIN}
${BIN}: ${OBJ}
${CC} ${OBJ} -o logotool
static: ${BIN}
${CC} -static ${OBJ} -o logotool
clean:
rm -f ${OBJ} logotool
+4 -2
View File
@@ -5,12 +5,14 @@ OBJ+=squeue/squeue.o
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 -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}
all: ${BIN}
${BIN}: ${OBJ}
${CC} ${LDFLAGS} -o ${BIN} ${OBJ} ${LIBS}
allusb: ${OBJ}
+6 -1
View File
@@ -46,8 +46,13 @@ void cmd_help(char *line)
void cmd_info(char *line)
{
char *p, str[128];
get_sw_version();
get_hw_revision(); // get hardware revision:
get_hw_revision(str, 128); // get hardware revision:
p = strstr(str, "hw_rev:");
if (p) // TODO: delimit string by comma
printf("SubVersionString autodetected: '%s'\n", p+7);
else printf("SubVersionString autodetected: (error)\n");
get_root_device(); // only for flashing
get_usb_mode();
get_rd_mode();
+55 -21
View File
@@ -27,16 +27,18 @@
#include "main.h"
#include "hash.h"
void (*fiasco_callback)(struct header_t *header) = NULL;
int (*fiasco_callback)(struct header_t *header) = NULL;
int openfiasco(char *name)
int openfiasco(char *name, char *piece_grep, int v)
{
struct header_t header;
unsigned char buf[128];
unsigned char data[128];
unsigned char *pdata;
unsigned int namelen;
off_t off;
int i;
off_t off, here;
int i,j;
header.fd = open(name, O_RDONLY);
if (header.fd == -1) {
@@ -59,21 +61,30 @@ int openfiasco(char *name)
memset(buf,'\0', 128);
read(header.fd, buf, namelen);
printf("Fiasco version: %2d\n", buf[3]);
if (v) printf("Fiasco version: %2d\n", buf[3]);
strcpy(header.fwname, (char *)buf+6);
if (v)
for(i=6;i<namelen;i+=strlen((char *)(buf+i))+1)
printf("Name: %s\n", buf+i);
/* walk the tree */
while(1) {
here = lseek(header.fd, 0, SEEK_CUR);
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;
/* skipping some bytes */
lseek(header.fd, -9, SEEK_CUR);
for(i=0;buf[0]!=0x54;i++) {
j = read(header.fd, buf, 1);
if (j == -1) {
printf("Cannot find next FIASCO header\n");
return close(header.fd);
}
}
if (v) printf("Skipping %d padding bytes\n", i);
lseek(header.fd, -1, SEEK_CUR);
continue;
}
header.hash = buf[7]<<8|buf[8];
@@ -85,15 +96,18 @@ int openfiasco(char *name)
if (data[0] == 0xff) {
printf(" [eof]\n");
break;
} else printf(" %s\n", data);
} else if (v) 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);
if (v) {
printf(" offset: 0x%08x\n", (unsigned int)here);
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 */
@@ -104,24 +118,45 @@ int openfiasco(char *name)
i = data[0];
if (read(header.fd, data, i)<i)
break;
if (data[0])
printf(" version: %s\n", data);
if (data[0]) {
if (v) {
printf(" version-length: %d\n", i);
printf(" version: %s\n", data);
}
pdata = data;
while(pdata<data+i) {
strcat(header.name,pdata==data?"-":",");
strcat(header.name, (char*)pdata);
if (v) printf(" sub-version: %s\n", pdata);
pdata = pdata+strlen((char*)pdata)+1;
for(;*pdata=='\0'&&pdata<data+i;pdata=pdata+1);
}
}
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;
if (v) {
printf(" name: %s\n", header.name);
printf(" body-at: 0x%08x\n", (unsigned int)off);
}
if (piece_grep==NULL || (strstr(header.name, piece_grep))) {
printf("==> (%s) %s\n", piece_grep, header.name);
if (fiasco_callback != NULL) {
fiasco_callback(&header);
free(header.data);
continue;
} else {
// ??huh
}
}
// XXX dup
lseek(header.fd, off, SEEK_SET);
lseek(header.fd, header.size, SEEK_CUR);
}
return 0;
return close(header.fd);
}
void fiasco_data_read(struct header_t *header)
@@ -173,7 +208,6 @@ int fiasco_add_eof(int fd)
return 0;
}
int fiasco_add(int fd, const char *name, const char *file, const char *version)
{
int gd,ret;
+18 -1
View File
@@ -74,7 +74,7 @@ void check_nolo_order()
check_nolo_order_failed();
}
void flash_image(char *filename, char *piece, char *version)
void flash_image(const char *filename, const char *piece, const char *version)
{
FILE *fd;
int vlen = 0;
@@ -86,6 +86,23 @@ void flash_image(char *filename, char *piece, char *version)
unsigned char nolofiller[128];
ushort hash = do_hash_file(filename);
if (piece == NULL) {
//exit(1);
piece = fpid_file(filename);
if (piece == NULL) {
printf("Unknown piece type\n");
return;
}
printf("Piece type: %s\n", piece);
}
if (piece != NULL) {
if (!strcmp(piece, "fiasco")) {
fiasco_flash(filename);
return;
}
}
if (version)
vlen = strlen(version)+1;
+8 -4
View File
@@ -48,7 +48,6 @@ const char *fpid_file(const char *filename)
FILE *fd;
char buf[512];
unsigned char *b = (unsigned char *)&buf;
char *piece = NULL;
long size;
// 2nd : +0x34 = 2NDAPE
@@ -80,10 +79,15 @@ const char *fpid_file(const char *filename)
if (!memcmp(b+0x14, "X-LOADER", 8))
return pieces[PIECE_XLOADER];
else
if (!memcmp(b+0x0c, "NOLOXldr", 8)) // TODO: this is xloader800, not valid on 770?
if (!memcmp(b+0x0c, "NOLOXldr", 8))
return pieces[PIECE_XLOADER];
else
if (!memcmp(b+0x00, "\x00\x00\xa0\xe1\x00\x00\xa0\xe1", 8))
if (!memcmp(b+4,"NOLOXldr",8))
// TODO: this is xloader800, not valid on 770?
return pieces[PIECE_2ND];
else
if (!memcmp(b+0x00, "\x00\x00\xa0\xe1\x00\x00\xa0\xe1", 8)
|| (!memcmp(b, "\x21\x01\x01", 3)))
return pieces[PIECE_KERNEL];
else
// JFFS2 MAGIC
@@ -94,5 +98,5 @@ const char *fpid_file(const char *filename)
return pieces[PIECE_ROOTFS];
}
return piece;
return NULL;
}
+7
View File
@@ -1,6 +1,13 @@
include ../../config.mk
ifeq (${HAVE_GUI},1)
all:
gtkamlc --save-temps --Xcc=-I../squeue ../squeue/squeue.c ../fpid.c ../squeue/squeue.vapi gui.gtkaml extras.vapi --pkg gtk+-2.0 -o goxf
test:
valac --save-temps --Xcc=-I.. squeue.vapi test.vala ../squeue.c -o v
valac --save-temps --Xcc=-I.. squeue.vapi client.vala ../squeue.c -o c
else
all:
@true
endif
+13 -17
View File
@@ -12,8 +12,8 @@
xmlns:SQueues="SQueues"
xmlns:class="http://gtkaml.org/0.2"
class:name="MainWindow"
title="0xFFFF GUI"
delete-event="{OnWindow1DeleteEvent}">
title="0xFFFF GUI">
<!-- delete-event="{OnWindow1DeleteEvent}" -->
<VBox>
<MenuBar expand="false">
<MenuItem label="_File" with-mnemonic="true">
@@ -32,6 +32,7 @@
<submenu>
<Menu>
<ImageMenuItem stock-id="gtk-connect" activate="{OnConnect}"/>
<ImageMenuItem stock-id="gtk-stop" activate="{OnStop}"/>
<ImageMenuItem stock-id="gtk-info" activate="{OnGetInformation}"/>
<ImageMenuItem label="Reset" activate="{OnReset}"/>
</Menu>
@@ -58,6 +59,7 @@
</VBox>
<VBox expand="false" border-width="3" spacing="3">
<Button label="gtk-connect" use-stock="true" expand="false" clicked="{OnConnect}"/>
<Button label="gtk-stop" use-stock="true" expand="false" clicked="{OnStop}"/>
<Button label="gtk-info" use-stock="true" expand="false" clicked="{OnGetInformation}"/>
<Label label="" />
<!-- <Button label="Options" use-stock="false" expand="false"/>
@@ -85,11 +87,6 @@
<![CDATA[
private void OnWindow1DeleteEvent ()
{
doCloseApplication ();
}
private void doCloseApplication ()
{
Gtk.main_quit ();
@@ -202,7 +199,6 @@ private void OnFileNewEvent ()
private void OnQuitEvent ()
{
doCloseApplication();
External.system("sudo pkill 0xFFFF");
// TODO: send message to gracefully kill 0xFFFF
// TODO: handle ^C when flashing
}
@@ -216,19 +212,13 @@ public void list_del()
{
TreeIter iter;
TreeModel model;
weak string str = "";
TreeSelection sel = tv.get_selection();
if (sel.count_selected_rows() == 1) {
sel.get_selected(out model, out iter);
//((ListStore)tv.model)).get(ref iter, 2, out str, -1);
//stdout.printf("NAME IS: "+str);
((ListStore)tv.model).remove(iter);
}
//return str;
}
public void add_file(string type, string size, string file)
@@ -304,13 +294,18 @@ private void OnGetInformation()
private void OnConnect()
{
//msg("connect:device");
External.system("sudo pkill 0xFFFF");
External.system("sudo ../0xFFFF -Q &");
OnStop();
External.system("sudo 0xFFFF -Q &");
p->close();
q->close();
p = q = null;
}
private void OnStop()
{
External.system("sudo pkill 0xFFFF");
}
private bool chk_queues()
{
@@ -348,9 +343,10 @@ static int main (string[] args)
viewer.loadFile (args[1]);
viewer.resize(600,400);
viewer.set_position(WindowPosition.CENTER);
viewer.delete_event += (x,y) => { Gtk.main_quit(); };
setup_treeview(viewer.tv);
viewer.show_all ();
viewer.showMessage("This software is beta and does not guaranties correct functionality", MessageType.WARNING);
// viewer.showMessage("This software is beta and does not guaranties correct functionality", MessageType.WARNING);
Timeout.add(200, (SourceFunc)(readFunc));
Gtk.main ();
return 0;
+102 -19
View File
@@ -32,6 +32,7 @@ struct usb_dev_handle *dev = NULL;
char *fiasco_image = NULL;
char *boot_cmdline = NULL;
char *reverseto = NULL;
char *subverstr = NULL;
int rd_mode = -1;
int rd_flags = -1;
int usb_mode = -1;
@@ -42,6 +43,7 @@ int moboreboot = 0;
int unpack = 0;
int qmode = 0;
int info = 0;
int nomode = 0;
char *modes[]={
"host",
@@ -86,6 +88,8 @@ void show_usage()
printf("Local stuff:\n");
printf(" -s [serial] serial port console (minicom like terminal)\n");
printf(" -h show this help message\n");
printf(" -S [subversion] unpacks/flash pieces matching this sub-version information\n");
printf(" -n do not flash or write to disk (simulation)\n");
printf(" -C [/dev/mtd] check bad blocks on mtd\n");
printf(" -e [path] dump/extract pieces to path\n");
printf(" -F [fiasco] flash a fiasco firmware image\n");
@@ -104,43 +108,104 @@ void show_usage()
exit(0);
}
void unpack_callback(struct header_t *header)
int unpack_callback(struct header_t *header)
{
FILE *fd = fopen(header->name, "wb");
FILE *fd;
fiasco_data_read(header);
if (subverstr) {
if (strchr(header->name, ',') != NULL) {
if (!strstr(header->name, subverstr)) {
printf("Skipping '%s' does not matches -S subversion\n",
header->name);
return 1;
}
}
}
if (nomode)
return 1;
fd = fopen(header->name, "wb");
if (fd == NULL) {
printf("Cannot open file.\n");
return;
return 1;
}
fiasco_data_read(header);
fwrite(header->data, header->size, 1, fd);
fclose(fd);
return 0;
}
int flash_callback(struct header_t *header)
{
int ret;
char *type;
ret = unpack_callback(header);
if (ret) {
printf("ignored\n");
return 1;
}
type = (char *)fpid_file(header->name);
printf("\nFlashing %s (%s)\n", header->name, type);
flash_image(header->name, type, NULL);
return 0;
}
void unpack_fiasco_image(char *file)
{
printf("Dumping firmware pieces to disk.\n");
fiasco_callback = &unpack_callback;
openfiasco( file );
openfiasco(file, NULL ,1);
}
int fiasco_flash(char *file)
int fiasco_flash(const char *file)
{
/* TODO */
fiasco_callback = NULL;
openfiasco( file );
char *p;
char version[64];
printf("\nTODO: Implement the fiasco flashing here.\n");
return -1;
if (connect_via_usb()) {
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
return 0;
}
// if (info)
cmd_info("");
check_nolo_order();
get_nolo_version();
get_sw_version();
get_hw_revision(version, 44);
if (subverstr == NULL) {
p = strstr(version, "hw_rev:");
if (p) {
subverstr = strdup(p+7);
// TODO: delimit string by comma
printf("SubVersionString autodetected: '%s'\n", subverstr);
}
}
printf("\n");
fiasco_callback = &flash_callback;
openfiasco(file, "xloader", 0);
openfiasco(file, "secondary", 0);
openfiasco(file, "kernel", 0);
openfiasco(file, "initfs", 0);
openfiasco(file, "rootfs", 0);
return 0;
}
#if HAVE_USB
int connect_via_usb()
{
static char pbc[]={'/','-','\\', '|'};
struct usb_device_descriptor udd;
struct devices it_device;
int c = 0;
static char pbc[]={'/','-','\\', '|'};
// usb_set_debug(5);
usb_init();
@@ -214,7 +279,7 @@ int main(int argc, char **argv)
{
int c;
while((c = getopt(argc, argv, "QC:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:")) != -1) {
while((c = getopt(argc, argv, "QC:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:S:n")) != -1) {
switch(c) {
case 'H':
printf("xorpair: %04x\n", do_hash_file(optarg));
@@ -227,11 +292,18 @@ int main(int argc, char **argv)
case 'b':
boot_cmdline = optarg;
break;
case 'S':
subverstr = optarg;
break;
case 'n':
nomode = 1;
break;
case 'U':
usb_mode = atoi(optarg);
break;
case 'F':
return fiasco_flash(optarg);
fiasco_image = optarg;
break;
case 'd':
sscanf(optarg, "%04hx:%04hx",
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
@@ -304,6 +376,9 @@ int main(int argc, char **argv)
if (qmode)
return queue_mode();
if (!unpack && fiasco_image)
return fiasco_flash(fiasco_image);
if (identify)
return 0;
@@ -321,8 +396,8 @@ int main(int argc, char **argv)
{
printf("# The Free Fiasco Firmware Flasher v"VERSION"\n"
"0xFFFF [-chilQRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n"
" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1]\n"
"0xFFFF [-chinlQRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n"
" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1] [-S subver]\n"
" [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
return 1;
}
@@ -349,10 +424,18 @@ int main(int argc, char **argv)
cmd_info("");
if (pcs_n) {
int c;
char version[64];
check_nolo_order();
get_sw_version();
get_hw_revision(version, 44);
if (subverstr == NULL) {
char *p = strstr(version, "hw_rev:");
if (p) {
subverstr = strdup(p+7);
// TODO: delimit string by comma
printf("SubVersionString autodetected: '%s'\n", subverstr);
}
}
get_nolo_version();
for(c=0;c<pcs_n;c++) {
+10 -5
View File
@@ -5,7 +5,6 @@
#include "hash.h"
#include "nolo.h"
#include "os.h"
extern char strbuf[1024];
#define _FILE_OFFSET_BITS 64
@@ -16,11 +15,11 @@ struct devices;
int queue_mode();
int reverse_extract_pieces(char *dir);
void flash_image(char *filename, char *piece, char *version);
void flash_image(const char *filename, const char *piece, const char *version);
int fiasco_read_image(char *file);
void check_nolo_order();
extern struct usb_dev_handle *dev;
unsigned long get_file_size(char *file);
unsigned long get_file_size(const char *file);
void progressbar(unsigned long long part, unsigned long long total);
const char *fpid_file(const char *filename);
int add_piece(char *piece);
@@ -34,6 +33,7 @@ void eprintf(const char *format, ...);
#if HAVE_USB
#include <usb.h>
int fiasco_flash(const char *file);
extern struct usb_device *device;
extern struct usb_dev_handle *dev;
int is_valid_device(struct usb_device_descriptor *udd);
@@ -103,14 +103,19 @@ extern char *modes[];
extern char *root_devices[];
// fiasco
int openfiasco(char *name);
int openfiasco(char *name, char *grep, int v);
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);
extern int (*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);
//
int reboot_board();
int get_rd_flags();
int get_usb_mode();
int get_nolo_version();
#endif
+12 -10
View File
@@ -19,7 +19,13 @@
#include "main.h"
#include "os.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#if HAVE_SQUEUE
struct squeue_t *q;
@@ -37,29 +43,25 @@ void process_message(char *msg)
{
char *str;
char *arg;
int c;
int c=1;
if (msg == NULL)
return;
printf("[x] (%s)\n", msg);
str = strdup(msg);
arg = strchr(str, ':');
if (c!=NULL) {
if (c!=0) {
arg[0]='\0';
arg = arg +1;
if (!strcmp(str, "flash")) {
char buf[1024];
char *type = fpid_file(arg);
const char *type = fpid_file(arg);
if (type == NULL) {
squeue_push2(p, "error", "Unknown piece format", 1);
} else {
flash_image(arg, type, NULL);
}
} else flash_image(arg, type, NULL);
} else
if (!strcmp(str, "reset")) {
if (reboot_board() == 0) {
squeue_push2(p,"info", "Device reboots", 1);
} else
squeue_push2(p,"error", "Cannot reboot device", 1);
} else squeue_push2(p,"error", "Cannot reboot device", 1);
} else
if (!strcmp(str, "info")) {
get_rd_flags();
@@ -95,7 +97,7 @@ int queue_mode()
pid = dofork();
if (pid) {
wait(pid);
wait(&pid);
return 0;
} else {
p = squeue_open("/tmp/0xFFFF.1", Q_CREAT);
+11 -10
View File
@@ -134,27 +134,28 @@ int set_rd_mode(unsigned short mode)
/*
* query root device
*/
int get_hw_revision()
int get_hw_revision(char *str, int len)
{
unsigned char string[512];
int i = 0;
char tmpstr[64];
int i = 0, j=0, mod=0;
if (str == NULL)
str = tmpstr;
memset(string,'\0',512);
if (usb_control_msg(dev, CMD_QUERY, NOLO_GET_HWVERSION, 0, 0, (char *)string, 512, 2000) == -1) {
fprintf(stderr, "Cannot query hw revision.\n");
return -1;
}
printf("HW revision string: '");
for(i=0;i<44;i++) { // XXX ??
if (string[i]==0) {
printf(" ");
} else {
if (string[i]>19)
printf("%c", string[i]);
for(i=0;i<44&&i<len;i++) { // XXX ??
if (string[i]>19) {
if (i>0 && string[i-1]<19)
str[j++] = (++mod%2)?':':',';
str[j++] = string[i];
}
}
printf("'\n");
printf("HW revision string: '%s'\n", str);
return 0;
}
+1 -1
View File
@@ -16,7 +16,7 @@ int set_rd_mode(unsigned short mode);
int get_rd_flags();
int set_rd_flags(unsigned short flags);
int get_hw_revision();
int get_hw_revision(char *str, int len);
int get_root_device();
int set_root_device(unsigned short);
+4
View File
@@ -1,13 +1,17 @@
#include "squeue.h"
#define _XOPEN_SOURCE 500 /* Or: #define _BSD_SOURCE */
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <signal.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define POOL_SIZE ITEM_MAX*ITEM_SIZE
+2 -2
View File
@@ -22,7 +22,7 @@
#include <stdarg.h>
#include <stdlib.h>
unsigned long get_file_size(char *file)
unsigned long get_file_size(const char *file)
{
FILE *fd = fopen(file, "r");
unsigned long len = 0;
@@ -53,7 +53,7 @@ void progressbar(unsigned long long part, unsigned long long total)
squeue_push2(p, "bar", msg, 0);
} else {
#endif
printf("\e[K %3d%% [", pc);
printf("\x1b[K %3d%% [", pc);
if (columns)
cols = atoi(columns);
cols-=15;