I currently have a design where a microcontroller reads audio data via SPI interface and writes to the SD card. I am currently generating 600KB file every minute. I am roughly writing at 10KB/sec.
I have to migrate my design to an Arduino Yun for several. I am using this Yun shield + Arduino Mega 2560 board. Since the SD card is not interfaced to the microcontroller on the Yun, I will have to write this via serial port.
I tried the File IO class of the Arduino Bridge. and it seems to be slow for requirements (it took 12 seconds to load a 40KB plugin. It takes only 2.15 seconds in my current design).
I have concluded that I have to write my own application with message header, CRC check etc at both the linux ends. I have a couple of questions:
Has someone tried writing their own UART-SD interface for the Yun? (I could avoid re-inventing the wheel)
At 115200 or 230400 bps, is it possible to write at approximately 10 kB/s with all the CRC check, message header etc?
According to the Atmega2560 datasheet, the microcontroller is capable of transmitting data via the UART interface at 1M bps when it is operated at 16 MHz. ( I have personally tried this with an Atmega328). Is the bootloader necessary for remote upload of hex files if it is compiled in Atmel studio?
Which route is better? Custom serial port API implemented in an Arduino sketch or code written in Atmel studio?
fat16lib wrote some code last summer that captures mono audio from SPI ADC and writes it to SD card at 44.1KHz rate (CD audio rate). I am going to use it capture audio samples for an electronic drum. It also can play files back from SD card at same rate.
If I can find the topic I'll post it.
[Edit]: Here it is: http://forum.arduino.cc/index.php?topic=180769.0
My Bobuino2 card started out to support that (and it will incorporate it all eventually, got usurped for more urgent needs before I had the ADC/DAC parts done). I'll add the ADC/DAC to the prototype area this summer and get back to testing. http://www.crossroadsfencing.com/BobuinoRev17/
If the interface is SPI, there may be another solution: do it all on the Linux side. I don't know about the Yun Shield, but on the actual Yun board the SPI lines from the AVR processor are also connected to the Linux processor (it's how the Linux side loads a sketch into the AVR.)
Perhaps you can just collect the data from the SPI interface directly on the Linux side, and have it write to the SD card with no serial communications needed? Here are a couple threads where one poster was able to do SPI directly from Linux:
The Dragino Yun shield's SPI lines from the AVR processor are also connected to the Linux processor (it's how the Linux side loads a sketch into the AVR.)
Perhaps you can just collect the data from the SPI interface directly on the Linux side, and have it write to the SD card with no serial communications needed? Here are a couple threads where one poster was able to do SPI directly from Linux:
What type audio data? Is it I2S (Integrated Interchip Sound) or MP3 file or analog audio with ADC/SPI interface?If file format is MP3 (average compression ratio is 10:1), generating 60KB file every minute, roughly writing at 1KB/sec.
SPI. I am using a VS1053 encoder. It is controlled via SPI.
Basic concept is first save into RAM then move to flash, It fixed overrun!!! problem, but met second bug.
arecord keep send out SIGHUP and SIGTERM signal.
It worked like a charm thanks. Thanks for the help.
I have to figure out one problem before I declare success. If I use a cheap 3.5 mm microphone (passive one), the audio is muffled. If I use a microphone like this one, the microphone heats up and there is a lot of static noise/white noise build up
I managed to fix the audio quality. It was a combination of gain adjustment + microphone adjustment. I tried 3 different types of USB audio cards. It works with only a certain type of USB audio card -- Creative Soundblaster SB1290. Thanks for your help. The idea of the USB audio card never occurred to me
I'm using Arduino Yun & a cheap USB Sound card. And for the moment a microphon plug directly to the USB Sound Card. After installing everything with the opkg command I send this command as you wrote it: