1
\$\begingroup\$

I need a single PCB solution for data storage (~2 MB) that can be accessed through USB using a computer.

I DON'T want the micro-controller to access external USB devices. I want the memory to be on the circuit board and files to be easily loaded using a USB cable and a computer.

Does anyone here know of a common solution? NOR/NAND flash just seems like a cheap solution with many things to go wrong if bad sectors aren't handled properly (erase/write is most likely once, but I want to cover my bases if someone changes files a lot).

Maybe a dedicated memory chip (soldered to the PCB) with USB interface and some interface for the micro-controller? The micro-controller needs to read this data after being disconnected from the PC.

I have seen cases where people used SPI flash chips, but the problem is that these need to be erased before the new data can be written and can have issues with bad sectors. I'm looking to avoid this if possible and need a cheap, simple solution (if one exists).

TL;DR
I want storage (~2 MB max capacity) for micro-controller that allows audio file uploads from a computer using USB. I would like it to be a common solution and not a weird alternative. I don't want an SD card as they are too expensive for this small cheap device. If it can take care of bad sectors automatically that's ideal.

I will try my best to answer any more questions you may have. Hopefully I covered everything for now.

Also, I hope this is not a duplicate. I've looked everywhere but my search terms are broad and I don't know how to narrow them down further.

\$\endgroup\$
9
  • \$\begingroup\$ how often will that memory need to be overwritten? 10 times? 100 times? 1000 times? 10000 times? Wild guess is that you're overthinking this a bit. Basically all memory for your use case is flash, and will need a block of memory to be block-erased before being overwritten. there's no real problem with that, and for most OSes and HALs you'd run on your microcontroller for an audio application, there will be drivers to do that for you. \$\endgroup\$ Apr 25, 2020 at 7:38
  • \$\begingroup\$ I mean, this 50 ct 16 Mbit flash memory has at least 100,000 erase cycles. Reading your question, the user connects it to a computer, writes a file, disconnects it. Say, due to inelegance of their computer, that means that blocks get overwritten twice per being connected to a computer. That makes 50,000 plug-in-write-plug-out cycles. Assuming the user has nothing to do with their life but plugging in a USB device 25 times a day, that's still 2000 days – 5.5 years of absurd usage life time. \$\endgroup\$ Apr 25, 2020 at 7:45
  • \$\begingroup\$ you could of course also use proper eMMC memory (like your smart phone does), but things get quite a bit more complicated if you have to start implementing that. \$\endgroup\$ Apr 25, 2020 at 7:47
  • \$\begingroup\$ Okay. I wasn't sure if flash was a common choice here. I don't want it to take more than 5 seconds to program one device though. USB peripheral is capable of 1.5MB/s. assuming peak performance that's about 1-2 seconds but what will performance be if using NOR/NAND and which is better in this situation? \$\endgroup\$ Apr 25, 2020 at 10:16
  • 1
    \$\begingroup\$ you don't want to learn this yourself and debug for a couple of years before you can successfully build a USB mass storage device. Look for STM32 USB mass storage examples online. \$\endgroup\$ Apr 25, 2020 at 20:08

1 Answer 1

1
\$\begingroup\$

Consider SPI flash memories. 2MB are definitely available. You could get an MCU with USB device capability and implement a mass storage device (there is a ready demo for that). Block read/write operations would map to the SPI flash memory. The external memory can be simply formatted with a FAT32 file system. That would be basically an overpriced USB thumb drive with mediocre performance ;)

Now, when the device is unplugged from the PC you would read out the files (for example using FatFs) from the external memory.

The only tricky bit: you can not (easily) open the same file system on the PC and your firmware at the same time (that is also why some digital cameras block all features when connected with a USB cable).

\$\endgroup\$
2
  • \$\begingroup\$ This is what i'm going with. Any idea on how to handle the file system locking? I dont need/want to access with FatFS if the USB is plugged in. \$\endgroup\$ Apr 27, 2020 at 23:44
  • \$\begingroup\$ Unmount FatFS (and disable features that access the file system) when you get a USB connection event. \$\endgroup\$
    – filo
    Apr 28, 2020 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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