Comments (14)
Hi Manuel,
is giving me no_filesystem, because inside it when it checks the Window for 55AA,
which it's done in Initialize_FS
if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then
Status := No_Filesystem;
return;
end if;it fails since WIndow is all 0's.
The windows data should be loaded from the SDcard before the 55AA check. With this function:
Status := FS.Ensure_Block (0);
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?
from ada_drivers_library.
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
SD_Err := Read_Blocks_DMA
(This,
Block_Number * UInt64 (This.Info.Card_Block_Size),
Data);
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.
from ada_drivers_library.
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
Disk /dev/sde: 1.9 GiB, 2002780160 bytes, 3911680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xaf10b81b
Device Boot Start End Sectors Size Id Type
/dev/sde1 * 2048 3911679 3909632 1.9G c W95 FAT32 (LBA)_
from ada_drivers_library.
inside the function Read of stm32_sdmmc.adb the call
SD_Err := Read_Blocks_DMA (This, Block_Number * UInt64 (This.Info.Card_Block_Size), Data);
I think it should always be Block_Number * 512
here. There's a disconnect between SDcard and HAL.Block_Drivers' definition of a block.
from ada_drivers_library.
I fix that value to 512 to test and I am getting an exception
In last chance handler
Unhandled Ada Exception: CONSTRAINT_ERROR
Message: file_io.adb:493 range check failed
Call stack traceback locations:
seems the Length value is also disconnected?
from ada_drivers_library.
I think that's another problem, what is the content and length of Path string?
from ada_drivers_library.
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.
from ada_drivers_library.
Maybe revert the changes you made in the Filesystem.MBR.Read function:
function Read
(Controller : HAL.Block_Drivers.Any_Block_Driver;
MBR : access Master_Boot_Record)
return File_IO.Status_Code
is
-- Tmp : aliased Master_Boot_Record;
Ptr : constant Master_Boot_Record_Access := MBR.all'Unchecked_Access;
Data : aliased HAL.UInt8_Array (1 .. 512) with Address => Ptr.all'Address;
-- Data : aliased HAL.UInt8_Array (1 .. 512) with Address => Tmp'Address;
begin
-- Let's read the MBR: located in the first block
if not Controller.Read (0, Data) then
return File_IO.Disk_Error;
end if;
-- MBR := Tmp; -- This was not working at all
if MBR.Signature /= 16#AA55# then
return File_IO.No_MBR_Found;
end if;
return File_IO.OK;
end Read;
It looks like it's messing with the stack...
from ada_drivers_library.
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
Unhandled Ada Exception: CONSTRAINT_ERROR
Message: demos.adb:188 discriminant check failed
Call stack traceback locations:
The code at line 188 is
Am I missing something here on this demo?
Please let me know,
from ada_drivers_library.
Hi @mhanuel26, where is the line 188 here?
from ada_drivers_library.
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?
from ada_drivers_library.
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 Name_Length
which is the number of characters in the entry name.
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 E
if the value of the discriminant is the same. The exception message that you see (Constraint_Error
) comes from the fact that you are trying is assign a new value with a different discriminant.
But you don't know that before actually calling the Read()
function, so the solution is to declare a new Directory_Entry every time. For instance like this:
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?
from ada_drivers_library.
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
SDcard size: 988 MB
Error when mounting the sdcard:NO_MBR_FOUND
from ada_drivers_library.
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
from ada_drivers_library.
Related Issues (20)
- Access to FE310-specific performance counters HOT 10
- FE310-specific performance counters HOT 1
- install_dependencies.py appears to be broken HOT 2
- Some examples do not build HOT 6
- Support LSM303AGR for newer micro:bit hardware revisions HOT 1
- Target not found for Micro:Bit with Debian Linux HOT 3
- Project Wizard doesn't generate startup files HOT 3
- Include directions in examples/README.md to have compatible versions of bb-runtimes and compiler
- Support for Adafruit Feather M0 board HOT 3
- mma8653 initialization fails on MicroBit HOT 21
- EXAMPLES: Installing run-time dependencies fails with both Python 2 and Python 3 on Linux HOT 2
- Make HAL packages preelaborable HOT 1
- I2C HAL ideas HOT 15
- Many warnings with GCC 12 HOT 2
- RISC-V requires "zicsr" ISA extension to build with FSF GNAT 12.1.1 HOT 11
- IO expander MCP23x08 reports GPIO mode always as Output HOT 1
- Support for STM32F411CEU6 board HOT 1
- Extension zicsr required in HiFive1_rev_B board
- Microbit.Time resets the board
- How to get the toolchain up and running? HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ada_drivers_library.