View Single Post
Old 01-19-2012, 06:08 PM   #111
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by Novas
Hi yifanlu,
I try to use your tool to create new update package to kindle touch.
I use it this way ./kindletool create ota2 -dk5w /media/USB_DISK/kindle/install/
but I get this error message:
Cannot read input.
Segmentation fault
What is wrong? Directory /media/USB_DISK/kindle/install/ exist and included install files.
Quote:
Originally Posted by yifanlu View Post
Are you sure you want to output to stdout? Try outputting to a file.
I'm experiencing the same here. (Ubuntu Lucid 64-bit). It seems that the argc/argv manipulation in conjunction with optind goes wrong somewhere. In fact, it's trying to read the file "ota2" and aborting for that reason.

I have been fiddling around in create.c, inserting a few debug prints around line 720. Now it looks like this:
Code:
   if(info.version != OTAUpdateV2 && (info.source_revision > UINT32_MAX || info.target_revision > UINT32_MAX))
    {
        fprintf(stderr, "Source/target revision for this update type cannot exceed %u\n", UINT32_MAX);
        goto do_error;
    }

    argc -= (optind-1); argv += optind; // next argument

fprintf(stderr, "Skipped %d arguments, argc now %d \n", optind, argc);
fprintf(stderr, "argv[0] is %s\n", argv[0]);
fprintf(stderr, "argv[1] is %s\n", argv[1]);
fprintf(stderr, "argv[2] is %s\n", argv[2]);
argv++;

    // input
    if(argc < 1)
    {
        fprintf(stderr, "No input found.\n");
        goto do_error;
    }
And the output is:
Code:
Skipped 3 arguments, argc now 4 
argv[0] is ota2
argv[1] is /tmp/kindle
argv[2] is /tmp/update_test_install.bin
There is clearly something weird happening. Note that incrementing argv once more gets the program to work, but it's still kinda fishy. I guess getopt just doesn't like starting off with optind == -1

PS: Invocation was via command "./kindletool create ota2 -d k5w -d k5g /tmp/kindle /tmp/update_test_install.bin". I would assume that getopt keeps argv[0] (because it thinks its the executable name), while throwing away the options it parsed?

Last edited by ixtab; 01-19-2012 at 06:14 PM.
ixtab is offline   Reply With Quote