RaspberryPi 3 A+ not recognizing USB Drives

Think you found a bug? Report it here.
_Tropo
Posts: 52
Joined: Tue Mar 20, 2018 1:01 pm
Location: Germany

RaspberryPi 3 A+ not recognizing USB Drives

Postby _Tropo » Tue Jul 09, 2019 8:54 am

Hey,

i was trying to move my project from a rpi3B to a rpi3A+ and apparently, the rpi3A+ does not recognize the USB Memory Stick that's plugged in. To make sure it wasn't a mistake in my code, i took the FileHandling example, included the RaspberryPi3 unit in uses and changed all "C:/" to "D:/" in the code. This runs just fine on a rpi3B and finds the USB Drive right away, but when i test it on the rpi3A+ (using the same SD cart and USB Stick), it doesn't find any D:/ Drive. I tried multiple memory sticks.

One thing that might be connected somehow: I'm on Linux and instead of updating the RTL (there is no "update RTL" option in the Linux version in the IDE under Tools, since i think it's not the "Ultibo Version"), i installed the latest ultibo core to another Location, hoping to not mess up my working ultibo version in case something goes wrong. After starting the newly installed second Lazarus, i had to change the paths to the new ultibo version under Tools/Settings/Environment. Once done, the rpi3A+ was booting with my project, it just doesn't find any USB Drive.

here's the modified FileHandling example:

Code: Select all

program FileHandling;

{$mode objfpc}{$H+}

{ Example 08 File Handling                                                     }
{                                                                              }
{  This example demonstrates just a few basic functions of file handling which }
{  is a major topic in itself.                                                 }
{                                                                              }
{  For more information on all of the available file function see the Ultibo   }
{  Wiki or the Free Pascal user guide.                                         }
{                                                                              }
{  To compile the example select Run, Compile (or Run, Build) from the menu.   }
{                                                                              }
{  Once compiled copy the kernel7.img file to an SD card along with the        }
{  firmware files and use it to boot your Raspberry Pi.                        }
{                                                                              }
{  Raspberry Pi 3B/3B+/3A+ version                                             }
{   What's the difference? See Project, Project Options, Config and Target.    }

{Declare some units used by this example.}
uses
  GlobalConst,
  GlobalTypes,
  Platform,
  Threads,
  Console,
  Framebuffer,
  BCM2837,
  SysUtils,
  Classes,     {Include the common classes}
  FileSystem,  {Include the file system core and interfaces}
  FATFS,       {Include the FAT file system driver}
  MMC,         {Include the MMC/SD core to access our SD card}
  BCM2710,     {And also include the MMC/SD driver for the Raspberry Pi}
  RaspberryPi3;

{A window handle plus a couple of others.}
var
 Count:Integer;
 Filename:String;
 SearchRec:TSearchRec;
 StringList:TStringList;
 FileStream:TFileStream;
 WindowHandle:TWindowHandle;


begin
 {Create our window}
 WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);

 {Output the message}
 ConsoleWindowWriteLn(WindowHandle,'Welcome to Example 08 File Handling');
 ConsoleWindowWriteLn(WindowHandle,'');

 {We may need to wait a couple of seconds for any drive to be ready}
 ConsoleWindowWriteLn(WindowHandle,'Waiting for drive D:\');
 Count := 0;
 while not DirectoryExists('D:\') do
  begin
   {Sleep for a second}
   Sleep(1000);
   Inc(Count);
   ConsoleWindowWriteLn(WindowHandle,'failed Try: ' + IntToStr(Count));
  end;
 ConsoleWindowWriteLn(WindowHandle,'D:\ drive is ready');
 ConsoleWindowWriteLn(WindowHandle,'');

 ConsoleWindowWriteLn(WindowHandle,'Contents of drive D:\');

 {To list the contents we need to use FindFirst/FindNext, start with FindFirst}
 if FindFirst('D:\*.*',faAnyFile,SearchRec) = 0 then
  begin
   {If FindFirst succeeds it will return 0 and we can proceed with the search}
   repeat
    {Print the file found to the screen}
    ConsoleWindowWriteLn(WindowHandle,'Filename is ' + SearchRec.Name + ' - Size is ' + IntToStr(SearchRec.Size) + ' - Time is ' + DateTimeToStr(FileDateToDateTime(SearchRec.Time)));

   {We keep calling FindNext until there are no more files to find}
   until FindNext(SearchRec) <> 0;
  end;

 {After any call to FindFirst, you must call FindClose or else memory will be leaked}
 FindClose(SearchRec);
 ConsoleWindowWriteLn(WindowHandle,'');

 {Let's try creating a file and writing some text to it, we'll assign our filename
  to a variable.}
 Filename:='D:\Example 08 File Handling.txt';

 {We should check if the file exists first before trying to create it}
 ConsoleWindowWriteLn(WindowHandle,'Checking to see if ' + Filename + ' exists');
 if FileExists(Filename) then
  begin
   {If it does exist we can delete it}
   ConsoleWindowWriteLn(WindowHandle,'Deleting the file ' + Filename);
   DeleteFile(Filename);
  end;

 {Now create the file, let's use a TFileStream class to do this. We pass both the
  filename and the mode to TFileStream. fmCreate tells it to create a new file.}
 ConsoleWindowWriteLn(WindowHandle,'Creating a new file ' + Filename);
 {TFileStream will raise an exception if creating the file fails}
 try
  FileStream:=TFileStream.Create(Filename,fmCreate);

  {We've created the file, now we need to write some content to it, we can use
   a TStringList for that but there are many other ways as well.}
  StringList:=TStringList.Create;

  {Add some text to our string list}
  StringList.Add('Example 08 File Handling');
  StringList.Add('This is a test file created by the example');
  StringList.Add('Here is a another line of text as well.');

  {Since TStringList has a SaveToStream method, we can just call that to write
   all the strings to our new file.}
  ConsoleWindowWriteLn(WindowHandle,'Saving the TStringList to the file');
  StringList.SaveToStream(FileStream);

  {With that done we can close the file and free the string list}
  ConsoleWindowWriteLn(WindowHandle,'Closing the file');
  ConsoleWindowWriteLn(WindowHandle,'');
  FileStream.Free;
  StringList.Free;

  {Did it work? Let's open the file and display it on screen to see.}
  ConsoleWindowWriteLn(WindowHandle,'Opening the file ' + Filename);
  try
   FileStream:=TFileStream.Create(Filename,fmOpenReadWrite);

   {Recreate our string list}
   StringList:=TStringList.Create;

   {And use LoadFromStream to read it}
   ConsoleWindowWriteLn(WindowHandle,'Loading the TStringList from the file');
   StringList.LoadFromStream(FileStream);

   {Iterate the strings and print them to the screen}
   ConsoleWindowWriteLn(WindowHandle,'The contents of the file are:');
   for Count:=0 to StringList.Count - 1 do
    begin
     ConsoleWindowWriteLn(WindowHandle,StringList.Strings[Count]);
    end;

   {Close the file and free the string list again}
   ConsoleWindowWriteLn(WindowHandle,'Closing the file');
   ConsoleWindowWriteLn(WindowHandle,'');
   FileStream.Free;
   StringList.Free;

   {If you remove the SD card and put in back in your computer, you should see the
    file "Example 08 File Handling.txt" on it. If you open it in a notepad you should
    see the contents exactly as they appeared on screen.}
  except
   {TFileStream couldn't open the file}
   ConsoleWindowWriteLn(WindowHandle,'Failed to open the file ' + Filename);
  end;
 except
  {Something went wrong creating the file}
  ConsoleWindowWriteLn(WindowHandle,'Failed to create the file ' + Filename);
 end;

 {Halt the thread}
 ThreadHalt(0);
end.
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby Ultibo » Wed Jul 10, 2019 7:22 am

_Tropo wrote:i was trying to move my project from a rpi3B to a rpi3A+ and apparently, the rpi3A+ does not recognize the USB Memory Stick that's plugged in. To make sure it wasn't a mistake in my code, i took the FileHandling example, included the RaspberryPi3 unit in uses and changed all "C:/" to "D:/" in the code. This runs just fine on a rpi3B and finds the USB Drive right away, but when i test it on the rpi3A+ (using the same SD cart and USB Stick), it doesn't find any D:/ Drive. I tried multiple memory sticks.

Hi _Tropo,

We've tested using your modified example and it works everytime on a Pi 3A+, one thing we did notice was if you boot the 3A+ with the USB stick attached it will always appear as C:\ (and the SD Card will be D:\) but the example is still able to find D:\ drive.

Can you test two things:

1. Insert the USB stick after booting the example so it will definitely find the SD card first, it should recognize it almost immediately after you plug it in.

2. Try running the Ultibo Demo and plug a USB stick in at the end of the demo when the logging window is displayed on screen. It should show some activity when the stick is inserted and no errors should be visible in the log window.
Ultibo.org | Make something amazing
https://ultibo.org
_Tropo
Posts: 52
Joined: Tue Mar 20, 2018 1:01 pm
Location: Germany

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby _Tropo » Wed Jul 10, 2019 2:16 pm

Ultibo wrote:1. Insert the USB stick after booting the example so it will definitely find the SD card first, it should recognize it almost immediately after you plug it in.

2. Try running the Ultibo Demo and plug a USB stick in at the end of the demo when the logging window is displayed on screen. It should show some activity when the stick is inserted and no errors should be visible in the log window.


Ok, did that. Plugging in the USB after boot up didn't work as well (already tried that before posting yesterday, but confirmed it again now) and the log window does indeed show errors! Here's a link to the photograph i took of the screen with the error message it shows. I tried 2 different sticks (All of them from SanDisk, but different kinds and capacity) and the errors are always the same, just the adresses in the beginning of each line are different each time.

https://imgur.com/h7SvSOY

(Can't upload to Forum directly, it says "Error, File too large" even though it's only 0.7mb...)

The only thing i could still imagine to be the problem, is that I power the rpi from a power bank. But it is supposed to be able to put out 2.4A, which i think should be more than enough, especially since this works perfectly on the rpi3B... But maybe something prevents the rpi3A+ to provide the USB with enough power, which is done differently on the rpi3B (hardware wise). But that doesn't seem too plausible to me. Plus, i tried it with one of those Samsung USB Plugs to charge your phone, since i don't have any "proper" rpi power supply lying around right now (think those can go up to 5A?). It gives the same result. But those can only put out 1.5A, so maybe that is the problem. Maybe i can get my hands on a rpi power supply tomorrow and try that.
But if that's not the problem, i guess my rpi3A+ is faulty... ?
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby Ultibo » Thu Jul 11, 2019 12:23 am

_Tropo wrote:Ok, did that. Plugging in the USB after boot up didn't work as well (already tried that before posting yesterday, but confirmed it again now) and the log window does indeed show errors! Here's a link to the photograph i took of the screen with the error message it shows. I tried 2 different sticks (All of them from SanDisk, but different kinds and capacity) and the errors are always the same, just the adresses in the beginning of each line are different each time.

Okay so that definitely explains why the disk doesn't appear as D:\ or C:\ etc, normally failure to read the start of the device descriptor (which is almost the first thing to happen when a device is detected) is due to some sort of communications failure.

I probably should have also asked you in my last post if you can try plugging a hub into the 3A+ to see if that is recognized and if so does the USB disk work when plugged into the hub. If you don't have a hub do you have any other devices like a keyboard or mouse that you could try plugging in while the logging window is visible in the demo to see if you get the same or similar errors.

_Tropo wrote:But if that's not the problem, i guess my rpi3A+ is faulty... ?

It's one possibility but it is also hard to prove so you need to test as many other things as you can. I doubt the power supply is a problem since the 3A+ draws less current than the 3B but it is still worth trying another power supply if you can.

I'd also be interested in what version (or date) the firmware you are using is (start.elf, fixup.dat, bootcode.bin) and if you have any other files on the SD card apart from those (and the kernel7.img). We haven't tested the very recent releases of the firmware yet (last few weeks) because there seems to have been quite a few issues reported with Pi 4 related changes causing failures for other models.

Since the same problem occurs with both your application and the demo that should rule out any problem with your compiler or setup, is there anything else about your test setup that might be unusual?
Ultibo.org | Make something amazing
https://ultibo.org
_Tropo
Posts: 52
Joined: Tue Mar 20, 2018 1:01 pm
Location: Germany

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby _Tropo » Thu Jul 11, 2019 12:20 pm

Ultibo wrote:I probably should have also asked you in my last post if you can try plugging a hub into the 3A+ to see if that is recognized and if so does the USB disk work when plugged into the hub. If you don't have a hub do you have any other devices like a keyboard or mouse that you could try plugging in while the logging window is visible in the demo to see if you get the same or similar errors.

Unfortunately i don't have an USB hub available right now. But i plugged in a mouse and also a keyboard and got the same errors (failed to read start of device descriptor: ...)

Ultibo wrote:I doubt the power supply is a problem since the 3A+ draws less current than the 3B but it is still worth trying another power supply if you can.

That's what I'm thinking as well. The lower current draw of the 3A+ is the reason i want to switch, hoping to squeeze out a a few more hours of runtime with the powerbanks i'm using. And as expected, i tried it with a rpi "brand" power supply just now, and the errors remain the same.

Ultibo wrote:I'd also be interested in what version (or date) the firmware you are using is (start.elf, fixup.dat, bootcode.bin) and if you have any other files on the SD card apart from those (and the kernel7.img). We haven't tested the very recent releases of the firmware yet (last few weeks) because there seems to have been quite a few issues reported with Pi 4 related changes causing failures for other models.

I downloaded the firmware from the github on June 17th, which should have been a few days before the rpi4 came out, so it should be fine. But with the demo you provided, i simply copied everything, so that runs with the firmware you put in it. There are no extra files on the SD card, except for some .Trash... folder which should be present on any SD card where something was deleted.
When i run my project, there is a config.ini file present on the sd card and in case no USB Drive is found, a data folder is created where a lot of binary data is written to (it's still the - now slightly more advanced, but not much - data acquisition system you helped me so much to set up last year, if you remember. Thanks for that once more!). But since your demo doesn't have any of that, it can't be related.

Ultibo wrote:... is there anything else about your test setup that might be unusual?

No, nothing i can think of. Right now it's just the bare 3A+ with only the SD card with nothing but your demo on it and a HDMI to VGA cable that connects to the second input of the screen, so i can just switch the input to the rpi without switching the cables on the screen constantly.

EDIT: I found a USB hub with a separate power supply. No change. When i connect the hub when the log screen is up, it shows the same errors. So naturally, no usb device that i connect to the hub causes any log event. When i connect the usb hub before booting, it obviously also doesn't show any events when i connect something to it when the log screen is up.
This really seems like the usb port is broken to me...
Last test that comes to my mind, is to throw raspian on an sd card and boot the 3A+ to see if the USB is working there, which i really would not expect. Will try to do that tomorrow.
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby Ultibo » Fri Jul 12, 2019 12:03 am

_Tropo wrote:EDIT: I found a USB hub with a separate power supply. No change. When i connect the hub when the log screen is up, it shows the same errors. So naturally, no usb device that i connect to the hub causes any log event. When i connect the usb hub before booting, it obviously also doesn't show any events when i connect something to it when the log screen is up.
This really seems like the usb port is broken to me...
Last test that comes to my mind, is to throw raspian on an sd card and boot the 3A+ to see if the USB is working there, which i really would not expect. Will try to do that tomorrow.

That's about the only other thing I can suggest as well, if Raspbian works (or doesn't work) then at least that should give a definite answer and somewhere to go next.

If anyone else has a 3A+ available and is willing to test plugging in a USB stick using either the Ultibo demo or the modified example posted earlier in this thread then it would be great to hear your results, so far our 3A+ works and the one that _Tropo has doesn't so that's 50/50 at the moment.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby Gavinmc42 » Fri Jul 12, 2019 2:39 am

Just tested brand new still in box 3A+.
New uSD and new USB sticks with new Buster.
Everything works including booting from USB stick in the Dell monitor USB hub.

Have not tested Ultibo kernels yet.
_Tropo
Posts: 52
Joined: Tue Mar 20, 2018 1:01 pm
Location: Germany

Re: RaspberryPi 3 A+ not recognizing USB Drives

Postby _Tropo » Fri Jul 12, 2019 11:09 am

I won't be able to test with Raspbian before Monday unfortunately, but i will report back once done. I'm still pretty sure the USB port is simply broken, especially since you're 3A+ doesn't show any problems.

Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 0 guests