Posts

Mass Storage Support for USB Host Library 2.0 released!

Mass Storage

Mass Storage

The code supporting USB Mass Storage Class of devices has been added to USB Host Shield 2.0 library and is available to download on GitHub. Mass storage devices include USB Flash drives, memory card readers, external hard drives/CD-ROMs, smartphones/tablets, and some others – almost anything that shows as a drive while connected to a PC (exceptions are digital cameras as well as some phones pretending to be digital cameras). Andrew Kroll (who made this release possible) – thank you very much!

At present, the code example, also featuring Andrew’s FAT and extended memory implementation, can only be run on “big” Arduinos such as Mega and Mega 2560. Another FAT implementation, developed by Alex Glushchenko, is being tested – there is a slight possibility that at least some functionality can be demonstrated on a regular UNO board. On the other hand, the mass storage component can be used without a file system by simply reading/writing physical sectors; this approach can save a lot of memory. The documentation for the mass storage class code is available here.

Many hours has been spent testing the code; it should work with any device which claims to support “mass storage bulk only” transport. While newer (less than 5 years old) won’t cause any problems, older ones could be finicky. If your device shows odd behaviour with this code, please let me know – I will trade it for the good working one.

Enjoy!

Oleg.

105 comments to Mass Storage Support for USB Host Library 2.0 released!

  • Is Arduino Due compatibility a possibility?

  • Mr. Oleg and everyone in this website,
    i really appropriate all of the wonderful libraries you provide and can’t tell you how much they are useful for people in their projects and i hope a time comes that you can control every single device involving USB connections using Arduino.
    best of luck.

  • Al

    Could you please post the code for the implementation that could run on an UNO?

  • Kabir

    Hmm, cannot compile on Arduino 1.0.5 :

    testusbhostFAT:49: error: variable or field ‘die’ declared void
    testusbhostFAT:49: error: ‘FRESULT’ was not declared in this scope
    testusbhostFAT:62: error: expected constructor, destructor, or type conversion before ‘*’ token
    testusbhostFAT:69: error: expected initializer before ‘*’ token
    testusbhostFAT:70: error: ‘part_t’ does not name a type
    testusbhostFAT:71: error: ‘storage_t’ does not name a type
    testusbhostFAT.ino: In function ‘void setup()’:
    testusbhostFAT:105: error: ‘_VOLUMES’ was not declared in this scope
    testusbhostFAT:106: error: ‘Fats’ was not declared in this scope
    testusbhostFAT:172: error: ‘Usb’ was not declared in this scope
    testusbhostFAT:176: error: ‘Usb’ was not declared in this scope
    testusbhostFAT:181: error: ‘Usb’ was not declared in this scope
    testusbhostFAT.ino: At global scope:
    testusbhostFAT:289: error: variable or field ‘die’ declared void
    testusbhostFAT:289: error: ‘FRESULT’ was not declared in this scope

    Please advise; Want to run it on Mega ADK.

    Regards,
    Kabir

    • You can’t compile the test in the Arduino IDE. Please use the bundled makefile: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/testusbhostFAT/Makefile.
      Also please update to the newest version of the submodules by executing the following command:

      git submodule foreach --recursive git pull origin master

      See the readme for more information: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/testusbhostFAT/README.md.

      • xxxajk

        As of a couple days ago, you may use the Arduino IDE to compile and play with the example.
        You will find that using make will result in a smaller binary since I set better compile options.

        • nelson

          hi,
          sorry i know the post was a bit dated. Im also trying out the ‘testusbhostfat’ demo on my arduino mega2560. Im having the same problems as Kabir. Ive already installed git, cloned and updated. I’m stumped. Thanks.

          testusbhostFAT:76: error: variable or field ‘die’ declared void
          testusbhostFAT:76: error: ‘FRESULT’ was not declared in this scope
          testusbhostFAT:88: error: expected constructor, destructor, or type conversion before ‘*’ token
          testusbhostFAT:95: error: expected initializer before ‘*’ token
          testusbhostFAT:96: error: ‘part_t’ does not name a type
          testusbhostFAT:97: error: ‘storage_t’ does not name a type
          testusbhostFAT.ino: In function ‘void setup()’:
          testusbhostFAT:178: error: ‘_VOLUMES’ was not declared in this scope
          testusbhostFAT:179: error: ‘Fats’ was not declared in this scope
          testusbhostFAT:180: error: ‘sto’ was not declared in this scope
          testusbhostFAT:180: error: expected type-specifier before ‘pvt_t’
          testusbhostFAT:180: error: expected `;’ before ‘pvt_t’
          testusbhostFAT:181: error: ‘pvt_t’ was not declared in this scope
          testusbhostFAT:181: error: expected primary-expression before ‘)’ token
          testusbhostFAT:181: error: expected `)’ before ‘sto’
          testusbhostFAT:285: error: ‘InitStorage’ was not declared in this scope
          testusbhostFAT.ino: At global scope:
          testusbhostFAT:399: error: variable or field ‘die’ declared void
          testusbhostFAT:399: error: ‘FRESULT’ was not declared in this scope

      • kevin

        How to compile the testusbhostFAT.ino without the Arduino IDE? Thanks.

  • jony

    hey thats great !

    i want to connect arduino uno bia usb to usb host shield on another arduino is it possible?
    can i add usb HUB and communicate with both USB PEN DRIVE and the uno?

  • Don Vukovic

    Has any more effort been made to connect a USB WiFi dongle ?

    Does anyone need help in getting this working with WiFi ?

    I am available.

    Don

    • AFAIK no one is working on WiFi support. You’re more than welcome to start developing it. Let me know if you need any help.

  • Carlos

    when I try to compile the file with the Arduino IDE I get the following error:
    testusbhostFAT.ino: In function ‘void loop ()’:
    testusbhostFAT.ino: 341:46: error: ‘on’ was not declared In this scope
    testusbhostFAT.ino: 344:46: error: ‘off’ was not declared In this scope

    to give values ​​to ‘on = 1’ and ‘off = 0’ for example shows:

    In file included from ~ / sketchbook / libraries / generic_storage / FAT.c: 4:0:
    / home / xscharlie / sketchbook / libraries / generic_storage / FAT / FATFS / src / ff.c: In function ‘f_write’:
    / home / xscharlie / sketchbook / libraries / generic_storage / FAT / FATFS / src / ff.c: 2868:1: error: unable to find a register to spill in class ‘POINTER_REGS’
    ~ / sketchbook / libraries / generic_storage / FAT / FATFS / src / ff.c: 2868:1: error: this is the insn:
    (insn 197 196 198 33 (set (reg: HI 26 r26)
             (reg / f: HI 231))
    ~ / sketchbook / libraries / generic_storage / FAT / FATFS / src / ff.c: 2825} 32 {* movhi
          (nil))
    ~ / sketchbook / libraries / generic_storage / FAT / FATFS / src / ff.c: 2868: confused by View earlier errors, bailing out

    any ideas?

  • avtop

    Hi
    I am asking about modem dongle i didn’t find where to ask, quarry so posting here
    I am trying to use USB2.0 lib for usb modem dongle but it is reset after reach USB_ATTACHED_SUBSTATE_WAIT_SOF 0x50
    USB_ATTACHED_SUBSTATE_WAIT_RESET 0x51
    this trace data
    Task State = 11
    Task State = 12
    Task State = 20
    Task State = 30
    Task State = 40
    Task State = 50
    Task State = 51
    Task State = 11 again repeat loop
    I am not able to find problem , what I need to check
    Thx

  • avtop

    Hi
    Thx Oleg for replay
    My device is Huawei E372
    idVendor : 0x12d1 (4817)
    idProduct : 0x1505 (5381)
    and same for 2nd device is EC168C same for both devices
    its Swtichable from zero cd to modem
    Thx

  • avtop

    Hi Oleg
    device is connecting/disconnecting
    Task HSRL READ = 3
    Task State = 11
    Task HSRL READ = 3
    Task State = 12
    Task HSRL READ = 3
    Task State = 20
    Task HSRL READ = 83
    Task State = 30
    Task HSRL READ = 83
    Task State = 40
    Task HSRL READ = 83
    Task State = 50
    Task HSRL READ = 83
    Task HIRQ READ = 69
    Task HSRL READ = 3

    Conf.LS: 0
    Task State = 51
    Task HSRL READ = 3

    i checked 2 usb modem
    thx

  • avtop

    hi
    I am running USB_desc sketch, first I want see device desc than start, this output is add debug print in usb.cpp to find problem
    thx

  • avtop

    hi oleg
    is this due to power? is that any way check this, I am using external 12v dc supply.
    is that all device connect the same way to get device desc.

    thx

    • You should be able to read descriptors from any device, supported or not. Have you tried to read descriptors from another USB device?

  • avtop

    Hi Oleg

    Yes, USBdesc Sketch can read all my USBHDD,USB Bluetooth,USB wifi and pen drive I checked but its resetting USB Data Modem
    and that USB Data Modem getting all data in computer
    I have checked with this code also
    http://forum.arduino.cc/index.php?action=profile;u=29238;sa=showPosts
    with same code and old v1.0 lib of yours its also get all thing as above but not that modem
    pls help why its reset and bus state goes to open state as shown above as soon as device connect its shows bus open state HSRL is 3 and aging when issue SOF bus set open state

    Thx

  • avtop

    Hi Oleg
    Is that any cap. on power pin to power or discharge problem
    when connect modem with extension cable its start resetting even on computer for a minute but same I connect this through hub even very low power usb cable its working on computers
    Is that cap. or res. require on my Arduino Mega ADK v2 board
    thx

  • avtop

    Hi Oleg
    Through Hub Sketch and through Hub USB Modem also giving device desc. no resetting
    thx

  • Dimitri

    Hello, unfortunately I can’t register on this website (it keeps saying: please fill the form, even if I do) so I write here.
    sorry if it is off-topic, but I have some questions about the V.2.0 library:

    in the old library, I had to make an EP_RECORD struct and fill it with the informations about the endpoints. Then I could plug this struct to the device using the SetDevTableEntry method. Last, I could use SetConf method to have the device ready.
    Now in the v.2.0 something changed, EP_RECORD is now EpInfo if I’m not wrong..and the method to attach this struct to the device is setEpInfoEntry. Am I right?
    the only difference is that this new method now requires the number of EPs?
    Then I was wondering what are used for those 3 members inside the struct:
    bmSndToggle, bmRcvToggle, bmNakPower,
    and how should I fill them (if I can get those values from my device).
    Last question is, how can I obtain the address assigned to my device, in order to call those methods correctly (now I’m assuming the address is always 1).
    After I set all those things, I can try to use InTransfer to my device and see what I get. 🙂
    many thanks
    Dimitri

    • Hello Dimitri,

      You don’t need to use seEpInfoEntry(). You allocate epInfo and fill it directly, like here 0> https://github.com/felis/USB_Host_Shield_2.0/blob/master/cdcacm.cpp#L34

      Toggles are set in transfer functions, you only need to reset them once during driver initialization. NAK power is number of automatic retries expressed as a number of 2, the number of NAKs counted is 2^bmNakPower – 1 . Certain useful values for Nak power are defined here -> https://github.com/felis/USB_Host_Shield_2.0/blob/master/address.h#L27

      • Dimitri

        hi, thanks for the reply 🙂
        I can’t find the allocation on that code..perhaps I need to do something like this:
        EpInfo epInfo[NUM_EP_OF_MY_DEVICE];
        globally, and then fill it inside my “configuration” method?
        so the library already knows that a declared and defined EpInfo struct is the right one to use for the device?
        then I have some other doubts..
        1) how can I get the address assigned to my device? now I’m assuming it’s 1, but who knows..
        2) about the 2 toggles, so I only need to write 0 to them during the EpInfo filling..and then forget about them?
        3) since I don’t know at all what NAK value should be suited for my application, what could you recommend me to use, as a start?
        4) Interval/poll value for EPs is not needed anymore (I can’t find it) or maybe should be set elsewhere?
        5) this line:
        ep_record[ CONTROL_EP ] = *( Usb.getDevTableEntry( 0,0 ));
        (taken from an example sketch of legacy library)
        to me is not clear.. what’s for?
        6) I can’t find infos about the Control EP of my device, descriptors only shows input and output endpoints..not the control endpoint.

        sorry for all those questions, I hope you can help me
        thanks

  • Dimitri

    thank you, could you please help me understand the other questions as well?

  • avtop

    Hi Oleg
    I am trying to understand USBHub code, but I am not able get it,
    I am trying to send cntrol msg to modem to switch Mode what I do to get device address,info
    like USB.? to get address,epinfo

    thx for your all help

  • avtop

    Hi Oleg
    I have gone through all the help documents but I am not able get pointer to start further
    Usb.ForEachUsbDevice(&PrintAllDescriptors);
    Usb.ForEachUsbDevice(&PrintAllAddresses);
    after I send Control Desc to device but I am not able to find which variable/function to go further even I start new like
    USB Usb;
    ..
    ..
    Usb.Task();
    if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
    {
    But still not able go
    Thx

  • avtop

    hi Oleg
    I run USBHub Sketch and list is
    I put Manual Address , How I can get pdev

    Start

    41

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: 09
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 08
    Vendor ID: 03EB
    Product ID: 0902
    Revision ID: 0100
    Mfg.string index: 00
    Prod.string index: 00
    Serial number index: 00
    Number of conf.: 01

    Configuration descriptor:
    Length: 09
    Descriptor type: 02
    Total length: 0022
    Num.intf: 01
    Conf.value: 01
    Conf.string: 00
    Attr.: E0
    Max.pwr: 32

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 01
    Intf. Class: 09
    Intf. Subclass: 00
    Intf. Protocol: 00
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 81
    Attr.: 03
    Max.pkt size: 0001
    Polling interval: FF

    Hub Descriptor:
    bDescLength: 9
    bDescriptorType: 29
    bNbrPorts: 4
    LogPwrSwitchMode: 1
    CompoundDevice: 0
    OverCurrentProtectMode: 1
    TTThinkTime: 0
    PortIndicatorsSupported:0
    Reserved: 0
    bPwrOn2PwrGood: 32
    bHubContrCurrent: 64
    001E

    09

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: 00
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 12D1
    Product ID: 1505
    Revision ID: 0000
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 04
    Number of conf.: 01

    Configuration descriptor:
    Length: 09
    Descriptor type: 02
    Total length: 0020
    Num.intf: 01
    Conf.value: 01
    Conf.string: 00
    Attr.: A0
    Max.pwr: FA

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 02
    Intf. Class: 08
    Intf. Subclass: 06
    Intf. Protocol: 50
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 87
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Endpoint descriptor:
    Endpoint address: 08
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Addr:41(1.0.1)

    Addr:9(0.1.1)

    This code is write after
    if (millis() >= next_time)
    {
    Usb.ForEachUsbDevice(&PrintAllDescriptors);
    Usb.ForEachUsbDevice(&PrintAllAddresses);

    USB_DEVICE_DESCRIPTOR buf;
    byte rcode;
    byte addr;
    byte num_conf = 0;
    addr = 09;
    Serial.println(“\r\nSetting Feture …….”);
    rcode = Hub1.SetHubFeature(1);
    Serial.println(“\r\nSetting Reset……”);
    Hub1.ResetHubPort(0x01);

    I got error 0D
    this is capature list Snoopy Pro

    1 in down n/a 0.001 GET_DESCRIPTOR_FROM_DEVICE
    1 in up n/a 0.001 CONTROL_TRANSFER 12 01 10 01 00 00 00 40 0x00000000
    URB
    Header (length: 80)

    SequenceNumber: 1

    Function: 0008 (CONTROL_TRANSFER)

    PipeHandle: f3229564

    SetupPacket:
    0000: 80 06 00 01 00 00 12 00

    bmRequestType: 80

    DIR: Device-To-Host

    TYPE: Standard
    RECIPIENT:
    Device
    bRequest: 06

    GET_DESCRIPTOR
    Descriptor Type: 0x0001

    DEVICE

    TransferBuffer: 0x00000012 (18)
    length
    0000: 12 01 10 01 00 00 00 40 d1 12 05 15 00 00 01 02
    0010: 04 01

    bLength : 0x12 (18)

    bDescriptorType : 0x01 (1)

    bcdUSB : 0x0110 (272)

    bDeviceClass : 0x00 (0)

    bDeviceSubClass : 0x00 (0)

    bDeviceProtocol : 0x00 (0)

    bMaxPacketSize0 : 0x40 (64)

    idVendor : 0x12d1 (4817)

    idProduct : 0x1505 (5381)

    bcdDevice : 0x0000 (0)

    iManufacturer : 0x01 (1)

    iProduct : 0x02 (2)

    iSerialNumber : 0x04 (4)

    bNumConfigurations : 0x01 (1)

    2 in down n/a 0.001 GET_DESCRIPTOR_FROM_DEVICE
    2 in up n/a 0.002 CONTROL_TRANSFER 09 02 20 00 01 01 00 a0 0x00000000

    3 in down n/a 0.002 GET_DESCRIPTOR_FROM_DEVICE
    3 in up n/a 0.002 CONTROL_TRANSFER 09 02 20 00 01 01 00 a0 0x00000000

    4 ??? down n/a 0.002 SELECT_CONFIGURATION

    4 ??? up n/a 0.002 SELECT_CONFIGURATION 0x00000000

    5 out down n/a 0.002 SET_FEATURE_TO_DEVICE
    5 out up n/a 0.003 CONTROL_TRANSFER – 0x00000000

    URB Header (length: 80)

    SequenceNumber: 5

    Function: 0008 (CONTROL_TRANSFER)

    PipeHandle: f3229564

    SetupPacket:
    0000: 00 03 01 00 00 00 00 00

    bmRequestType: 00

    DIR: Host-To-Device

    TYPE: Standard

    RECIPIENT: Device

    bRequest: 03

    SET_FEATURE

    No TransferBuffer

    6 ??? down n/a 0.003 RESET_PIPE

    6 ??? up n/a 0.003 RESET_PIPE 0x00000000

    7 ??? down n/a 0.003 RESET_PIPE

    7 ??? up n/a 0.003 RESET_PIPE 0x00000000

  • Andrey

    Hello Oleg,
    Could you answer a question. If i want to write and read information without a file system from hard disk, is it enough to use masstorage.h and masstorage.cpp?

  • Benjamin Richards

    I don’t know if I am in the right location. However I’m looking for instructions and sample code for getting the the sd shield installed on an arduino uno to act as a usb storage device but not to the arduino itself but to the computer where it is attached to. The sd shield will have a 16 gb sdhc card installed.
    Here is the in depth description of what I’d like to see as the outcome of this project:
    A USB mass storage device with bootable partion(s) the plural is optional the bootable aspect is mandatory.
    B software package for installing arduino ide to the host computer loaded onto the sd card
    C backup of the entire sketch that runs the arduino loaded onto the sd card
    D drivers or code, loaded on the sd card in an auto-run executable for windows or a disk image for mac os x on powerPC or a tar.gz package for linux, such that any machine can recognise the gprs/ gsm shield as a network interface by both the arduino and host computer analogous to cellphone via usb host shield post that I saw,

    • This is not the right place – we are doing USB host code. You first need to figure out how to run mass storage device code on 8u2 – the device used on UNO to provide USB to serial conversion. I’m not sure this is even possible, look at the Atmel site to see if they have any ms examples for this micro.

  • Shivarama

    Could you please release a video showing how to interface the mass storage device using the USB Host Shield 2.0. Also can you inform if any vendors are available for USB Host Shield 2.0 in India.

  • nelson

    Hi,

    Im kind of a newb when it comes to this USB host shield I purchased. What im trying to do is attach a hub onto the usb host shield and extend the number of ports to 4, plug 4 usb flash drives on each port, i would then transfer files between the usb flash drives. is this even possible, could you point me to the right direction please. Thanks and great work!

  • nelson

    Hi Oleg,

    Thanks for the reply. This is exciting news for me at least now I know its possible.I forgot to mention im using a mega2560 with 2.4tft touchscreen lcd (for GUI) and the usb host shield + hub. no PC connected so all file transfers will happen between the mega, host shield and hub only like a standalone usb file organizer. If you have like suggestions for reading and libraries you think i might need, it would help a lot. Thanks again great news!

  • etherViz

    I’m having some problems getting the USBHostFAT examples to compile on the Due. I understand the problem is all the AVR files that it wants to link in, instead of their SAM equivalents. Before I start tearing apart the FAT libraries to make them compatible I thought I would ask if there is an easy solution, existing fix, or perhaps a fork in beta.

  • wernert

    I’m experiencing problems to compile the example called testusbhostFAT for my AtMega1280.

    The error message I get says: “InitStorage() was not declared in this scope”.

    Please note that I downloaded and installed xmem2, generic storage and rtclib.

    Any advice?

  • wernert

    Thank you very much xxxajk. It does not look like my version of GIT understands the -recursive command. When I execute the command just like you gave it, it generates a new directory called -recursive and then puts some files in there but not all the files from the sub-directories. I use git version 1.9.2.mysysgit.0

  • wernert

    Since my GIT can not handle recursive, I was able to download all the individual libraries using this:
    git clone https://github.com/felis/USB_Host_Shield_2.0
    git clone https://github.com/xxxajk/RTClib
    git clone https://github.com/xxxajk/ajkstack
    git clone https://github.com/xxxajk/generic_storage
    git clone https://github.com/xxxajk/spi4teensy3
    git clone https://github.com/xxxajk/xmem2
    git clone https://github.com/xxxajk/xmemUSB
    git clone https://github.com/xxxajk/xmemUSBFS

    It now compiles for a while and then output the following error message:

    C:\Users\werner\Documents\Arduino\libraries\RTClib\set_system_time.c: In function ‘set_system_time’:
    C:\Users\werner\Documents\Arduino\libraries\RTClib\set_system_time.c:45: error: ‘for’ loop initial declaration used outside C99 mode

    I use: Arduino: 1.5.6-r2 (Windows 8), Board: “Arduino ATmega1280”

    This looks more like an RTClib issue that and issue with the example itself.

  • wernert

    I got it working! 🙂
    Here is what I had to do: First I deleteted all the libraries from my Arduino section and then re-added them. There was still a compile error for FAT.cpp -> RTClock() -> return RTC.now().FatPacked();
    So I just made it return zero so it compiled and the example worked. Thank you very much. This is excellent!

    • xxxajk

      Please report this and the other bugs on github, so that I can try to fix them. Thanks!

  • wiesiek

    Arduino: 1.5.6-r2 (Windows Vista), Board: ‘Arduino Tmega2560’ improved library
    and everything is OK. Operates without external memory and RTC. Reads and Pen Drives.
    If anyone needs these files, please contact us by e-mail: wiesiek1p
    gmail.com.
    Ps: Poor writing in English. Files Generic Mass Storage.

    • xxxajk

      Yes, it will work this way. It can’t do as much though, since nearly all RAM memory is used.

  • wiesiek

    After processing my memory is 6.5 k

    • xxxajk

      Try the update for RTClib.
      I did a hack that bypasses C99 requirement by using C++ and declaring it as C.
      This should allow the ATOMIC_BLOCK for updating the system_time variable to work.

      Please go to github.com, register and file any remaining problems you have there, because I don’t visit this area much.

  • wernert

    Thanks. I tried it and still had a C99 compile error. I reported it at https://github.com/xxxajk/RTClib

    • Felipe

      Hello,

      I’m having the exact same problem. I’m trying to compile from IDE version 1.5.6-r2 with all library files updated.

      Wernerterreb, may I ask you what is the workaround to compile? I’ve already tried to change RTC.now().FatPacked() to zero.

      Thank you.

    • Hi I succeed compiled everything and made it work.
      The problem is there is a bug in the set_system_time.c of RTCLib. It duplicated define the function. You just need to remove one definition.

      extern “C” {
      extern volatile time_t __system_time;

      void
      set_system_time(time_t timestamp) {

      ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
      __system_time = timestamp;
      }
      }
      }

  • Hi xxajk,
    I have made the USB shield working with mega2560 when I plug and unplug my USB stick. It works great independently. Its behavior meet my expectation.
    But when there is an ethernet shield. there are lots of confliction.
    1. there are a lot of MICRO duplicated with Sdlib.
    2. USB stick can not be detected after I change the Sdlib to remove the duplicated MICRO definition.

    I know the ethernet shield using ICSP and PIN 10,11,12,13, and PIN 4 for SD card.
    My question is How can I make the USB shield work ethernet work together?.

    Thanks a head, xxajk

    • xxxajk

      Which Ethernet shield are you using?

      You will need to determine if both SPI devices speak the same SPI protocols, and share SPI somehow.

      OR

      Perhaps wait for my IP stack to support ethernet on USB.
      Perhaps wait for my IP stack to support your shield, if that is even possible.
      Right now the IP stack only supports serial devices, see my github repository if interested.

      • I already made the the USB shield working with Ethernet shield and CAN bus shield.
        I modified your library.

        What time you will release the IP stack support for ethernet shield?
        Thanks xxxajk.

  • I am using official ethernet shields. http://arduino.cc/en/Main/ArduinoBoardEthernet. It looks like USB shield and ethernet shield can not live together.
    I did some research, it looks like if I change the USB Shield Selection PIN from 10 to other unused PIN, they should be able to work together.
    But I do not find the file that has the selection pin definition as #define MAX_SS 10.
    But some version has file Max3421e_constants.h, it has the MAX_SS definition.
    for example, https://github.com/felis/USB_Host_Shield
    If my test is successful, I may purchase a bunch of USB shields. I am doing comparative testing and prototype now.

  • zimmes

    Hi Oleg!
    Maby i have been bad at searching in the posts but can u use an usb flashdrive as flash memory
    on the arduino uno ? i really want to have a possibility to have more then 32kb storage for my code.
    can be fun if you can direct to files in the usb storage in the code to save memory.
    Is this possible ?

    Thanks in advance

  • nupur

    hi,,
    i am trying to read and write in pen drive using testusbhost.ino file from examples of usbhostshield 2.0 library on arduino mega adk. Create new file and read command are working great but theres some problem in the write command. if i unplug the pendrive from arduino after writing something to a file and plug it into my laptop, i do not see anything written in the file. But reading from the file during the execution of the code itself after writing something prints the right result. dont know why this is happening .
    it would be great if someone can help.

  • Hi Oleg Mazurov,
    I found there is another shield at:
    http://arduino.cc/en/Main/ArduinoUSBHostShield
    I am not sure this shield is as same as your USB shield.
    Please tell me are there any difference?
    Thanks.

    Rick

  • Hi xxxajk,
    I replace my modbus server with new release.
    It has nothing to do with USB shield mass storage code and its function.
    But there are error when to create direction at USB stick memory. the error code =12 or 17

    FRESULT f_mkdir(const TCHAR* path)

    it mean:
    FR_NOT_ENABLED, /* (12) The volume has no work area */
    FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */

    Please help me what is wrong with USB code?
    Thanks.

    Rick

  • I have 4 sheilds. I did some tests.
    My application needs the shield to transfer/save a lot of files from SD card to the USB memory stick.
    generally, its function is ok but the performance is not that good. I mean it is too slow.
    Are there any plan to improve the performance of the shield for mass storage function? it looks like the initialization is very slow too.

    Thanks.

  • OmkarDokur

    Dear Oleg,

    I have Arduino Mega 2560, USB Host Shield, 250 GB Sandisk Hard drive and Cammera Shield. Can i use these libraries to store images from camera into the Harddrive?

    Please advise !

    Thanks and regards,
    Omkar

  • OmkarDokur

    In your testhostfat example why there is a delay of 27 seconds before writing to the file?? Is this necessary?? Can i remove this delay ???

  • OmkarDokur

    This part of the code is taking more time.. Do we really need to make parts ready?? If yes, do we need make parts ready every time we write to the file ??
    This part is taking time of 27 seconds. Please guide me !
    if(usbon) {
    Serial.print(“1111111111111111111111111111111111111”);
    if(partsready && !fatready) {
    if(cpart > 0) fatready = true;
    }
    // This is horrible, and needs to be moved elsewhere!
    for(int B = 0; B GetAddress() != NULL)) {

    // Build a list.
    int ML = UHS_USB_BulkOnly[B]->GetbMaxLUN();
    //printf(“MAXLUN = %i\r\n”, ML);
    ML++;
    for(int i = 0; i LUNIsGood(i)) {
    partsready = true;
    ((pvt_t *)(sto[i].private_data))->lun = i;
    ((pvt_t *)(sto[i].private_data))->B = B;
    sto[i].Reads = *UHS_USB_BulkOnly_Read;
    sto[i].Writes = *UHS_USB_BulkOnly_Write;
    sto[i].Status = *UHS_USB_BulkOnly_Status;
    sto[i].Initialize = *UHS_USB_BulkOnly_Initialize;
    sto[i].Commit = *UHS_USB_BulkOnly_Commit;
    sto[i].TotalSectors = UHS_USB_BulkOnly[B]->GetCapacity(i);
    sto[i].SectorSize = UHS_USB_BulkOnly[B]->GetSectorSize(i);
    printf_P(PSTR(“LUN:\t\t%u\r\n”), i);
    printf_P(PSTR(“Total Sectors:\t%08lx\t%lu\r\n”), sto[i].TotalSectors, sto[i].TotalSectors);
    printf_P(PSTR(“Sector Size:\t%04x\t\t%u\r\n”), sto[i].SectorSize, sto[i].SectorSize);
    // get the partition data…
    PT = new PCPartition;

    if(!PT->Init(&sto[i])) {
    part_t *apart;
    for(int j = 0; j GetPart(j);
    if(apart != NULL && apart->type != 0x00) {
    memcpy(&(parts[cpart]), apart, sizeof (part_t));
    printf_P(PSTR(“Partition %u type %#02x\r\n”), j, parts[cpart].type);
    // for now
    if(isfat(parts[cpart].type)) {
    Fats[cpart] = new PFAT(&sto[i], cpart, parts[cpart].firstSector);
    //int r = Fats[cpart]->Good();
    if(Fats[cpart]->MountStatus()) {
    delete Fats[cpart];
    Fats[cpart] = NULL;
    }
    else cpart++;
    }
    }
    }
    }
    delete PT;
    }
    }

    }
    }
    if(fatready) {
    FRESULT rc; /* Result code */
    UINT bw, br, i;
    if(!notified) {
    notified = true;
    FATFS *fs = NULL;
    for(int zz = 0; zz volmap == 0) fs = Fats[zz]->ffs;
    }
    printf_P(PSTR(“\r\nOpen an existing file (message.txt).\r\n”));
    rc = f_open(&My_File_Object_x, “0:/MESSAGE.TXT”, FA_READ);
    if(rc) printf_P(PSTR(“Error %i, message.txt not found.\r\n”), rc);
    else {
    printf_P(PSTR(“\r\nType the file content.\r\n”));
    for(;;) {
    rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &br); /* Read a chunk of file */
    if(rc || !br) break; /* Error or end of file */
    for(i = 0; i drv, CTRL_COMMIT, 0);
    printf_P(PSTR(“\r\nTest completed.\r\n”));

    }

    }
    }
    }

  • Daniel

    Hello.

    Is there already some library running on the Arduino Uno board?

  • Jacks

    I just got an Intel Galileo and noticed it is compatible with the “regular” usb host library, which leads me to the question: is the Galileo supported / has anyone got it working with the usb host library 2.0? If not, could anyone give me some pointers where to look at for a custom implementation?

  • Daniel

    Hello, I am testing the example “testusbhostFAT” and did not work well. When I run the program with a USB host to MEGA board and 4GB USB in FAT or FAT32 shows me the following:


    Start
    Current UsbDEBUGlvl 51
    '+' and '-' increase/decrease by 0x01
    '.' and ',' increase/decrease by 0x10
    't' will run a 10MB write/read test and print out the time it took.
    'e' will toggle vbus off for a few moments.

    Long filename support: Enabled
    Total EXT RAM banks 0
    Available heap: 6358 Bytes
    SP 21f0
    VBUS on
    USB state = 20
    USB state = 40
    USB state = 50
    USB state = 51
    USB state = a0
    Available heap: 5900 Bytes
    Available heap: 5900 Bytes
    ...

    when I send ‘t’ (without the quotes) using the serial monitor does nothing, still shows “Available heap: 5900 Bytes”

    That is what is happening? How can I solve it?

    Thanks you.
    Regards,
    Daniel.

  • USB state = a0
    This means that the device was no enumerated. Re-plug in the device.
    Installing the vbus switch solves this problem automatically, see here:
    http://www.circuitsathome.com/mcu/vbus-power-control-on-usb-host-shield

    Once the device is properly enumerated, you will see:
    USB state = 90

    followed by information about the device, partition information (if partitions exist), and finally a short test.
    The 10MB test I left as a manual option in order to let you do speed tests. Not everyone may want to run such a test.

  • lee

    I’m not sure if this is the correct forum for this enquiry, so please go easy on me, if my question(s) are too low-brow!

    PREAMBLE: I’m working on a solar-science project for poorly-resourced high-schools in Ireland, using an Adafruit sensor (INA219) to measure the voltage and current from a solar-panel, using an I2C connection to a Leonardo board. I’ve written a little script that “prints” the measured Voltage, Current, and Power to my laptop via the serial-port connection – all works fine. Now the teachers are complaining that they can’t justify setting-aside a computer for long-term (a few weeks) of data-logging form the panel, and are not comfortable/interested in working with a RPi.

    PROBLEM: I bought a USB host-shield from Maplin (seems to be fabricated by Linksprite?) with the hope/idea of saving the solar-panel data directly to a USB thumb-drive. However, I now find myself completely outclassed by the complexity of the USB_Host_library_2 files! I can’t even understand IF it is possible to save three or four float variables to a USB stick every 10 minutes or so, let alone the commands to actually do it!

    Do you know of any existing (simple!?) example code that might help me figure this out? I understand that even the simple-sounding action of appending lines to a CSV or TXT file might require fiendishly complicated library files, but surely some kind soul has already tried it, and would be willing to share?

    Many thanks for any help/advice you can give!

    Problem: To get around this I bought a USB host

  • Please help me!!!
    I have done everything!… I can’t seem to compile testusbhostFAT.ino in the Arduino 1.0.5 IDE. I am using a Arduino Mega 2560 with a MAC OS X 10.9.4
    I even updated the submodules they are “Already up-to-date.”
    But I keep getting this darn error message… Help me I want to be able to use a flash drive to control a servo.

    testusbhostFAT:88: error: variable or field ‘die’ declared void
    testusbhostFAT:88: error: ‘FRESULT’ was not declared in this scope
    testusbhostFAT:100: error: expected constructor, destructor, or type conversion before ‘*’ token
    testusbhostFAT:107: error: expected initializer before ‘*’ token
    testusbhostFAT:108: error: ‘part_t’ does not name a type
    testusbhostFAT:109: error: ‘storage_t’ does not name a type
    testusbhostFAT.ino: In function ‘void setup()’:
    testusbhostFAT:193: error: ‘_VOLUMES’ was not declared in this scope
    testusbhostFAT:194: error: ‘Fats’ was not declared in this scope
    testusbhostFAT:195: error: ‘sto’ was not declared in this scope
    testusbhostFAT:195: error: expected type-specifier before ‘pvt_t’
    testusbhostFAT:195: error: expected `;’ before ‘pvt_t’
    testusbhostFAT:196: error: ‘pvt_t’ was not declared in this scope
    testusbhostFAT:196: error: expected primary-expression before ‘)’ token
    testusbhostFAT:196: error: expected `)’ before ‘sto’
    testusbhostFAT:302: error: ‘Init_Generic_Storage’ was not declared in this scope
    testusbhostFAT.ino: At global scope:
    testusbhostFAT:395: error: variable or field ‘die’ declared void
    testusbhostFAT:395: error: ‘FRESULT’ was not declared in this scope

    Thank you,
    IS_Ardu_Alive

  • OK so I’m understanding a bit more of what has to go into this whole setup from github and the process to install this USB Host shield on a MAC OSX. So far I have updated the submodules in the Terminal and I have located the Makefile, as well as to call it “make” in Terminal. The error now is the following in Terminal:

    Arduino_Makefile_master/_Makefile.master:145: Your shell is unknown, please report on github if it works or not.
    Building “build/mega2560/testusbhostFAT_ino.o”… /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -x c++ -Wa,-adhlns=build/mega2560/testusbhostFAT.lst -Os -freorder-blocks -fno-inline-small-functions -fno-exceptions -ffunction-sections -fdata-sections -MMD -g -w -D _USE_LFN=3 -D _FS_TINY=1 -D _MAX_SS=512 -D EXT_RAM_STACK=1 -D EXT_RAM_HEAP=1 -D USB_HOST_SERIAL=Serial3 -D DEBUG_USB_HOST -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/mega -DF_CPU=16000000L -DARDUINO=105 -mmcu=atmega2560 -DUSING_MAKEFILE=1 -Wall -Wextra -Wformat=2 -Wuninitialized -Wshadow -Wconversion -MMD testusbhostFAT.ino -o build/mega2560/testusbhostFAT_ino.o
    testusbhostFAT.ino:79: error: ‘USB’ does not name a type
    testusbhostFAT.ino:83: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:84: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:85: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:86: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:87: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:89: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:90: error: ‘boolean’ does not name a type
    testusbhostFAT.ino:92: error: expected constructor, destructor, or type conversion before ‘*’ token
    testusbhostFAT.ino:99: error: expected initializer before ‘*’ token
    testusbhostFAT.ino:100: error: ‘part_t’ does not name a type
    testusbhostFAT.ino:101: error: ‘storage_t’ does not name a type
    testusbhostFAT.ino: In function ‘int tty_stderr_putc(char, __file*)’:
    testusbhostFAT.ino:118: error: ‘Serial3’ was not declared in this scope
    testusbhostFAT.ino: In function ‘int tty_stderr_flush(__file*)’:
    testusbhostFAT.ino:123: error: ‘Serial3’ was not declared in this scope
    testusbhostFAT.ino: In function ‘int tty_std_putc(char, __file*)’:
    testusbhostFAT.ino:128: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino: In function ‘int tty_std_getc(__file*)’:
    testusbhostFAT.ino:133: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:134: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino: In function ‘int tty_std_flush(__file*)’:
    testusbhostFAT.ino:138: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino: In function ‘void setup()’:
    testusbhostFAT.ino:181: error: ‘boolean’ was not declared in this scope
    testusbhostFAT.ino:181: error: expected `;’ before ‘serr’
    testusbhostFAT.ino:182: error: ‘_VOLUMES’ was not declared in this scope
    testusbhostFAT.ino:183: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:184: error: ‘sto’ was not declared in this scope
    testusbhostFAT.ino:184: error: expected type-specifier before ‘pvt_t’
    testusbhostFAT.ino:184: error: expected `;’ before ‘pvt_t’
    testusbhostFAT.ino:185: error: ‘pvt_t’ was not declared in this scope
    testusbhostFAT.ino:185: error: expected primary-expression before ‘)’ token
    testusbhostFAT.ino:185: error: expected `)’ before ‘sto’
    testusbhostFAT.ino:189: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:193: error: ‘LED_BUILTIN’ was not declared in this scope
    testusbhostFAT.ino:193: error: ‘OUTPUT’ was not declared in this scope
    testusbhostFAT.ino:193: error: ‘pinMode’ was not declared in this scope
    testusbhostFAT.ino:198: error: ‘Serial3’ was not declared in this scope
    testusbhostFAT.ino:201: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:202: error: ‘serr’ was not declared in this scope
    testusbhostFAT.ino:207: error: ‘delay’ was not declared in this scope
    testusbhostFAT.ino:208: error: ‘analogWrite’ was not declared in this scope
    testusbhostFAT.ino:232: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:245: error: ‘serr’ was not declared in this scope
    testusbhostFAT.ino:271: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:291: error: ‘Init_Generic_Storage’ was not declared in this scope
    testusbhostFAT.ino:293: error: ‘Usb’ was not declared in this scope
    testusbhostFAT.ino:295: error: ‘Notify’ was not declared in this scope
    testusbhostFAT.ino: In function ‘void serialEvent()’:
    testusbhostFAT.ino:321: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:325: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:326: error: ‘reportlvl’ was not declared in this scope
    testusbhostFAT.ino:329: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:333: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:337: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:344: error: ‘runtest’ was not declared in this scope
    testusbhostFAT.ino:347: error: ‘change’ was not declared in this scope
    testusbhostFAT.ino:348: error: ‘usbon’ was not declared in this scope
    testusbhostFAT.ino: In function ‘void __vector_32()’:
    testusbhostFAT.ino:358: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:362: error: ‘LED_BUILTIN’ was not declared in this scope
    testusbhostFAT.ino:362: error: ‘analogWrite’ was not declared in this scope
    testusbhostFAT.ino: At global scope:
    testusbhostFAT.ino:384: error: variable or field ‘die’ declared void
    testusbhostFAT.ino:384: error: ‘FRESULT’ was not declared in this scope
    testusbhostFAT.ino: In function ‘void loop()’:
    testusbhostFAT.ino:390: error: ‘FIL’ was not declared in this scope
    testusbhostFAT.ino:390: error: expected `;’ before ‘My_File_Object_x’
    testusbhostFAT.ino:394: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:395: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:396: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:408: error: ‘change’ was not declared in this scope
    testusbhostFAT.ino:408: error: ‘usbon’ was not declared in this scope
    testusbhostFAT.ino:408: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:413: error: ‘change’ was not declared in this scope
    testusbhostFAT.ino:415: error: ‘usbon’ was not declared in this scope
    testusbhostFAT.ino:416: error: ‘Usb’ was not declared in this scope
    testusbhostFAT.ino:416: error: ‘vbus_on’ was not declared in this scope
    testusbhostFAT.ino:417: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:419: error: ‘Usb’ was not declared in this scope
    testusbhostFAT.ino:419: error: ‘vbus_off’ was not declared in this scope
    testusbhostFAT.ino:420: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:423: error: ‘Usb’ was not declared in this scope
    testusbhostFAT.ino:426: error: ‘UsbDEBUGlvl’ was not declared in this scope
    testusbhostFAT.ino:427: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:429: error: ‘USB_STATE_RUNNING’ was not declared in this scope
    testusbhostFAT.ino:433: error: ‘USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE’ was not declared in this scope
    testusbhostFAT.ino:437: error: ‘partsready’ was not declared in this scope
    testusbhostFAT.ino:439: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:441: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:443: error: ‘fatready’ was not declared in this scope
    testusbhostFAT.ino:444: error: ‘notified’ was not declared in this scope
    testusbhostFAT.ino:451: error: ‘usbon’ was not declared in this scope
    testusbhostFAT.ino:452: error: ‘partsready’ was not declared in this scope
    testusbhostFAT.ino:452: error: ‘fatready’ was not declared in this scope
    testusbhostFAT.ino:456: error: ‘MAX_USB_MS_DRIVERS’ was not declared in this scope
    testusbhostFAT.ino:457: error: ‘partsready’ was not declared in this scope
    testusbhostFAT.ino:457: error: ‘UHS_USB_BulkOnly’ was not declared in this scope
    testusbhostFAT.ino:466: error: ‘pvt_t’ was not declared in this scope
    testusbhostFAT.ino:466: error: expected primary-expression before ‘)’ token
    testusbhostFAT.ino:466: error: ‘sto’ was not declared in this scope
    testusbhostFAT.ino:467: error: expected primary-expression before ‘)’ token
    testusbhostFAT.ino:468: error: ‘UHS_USB_BulkOnly_Read’ was not declared in this scope
    testusbhostFAT.ino:469: error: ‘UHS_USB_BulkOnly_Write’ was not declared in this scope
    testusbhostFAT.ino:470: error: ‘UHS_USB_BulkOnly_Status’ was not declared in this scope
    testusbhostFAT.ino:471: error: ‘UHS_USB_BulkOnly_Initialize’ was not declared in this scope
    testusbhostFAT.ino:472: error: ‘UHS_USB_BulkOnly_Commit’ was not declared in this scope
    testusbhostFAT.ino:475: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:479: error: ‘PT’ was not declared in this scope
    testusbhostFAT.ino:479: error: expected type-specifier before ‘PCPartition’
    testusbhostFAT.ino:479: error: expected `;’ before ‘PCPartition’
    testusbhostFAT.ino:482: error: ‘part_t’ was not declared in this scope
    testusbhostFAT.ino:482: error: ‘apart’ was not declared in this scope
    testusbhostFAT.ino:486: error: ‘parts’ was not declared in this scope
    testusbhostFAT.ino:486: error: ‘memcpy’ was not declared in this scope
    testusbhostFAT.ino:490: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:490: error: expected type-specifier before ‘PFAT’
    testusbhostFAT.ino:490: error: expected `;’ before ‘PFAT’
    testusbhostFAT.ino:501: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:501: error: expected type-specifier before ‘PFAT’
    testusbhostFAT.ino:501: error: expected `;’ before ‘PFAT’
    testusbhostFAT.ino:510: error: type ” argument given to ‘delete’, expected pointer
    testusbhostFAT.ino:512: error: ‘sto’ was not declared in this scope
    testusbhostFAT.ino:523: error: ‘fatready’ was not declared in this scope
    testusbhostFAT.ino:524: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:527: error: ‘UHS_USB_BulkOnly’ was not declared in this scope
    testusbhostFAT.ino:527: error: invalid use of incomplete type ‘struct Pvt’
    testusbhostFAT.ino:525: error: forward declaration of ‘struct Pvt’
    testusbhostFAT.ino:527: error: invalid use of incomplete type ‘struct Pvt’
    testusbhostFAT.ino:525: error: forward declaration of ‘struct Pvt’
    testusbhostFAT.ino:532: error: ‘partsready’ was not declared in this scope
    testusbhostFAT.ino:539: error: ‘notified’ was not declared in this scope
    testusbhostFAT.ino:545: error: ‘fatready’ was not declared in this scope
    testusbhostFAT.ino:546: error: ‘FRESULT’ was not declared in this scope
    testusbhostFAT.ino:546: error: expected `;’ before ‘rc’
    testusbhostFAT.ino:547: error: ‘UINT’ was not declared in this scope
    testusbhostFAT.ino:547: error: expected `;’ before ‘bw’
    testusbhostFAT.ino:548: error: ‘notified’ was not declared in this scope
    testusbhostFAT.ino:553: error: ‘FATFS’ was not declared in this scope
    testusbhostFAT.ino:553: error: ‘fs’ was not declared in this scope
    testusbhostFAT.ino:554: error: ‘_VOLUMES’ was not declared in this scope
    testusbhostFAT.ino:555: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:557: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:558: error: ‘rc’ was not declared in this scope
    testusbhostFAT.ino:558: error: ‘My_File_Object_x’ was not declared in this scope
    testusbhostFAT.ino:558: error: ‘FA_READ’ was not declared in this scope
    testusbhostFAT.ino:558: error: ‘f_open’ was not declared in this scope
    testusbhostFAT.ino:563: error: ‘br’ was not declared in this scope
    testusbhostFAT.ino:563: error: ‘f_read’ was not declared in this scope
    testusbhostFAT.ino:565: error: ‘i’ was not declared in this scope
    testusbhostFAT.ino:568: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:570: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:571: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:575: error: ‘f_close’ was not declared in this scope
    testusbhostFAT.ino:580: error: ‘f_close’ was not declared in this scope
    testusbhostFAT.ino:584: error: ‘FA_WRITE’ was not declared in this scope
    testusbhostFAT.ino:584: error: ‘FA_CREATE_ALWAYS’ was not declared in this scope
    testusbhostFAT.ino:586: error: ‘die’ was not declared in this scope
    testusbhostFAT.ino:590: error: ‘bw’ was not declared in this scope
    testusbhostFAT.ino:590: error: ‘f_write’ was not declared in this scope
    testusbhostFAT.ino:597: error: ‘f_close’ was not declared in this scope
    testusbhostFAT.ino:599: error: ‘die’ was not declared in this scope
    testusbhostFAT.ino:604: error: ‘_MAX_LFN’ was not declared in this scope
    testusbhostFAT.ino:605: error: ‘FILINFO’ was not declared in this scope
    testusbhostFAT.ino:605: error: expected `;’ before ‘My_File_Info_Object_x’
    testusbhostFAT.ino:606: error: ‘My_File_Info_Object_x’ was not declared in this scope
    testusbhostFAT.ino:606: error: ‘lfn’ was not declared in this scope
    testusbhostFAT.ino:608: error: ‘DIR’ was not declared in this scope
    testusbhostFAT.ino:608: error: expected `;’ before ‘My_Dir_Object_x’
    testusbhostFAT.ino:610: error: ‘My_Dir_Object_x’ was not declared in this scope
    testusbhostFAT.ino:610: error: ‘f_opendir’ was not declared in this scope
    testusbhostFAT.ino:612: error: ‘die’ was not declared in this scope
    testusbhostFAT.ino:625: error: ‘f_readdir’ was not declared in this scope
    testusbhostFAT.ino:628: error: ‘AM_DIR’ was not declared in this scope
    testusbhostFAT.ino:629: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:631: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:633: error: ‘Serial’ was not declared in this scope
    testusbhostFAT.ino:635: error: ‘AM_RDO’ was not declared in this scope
    testusbhostFAT.ino:640: error: ‘AM_HID’ was not declared in this scope
    testusbhostFAT.ino:646: error: ‘AM_SYS’ was not declared in this scope
    testusbhostFAT.ino:652: error: ‘AM_ARC’ was not declared in this scope
    testusbhostFAT.ino:667: error: ‘die’ was not declared in this scope
    testusbhostFAT.ino:669: error: ‘CTRL_COMMIT’ was not declared in this scope
    testusbhostFAT.ino:669: error: ‘DISK_IOCTL’ was not declared in this scope
    testusbhostFAT.ino:674: error: ‘runtest’ was not declared in this scope
    testusbhostFAT.ino:675: error: ‘ULONG’ was not declared in this scope
    testusbhostFAT.ino:675: error: expected `;’ before ‘ii’
    testusbhostFAT.ino:676: error: ‘FATFS’ was not declared in this scope
    testusbhostFAT.ino:676: error: ‘fs’ was not declared in this scope
    testusbhostFAT.ino:677: error: ‘_VOLUMES’ was not declared in this scope
    testusbhostFAT.ino:678: error: ‘Fats’ was not declared in this scope
    testusbhostFAT.ino:681: error: ‘f_unlink’ was not declared in this scope
    testusbhostFAT.ino:682: error: ‘PSTR’ was not declared in this scope
    testusbhostFAT.ino:683: error: ‘rc’ was not declared in this scope
    testusbhostFAT.ino:683: error: ‘My_File_Object_x’ was not declared in this scope
    testusbhostFAT.ino:683: error: ‘FA_WRITE’ was not declared in this scope
    testusbhostFAT.ino:683: error: ‘FA_CREATE_ALWAYS’ was not declared in this scope
    testusbhostFAT.ino:683: error: ‘f_open’ was not declared in this scope
    testusbhostFAT.ino:685: error: ‘bw’ was not declared in this scope
    testusbhostFAT.ino:687: error: ‘start’ was not declared in this scope
    testusbhostFAT.ino:687: error: ‘millis’ was not declared in this scope
    testusbhostFAT.ino:689: error: ‘ii’ was not declared in this scope
    testusbhostFAT.ino:690: error: ‘f_write’ was not declared in this scope
    testusbhostFAT.ino:693: error: ‘f_close’ was not declared in this scope
    testusbhostFAT.ino:695: error: ‘end’ was not declared in this scope
    testusbhostFAT.ino:696: error: ‘wt’ was not declared in this scope
    testusbhostFAT.ino:698: error: ‘FA_READ’ was not declared in this scope
    testusbhostFAT.ino:704: error: ‘f_read’ was not declared in this scope
    testusbhostFAT.ino:711: error: ‘rt’ was not declared in this scope
    testusbhostFAT.ino:714: error: ‘die’ was not declared in this scope
    testusbhostFAT.ino:715: error: ‘CTRL_COMMIT’ was not declared in this scope
    testusbhostFAT.ino:715: error: ‘DISK_IOCTL’ was not declared in this scope
    make: *** [build/mega2560/testusbhostFAT_ino.o] Error 1

    Is there something I have to do the MAKEFILE, if so what does that entail?… I don’t know what else to do… someone please help me

    Again I am using a Mega 2560 with a MAC OS X 10.9.4 and a Keyes USB HOST SHIELD from funduino.com