SparkFun USB Host Shield USB Flash Drive problems

Hi all,

I have a Sparkfun USB Host Shield, bough this past week, connected to a Mega2560 board.

Version 2.0-1.3.2 of the Circuits@Home USB Shield library is installed.

I am trying to do a simple read/write of text data from a flash drive.

I have the boards powered by a robust 12 Volt supply.

The Board_QC and USB_Desc Examples work perfectly.

I am having no luck, however, getting testusbFAT to read and write from the Flash drive.

I have tried multiple Flash drives, and get the same result with each.

The sketch starts, runs until USB_State settles at 0x90 (State_Running),

shows USB_ON and MAXLUN =0, then loops once every 10 seconds.

I never see the Flash Drive “Total Sectors” or "Sector Size " messages, and if I hit “t(return)” on my keyboard,

which should do a read/write test of a 10 mB file, nothing whatsoever happens, except I get a serial message

" r creates a new 10MB test file (10MB.bin)". After this message, the sketch continues to loop once every 10 seconds.

Doing some debugging with serial message tags, I find that the program cannot get past Line 495, where

the following test is done: " if(UHS_USB_BulkOnly->LUNIsGood(i))".
It Faults out every time, branching to the “fail” code, which writes NULL to the sto registers.
I am at a wall, trying to understand why this test does not result in a True state and what I might do to fix the problem.
I’ve made NO changes to the stock code, save to change the Baud Rate to 9600 for convenience.
Can anyone help me through this maze?
I’m a pretty experienced embedded developer, but unraveling this puzzle seems to be beyond me.
Any help and advice MUCH appreciated!
thanks

Use the latest code from git. You probably need the fix in PR #473. Also see issue #462.

Hi BBX, can you please tell me where I can find PR #473 and issue #462? Have no idea what location(s) you are referring to!

Thanks

The USB Host Shield library source code is on github.com. The last release was in 2018 so use the latest code which has many fixes.

https://github.com/felis/USB_Host_Shield_2.0

https://github.com/felis/USB_Host_Shield_2.0/pull/473

Well I thought I had been using the latest version from GitHub, Ver 2.0-1.3.2, which I downloaded a month ago.

It seems this was NOT the latest. I downloaded the latest as of this morning, loaded and ran the testusbFAT sketch, and it works!

So thanks very much for pointing me in the right direction! Much Obliged. Now I can integrate the routines into my main project,

which is a control interface for a PM2.5 Air Quality monitor.