EEPROM not saving on Arduino Uno Wifi Rev 2

Hey all! Anyone would know if the EEPROM library is properly supporting the Arduino UNO wifi Rev2 (ATMEGA4809) - I am currently trying to save some String values into my EEPROM, and it doesn’t seem to be saving with the following code:

eeprom class file

#include <EEPROM.h>

class Data{
  
  String group_id;
  String IPis;

  public:
    Data(String group_number)
    {
      group_id = group_number;
    }

    void save_data() {

      int size = group_id.length();
      char val[size];
        
      Serial.println("Saving");
      group_id.toCharArray(val,size + 1);
      Serial.println(sizeof(val));


      for(int i=0 ; i < sizeof(val); i++)
      {
        if (EEPROM.read(i) != val[i])
        {
          Serial.println("That character does not exists");
          EEPROM.put(i,val[i]);

        } 
        else 
        {
          Serial.println("That character exists");
          Serial.println(val[i]);
        }
      }
    }

    void read_data() {
      int size = group_id.length();
      char val[size];

      Serial.println(size);
      
      Serial.println("reading!");
      
      group_id.toCharArray(val,size + 1);

      for(byte b=0 ; b < sizeof(val); b++)
      {
        char f = EEPROM.read(b);
        IPis += (f);
      }
      Serial.println(IPis);
    }
};

Main file

#include<EEPROM.h>
#include "data.h";

void setup() {
  Serial.begin(9600);
  Serial.println("starting!");
  delay(5000);
  Serial.println("we are closing to saving!");
  Data eeprom_data("121234");
  eeprom_data.save_data(); // the test is to run this file and then comment the save_data() function and try to read from ee prom
  eeprom_data.read_data();

  
}

void loop() {
}

Note: I have tested this same exact code in the following way with the following devices:

Instructions:

Device Arduino Uno (ATmega328P)

1- Run main file once - Actual output: Saves constructor string and prints constructor string
2- Run main file without save_data() function - Actual Output: Prints out the constructor string that was earlier saved on the EEPROM (Obviously the device is reading only, Not writing)

So, for the Arduino Uno it works perfectly.

Now for the Arduino Uno wifi Rev2

1- Run main file once - Actual output: Saves constructor string and prints constructor string
2- Run main file without save_data() function - Actual Output: Prints all interrogation marks " ?? " In other words, it seems like the device is not saving…

Question: Would anyone know what is the issue? My hypothesis is that either the firmware of the device is not configured properly for EEPROM usage - Or the EEPROM library does not support ATMEGA4809 devices. TIA!

Welcome to the forum Keith.

I do not know the answer to your question, but I can point you at two placdes.

First, there is a special section of the forum devoted to the Arduino WiFi Rev 2

There is also lots to be found at the GitHub site for the megaavr core https://github.com/arduino/ArduinoCore-megaavr

The "fuses" folder is tagged with a note about "fix EEPROM bing erased by upload".

Good luck with your issue.