Skip to content

FatFileSystem (unnecessarily) requires a minimum allocation of 64K  #4386

Closed
@NeilMacMullen

Description

@NeilMacMullen

For testing purposes, it's useful to be able to create RAM drives on smaller devices where the amount of available RAM is limited. The following code on a Nordic RF52 will show an error (-5) on the format operation. Interestingly if BLOCKS is increased to 128, the format and subsequent file operations will complete although presumably once the filesystem grows too large the system will fail unpredictably.

Target: UBLOX_EVK_NINA_B1
Toolchain: GCC_ARM
Mbed: 5.4.5

#include "mbed.h"
#include "FATFileSystem.h"
#include "HeapBlockDevice.h"

Serial pc(USBTX, USBRX);
//RF52 doesn't have 64K of RAM so try using a more sensible size....
#define BLOCKS 32
#define BLOCKSIZE 512
HeapBlockDevice bd(BLOCKS * BLOCKSIZE, BLOCKSIZE);
FATFileSystem fs("fs");

int main()
{
  pc.format(8, Serial::None, 1);
  pc.set_flow_control(Serial::RTSCTS);
  pc.baud(115200);
  int error = FATFileSystem::format(&bd);
  pc.printf("RAMdisk %d bytes, Error code from format %d\r\n", (BLOCKS*BLOCKSIZE),error);
  while (true);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions