avrdude dfu start application command

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0



int flip2_parseextparams(PROGRAMMER* pgm, LISTID
extparams)


{

 LNODEID ln;

 const char *extended_param;

 //struct dfu_status status;

 int cmd_result = 0;

 //int aux_result;



 for (ln = lfirst(extparams); ln; ln = lnext(ln)) {

  extended_param = ldata(ln);



  if (strncmp(extended_param, "s", strlen("s")) == 0) {

   if (verbose >= 2)

    fprintf(stderr,

                   "%s: flip2_parseextparams(): start
application\n", progname);


   struct flip2_cmd cmd = {

    FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_START_APP, { 0x00,
0, 0, 0 }


   };



   cmd_result = dfu_dnload(FLIP2(pgm)->dfu,
&cmd, sizeof(cmd));


   aux_result = dfu_getstatus(FLIP2(pgm)->dfu,
&status);




   if (aux_result != 0)

      return aux_result;



    if (status.bStatus != DFU_STATUS_OK) {

        fprintf(stderr, "%s: Error: DFU status %s\n",
progname,


          flip2_status_str(&status));

      dfu_clrstatus(FLIP2(pgm)->dfu);

    } else

      break;

    break;

   }



    fprintf(stderr,

            "%s: wiring_parseextparms(): invalid
extended parameter '%s'\n",


            progname, extended_param);

    cmd_result = -1;

   }



  return cmd_result;

}

Hey,

In the DFU FLIP there is a "Start application" command: http://www.atmel.com/Images/doc8457.pdf [Page 13]

In flip2.c (DFU implementation for avrdude) this command is not implemented,

So I added another function:

int flip2_parseextparams(PROGRAMMER* pgm, LISTID extparams)
{
 LNODEID ln;
 const char *extended_param;
 //struct dfu_status status;
 int cmd_result = 0;
 //int aux_result;

 for (ln = lfirst(extparams); ln; ln = lnext(ln)) {
  extended_param = ldata(ln);

  if (strncmp(extended_param, "s", strlen("s")) == 0) {
   if (verbose >= 2)
    fprintf(stderr,
                   "%s: flip2_parseextparams(): start application\n", progname);
   struct flip2_cmd cmd = {
    FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_START_APP, { 0x00, 0, 0, 0 }
   };

   cmd_result = dfu_dnload(FLIP2(pgm)->dfu, &cmd, sizeof(cmd));
   aux_result = dfu_getstatus(FLIP2(pgm)->dfu, &status);

   if (aux_result != 0)
      return aux_result;

    if (status.bStatus != DFU_STATUS_OK) {
        fprintf(stderr, "%s: Error: DFU status %s\n", progname,
          flip2_status_str(&status));
      dfu_clrstatus(FLIP2(pgm)->dfu);
    } else
      break;
    break;
   }

    fprintf(stderr,
            "%s: flip2_parseextparams(): invalid extended parameter '%s'\n",
            progname, extended_param);
    cmd_result = -1;
   }

  return cmd_result;
}

But when I run it, I get the next error:

Segmentation fault (core dumped)

What is the problem?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isn't this a cross post? I thought we were already discussing DFU start commands in another thread.

 

Anyway the joy of developing for PCs not AVRs is that it is SO easy to debug. Surely you can just run that code in a debugger and trap of things like Seg errors and it will give you a pointer(sic!) to what's wrong.

 

I imagine the issue is a read/write through a NULL pointer (it almost always is!).