Go Down

Topic: Error Saying a variable from the FFT Library "defined in discarded section" (Read 3064 times) previous topic - next topic

PhysArduino

`fft_lin_out' referenced in section `.text.startup' of /var/folders/r_/cq1rth1s67g0vdc4p_n2th3h0000gn/T//ccOew28r.ltrans0.ltrans.o: defined in discarded section `.text' of /var/folders/r_/cq1rth1s67g0vdc4p_n2th3h0000gn/T/build4f8279ca2bbd19c8b56e907dc6fe0cec.tmp/sketch/Photodiode_FFT_V6.ino.ino.cpp.o (symbol from plugin)


It pretty much is saying the variables listed are in a discarded section of the .text section of the program I'm running. Have any of you run into this? This popped up yesterday after the update and now none of my code will compile.

Im using the FFT Library from http://wiki.openmusiclabs.com/wiki/ArduinoFFT to processes a signal generated from light falling on a photodiode array. The original project can be found here: http://playground.arduino.cc/Main/TSL1402R.

and this is the code I'm using in my program. Thank You!!

Code: [Select]
// Parallel read of the linear sensor array TSL1402R (= the sensor with 256 photodiodes)
//-------------------------------------------------------------------------------------

// Define various ADC prescaler:
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
byte CLKpin = 4;    // <-- Arduino pin delivering the clock pulses to pin 3 (CLK) of the TSL1402R
byte SIpin = 5;     // <-- Arduino pin delivering the SI (serial-input) pulse to pin 2 of the TSL1402R
byte AOpin0 = 0;    // <-- Arduino pin connected to pin 4 (analog output 1)of the TSL1402R
byte AOpin1 = 1;    // <-- Arduino pin connected to pin 8 (analog output 2)of the TSL1402R
float maxindex; //integer storing the index at which we register the maxima of the fft
float maxvalue; // float variable that allows us to compare the values of the maxima making sure we get the maxima we are intersted in
float kmax; //float variable that calculates the magnitude of the fft at each index
// do #defines BEFORE #includes
#define LIN_OUT 1 // use the lin output function
#define FFT_N 256  //sets the FFT to 256 points
#include <FFT.h>;  //includes the FFT library allowing for the functions to be carried out
#include <math.h>;
void setup()
{
  // Initialize two Arduino pins as digital output:
  pinMode(CLKpin, OUTPUT);
  pinMode(SIpin, OUTPUT);  

  // To set up the ADC, first remove bits set by Arduino library, then choose
  // a prescaler: PS_16, PS_32, PS_64 or PS_128:
  ADCSRA &= ~PS_128;  
  ADCSRA |= PS_32; // <-- Using PS_32 makes a single ADC conversion take ~30 us

  // Next, assert default setting:
  analogReference(DEFAULT);

  // Set all IO pins low:
  for( int i=0; i< 14; i++ )
  {
      digitalWrite(i, LOW);  
  }

  // Clock out any existing SI pulse through the ccd register:
  for(int i=0;i< 260;i++)
  {
      ClockPulse();
  }

  // Create a new SI pulse and clock out that same SI pulse through the sensor register:
  digitalWrite(SIpin, HIGH);
  ClockPulse();
  digitalWrite(SIpin, LOW);
  for(int i=0;i< 260;i++)
  {
      ClockPulse();
  }

  Serial.begin(9600);

  // Stop the ongoing integration of light quanta from each photodiode by clocking in a SI pulse
      // into the sensors register:
      digitalWrite(SIpin, HIGH);
      ClockPulse();
      digitalWrite(SIpin, LOW);

      // Next, read all 256 pixels in parallell. Store the result in the array. Each clock pulse
      // causes a new pixel to expose its value on the two outputs:
      for(int i=0; i < 128; i++)
      {
          delayMicroseconds(20);// <-- We add a delay to stabilize the AO output from the sensor
          fft_input[i] = analogRead(AOpin0);
          fft_input[i+128] = analogRead(AOpin1);
          ClockPulse();
      }
        
      // Next, stop the ongoing integration of light quanta from each photodiode by clocking in a
      // SI pulse:
      digitalWrite(SIpin, HIGH);
      ClockPulse();
      digitalWrite(SIpin, LOW);

      // Next, send the measurement stored in the array to host computer using serial (rs-232).
      // communication. This takes ~80 ms during whick time no clock pulses reaches the sensor.
      // No integration is taking place during this time from the photodiodes as the integration
      // begins first after the 18th clock pulse after a SI pulse is inserted:
  
      //Serial.println(""); // <-- Send a linebreak to indicate the measurement is transmitted.

      // Next, a new measuring cycle is starting once 18 clock pulses have passed. At  
      // that time, the photodiodes are once again active. We clock out the SI pulse through
      // the 256 bit register in order to be ready to halt the ongoing measurement at our will
      // (by clocking in a new SI pulse):
      
        
      fft_reorder(); //reorders the fft_input array to allow the fft_run() command to be used
      fft_run();  // This is the function that actually does the FFT
      fft_mag_lin(); // Does the magnitude calculation sothe data can be read

      maxvalue = 0;
      maxindex = 0;
      for (int i = 5; i < 128; i++)
      {
         if (fft_lin_out[i] > maxvalue) //if the magnitude is larger than the previously measured max it makes the new max that measured value and outputs the index at which it occurs
         {
            maxvalue = fft_lin_out[i];
            maxindex = i;
         }  
      }
}

