--- gobi_loader.c 2009-04-04 20:36:19.000000000 +0200 +++ gobi_loader.c 2010-02-13 10:16:35.542254191 +0100 @@ -1,5 +1,7 @@ /* Firmware loader for Qualcomm Gobi USB hardware */ +/* Modified/Slightly rewritten by Madox */ + /* Copyright 2009 Red Hat - heavily based on work done by * Alexander Shumakovitch * @@ -26,27 +28,19 @@ #include #include -char magic1[] = {0x01, 0x51, 0x43, 0x4f, 0x4d, 0x20, 0x68, 0x69, +char cmd_devinit[] = {0x01, 0x51, 0x43, 0x4f, 0x4d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x20, 0x73, 0x70, 0x65, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x20, 0x68, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x30, 0xff, 0xff}; -//char magic1[] = "QCOM high speed protocol hst\0\0\0\0\x04\x04\x30"; - -char magic2[] = {0x25, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0xff, 0xff}; - -char magic3[] = {0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff}; - -char magic4[] = {0x25, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0xff, 0xff}; - -char magic5[] = {0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff}; - -char magic6[] = {0x29, 0xff, 0xff}; +char cmd_devinit2k[] = {0x01, 0x51, 0x43, 0x4f, 0x4d, 0x20, 0x68, 0x69, + 0x67, 0x68, 0x20, 0x73, 0x70, 0x65, 0x65, 0x64, 0x20, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x20, + 0x68, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, + 0x30, 0xff, 0xff}; + +char cmd_complete[] = {0x29, 0xff, 0xff}; /* * This mysterious table is just the CRC of each possible byte. It can be @@ -101,6 +95,7 @@ * @buffer: data pointer * @len: number of bytes in the buffer */ + unsigned short crc_ccitt(short crc, char const *buffer, size_t len) { while (len--) @@ -108,29 +103,136 @@ return crc; } -void usage (char **argv) { +void usage (char **argv) +{ printf ("usage: %s serial_device firmware_dir\n", argv[0]); } -int main(int argc, char **argv) { - int serialfd; +void printhexstring (char *string, int len) { + int i; + for(i=0; i