Hi, I'm pretty new to ESP-IDF, but I think I've got the hang of the hello world scripts and stuff.
I have this i2c scanner I'm trying to test out and I'm getting stuck in a boot loop so I'm just looking for some help getting unstuck and understanding what's going on so I can start writing my own stuff.
main.c:
[Codebox]#include <driver/i2c.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#ifndef APP_CPU_NUM
#define APP_CPU_NUM PRO_CPU_NUM
#endif
#define SDA_PIN 16
#define SCL_PIN 17
static const char *TAG = "i2cscanner";
void task(void *ignore)
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = SDA_PIN;
conf.scl_io_num = SCL_PIN;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 100000;
i2c_param_config(I2C_NUM_0, &conf);
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
while (1)
{
esp_err_t res;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
printf("00: ");
for (uint8_t i = 3; i < 0x78; i++)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (i << 1) | I2C_MASTER_WRITE, 1 /* expect ack */);
i2c_master_stop(cmd);
res = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10 / portTICK_PERIOD_MS);
if (i % 16 == 0)
printf("\n%.2x:", i);
if (res == 0)
printf(" %.2x", i);
else
printf(" --");
i2c_cmd_link_delete(cmd);
}
printf("\n\n");
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void app_main()
{
// Start task
//xTaskCreatePinnedToCore(task, TAG, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, APP_CPU_NUM);
xTaskCreate(task, TAG, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL);
}[/Codebox]
After flashing and connecting via minicom:
[Codebox]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:0x1738
load:0x403cc710,len:0xae8
load:0x403ce710,len:0x2e70
entry 0x403cc71a
I (35) boot: ESP-IDF v5.2-dev-1805-g9a1cc59338-dirty 2nd stage bootloader
I (35) boot: compile time Feb 4 2024 00:04:49
I (36) boot: chip revision: v0.3
I (40) boot.esp32c3: SPI Speed : 80MHz
I (45) boot.esp32c3: SPI Mode : DIO
I (50) boot.esp32c3: SPI Flash Size : 2MB
W (54) boot.esp32c3: PRO CPU has been reset by WDT.
I (60) boot: Enabling RNG early entropy source...
I (65) boot: Partition Table:
I (69) boot: ## Label Usage Type ST Offset Length
I (76) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (84) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (91) boot: 2 factory factory app 00 00 00010000 00100000
I (99) boot: End of partition table
I (103) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=09b80h ( 39808) map
I (118) esp_image: segment 1: paddr=00019ba8 vaddr=3fc8c000 size=01158h ( 4440) load
I (121) esp_image: segment 2: paddr=0001ad08 vaddr=40380000 size=05310h ( 21264) load
I (132) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=17b50h ( 97104) map
I (152) esp_image: segment 4: paddr=00037b78 vaddr=40385310 size=06bf4h ( 27636) load
I (161) boot: Loaded app from partition at offset 0x10000
I (161) boot: Disabling RNG early entropy source...
I (173) cpu_start: Unicore app
I (173) cpu_start: Pro cpu up.
I (182) cpu_start: Pro cpu start user code
I (182) cpu_start: cpu freq: 160000000 Hz
I (182) cpu_start: Application information:
I (185) cpu_start: Project name: i2cscanner
I (190) cpu_start: App version: 743f091-dirty
I (195) cpu_start: Compile time: Feb 4 2024 00:04:40
I (201) cpu_start: ELF file SHA256: 684ac6cbf...
I (207) cpu_start: ESP-IDF: v5.2-dev-1805-g9a1cc59338-dirty
I (214) cpu_start: Min chip rev: v0.3
I (219) cpu_start: Max chip rev: v0.99
I (223) cpu_start: Chip rev: v0.3
I (228) heap_init: Initializing. RAM available for dynamic allocation:
I (235) heap_init: At 3FC8DFE0 len 0004E730 (313 KiB): DRAM
I (242) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (248) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (255) spi_flash: detected chip: generic
I (259) spi_flash: flash io: dio
W (263) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (276) sleep: Configure to isolate all GPIO pins in sleep state
I (283) sleep: Enable automatic switching of GPIO sleep configuration
I (290) app_start: Starting scheduler on CPU0
I (295) main_task: Started on CPU0
I (295) main_task: Calling app_main()[/Codebox]
Any advice getting started is appreciated!
ESP32-C3-MINI-1 boot loop
-
- Posts: 2
- Joined: Sun Feb 04, 2024 6:36 am
Re: ESP32-C3-MINI-1 boot loop
I don't know how to make this SOLVED but I ended up redoing it differently and this time it worked out. Here's the code for the next person who find this:
[Codebox]#include <driver/i2c.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include "sdkconfig.h"
#define SDA_PIN 5
#define SCL_PIN 6
static char tag[] = "i2cscanner";
void task_i2cscanner(void *ignore) {
ESP_LOGD(tag, ">> i2cScanner");
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = SDA_PIN;
conf.scl_io_num = SCL_PIN;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 100000;
i2c_param_config(I2C_NUM_0, &conf);
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
int i;
esp_err_t espRc;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
printf("00: ");
for (i=3; i< 0x78; i++) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (i << 1) | I2C_MASTER_WRITE, 1 /* expect ack */);
i2c_master_stop(cmd);
espRc = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10/portTICK_PERIOD_MS);
if (i%16 == 0) {
printf("\n%.2x:", i);
}
if (espRc == 0) {
printf(" %.2x", i);
} else {
printf(" --");
}
//ESP_LOGD(tag, "i=%d, rc=%d (0x%x)", i, espRc, espRc);
i2c_cmd_link_delete(cmd);
}
printf("\n");
vTaskDelete(NULL);
}
void app_main()
{
// Start task
//xTaskCreatePinnedToCore(task, TAG, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, APP_CPU_NUM);
xTaskCreate(task_i2cscanner, tag, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL);
}[/Codebox]
[Codebox]#include <driver/i2c.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include "sdkconfig.h"
#define SDA_PIN 5
#define SCL_PIN 6
static char tag[] = "i2cscanner";
void task_i2cscanner(void *ignore) {
ESP_LOGD(tag, ">> i2cScanner");
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = SDA_PIN;
conf.scl_io_num = SCL_PIN;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 100000;
i2c_param_config(I2C_NUM_0, &conf);
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
int i;
esp_err_t espRc;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
printf("00: ");
for (i=3; i< 0x78; i++) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (i << 1) | I2C_MASTER_WRITE, 1 /* expect ack */);
i2c_master_stop(cmd);
espRc = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10/portTICK_PERIOD_MS);
if (i%16 == 0) {
printf("\n%.2x:", i);
}
if (espRc == 0) {
printf(" %.2x", i);
} else {
printf(" --");
}
//ESP_LOGD(tag, "i=%d, rc=%d (0x%x)", i, espRc, espRc);
i2c_cmd_link_delete(cmd);
}
printf("\n");
vTaskDelete(NULL);
}
void app_main()
{
// Start task
//xTaskCreatePinnedToCore(task, TAG, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, APP_CPU_NUM);
xTaskCreate(task_i2cscanner, tag, configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL);
}[/Codebox]
Who is online
Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 130 guests