Problems adding functions to RamDisk

I'm using the example sketch RamDiskToSdFat and converting some of that code into functions. I created three functions: setupRam, writeToRam and saveToSD. When I run this sketch (with n = 8000), the SD file is limited to 125kB. That means only one of the two ram chips are used.

Any idea what I'm doing wrong?

// Create a text fine on the RamDisk an then copy the file to an SD.
// Warning this requires a new test version of SdFat.

#include <SdFat.h>
#include <SdFatUtil.h>
#include <RamDisk.h>
#include <M23LCV1024.h>
#include <RTClib.h>
#include <Wire.h>


//void setupRAM (void);
//void writeToRam (void);
//void saveToSD (void);
//void dateTime (uint16_t* , uint16_t*);

// Multiple SRAM chips so use CS pin list.
uint8_t csPins[] = {9,8};
const uint8_t CHIP_COUNT = 2;
M23LCV1024 ram;

#define FILENAME "TEST.CSV"
const uint8_t SD_CS_PIN = SS;


SdFat sd;
SdBaseFile sdFile;
RamVolume vol;
RamFile ramFile;
char buf[40];
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
 
  setupRAM();
  writeToRam();
  saveToSD(); 
 
}
void loop() {}

//---------------------------------------------------------------------------------
void setupRAM(){ 

  ram.begin(csPins, CHIP_COUNT);
  
  Serial.print(F("FreeRam: "));
  Serial.println(FreeRam());
  if (!sd.begin(SD_CS_PIN)) sd.errorHalt();
 

    if (!vol.format(&ram, 256, 4, 1)) {
      Serial.println(F("format fail"));
      return;
    }
  if (!vol.init(&ram)) {
    Serial.println(F("init fail"));
    return;
  }
    // Remove old version.
  vol.remove(FILENAME);
  if (!ramFile.open(FILENAME, O_CREAT | O_RDWR)) {
    Serial.println(F("open fail"));
    return;
  }
}
  
/*
  Wire.begin();                            // add time stamp
  if (!RTC.begin()) {
    Serial.println("RTC failed");
    while(1);
  }
 
  SdFile::dateTimeCallback(dateTime);             // set date time callback function
  sprintf(FILENAME, "run_%d.CSV", fileNum);
  vol.remove(FILENAME);                           //format
   if (!ramFile.open(FILENAME, O_CREAT | O_RDWR)) {
    Serial.println(F("open fail"));
    return;
  }
  Serial.println(F("Ready to write ramFile"));
  
}
*/
//----------------------------------------------------------------------------
void writeToRam(){
Serial.println(F("Writing ramFile"));
  uint32_t m0 = micros();
  for (int i = 0; i < 8000; i++) {
    ramFile.print(micros() - m0);
    ramFile.write(",Line,");
    ramFile.println(i);
  }
}

//--------------------------------------------------------------------------------
void saveToSD()
{
    // like closing and opening file (need to update dir for ls).
  ramFile.sync();
  ramFile.rewind();
  
  vol.ls(&Serial, LS_DATE | LS_SIZE);

  if (!sdFile.open(FILENAME, O_CREAT | O_RDWR | O_TRUNC)) {
    Serial.println(F("sdFile.open failed"));
    return;
  }
  Serial.println(F("Copying ramFile to sdFile"));
  int n;
  while ((n = ramFile.read(buf, sizeof(buf))) > 0) {
   
    if (sdFile.write(buf, n) != n) {
      Serial.println(F("sdFile.write failed"));
      return;
    }
  }
  ramFile.close();
  sdFile.close();
  sd.ls(&Serial, LS_DATE | LS_SIZE);

  Serial.println(F("Done"));
}

//----------------------------------------------------------------------------------
/*
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = RTC.now();

  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}
*/

Thanks
Gerry

    if (!vol.format(&ram, 256, 4, 1)) {
      Serial.println(F("format fail"));
      return;
    }

This says use 256 blocks of ram, allocate 4 blocks for directory, and cluster size of 1 block.

You probably should just use the defaults.

    if (!vol.format(&ram)) {
      Serial.println(F("format fail"));
      return;
    }

This will use all blocks, allocate at least four blocks for directory, and use a cluster size of one.

Thanks again. That fixed the problem.

Gerry