Ramdisk

Discussion to talk about software related topics only.
Kansuze
Posts: 7
Joined: Mon Feb 05, 2024 10:54 am

Ramdisk

Post by Kansuze »

Version 3.4:
There is an example program for using a small ramdisk and I can configure one in my software. I can format, mount a FAT file system, and change to it, but when I try to use a 2.8 MB ramdisk (medium size according to the software), the error message says the disk is too small. Really, I only need about 150k.

USE_RAM is defined
EXT_FLASH_DRV_NUM is set to F_RAM _DRIVE0
Documentation is unclear of what should be passed to f_mountfat(), f_format()

Thanks!
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Ramdisk

Post by TomNB »

What platform, and how much physical ram is on it?
Also, when you build your project, what is the ram usage?
Any dynamic allocations?
Which example are you using?
Where do you see 2.8MB in the documentation?
Which documentation is unclear on the mount and format functions?

Always need this level of detail to help on something like this, otherwise wouldn't know where to start.
Kansuze
Posts: 7
Joined: Mon Feb 05, 2024 10:54 am

Re: Ramdisk

Post by Kansuze »

MODM7AE70, 8 MB Ram of which the program uses 20% when built in debug mode. Some dynamic allocation but not at startup when I have this problem. I ran the minimalram example and then incorporated it into my code. It creates a 50k RAM disk with a FAT file system on it. The mention of 2.8 MB is within the example’s software where the mount and format functions are run, same example. They give more info than the EFFS-FAT programmer documentation. Sorry, I’m not at work so I can’t provide the exact file name.
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Ramdisk

Post by TomNB »

Thanks for that. Starting with the unmodified RamMinimal example, it is only a 1 line change. In ramdrv_mcf.cpp, set the drive size by editing the line:
const uint32_t RAMDRV0_SIZE = 0x80000; // Adjust size of ram drive here

The above 0x80000 is a 512k drive. 0x40000 would be a 256k drive.

The comment you are referring to:
/* Minumum RAM drive sizes:
* FAT12: 50KB (most commonly used)
* FAT16: 2.8MB
* FAT32: 32MB
*/

the key word is "minimum". You would need to change from FAT12 to FAT16 to go to 2.8M - 32M. You got the error with FAT12 because it could not fit your 2.8M file system. Not enough bits.
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Ramdisk

Post by TomNB »

Just one more point, the most commonly used refers to FAT12, not 50k. FAT12 goes up to 2.8M in size.
Kansuze
Posts: 7
Joined: Mon Feb 05, 2024 10:54 am

Re: Ramdisk

Post by Kansuze »

Thank you for this! The part I didn’t find at all was the RAMDRV0_SIZE. I’ll try it in the morning.

Kansuze
Kansuze
Posts: 7
Joined: Mon Feb 05, 2024 10:54 am

Re: Ramdisk

Post by Kansuze »

So… until I tried to change its size, I had a ramdisk but couldn’t tell because the DisplayEffsSpaceStats showed the total flash memory instead of the ramdisk memory. I also get the flash stats when I run the EffsFatRamMinimal example program. Is there another way to display the ramdisk stats?
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Ramdisk

Post by TomNB »

Are you seeing this in the RamMinimal example?

Or, are you saying you have both flash and ram drives in your app?
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Ramdisk

Post by TomNB »

Ah, I see you answered that already, sorry. In RamMinimal that is our fault. The RAM drive was added as an option to the flash utilities, so what you see on the serial port is incorrect. The stats are for the RAM drive. Do they match the size you set? You can see the serial printout code in FileSystemUtils.cpp. Almost no one uses a RAM drive, so I think that is why it was missed. I'll make a note to check for the drive type and adjust the messages
Kansuze
Posts: 7
Joined: Mon Feb 05, 2024 10:54 am

Re: Ramdisk

Post by Kansuze »

The display doesn't match the size of ramdisk exactly but I imagine there is some overhead. If I set it to 256k, I get 243,200.

Related to this... I was able to use ftp from my desktop computer to get a file I created on flash. Using the ramdisk instead, I can see the file is being created correctly, but with ftp, I can't see the file. Is there a different mount point for the ramdisk?
Post Reply