Problem when compile reverb example as APP_TYPE = BOOT_SRAM

Hi!

If i compile reverb example without any change the result after compile are ok and works. But
if i try to compile using flag APP_TYPE = BOOT_SRAM the result after compile are:

c:/program files (x86)/gnu arm embedded toolchain/10 2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: region `DTCMRAM' overflowed by 278492 bytes
Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB       128 KB      0.00%
         DTCMRAM:      409564 B       128 KB    312.47%
            SRAM:       77524 B       480 KB     15.77%
      RAM_D2_DMA:       16896 B        32 KB     51.56%
          RAM_D2:          0 GB       256 KB      0.00%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:          0 GB      7936 KB      0.00%
collect2.exe: error: ld returned 1 exit status
make: *** [../../libDaisy//core/Makefile:291: build/ReverbExample.elf] Error 1

Anyone have any idea what is happening?
Thank you!

We can clearly see that the DTCMRAM is past its limit.

Can you link to the specific code? I’m not familiar with this example or where it is.

Hi @dreamer

The code is from examples folder DaisyExamples/patch_sm/ReverbExample but only change make file adding flag APP_TYPE = BOOT_SRAM.
Compile and DTCMRAM get 312.47%

Ok I’ve been able to reproduce this.

Normal build:

Memory region         Used Size  Region Size  %age Used
           FLASH:       77740 B       128 KB     59.31%
         DTCMRAM:          0 GB       128 KB      0.00%
            SRAM:      409564 B       512 KB     78.12%
          RAM_D2:       16896 B       288 KB      5.73%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:          0 GB         8 MB      0.00%

Adding APP_TYPE = BOOT_SRAM:

Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB       128 KB      0.00%
         DTCMRAM:      409572 B       128 KB    312.48%
            SRAM:       77584 B       480 KB     15.78%
      RAM_D2_DMA:       16896 B        32 KB     51.56%
          RAM_D2:          0 GB       256 KB      0.00%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:          0 GB      7936 KB      0.00%

What you can do is try BOOT_QSPI then the layout will look like this:

Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB       128 KB      0.00%
         DTCMRAM:          0 GB       128 KB      0.00%
            SRAM:      409572 B       512 KB     78.12%
      RAM_D2_DMA:       16896 B        32 KB     51.56%
          RAM_D2:          0 GB       256 KB      0.00%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:       77584 B      7936 KB      0.95%

But basically the problem we see is because of DTCMRAM overflow trying to save large buffer - #8 by infrasonicaudio

Thank you @dreamer!

I’ve just check the link, very help full and same problem.

I think the solution here is a much simpler than the other thread. You should just be able to change the reverb example like this:

DSY_SDRAM_BSS ReverbSc reverb;

Which will allocate the reverb into SDRAM instead of default .bss (which is mapped to DTCMRAM for BOOT_SRAM apps).

The problem is that the reverb internally uses a delay line which fits into SRAM but not DTCMRAM, and when you use BOOT_SRAM the default linker script for that app type tries to put the reverb instance into DTCMRAM. You can allocate it into SDRAM using the macro attribute like I showed above and this should fix the immediate problem.

2 Likes

Hi @infrasonicaudio

Thank you
For sumarize i post results with your proposal, that for me is better, because i´m working in a project where i need BOOT_SRAM type because of the size of the code.

Code from Reverb example without BOOT_SRAM:

#include "daisy_patch_sm.h"
#include "daisysp.h"

using namespace daisy;
using namespace daisysp;
using namespace patch_sm;

DaisyPatchSM patch;
ReverbSc     reverb;
// DSY_SDRAM_BSS ReverbSc     reverb;

void AudioCallback(AudioHandle::InputBuffer  in,
                   AudioHandle::OutputBuffer out,
                   size_t                    size)
{
    patch.ProcessAnalogControls();

    /** Update Params with the four knobs */
    float time_knob = patch.GetAdcValue(CV_1);
    float time      = fmap(time_knob, 0.3f, 0.99f);

    float damp_knob = patch.GetAdcValue(CV_2);
    float damp      = fmap(damp_knob, 1000.f, 19000.f, Mapping::LOG);

    float in_level = patch.GetAdcValue(CV_3);

    float send_level = patch.GetAdcValue(CV_4);

    reverb.SetFeedback(time);
    reverb.SetLpFreq(damp);

    for(size_t i = 0; i < size; i++)
    {
        float dryl  = IN_L[i] * in_level;
        float dryr  = IN_R[i] * in_level;
        float sendl = IN_L[i] * send_level;
        float sendr = IN_R[i] * send_level;
        float wetl, wetr;
        reverb.Process(sendl, sendr, &wetl, &wetr);
        OUT_L[i] = dryl + wetl;
        OUT_R[i] = dryr + wetr;
    }
}

int main(void)
{
    patch.Init();
    reverb.Init(patch.AudioSampleRate());
    patch.StartAudio(AudioCallback);
    while(1) {}
}

And makefile:

# Project Name

TARGET = ReverbExample

USE_DAISYSP_LGPL = 1

# Sources

CPP_SOURCES = ReverbExample.cpp \

# APP_TYPE = BOOT_SRAM

# Library Locations

LIBDAISY_DIR = ../../libDaisy/

DAISYSP_DIR = ../../DaisySP/

# Core location, and generic Makefile.

SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core

include $(SYSTEM_FILES_DIR)/Makefile

Results are:

Memory region         Used Size  Region Size  %age Used
           FLASH:       77700 B       128 KB     59.28%
         DTCMRAM:          0 GB       128 KB      0.00%
            SRAM:      409564 B       512 KB     78.12%
          RAM_D2:       16896 B       288 KB      5.73%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:          0 GB         8 MB      0.00%

Now with BOOT_SRAM and allocate reverb in SDRAM:

#include "daisy_patch_sm.h"
#include "daisysp.h"

using namespace daisy;
using namespace daisysp;
using namespace patch_sm;

DaisyPatchSM patch;
// ReverbSc     reverb;
DSY_SDRAM_BSS ReverbSc     reverb;

void AudioCallback(AudioHandle::InputBuffer  in,
                   AudioHandle::OutputBuffer out,
                   size_t                    size)
{
    patch.ProcessAnalogControls();

    /** Update Params with the four knobs */
    float time_knob = patch.GetAdcValue(CV_1);
    float time      = fmap(time_knob, 0.3f, 0.99f);

    float damp_knob = patch.GetAdcValue(CV_2);
    float damp      = fmap(damp_knob, 1000.f, 19000.f, Mapping::LOG);

    float in_level = patch.GetAdcValue(CV_3);

    float send_level = patch.GetAdcValue(CV_4);

    reverb.SetFeedback(time);
    reverb.SetLpFreq(damp);

    for(size_t i = 0; i < size; i++)
    {
        float dryl  = IN_L[i] * in_level;
        float dryr  = IN_R[i] * in_level;
        float sendl = IN_L[i] * send_level;
        float sendr = IN_R[i] * send_level;
        float wetl, wetr;
        reverb.Process(sendl, sendr, &wetl, &wetr);
        OUT_L[i] = dryl + wetl;
        OUT_R[i] = dryr + wetr;
    }
}

int main(void)
{
    patch.Init();
    reverb.Init(patch.AudioSampleRate());
    patch.StartAudio(AudioCallback);
    while(1) {}
}

Make file:

# Project Name

TARGET = ReverbExample

USE_DAISYSP_LGPL = 1

# Sources

CPP_SOURCES = ReverbExample.cpp \

APP_TYPE = BOOT_SRAM

# Library Locations

LIBDAISY_DIR = ../../libDaisy/

DAISYSP_DIR = ../../DaisySP/

# Core location, and generic Makefile.

SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core

include $(SYSTEM_FILES_DIR)/Makefile

And results:

Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB       128 KB      0.00%
         DTCMRAM:       13460 B       128 KB     10.27%
            SRAM:       77548 B       480 KB     15.78%
      RAM_D2_DMA:       16896 B        32 KB     51.56%
          RAM_D2:          0 GB       256 KB      0.00%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:      396100 B        64 MB      0.59%
       QSPIFLASH:          0 GB      7936 KB      0.00%

There is difference memory usage than just use BOOT_QSPI.

Thank´s a lot both of you!

1 Like