'Text1' will not fit in region 'iram1_0_seg'

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
YelloT
New user
Posts: 7
Joined: 18 Jul 2020, 12:49

'Text1' will not fit in region 'iram1_0_seg'

#1 Post by YelloT » 02 Oct 2020, 15:28

Hello guys,

I run into the following compilation error trying to compile my experimental radon sensor plugin with latest mega-20200929 release:

`.text1' will not fit in region `iram1_0_seg'

With very novice programming skills, I am afraid I am stuck here. Does anyone have any suggestions on how to fix this?

Detailed error message on compilation:

Compiling .pio\build\dev_ESP8266_4M1M\src\ESPEasy.ino.cpp.o
Linking .pio\build\dev_ESP8266_4M1M\ESP_Easy_mega_20201002_dev_ESP8266_4M1M.elf
c:/users/YT/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\dev_ESP8266_4M1M\ESP_Easy_mega_20201002_dev_ESP8266_4M1M.elf section `.text1' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\dev_ESP8266_4M1M\ESP_Easy_mega_20201002_dev_ESP8266_4M1M.elf] Error 1
========================================= [FAILED] Took 24.81 seconds =========================================

Thanks! :-)


_P214_RD200M.zip
(2.09 KiB) Downloaded 202 times
Plugin code:

Code: Select all

/*
//#######################################################################################################
//#################################### Plugin NNN: RD200M Radon Sensor ##################################
//#######################################################################################################
// RD200M Radon Sensor from FTLab
// https://www.radonshop.com/mediafiles/Anleitungen/Sensor/datasheet_RD200M_v1.2_eng.pdf
// Plugin is based upon MHZ19 plugin by Dmitry (rel22 ___ inbox.ru) 
// and SenseAir plugin by Daniel Tedenljung (info__AT__tedenljungconsulting.com)
*/

#ifdef USES_P214

#define PLUGIN_214
#define PLUGIN_ID_214         214
#define PLUGIN_NAME_214       "Radon RD200M [TESTING]"
#define PLUGIN_VALUENAME1_214 "1 - Status"
#define PLUGIN_VALUENAME2_214 "2 - Bq/m3"
#define PLUGIN_VALUENAME3_214 "3 - Counter" 
#define PLUGIN_READ_TIMEOUT   300

boolean Plugin_214_init = false;

#include <SoftwareSerial.h>
SoftwareSerial *Plugin_214_SoftSerial;

// RD200M commands and response
byte radonCmdReadRequest[4] = {0x02,0x01,0x00,0xFE}; // Command for requesting data from RD200M
byte radonCmdReset[4] = {0x02,0xA0,0x00,0x5F}; // Command for resetting RD200M
byte radonResponse[8];    // 8 bytes bytes response from RD200M

boolean Plugin_214(byte function, struct EventStruct *event, String& string)
{
  bool success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_214;
        Device[deviceCount].Type = DEVICE_TYPE_DUAL;
        Device[deviceCount].VType = SENSOR_TYPE_TRIPLE;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = true;
        Device[deviceCount].ValueCount = 3;
        Device[deviceCount].SendDataOption = true;
        Device[deviceCount].TimerOption = true;
        Device[deviceCount].GlobalSyncOption = true;
        break;
      }

    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_214);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_214));
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_214));
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_214));
        break;
      }

    case PLUGIN_INIT:
      {
     /*   WiFi.disconnect(true); */
        Plugin_214_SoftSerial = new SoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex], Settings.TaskDevicePin2[event->TaskIndex]);
        Plugin_214_SoftSerial->begin(19200);
        addLog(LOG_LEVEL_INFO, F("Radon RD200M: Initialization OK"));

        Plugin_214_init = true;
        success = true;
        break;
      }

    case PLUGIN_WRITE:
      {
        String command = parseString(string, 1);

        if (command == F("radonreset"))
        {
          Plugin_214_SoftSerial->write(radonCmdReset, 4);
          addLog(LOG_LEVEL_INFO, F("Radon RD200M: Sensor reset command sent"));
          success = true;
        }

        break;

      }

    case PLUGIN_READ:
      {
        Plugin_214_init = true; //Can this line be deleted?

        if (Plugin_214_init)
        {
          //send Read valueBqm3 command
           addLog(LOG_LEVEL_INFO, F("Radon RD200M: Sensor read command sent"));
          int nbBytesSent = Plugin_214_SoftSerial->write(radonCmdReadRequest, 4);
          if (nbBytesSent != 4) {
            String log = F("Radon RD200M: Error, nb bytes sent != 4 : ");
              log += nbBytesSent;
              addLog(LOG_LEVEL_INFO, log);
          }

          // get response
          memset(radonResponse, 0, sizeof(radonResponse));
          long start = millis();
          int counter = 0;
          while (((millis() - start) < PLUGIN_READ_TIMEOUT) && (counter < 8)) {
            if (Plugin_214_SoftSerial->available() > 0) {
              radonResponse[counter++] = Plugin_214_SoftSerial->read();
              String log = F("Radon RD200M: Reading data from sensor");
            } else {
              String log = F("Radon RD200M: An error occured while trying to read");
              delay(10);
            }
          }
          if (counter < 8){
              addLog(LOG_LEVEL_INFO, F("Radon RD200M: Error, timeout while trying to read"));
          }
          unsigned int valueBqm3 = 0;
          int i;
          signed int valueCounter = 0;
          unsigned int valueStatuscode = 0;
          byte crc = 0;
          for (i = 1; i < 7; i++) crc+=radonResponse[i];
              crc = 255 - crc;
              crc++;

            if (radonResponse[0] == 0x02 )  {

              //calculate RADON READING IN BQ/M3
              unsigned int radonResponseHigh = (unsigned int) radonResponse[5];
              unsigned int radonResponseLow = (unsigned int) radonResponse[6];
              valueBqm3 = ((100*radonResponseHigh) + radonResponseLow)*37; //converting from PCi to Bq by multiplier *37

              //  USED FOR COUNTER VALUE (UPTIME MINUTES)
              unsigned int radonResponseCount = (unsigned int) radonResponse[4];
              valueCounter = radonResponseCount;

              // USED FOR STATUS CODE VALUE
              unsigned int radonResponseS = (unsigned int) radonResponse[3];
              valueStatuscode= radonResponseS;

              String log = F("Radon RD200M: ");

              if (valueStatuscode == 0) {

                log += F("Bootup detected! ");
                success = false;

            } else if (valueStatuscode > 0) {

                log += F("Values read! ");
                log += radonResponse[0];
                log += radonResponse[1];
                log += radonResponse[2];
                log += F(" ");
                log += radonResponse[3];
                log += F(" ");
                log += radonResponse[4];
                log += F(" ");
                log += radonResponse[5];
                log += radonResponse[6];
                log += F(" ");
                log += radonResponse[7];
                log += F(" ");
                log += F("Bq/m3 calculated as ");
                log += (float)valueBqm3/100;
                addLog(LOG_LEVEL_INFO, log);

                // Readings are used for variables
                UserVar[event->BaseVarIndex] = valueStatuscode;
                UserVar[event->BaseVarIndex + 1] = (float)valueBqm3/100;
                UserVar[event->BaseVarIndex + 2] = valueCounter;         

              }
              
              success = true;
              break;
              return success;
          }

           else {
              String log = F("Radon RD200M: Unknown response: ");
              log += String(radonResponse[0], HEX);
              log += F(" ");
              log += String(radonResponse[1], HEX);
              log += F(" ");
              log += String(radonResponse[2], HEX);
              log += F(" ");
              log += String(radonResponse[3], HEX);
              log += F(" ");
              log += String(radonResponse[4], HEX);
              log += F(" ");
              log += String(radonResponse[5], HEX);
              log += F(" ");
              log += String(radonResponse[6], HEX);
              log += F(" ");
              log += String(radonResponse[7], HEX);
              addLog(LOG_LEVEL_INFO, log);
              success = false;
              break;
          }
        }
        break;
      }
  }
  return success;
}

#endif

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 'Text1' will not fit in region 'iram1_0_seg'

#2 Post by TD-er » 02 Oct 2020, 15:55

Please have a look at the plugins mentioned in that code, to see how to use the ESPEasySerial wrapper.

The SoftwareSerial library itself uses quite a lot of iram. That's the reason why we have our own version of it included, which is wrapped in the ESPEasySerial wrapper.

Also try limiting other plugins in the build, to see if it is even possible to build this plugin you try to use.

User avatar
YelloT
New user
Posts: 7
Joined: 18 Jul 2020, 12:49

Re: 'Text1' will not fit in region 'iram1_0_seg'

#3 Post by YelloT » 03 Oct 2020, 12:34

Ok, thanks!
I tried building with a very limited number of plugins, that worked fine. Building succeeded without any errors.

So iram usage is definitely the issue here, and I guess do need figure out how to replace SoftwareSerial with ESPEasySerial.
I assume this is not as simple as just replacing the references to SoftwareSerial with ESPEasySerial. Are there any bits of documentation on ESPEasySerial, or is looking at the code for P049 or P052 the best way to start?

User avatar
YelloT
New user
Posts: 7
Joined: 18 Jul 2020, 12:49

Re: 'Text1' will not fit in region 'iram1_0_seg'

#4 Post by YelloT » 03 Oct 2020, 15:55

Well, it _was_ more or less as simple as just replacing the references to SoftwareSerial with ESPEasySerial ;-)
Got my plugin for RD200M radon sensor up and running now, using ESPEasyserial. Compiles without errors, and provides good readings.
Will do some more testing.
_P214_RD200M.zip
(2.05 KiB) Downloaded 241 times

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 'Text1' will not fit in region 'iram1_0_seg'

#5 Post by TD-er » 04 Oct 2020, 10:23

Great :)

There is one "but"... as I have just now merged a commit that does need you to change a few parts of your code.
See: https://github.com/letscontrolit/ESPEasy/pull/3289

The reason for this change is that on ESP32 you need to specify a port number and GPIO pins, so it was no longer possible to decide on the pin numbers what port was used.
This lead to issues (even crashes) on ESP32, so I had to add a few changes there.

In short, what is needed is this:

Code: Select all

const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(CONFIG_PORT);
easySerial = new (std::nothrow) ESPeasySerial(port, serial_rx, serial_tx);
So you need an extra port to the ESPEasySerial.

If you use PlatformIO, it will automatically update ESPEasySerial library to the required version.
On ArduinoIDE, you may need to update the lib by hand.

User avatar
YelloT
New user
Posts: 7
Joined: 18 Jul 2020, 12:49

Re: 'Text1' will not fit in region 'iram1_0_seg'

#6 Post by YelloT » 04 Oct 2020, 23:03

Ok, I will fix that.
Thanks for letting me know :-)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 'Text1' will not fit in region 'iram1_0_seg'

#7 Post by TD-er » 05 Oct 2020, 09:16

If you think it is ready to be used by others, please make a pull request for it on GitHub.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests