Subject : Adafruit flash(XTSD04GLGEAG) not appearing as usb msc(Mass Storage Class) in Arduino Ide

(My Specs)
→ Controller - esp32-s3-wroom-2-n32r8v
→ IDE - Platformio
→ Adafruit flash - XTSD04GLGEAG
→ Operating system - UBUNTU

I am trying to implement usb msc with esp32s3-wroom2 controller with Adafruit flash(XTSD04GLGEAG). Below is the listed Platform.ini file and Code for the same.
According to the given code , the flash is appearing as mass storage class , but my files are getting corrupted and after unplugging and plugging it again , I am not able to open those files .
What I want is to run this code to open my adafruit flash as msc and I should be able to drag , drop , open and delete files , without the files getting corrupted.

I have also attached image to provide more insights on that.

  1. img1 shows the files , that are being stored in adafruit flash.
  2. img2 show the img file that I have opened showing source file is missing.

(My Platform.ini file)

platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
board_build.flash_mode = dio
build_flags =
lib_deps = chegewara/ESP32TinyUSB@^2.0.2

(My Platformio Code)

#include <Arduino.h>

 * Simple MSC device with SD card
 * author: chegewara
#include "sdusb.h"

#define SD_MISO  13
#define SD_MOSI  11
#define SD_SCK   12
#define SD_CS    10

SDCard2USB dev;

void setup()

  if(dev.initSD(SD_SCK, SD_MISO, SD_MOSI, SD_CS))
    if(dev.begin()) {
      Serial.println("MSC lun 1 begin");
    } else log_e("LUN 1 failed");
  } else Serial.println("Failed to init SD");

  // test();

void loop()



Does it work in the Arduino IDE?

Well , in both platformio and Arduino Ide , the code functions in a similar way . It is allowing me to see the files but thats it , whenever I am opening it , it says the source file is missing .

Good, if it also fails in the Arduino IDE, the people at will be able to help you.

Can you please guide me further on this topic , on how to solve this issue ?