This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB host MSC stack overflow

I managed to get usb host msc (mass storage class) running up until detection of the USB stick.

   while(true) {
      os_dly_wait(2);
      usbh_engine(0); // check for new devices
      if (!bConnected && usbh_msc_status(0, 0)) {
         printf("MSC connected");
         bConnected = true;
      }
      else if (bConnected && !usbh_msc_status(0, 0)) {
         printf("MSC disconnected");
         bConnected = false;
      }
   }

When I insert the stick, the "MSC connected" message appears (after some delay). When I remove the stick, the "MSC disconnected" message appears.

However, when I try to read from the stick, no files are found and I get a stack overflow (in void os_error(U32 err_code)).

   if (ffind("U0:*.*", &fInfo) == 0) {
      printf("MSC connected: %s", fInfo.name); // We never get here
   }
   // ffind does not find any files
   // and a stack overflow occurs here
   // (Note that it does not appear when I remove the ffind() command!

I also tried to open a file by name (which certainly exists on the stick), but fopen() returns NULL.

Parents
  • fcheck("U0:") returns nonzero.
    It seems that on fcheck, none of the functions in fs_usbh_msc.c is called.

    There seems to be something wrong in the connection between the file system layer (where all the file commands are) and the host class layer (with the functions from fs_usbh_msc.c).

    It seems something doesn't get initialized.
    I am calling finit(NULL) at the start of my program and finit("U0:") on detection of a USB stick.

    (And I am talking to myself a lot...)

Reply
  • fcheck("U0:") returns nonzero.
    It seems that on fcheck, none of the functions in fs_usbh_msc.c is called.

    There seems to be something wrong in the connection between the file system layer (where all the file commands are) and the host class layer (with the functions from fs_usbh_msc.c).

    It seems something doesn't get initialized.
    I am calling finit(NULL) at the start of my program and finit("U0:") on detection of a USB stick.

    (And I am talking to myself a lot...)

Children