I have an SPI flash based mp3 module and was wondering whether its possible to write to the flash chip using a microcontroller(arduino). the IC supports FAT16/FAT32 file systems. I have researched arduino and the fat file system but they are all in relation to SD cards which operate differently as far as i understand. Is it possible to write data to a fat file system on SPI flash using an arduino?

  • Isn't that SPI flash on this board already connected to the boards controller? I think SPI not multi-master capable. So you would need to disconnect the flash from the boards controller – chrisl Feb 17 at 12:49
  • yes it is. but i wanted to load new content onto it using a MCU. – user2105725 Feb 17 at 14:54
  • But that means, that the first important question is, how to communicate with the flash chip, without conflicting with the boards MCU. At that point the filesystem is irrelevant. – chrisl Feb 17 at 15:31
  • I'd thought that since its possible to write files onto the chip from a computer it might be possible to do the same thing with an external MCU – user2105725 Feb 18 at 9:42
  • Most likely the USB port connects to the boards MCU, which then in turn connects via SPI to the flash chip. So for the flash chip it is equal if you write data via USB or play music on the board. Both are only SPI communications with the boards MCU. My guess is, that you either need to extract the flash chip from the board and add some kind of multiplexer to it (so that you can switch between the SPI connections to the internal MCU and your external one), or that you need to use an USB host board with your external MCU to write data through the USB interface. – chrisl Feb 18 at 10:12

The first and most important problem is not the filesystem. Currently on the board the USB port is connected to the internal MCU, which in turn is connected via SPI to the flash chip. The internal MCU is the master on the SPI bus. But the SPI bus does not support multiple masters on one bus. So just connecting the external MCU to the SPI lines as master would not work.

I see 2 possible ways to go here:

  • You can unsolder the flash chip from the board and add a fitting multiplexer chip, which can switch the SPI lines between the two masters. That effectively gives you only one master on the SPI bus at any time. This way would be rather hacky and difficult for a beginner. It might also be important to keep an eye on the capacitance of the bus, since it might run with rather high speed. A too high capacitance (for example through using a breadboard) might result in erroneous communication.

    Then you could use one of the FAT libraries. I don't know them in detail, but I think you could also use them for a simple SPI flash chip. You just would need to implement the lower level access functions, that the FAT library needs.

  • Or you could try to use a USB host board with your external MCU and try to write data through the USB port. I don't have much experience with USB host boards, so I cannot really tell you, if and how exactly this is possible with the available hardware (the board will most likely implement an USB interface like a simple flash USB stick).

All in all I think, this would be rather hacky. Your board is not really made for changing the data through another microcontroller. Depending on what exactly you want to achieve, you might want to go to a different hardware setup.

  • Thanks very much for taking the time to answer. much appreciated. – user2105725 Feb 22 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.