Working with wav files without sd card?

Hey, I’d like to load some samples and store them as float variables in SDRAM without using sd card.

How can I do this? Can someone provide me an example?

Many Thanks! K

Data can’t be “stored” in the SDRAM because SDRAM is volatile – it’s not retained across power cycles, and probably not even across MCU restarts (e.g. when flashing a new firmware). DRAM must be continually refreshed by the memory controller to maintain its contents.

You should look into using the QSPI flash memory to store persistent data. Your application can copy data from flash into SDRAM, or even read directly from flash. You’ll be limited to 8MB, though.

1 Like

nice, thanks! a small example would be really helpful :slight_smile:

There is a QSPI project in the Seed examples, but it doesn’t do quite what you want.

You’ll need to do something like create a C-style array with your sample data, with the DSY_QSPI_BSS attribute to tell the linker to put it in flash (see line 12 in QSPI.cpp). There are various bin2c utilities that will generate a C-style array from a binary file, so you should check them out.

The details of how to make this all work depend on your application. I’d start with just getting something into the QSPI flash, and then take it from there.

1 Like

I’ve come to the point where I need to use the QSPI flash in order to recover a bit of code space, but unfortunately I’m not sure how it works in practice. :slight_smile:

I have a handful of big lookup tables that are statically initialized. They total a few kilobytes. Since I’ve exhausted the 128KB program flash, I’d like to move the tables into the QSPI flash to make a little more room for my code.

I’ve added the DSY_QSPI_BSS attribute to the arrays, but unfortunately the QSPI flash is not initialized with my values (AFAICT). Maybe the linker script needs to be adjusted in order for the values to be copied over when programming. I’ll take a look.

Oh, duh … my old systems professor is probably rolling in his grave.

Of course we don’t want to use DSY_QSPI_BSS for this kind of initialized data, but rather DSY_QSPI_DATA … Unfortunately when I try to put my tables in that section, I’m unable to flash my program at all:

$ make program-dfu
dfu-util -a 0 -s 0x08000000:leave -D build/SamplePlayer.bin -d ,0483:df11
dfu-util 0.10

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2020 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to

Warning: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Downloading element to address = 0x08000000, size = -2013258752
Last page at 0x90001bff is not writeable
make: *** [../../libDaisy//core/Makefile:330: program-dfu] Error 74

I don’t know what that error is all about, but I’ll keep digging.

I keep reading this thread since I wasn’t able to get my project working.
As a beginner I heavily relay on working examples… :slight_smile: