An example of Arduino Due as an USB host mass storage

Nice Work :)

When i connect pen drive to native port of Due it is showing Vendor ID and Product id

But when i connect ipod to native port it is not showing anything..

Any idea why it is not showing :(

cause an ipod isn't a genuine USB massstorage device, it's an apple whatever-device.

This topic is one of the most important for practical use, although I can't test it, because I don't have Atmel Studio.

Is there an existing solution/example to be used with arduino IDE?

Thanks!

Measureino: This topic is one of the most important for practical use, although I can't test it, because I don't have Atmel Studio.

Is there an existing solution/example to be used with arduino IDE?

Thanks!

Yes and no. There is a "enumerate USB devices on DUE " posted ( about year old ) and no discussion on that. That is based on "USBHost class" and works, It will identify USB info on mouse , keyboard , flash drive and webcam ( tested so far). The MSC ASF sample code is a challenge to "port" to DUE. The true ASF code is documented and has a nice debug trace macro. I got as far as CONFIGURE and cannot get pass detecting end points. ( The header files contents is pretty inconsistent - sometime only #defines, sometime mixture of classes ). So I am going to use the enumerating code to get the USB device to RUNNING state and than add the MSC ( heavilly modified I expect). I am still not sure how to actually communicate from DUE to "MSC controller". But again ATmel puts out tons of API (USB) notes, nice.

Palliser:
I wanted to share an example from Atmel ASF that shows how to implement a USB host mass storage on Arduino Due with USB module.

I have upload the .bin file in github for those interested to test it. If you want to move forward with this application, I’d recommend to install Atmel Studio 6 with ASF and build/compile the Arduino Due based example called “USB Host MSC FatFS example”. I could write a sketch for Arduino IDE but you have to be patient.

For this application you will need:

  • Arduino board
  • Flash memory card (FAT or FAT32)
  • A USB to mini-USB cable
  • Bossac.exe in you computer
  • Download my HOST_EXAMPLE21.bin file from github

Then, follow these steps:
1. Download the file HOST_EXAMPLE21.bin from this link:
https://github.com/downloads/Palliser/Arduino-DUE/HOST_EXAMPLE21.bin

1.1. Download the file HOST_EXAMPLE21.bin attached to this post (EDITED: March-05-2014).
2. Load HOST_EXAMPLE21.bin to Arduino Due using bossac.exe as follows:

Notice that I am using port 23 because that is the port in my laptop where my Due is connected.

  1. After loading HOST_EXAMPLE21.bin in your Due, connect Due to a Flash Memory card (FAT/FAT32 are supported) using the USB-mini USB cable.

  2. Finally disconnect the memory stick from Due and read it in your computer. The example creates in your memory card (stick) a file “uhi_msc_test.txt” that contains the text: Arduino Due Rocks!

If you want to create your own file and text you’ll find the example in Atmel Studio 6 as follows:
File->New->Example Project from ASF->[Under Kit] Arduino Due X->USB Host MSC FatFS example

Regards!

Hi Palliser, I read the post, and I’m interested at your arduino due “library” if I can call it in this way, but I read that:

  1. It can only be used on SdCard; and I want to use it on USB pens,
  2. For using it I must program directly the ARM processor, and I don’t have much time to learn how-to-use/program it,
    What should I do? I want to simply read/write variable text files on usb pens with my Arduino 2 but without buy an USB Host Shield…
    Regards and thanks in advance for the help

Hola Juan,

I must say I am half way to finish my porting of the Atmel ASF example for Due. I just need time to finish it (nowadays I am busy at my work). I hope to have the library and raw example (write/read USB memory stick) ready by the end of this Summer, thus, it is about to wait. Regards,

p

Hola Palliser, gracias for the answer

But that's the problem, I must make a school project with it, and I don't have enough time to expect the summer. I want only to ask you if there's an alternative to create the "library code" for rd/rw usb pen drive. For example, can the USB Host Library 2.0 be used for this on Arduino Due without buy an USB Host Shield? I think not but I can myself wrong...

Juan: I've tried USB Host Library 2.0 and it most definitely can not be used with the Due. Everything is written for the MAXIM usb host chip. So all the MAXIM code needs to be replaced with SAM3 uhc code.

On a more positive note! This ASF example is great news for me! I want to have keyboard + usb stick connected to the Due at the same time and it looks like Palliser's example can do just this?

Is there any easy way to convert this to the Arduino IDE?

well, i'm already trying to hack and get this working on plain old arm-gcc..

afaik, Atmel/Arduino are working on a new USB host stack for both Due and Zero. It will have the support of Mass Storage. No milestone announced yet. Regards,

p

Holy shit, that would be amazing!! Thanks for that news!!

I've even gone so far as to turn the entire USBHost system into statemachines. Costing me a whole week of development alone. It works, but mass storage had to be backported from USBHost 2.0/3.0 and that's no walk in the park.

Palliser: Is there any way I could come into contact with Atmel or Arduino about this new development. If possible, I would like to help!

Cheers!

hi all

I have a small doubt, at time of programming using bossac.exe file my USB cable connected to Programming port or Native USB port

vinod_chinthoti: hi all

I have a small doubt, at time of programming using bossac.exe file my USB cable connected to Programming port or Native USB port

Hello vinod_chinthoti, You can use any of the Arduino Due USB ports (Programming or Native) but make sure you use:

'false' with USB Programming port

'true' with USB Native port

Example:

Let's say...

...your directory_path_to_bossac' is: C:\Users\YourName\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.6.1-arduino ...your 'directory_path_to_program' is: C:\Users\YourName\AppData\Local\Temp\arduino_build_805975 ...your program is: program.ino.bin ...you USB Programming port is: COM2 ...you USB Native port is: COM3

Then:

When connected to USB Programming port (COM2):

directory_path_to_bossac\bossac.exe --port=COM2 -U false -e -w -v -b \directory_path_to_program\program.ino.bin -R


Example when connected to USB Native port (COM3):

directory_path_to_bossac\bossac.exe --port=COM3 -U true -e -w -v -b \directory_path_to_program\program.ino.bin -R

Regards,

-p

Palliser: Hola Juan,

I must say I am half way to finish my porting of the Atmel ASF example for Due. I just need time to finish it (nowadays I am busy at my work). I hope to have the library and raw example (write/read USB memory stick) ready by the end of this Summer, thus, it is about to wait. Regards,

p

Добрый день Palliser. Вы завершили проект?

Hello guys, I need your help... please. I followed all the recommendations of Travis .... Termit 3.4 shows me - USB HOST HID / MSC Example - - Arduino Due / X - - Compiled: Feb 3 2019 03:48:48 -

[main] MAX_DRIVE = 8: [main] Device Attached! Vid = 0x1307 PID = 0x0165 [main] Sof Detected! [main] create file

where "create file" its my debug string from function

res = f_open (& file_object, (char const *) test_file_name, FA_CREATE_ALWAYS | FA_WRITE); if (res == FR_OK) {DbgPrint ("create file"); }

everything seems to be ok, but when connect my USB stick(fat32) to the PC, I don’t find file (uhi_msc_test.txt) . I’m trying to figure it out the third day .. Please help me.

if i call :

res= f_mkdir ((char const *)test_file_name); DbgPrint("f_mkdir=%d",res);

I get :

[main] f_mkdir=8 // FR_EXIST /* (8) Acces denied due to prohibited access */

thank you for your help

Hi guys! Is there any news on code migration to ARDUINO IDE? I tried to create a reading based on the USB HOST library but it was without result, it only works with the mouse and keyboard. Whether prompt there is a decision to use USB storage with Native Usb from Arduino Due?

For those who don’t want to wait for an hypothetical Arduino release of a USB Host Mass Storage library for the DUE, and if you have some spare time (~ 6 months) :slight_smile: , read chapter 17 of Benjamin David LUNT book: “USB : The Universal Serial Bus”. There is everything you need for a USB Mass Storage driver implementation to handle your favorite thumb drive.

Although it’s for video streaming only, I warmly recommend the preliminary reading of the following tutorial:

https://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7828517

The DUE embeds a USB 2.0 compliant High Speed capable peripheral usable either as a Host or a Device.

Hello ard_newbie. I used your recommended library and example (dueUsbhost) in topic: Usb Host (Due) support for mass storage devices (thumbdrives) My Due was able to read and write a thumb drive (Fat32) thoroughly. That's incredibly awesome! Thank you ard_newbie, Andreas Meyer (controlord) for resolving for me an old dream. Caveats: 1) Use an OTG Cable Male Micro USB to USB A-Female 2) Use a new or a blank thumb drive (Fat32) -p |375x500

Hi Palliser,

Nice to see you back on the forum :slight_smile: