I am new to embedded systems and have been trying to port over a MP3 conversion program to an ARM-based STM32L476G-DISCO development board. I'm also using the free System Workbench software based on Eclipse. I've been successful to the point that I have compiled the program and flashed it onto the board. It even runs right up to the point that the program asks for file input (.wav).
My question is how do I implement the file handling part? Previously when running the original windows console app I would just send in a command line argument like "'>C:\file.wav < C:\file.mp3".
The board comes with 128Mbit of flash memory utilizing QSPI for communications as well as internal flash. Do I need a file system to read/write a file into my program? I was thinking to start simple and just embed the file but I don't know how to call it in my code. I can program the memory manually via the programming software but again, all I know is the address of where I flashed the data.
If you have written the data to the internal flash, all you need is its address - it is no longer a "file" it can be treated as if you have read the data from the file into that location. Rather then separately programming the data from your application you could write a code generation tool that reads teh fike on teh development host and converts it to a C code data array thus:
static const uint8_t wav_file[] = { '\x00, `\x55` ...
...
... } ;
that you then compile and link to your application code.
This would then allow the linker to locate your data and avoid any issues of the application code and the data encroaching on each other. Moreover it gives toy data a symbolic start address and a size that can be determined by sizeof(wav_file)
.
You cannot however use this method if the data is stored in the external flash since that is not memory mapped. In that case the data will need to be read into RAM for processing.
If your audio library expects a file and you do not wish to modify it, then yes you need a file system. A file system is probably the simplest and safest means of managing the external flash in any case.