-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fat Filesystem return no_filesystem even when reading the MBR #220
Comments
Hi Manuel,
The windows data should be loaded from the SDcard before the 55AA check. With this function: It looks like there's a problem with SDcard reads here. Maybe it's an optimization or a cache problem. Which board are you using? |
Hello Fabien, I have found that the function you mention Status := FS.Ensure_Block (0); is working fine, but I suspect that the block size is not correct, inside the function Read of stm32_sdmmc.adb the call
when it was failing I found that the Card_Block_Size was set to 1024, I change it manually to 512 during a debug session and it worked, at least to read the disk_parameters, after that it fills up correctly , please see the attached picture I am still trying to figure out why it was 1024 and not 512. I am using STM32F769-DISC. |
I actually found that the block size it's been set to 1024 in the function Compute_Card_Block_Size, not sure if it's ok since the comparison if clause return 2 ** 10, where the 10 comes from the Max_Read_Data_Block_Length, but I am not sure if that is some default value, I am using a 2 GB sd card, the fdisk print partition of the card is _Command (m for help): p Device Boot Start End Sectors Size Id Type |
I think it should always be |
I think that's another problem, what is the content and length of Path string? |
Well, It's actually undefined, I did some trace about it, my calling function is Status := Mount_Drive ("sdcard", STM32.Board.SDCard_Device'Access); when it first enters there Mount_Point has the "sdcard" value, but after the Read is done it become Unknown, perhaps some memory overlapping, really don't know. Attached are some self explained screenshots of before and after read is done. Of course when it enter Mount_Volume it is Unknown as well. |
Maybe revert the changes you made in the Filesystem.MBR.Read function:
It looks like it's messing with the stack... |
Hi Fabien, I did it and now it seems to Mount the Drive correctly, at least it return ok, but now I am trying to print the directory contents as this example code but it's giving me the following exception In last chance handler The code at line 188 is Am I missing something here on this demo? Please let me know, |
Hi @mhanuel26, where is the line 188 here? |
Hi @Fabien-Chouteau, I didn't notice the line was not clear, the line 188 is E := Read (Dir); Have you test the SD card on a STM32F769I board? |
Hi @mhanuel26, I don't remember trying specifically on the STM32F769I but I see what the problem is here. Directory_Entry is a record with a discriminant, here it's type Directory_Entry (Name_Length : Natural) is record
Name : String (1 .. Name_Length);
Subdirectory : Boolean;
Read_Only : Boolean;
Hidden : Boolean;
Symlink : Boolean;
Size : File_Size;
end record; You can only assign a new value to But you don't know that before actually calling the loop
declare
E : constant Directory_Entry := Read (Dir);
begin
exit when E = Invalid_Dir_Entry;
-- Use the directory entry here
end;
end loop; This example, needs to be included in the doc: https://github.com/AdaCore/Ada_Drivers_Library/blob/master/docs/filesystem.md Can you try with this loop and tell me if that solves your problem? |
Hi @Fabien-Chouteau, At least the Constraint_Error seems to be fixed but now I am getting NO_MBR_FOUND after Mount_Volume. I have created the SD card following this guide https://www.pcworld.com/article/3176712/linux/how-to-format-an-sd-card-in-linux.html and has some directories and files on it to test. The Sd card is 1GB, here is the openOcd console output SD card is present |
This sounds like the problem you described before. What is the content of the fist data block? BTW, the doc is updated: https://github.com/AdaCore/Ada_Drivers_Library/blob/master/docs/filesystem.md |
I have a hard time to make the sd card Mount_Drive function to work.
The sd card is reading Ok since the snippet code to read it's size and MBR does it correctly, i.e. this snippet prints the 2GB size of my sd card.
Then I call
Status := Mount_Drive ("sdcard", STM32.Board.SDCard_Device'Access);
Inside the Mount_Drive, the function read
Status := Read (Device, MBR);
was returning OK but actually the MBR variable was all in 0's, so I did some debugging and determine that inside the function the assignment was not execute correctly, that is the line
MBR := Tmp; so I rewrite the function a little bit
Notice that I am using an access for MBR, so the calling function change to
Status := Read (Device, MBR'Access);
after that I can read the MBR correctly and it pass the sanity checks
but then in function function Mount_Drive, the call to
is giving me no_filesystem, because inside it when it checks the Window for 55AA,
which it's done in Initialize_FS
it fails since WIndow is all 0's.
I guess the following call done prior to the Open call
FAT_FS := new FAT_Filesystem;
should have read or set that Window "data".
The text was updated successfully, but these errors were encountered: