some background to my story to begin with: I went to a store and asked for a bluetooth fm transmitter for my car and the guy sold me something that only plays from an SD card and I didn't even bother to check it. So I'm sitting here trying to hack it into playing audio from bluetooth. I thought that it would use an ic to read from the SD and export audio into another ic that sends the sound to the fm antenna but as it turns out it uses a single ic for everything (even for driving the little LCD screen). So I thought that I could emulate an SD card with a microcontroller or even better a RaspberryPi and dynamically change the contents of the "SD" on the go. I remembered that when I was trying out online streaming sound my software created an mp3 file that continued writing the currently streaming audio and in that way it kept playing. So if I could "stream" a file like that into the emulated SD card and have my little FM transmitter play it I could actually create a little radio station for my car. Is something like that possible? How could I emulate an SD?
closed as too broad by Chris Stratton, JRE, Finbarr, Lior Bilia, Sparky256 Jan 2 at 22:40
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Is something like that possible?
Not with any arduino compatible MCUs or the Raspberry Pi. To properly emulate a card you would need to support the SD protocol in one-bit mode up to 25MHz - waaay too fast for any microcontroller without special hardware support. No arduino is known to have this hardware.
It might be just doable with an FPGA - but the required SD specs are not exactly open, either.
Emulating a raw SD/MMC interface is not the base problem for you. Creating a hardware interface is relatively easy and there are multiple FPGA implementations out there. If your player can read V1.0 SD cards, then you can run 1 lane at 12.5Mhz, which could easily use something like an Arduino SPI interface. Raspberry Pi would be a greater challenge, though you might be able to boot from USB and hack the SD card interface (a huge low level driver challenge) hardware.
The real problem (after you've built the raw interface) is that you have media which is dual access with no way to sync the contents for the player side.
- The device you plug the SD card into (emulated or not) will read the card and probably hold some small part of the file system metadata in ram as it functions. In your case the player only reads from the SD card, but even so it will have to manage streaming the file system segments into memory to play the music.
- You want to come behind the scenes and dynamically add data to the file system, but the player does not know the file system is changing.
If you were to dynamically load data on your dual port SD card emulator, you'd have to fake an eject/insert to get the player to re-read the filing system. That would be possible but again you are left with the potential for misreading if you alter the FS content unknown to the reader.
You could be incredibly lucky and the player holds almost no file system metadata in ram, so does re-read and scan the FS directory for each item it plays. You could ascertain this by monitoring the reads to the SD card. Following the command structure is quite a task on it's own, and not doable without a logic analyzer.
There is help, and you could start here for a simple view of the transactions.