Sampler - writing to the internal Flash and other crazy things.

Ok, so I read that it IS possible to write to the flash area in real-time, its slow, but its possible, that's what the bootloader actually does.

So, I was just daydreaming of a small sampler using the arduino. I already did a 6 voice drum playback from flash in the following project, and it works great. (8 bit, mono one shot samples read from the flash) https://github.com/Beat707/BeatVox

But what if I could change all samples by reading from a SD card and replacing the flash contents? Of course, we couldn't do too many times, as the flash can be written only 100,000 times, so its more like during a live performance, you would change all drum sounds once or twice, so it should be ok. Even if you did 10 changes every single day, you would end up with 27 years total. :wink:

But, I couldn't figure out yet how to handle this flash programming thing. From what I could see, the best thing would be to have a buffer set in the flash, and know the address and size of this buffer, so its always fixed, and use that. Something like that.

I know that the process would be slow, to read from the SD and re-flash this area, but time wouldn't be a big issue. As long as it wouldn't take more than a minute, of course, but I doubt, since flashing the BeatVox + samples at a 30k of flash doesn't take a minute with a Due.2009 card, and its just a few seconds with an Uno card.

Has anyone created a nifty library for doing this?

Anyway, just a crazy idea. :wink:

Best Regards, WilliamK

The big problem with having your sketch make changes to FLASH is that only code running in the protected BOOTLOADER area is allowed to write to FLASH. The easiest way to do this would be a callable function in the bootloader to copy data from RAM to FLASH but you would have to write your own bootloader to get such a callable function.

Ahhh, is that so? Now I see why no lib has been done yet. :blush: :frowning:

Well, its was a nut idea anyway. :wink:

Maybe its just easier to interface with some small RAM chip instead? Reading from flash takes 2 cycles, so, if somehow we could read from an external RAM chip without much fuzz...

Yeah, just as an external FRAM chip - fast access like SRAM, storage like EEPROM - but many more writes available.
Can be SPI serial, or parallel
How much memory did you want?
http://www.mouser.com/Semiconductors/Memory/F-RAM/_/N-488wv?Keyword=fram&FS=True

"A ferroelectric random access memory or F-RAM is nonvolatile and performs reads and writes like a
RAM. It provides reliable data retention for 10 years while eliminating the complexities, overhead, and
system level reliability problems caused by EEPROM and other nonvolatile memories .... capable of
supporting 10^14 read/write cycles, or 100 million times more write cycles than EEPROM."

Indeed, I have to research more about external RAM, if its usable or not for sample-reading.

It because possible in 2015 : Writing to FLASH from application. Please test and enjoy :-) - Microcontrollers - Arduino Forum
(I have added the link, since Google finds this topic easier than the new topic about writing flash memory).