I need to recompile libesp32.a to use the external RTC crystal. See
opened 11:35AM - 16 Mar 18 UTC
closed 05:23PM - 25 Mar 18 UTC
### Hardware:
Board: ESP-WROVER-KIT
Core Installation/update date: 2018… -03-10
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 921600
### Description:
Is there any way, or plans for a way, to enable the slow xtal osc for the RTC? The current way the RTC is set up seems to keep time during deep sleep, but drift seems extreme at times.
I have tried to change the RTC clock using:
rtc_clk_32k_bootstrap();
rtc_clk_32k_enable(true);
rtc_clk_slow_freq_set(RTC_SLOW_FREQ_32K_XTAL);
But that did not enable the osc, and it prevents deepsleep from ever waking up.
### Sketch:
```cpp
#include <WiFi.h>
#include "time.h"
#include <rom/rtc.h>
const char* ssid = "abc";
const char* password = "xyz";
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600;
void printLocalTime()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
return;
}
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}
void setup()
{
Serial.begin(115200);
//init and get the time
if(rtc_get_reset_reason(0)!=DEEPSLEEP_RESET)
{
//connect to WiFi
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");
Serial.println("Getting Time.");
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
//disconnect WiFi as it's no longer needed
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
}
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
Serial.println("Going to sleep");
esp_sleep_enable_timer_wakeup(5000000);
esp_deep_sleep_start();
}
void loop()
{
}
```
The file $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/lib/libesp32.a in my Linux PC is from 26/3/2021 (today is 2/3/2022) so I assume PlatfromIO has downloaded a precompiled version. I would like to modify the configuration in
$HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/sdkconfig
and build the framework again. How can I do that?
I have tried setting build_flags in platformio.ini but it didn’t work. I got warnings stating that my macro was defined multiple times.
Thanks