Skip to content

ESP32 C3 Preferences lib conflict #11368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
ITstreet1 opened this issue May 16, 2025 · 5 comments
Closed
1 task done

ESP32 C3 Preferences lib conflict #11368

ITstreet1 opened this issue May 16, 2025 · 5 comments
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@ITstreet1
Copy link

Board

ESP32 C3 WROOM 02

Device Description

ESP32 C3

Hardware Configuration

Nothing

Version

latest stable Release (if not listed below)

IDE Name

Arduino IDE

Operating System

Windows

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

Hello,

I have some conflict with Preferences lib as the C3 goes into continuous restarts.

Here is the sketch.

What am I doing wrong?

Sketch

#include <Preferences.h>
Preferences preferences;
int rly = 12;
int led = 0;

void setup(){
  Serial.begin(9600);
  Serial.println();
  preferences.begin("data", false);
  pinMode(led, OUTPUT);
  pinMode(rly, OUTPUT);
  digitalWrite(rly, HIGH);
  digitalWrite(led, HIGH);
}
void loop(){
  Serial.println("test");
  delay(1000);
}

Debug Message

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380000
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1148
load:0x403cc710,len:0xb40
load:0x403ce710,len:0x2f58
entry 0x403cc710

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@ITstreet1 ITstreet1 added the Status: Awaiting triage Issue is waiting for triage label May 16, 2025
@SuGlider
Copy link
Collaborator

@ITstreet1 - please enable the Core Debug Level: "Verbose and Erase All Flash Before Sketch Upload: "Enabled"
Please send back here the log output in order to allow us to understand better what may be happening.

@ITstreet1
Copy link
Author

Here is the output:

ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1148
load:0x403cc710,len:0xb40
load:0x403ce710,len:0x2f58
entry 0x403cc710
[ 0][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42003bfc
[ 12][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42003bea
[ 23][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42003bd8
[ 34][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42003bc6
[ 46][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42003bfc
[ 57][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42003bea
[ 68][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42003bd8
[ 80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42003bc6
[ 91][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type USB_DM (38) successfully set to 0x420020a8
[ 103][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type USB_DP (39) successfully set to 0x420020a8
[ 118][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 20 successfully set to type UART_RX (2) with bus 0x3fc8deac
[ 129][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 21 successfully set to type UART_TX (3) with bus 0x3fc8deac
[ 140][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 18 successfully set to type USB_DM (38) with bus 0x3fc8f974
[ 151][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 19 successfully set to type USB_DP (39) with bus 0x3fc8f974

@ITstreet1
Copy link
Author

USB CDC On Boot was enabled. Disabled outputs this:

ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xf (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1148
load:0x403cc710,len:0xb40
load:0x403ce710,len:0x2f58
entry 0x403cc710
[ 0][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42003a80
[ 12][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42003a6e
[ 23][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42003a5c
[ 34][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42003a4a
[ 46][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42003a80
[ 57][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42003a6e
[ 68][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42003a5c
[ 80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42003a4a
[ 95][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 20 successfully set to type UART_RX (2) with bus 0x3fc8dcac
[ 106][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 21 successfully set to type UART_TX (3) with bus 0x3fc8dcac
=========== Before Setup Start ===========
Chip Info:

Model : ESP32-C3
Package : 0
Revision : 0.03
Cores : 1
CPU Frequency : 160 MHz
XTAL Frequency : 40 MHz
Features Bitfield : 0x00000012
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : Yes
Classic BT : No
BT Low Energy : Yes
IEEE 802.15.4 : No

INTERNAL Memory Info:

Total Size : 327564 B ( 319.9 KB)
Free Bytes : 288296 B ( 281.5 KB)
Allocated Bytes : 35476 B ( 34.6 KB)
Minimum Free Bytes: 288296 B ( 281.5 KB)
Largest Free Block: 147444 B ( 144.0 KB)

Flash Info:

Chip Size : 4194304 B (4 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Bus Mode : QIO

Partitions Info:

            nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
        otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
           app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
           app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
         spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
       coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP

Software Info:

Compile Date/Time : May 16 2025 15:17:37
Compile Host OS : windows
ESP-IDF Version : v5.4.1-1-g2f7dcd862a-dirty
Arduino Version : 3.2.0

Board Info:

Arduino Board : ESP32C3_DEV
Arduino Variant : esp32c3
Arduino FQBN : esp32:esp32:esp32c3:JTAGAdapter=default,CDCOnBoot=default,PartitionScheme=default,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=verbose,EraseFlash=all,ZigbeeMode=default
============ Before Setup End ============
[ 433][V][esp32-hal-uart.c:552] uartBegin(): UART0 baud(9600) Mode(800001c) rxPin(20) txPin(21)
[ 442][V][esp32-hal-uart.c:650] uartBegin(): UART0 not installed. Starting installation
[ 450][V][esp32-hal-uart.c:660] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
[ 461][V][esp32-hal-uart.c:677] uartBegin(): Setting UART0 to use XTAL clock

@ITstreet1
Copy link
Author

The answer was here:
rst:0x8 (TG1WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)

There is no such thing as GPIO12 available for users. It was my typo, as I am using GPIO10.

@SuGlider
Copy link
Collaborator

@ITstreet1 - happy that you have found the issue and it is working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

2 participants