The error you're encountering (fatal error: esp32/rom/rtc.h: No such file or directory) typically occurs when the Arduino IDE is not properly configured with the correct ESP32 board support package (BSP) or when there's a mismatch between the installed libraries and the board you're targeting (Core S3 in this case).
Here are the steps to resolve the issue:
Open the Arduino IDE.
Go to File > Preferences.
In the "Additional Boards Manager URLs" field, ensure you have the following URL:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
If it's not there, add it and click "OK."
Go to Tools > Board > Boards Manager.
Search for esp32 and install or update the esp32 package by Espressif Systems.
After installing the ESP32 BSP, go to Tools > Board and select M5Stack CoreS3 (or the closest match if "CoreS3" isn't listed explicitly).
Ensure the Flash Mode, Partition Scheme, and other settings are appropriate for the Core S3.
The error suggests a conflict with the M5Stack library. Ensure you're using the latest version of the M5Stack library compatible with the Core S3.
Go to Sketch > Include Library > Manage Libraries.
Search for M5Stack and install the latest version.
If you already have it installed, try uninstalling and reinstalling it.
The example you're using includes M5Stack.h and M5CoreS3.h. Ensure these headers are compatible with your setup.
If the example is from an older version of the library, it might not work with the Core S3. Look for updated examples in the latest library documentation.
Ensure the correct serial port is selected under Tools > Port.
If uploading fails, try pressing the reset button on the Core S3 just before uploading.
Sometimes, leftover files from previous builds can cause issues. Try creating a new sketch and copying the code into it.
Debugging FurtherIf the issue persists, share the exact steps you followed to set up the Arduino IDE and install the libraries. This will help pinpoint the problem.