512MB flash card that looks like SD to ESP32

Hi Pimoroni Support. I bought this cool 512MB flash chip that pretends to be an SD card. I can’t find any documentation about how to copy files onto it. I have some 50MB wav files to store on it. I’m using a Beetle ESP32-C3 dev board. Thanks!

The article on adafruit website doesn’t address the problem.

You need firmware that supports mounting of SD-cards. I know that CircuitPython does, but there is also an Arduino-lib for that if you prefer C++.

Read the text of the product you linked to, you will find two links there. The second link has sample code, and it also shows how to do that using micropython.

Ok, thanks. So looks like if I install Circuit Python and the SD module, mount the file system for Circuit Python and the 512MB flash card and then I can copy directly from desktop to the flash chip, is that right?

After transferring the files I’ll then need to go back to the C++ boot loader (which as I have discovered is simply upload the C++ sketch from Arduino IDE).

Would be good if Arduino IDE had an extension or tool to copy files directly to an SD card connected to the ESP32, does such a thing exist?

Install Circuit Python to Beetle ESP32-C3

Circuit Python SD Module

It is not that easy, because the sd-mount is only visible from within the device (it is not a fileserver after all). So you also need some program logic that receives data (e.g. from serial or from wlan) and writes these bytes to a file in the filesystem of the sd-card.

The problem with this flash-device is, that you cannot just insert it into a card-reader attached to a computer. So reading/writing direct from your programs is easy (all libraries are available), but getting files in and out from outside is more involved. You should search the web for arduino and sd-card, there are some examples available where the arduino is a web-server serving files on the sd-card. I think this could be adapted to not only download files (arduino->pc) but also upload files.

To be honest, given your use case you might find it easier just to get an SD card adapter, which would then allow you to use a regular microSD card, put your files on it and pop it in the adapter.

As the flash card presents as a standard SD card, you logic on the microcontroller would remain the same.

(the other alternative, as discussed on Discord, is to add logic to your microcontroller to present itself as a USB drive mount, but you would then have to integrate that with whatever other code you’re running there)

I was going to see if ElegantOTA can be enhanced to upload to SD as well as internal ESP32 flash as it does now.

You’re right of course. I have been using a blue adafruit SD board but it is quite big for my use-case - inside a gopro case. I have a second smaller one to try now which is almost the size of the microsd card. The advantage of the flash chip is it’s a bit smaller than this even.

That’s an interesting library, and certainly a different approach; you’d basically just have to replace the Update stuff with writes to the SD card (although I’m not sure what the web stack would make of huge files running through it…)

Is your ultimate application C++ or {Micro|Circuit}Python based? If it’s C++ I might be able to retrofit some of my Pico stuff to do the mass storage stuff on an ESP32 (it’s all just tinyusb at the end of the day) but obviously that doesn’t help much in the pythonesque world!

Thanks for your kind offer. Yes, my 4 microcontrollers for this project are running c++. Only the audio module is looking for large files support at present. In case you’re interested I’m documenting everything (eventually) at Mark B Jones's Profile | Hackaday.io

i can’t add a third url… you can find my youtube channel by searching ‘youtube scuba hacker’

I’ve found a solution which installs an FTP server to the ESP32, files can then be uploaded directly to the SD card using the FileZilla FTP client on the PC. I’m using the SimpleFTPServer library and have changed the default storage type for ESP32 from STORAGE_FFAT to STORAGE_SD in line 63 of this file:


more info: