Troubleshooting RAM overflow (crosspost)

Status
Not open for further replies.

faemagedon

New member
Hi I've been trying to run a library made with the faust IDE and keep getting this error on Teensy 3.5:

I'm using teensyduino as the IDE and including faust library.

Arduino: 1.8.13 (Mac OS X), TD: 1.53, Board: "Teensy 3.5, Serial, 120 MHz, Faster, US English"

/Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: /var/folders/xw/4_chkj0n4w58bfhrx_pb57pm0000gn/T/arduino_build_415137/sketch_may06a.ino.elf section `.bss' will not fit in region `RAM'
/Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: region `RAM' overflowed by 41148 bytes
collect2: error: ld returned 1 exit status
Multiple libraries were found for "SD.h"
Used: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD
Not used: /Applications/Teensyduino.app/Contents/Java/libraries/SD
Error compiling for board Teensy 3.5.


The code is as follows:

Code:
#include <Audio.h>


#include "AMSmallSynth.h"
// GUItool: begin automatically generated code
AMSmallSynth      waveform1;      //xy=345,257
AudioOutputAnalogStereo  dacs1;          //xy=577,253
AudioConnection          patchCord1(waveform1, 0, dacs1, 0);
AudioConnection          patchCord2(waveform1, 0, dacs1, 1);
AudioControlSGTL5000     audioShield;     //xy=383,373
// GUItool: end automatically generated code




int buttonPinsOrange[] = {24, 25 ,26, 27};
int buttonPinsBlue[] = {28, 29, 30, 31};
byte currentPressOrange = 0;
byte currentPressBlue = 0;

int ledPinsBlue[] = {36, 37, 38, 39};
int ledPinsOrange[] = {32, 33, 34, 35};

float activeFrequency;
float octaveMultiplier = 1;

//float fundementals[] = {220, 220, 233.08, 246.94, 261.6, 277.18, 293.67, 311.13, 329.63, 349.23, 369.99, 392, 415.3, 440, 220, 220};


void setup() {
  // put your setup code here, to run once:
  for(int i = 0; i < 4; i++){
    pinMode(buttonPinsOrange[i],OUTPUT);
    pinMode(buttonPinsBlue[i],OUTPUT);
    pinMode(ledPinsBlue[i], OUTPUT);
    pinMode(ledPinsOrange[i], OUTPUT);
  }
  AudioMemory(127);
  audioShield.enable();
  audioShield.volume(0.1);
  waveform1.setParamValue("gain",0.9);
//  verb1.roomsize(0.2);
//  verb1.damping(0.7);
  //waveform1.setParamValue("duration",0.250);
}

void loop() {
  // put your main code here, to run repeatedly:
 currentPressOrange = readButtonPins(buttonPinsOrange);
 currentPressBlue = readButtonPins(buttonPinsBlue);
 writeLeds(currentPressBlue, currentPressOrange);
 if (currentPressOrange == 0) {
  activeFrequency = 0;
  waveform1.setParamValue("trigger",0);
 } else {
  activeFrequency = octaveMultiplier * (fundementals[currentPressBlue]*pow(2,((currentPressOrange)-1)/12.));
  waveform1.setParamValue("trigger",1);
 }
 waveform1.setParamValue("car_freq",activeFrequency);
 while (currentPressOrange == 14) {
      octaveMultiplier *= 2;
      activeFrequency = 0;
      delay(500);
      break;
    }
  while (currentPressOrange == 15){
    octaveMultiplier *= 0.5;
    activeFrequency = 0;
    delay(500); 
    break;
  }
  
  delay(50);
}

byte readButtonPins(int buttonPinsArr[]) {
  byte r_press = 0;
  for(int i = 0; i < 4; i++){
    if (digitalRead(buttonPinsArr[i]) == HIGH){
      bitWrite(r_press,i,1);
    } else {
      bitWrite(r_press,i,0);
    }
  }
  return r_press;
}

void writeLeds(byte blue_press, byte orange_press){
  for(int i = 0; i < 4; i++){
    digitalWrite(ledPinsBlue[i],bitRead(blue_press,i));
    digitalWrite(ledPinsOrange[i],bitRead(orange_press,i));
  }
}

Any suggestions as to what I could do to remedy this error?
 
Sorry, there is almost nothing shown here to know where your memory is being used.
Also I don't know what it means to say library made with the faust IDE...

But it does sound like either:

a) there are some very large buffers defined like: uint8_t myBuffer[250000];
Or lots of little ones that add up:

b) Or lots of tables that were defined that are eating up memory.
Like uint8_t mySoundslist[] = {0,0,........ lots and lots of values};

These like tables are downloaded to RAM at startup time. These can be resolved my specifying the table as const
const uint8_t myTable[] = {.......};
These are left in program in the FLASH memory and don't eat up RAM...
Note on T4.x you also need to specify DMAMEM as well.
 
Status
Not open for further replies.
Back
Top