void loop()
{  
float Am; //coefficent of the real data
float Bm; //coefficent of imaginary data
float theta; //float variable that stores the value of displacement
float thetaD; //theta in degrees
float displacement; //measurement of displacement in nanometers
      // Stop the ongoing integration of light quanta from each photodiode by clocking in a SI pulse
      // into the sensors register:
      digitalWrite(SIpin, HIGH);
      ClockPulse();
      digitalWrite(SIpin, LOW);

      // Next, read all 256 pixels in parallell. Store the result in the array. Each clock pulse
      // causes a new pixel to expose its value on the two outputs:
      for(int i=0; i < 128; i++)
      {
          delayMicroseconds(20);// <-- We add a delay to stabilize the AO output from the sensor
          fft_input[i] = analogRead(AOpin0);
          fft_input[i+128] = analogRead(AOpin1);
          ClockPulse();
      }
        
      // Next, stop the ongoing integration of light quanta from each photodiode by clocking in a
      // SI pulse:
      digitalWrite(SIpin, HIGH);
      ClockPulse();
      digitalWrite(SIpin, LOW);

      // Next, send the measurement stored in the array to host computer using serial (rs-232).
      // communication. This takes ~80 ms during whick time no clock pulses reaches the sensor.
      // No integration is taking place during this time from the photodiodes as the integration
      // begins first after the 18th clock pulse after a SI pulse is inserted
      
      //Serial.println(""); // <-- Send a linebreak to indicate the measurement is transmitted.

      // Next, a new measuring cycle is starting once 18 clock pulses have passed. At  
      // that time, the photodiodes are once again active. We clock out the SI pulse through
      // the 256 bit register in order to be ready to halt the ongoing measurement at our will
      // (by clocking in a new SI pulse):
      
        
       kmax = maxvalue/256; //for debugging see if maxval/256 works
       Am = 0;
       Bm = 0;
      for (int i = 0; i < 256; i++)
      {
        Am = Am + fft_input[i]*cos(kmax*i); //magnitude of real part
        Bm = Bm + fft_input[i]*sin(kmax*i); //magnitude of imaginary part
      }
       theta = atan(Bm/Am); //faze angle measurement (rads)
       thetaD = (180/(3.14159))*theta; //faze angle measurement (degrees)

     displacement = ((theta*632*sqrt(2))/(4*3.14159));
      
      Serial.println(displacement);
      for(int i = 0; i < 260; i++)
      {
          if(i==18)
          {
              // Now the photodiodes goes active..
              // An external trigger can be placed here
          }
          ClockPulse();
      }    

      // The integration time of the current program / measurement cycle is ~3ms. If a larger time
      // of integration is wanted, uncomment the next line:
      // delay(15);// <-- Add 15 ms integration time
}

// This function generates an outgoing clock pulse from the Arduino digital pin 'CLKpin'. This clock
// pulse is fed into pin 3 of the linear sensor:
void ClockPulse()
{
  delayMicroseconds(1);
  digitalWrite(CLKpin, HIGH);
  digitalWrite(CLKpin, LOW);
}

jremington

The code is a mess, with all sorts of misleading or wrong comments, but it compiles without error for me.

PhysArduino

Yeah I'm sorry about that still a beginner. Ok so yesterday there was an update for arduino but i can't remember exactly if it was a firmware update for the board or the just an update for the IDE but ever since i installed that update it stopped working. Is there anyway to see what that update was or just revert to factory settings for the arduino?

jremington


PhysArduino

I've tried everything man. I even did a clean install on a different computer and when i run it i still get the error message.

`fft_lin_out' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_lin_table' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_lin_table' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_reorder_table' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_reorder_table' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_wk_constants' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

`_wk_constants' referenced in section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\ccjZgxi6.ltrans0.ltrans.o: defined in discarded section `.text' of C:\Users\MIGHTY~1\AppData\Local\Temp\build7886a4da0ed1ea05f0b7119459358847.tmp\sketch\ReferenceDisplacement2.ino.cpp.o (symbol from plugin)

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

jremington

Use a different version of the IDE. I'm at work so I can't check what I used, but it was an older one, probably 1.5. something.

tmd3

I tried it on several versions of the IDE.  It compiled on 1.6.5-r5 and several earlier versions.  It failed on 1.6.6 with an unusual message saying that a file name was missing from a command.  On 1.6.7 and above, it failed with a list of "defined in discarded section" messages.

Rich04096

Does anyone have a solution?  This is still happening in 1.6.12

jremington

Code: [Select]
#include <FFT.h>;  //includes the FFT library allowing for the functions to be carried out
#include <math.h>;


Try removing the ";" from after the include statement. It should not be there.

I suspect that you have some bad characters elsewhere in the file.

rjmatthews62

I can compile the example code from Open Music Labs site, but this error comes up as soon as I comment out the line 'Serial.write(fft_log_out)'

This is apparently a known problem with GCC 4.8 (from memory) and is a result of feral optimization.

I am using Arduino 1.6.10

I don't particularly *want* the Serial.write in the code I'm putting together. I'm trying to refer to fft_log_out in different ways, but it does not seem interested in behaving unless the serial.write is there.


rjmatthews62


jremington

I contacted the author of the OpenMusicLabs FFT code, and he uploaded a new version (3.0) a couple of days ago. Try it out (I haven't yet) and let us know if it works.

http://wiki.openmusiclabs.com/wiki/ArduinoFFT

rjmatthews62

I'm working with the FFT I downloaded last night.

I have been able to compile successfully by putting my analysis code into a separate function... but it is not completely clear what the magic method is.

Attached code compiles in 1.6.12, for what it's worth (not pretty but it does compile)

I suspect strongly the more complex you make the sketch, and the more you refer to fft_log_out, the less likely the linker is to try to optimize it out.

jremington

There appear to be several errors in your code, so I would not suspect compiler optimization to be the problem.

For example, why do you call the function frequencies() with fft_log_out[] in the call argument but refer to it as "uint8_t mylist[]" in the function? fft_log_out[] is global.

I suggest to move the relevant code to loop() and get rid of "frequencies()".


Go Up