[ERROR] class EEPROMClass has no member named length

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
LORDHADES
Posts: 24
Joined: Thu Nov 19, 2020 4:53 am

[ERROR] class EEPROMClass has no member named length

Post by LORDHADES »

Hey all !!!

I hope y'all are doing well...

I'm using Setup : Digital weighing scale using Renesas chip connected to one channel of Max232, another channel of Max232 connected to STM32. STM32 is connected to PC via FTDI232 serial to USB converter. A push button is attached to STM32, to facilitate data printing on serial monitor when enabled.

I used this tutorial for preliminary setup : "https://www.instructables.com/Getting-S ... duino-IDE/"
Arduino IDE: v1.8.13(Windows Store 1.8.42.0) from Microsoft store
Board Manager: STM32F1XX/GD32F1XX by stm32duino v2020.11.14
Additional board manager URL: "http://dan.drown.org/stm32duino/package ... index.json"

I am trying to save the serially received data into stm32's EEPROM(emulated flash memory in this case). For this, I wrote a dummy code derived from inbuilt examples. The code is :

Code: Select all

#include <EEPROM.h>

int addr = 0;
int address = 0;
int ledPin = PC13;
int inByte;
int inByte_1;
const char welMsg[] = "Ciao, Press :\r\n" \
                    "0 to write data\r\n" \
                    "1 to read written data\r\n" \
                    "2 to display status\r\n";
uint16 DataWrite = 0;
uint16 AddressWrite = 0;

void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
  Serial.print(welMsg);
}

void loop()
{
  uint16 Status;
  uint16 Data;

  while (Serial.available())
  {
    char cmd = (char)Serial.read();
    Serial.println(cmd);

    if(cmd == '0')
    {
      Serial.println("Enter something");
      inByte = Serial.read();
      EEPROM.write(addr, inByte);
      addr = addr + 1;

      if (addr == EEPROM.length())
      {
        addr = 0;
      }
    delay(100);
    }
    
    else if (cmd == '1')
    {
      inByte_1 = EEPROM.read(address);
      Serial.print(address);
      Serial.print('\t');
      Serial.print(inByte_1, DEC);
      Serial.println();

      address = address + 1;

      if (address == EEPROM.length())
      {
        address = 0;
      }
    delay(1000);
    }

    else if (cmd == '2')
    {
      Status = EEPROM.write(AddressWrite, DataWrite);
      Serial.print("EEPROM.write(0x");
      Serial.print(AddressWrite, HEX);
      Serial.print(", 0x");
      Serial.print(DataWrite, HEX);
      Serial.print(") : Status : ");
      Serial.println(Status, HEX);
    }

    else

    Serial.print(welMsg);
  }

  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}
But unfortunately, while compiling, I get an error like :

Code: Select all

EEPROM_trial:39:26: error: 'class EEPROMClass' has no member named 'length'

if (addr == EEPROM.length())

^

EEPROM_trial:56:29: error: 'class EEPROMClass' has no member named 'length'

if (address == EEPROM.length())

^

Using library EEPROM in folder: C:\Users\IIoT\OneDrive\Documents\ArduinoData\packages\stm32duino\hardware\STM32F1\2020.11.27\libraries\EEPROM (legacy)

exit status 1

'class EEPROMClass' has no member named 'length'
When I took a look on EEPROM.h file, length was not defined there. Since i'm a novice programmer, I really dunno how to define length on that library. I tried to figure it out, but I failed to do it and found nothing useful on internet.

Somebody please gimme a suggestion on this concern. Thanks in advance. God bless y'all.

P.S. I use STM32F103C6/8, with 128 KB internal flash.

Hades
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: [ERROR] class EEPROMClass has no member named length

Post by stevestrong »

The EEPROM library for Libmaple (Roger's core) seems to not support the length() function.
This library was last updated 3 years ago, there is no active support for that.

So I am afraid you should either implement yourself this function, or look for alternative solutions (use external EEPROMs).
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: [ERROR] class EEPROMClass has no member named length

Post by GonzoG »

Those examples are for arduino compatible cores (like STM32 core).
Roger's core has own EEPROM library. It has 2 functions:

Code: Select all

uint16 EEPROMClass::count(uint16 *Count);
and

Code: Select all

uint16 EEPROMClass::maxcount(void);
Don't know what exactly they do but they return some value related to EEPROM size.


Now one big "BUT":
If you want to do many writes to EEPROM don't use emulated EEPROM. It will damage MCU's flash memory.
With emulated EEPROM every write to EEPROM erases whole page in flash and rewrites it. So even if you change 1 byte it erases whole page. And flash life is about 10k erase cycles.

I recommend using external EEPROM chip. They are cheap, you can write/erase each byte and have better life (100k - 1M cycles for each cell).
Post Reply

Return to “General discussion”