Page 1 of 1

ESP-IDF, Platformio & ESP32-C3 uploading problem

Posted: Thu Nov 04, 2021 1:58 pm
by Kralik
Hi,

I've been trying to program my ESP32-C3 board, but so far Arduino IDE worked for me, but this is not the solution I want to go with. I've installed ESP-IDF via platformio on my Mac, (removed EC-ACC certificate in order to compile successfully) and tried to upload blink example sketch from ESP-IDF.

It connected to my board and apparently started to uploading, but when it finished the ESP did nothing. No (desired) serial output nor any "blinking" pin.

I'm using a custom devboard made by Bastlir, schematic can be found here: https://github.com/Bastlirovo/esp32c3-m ... main/HW/v1
As this board is meant to be programmed via internal USB, I had to enable "USB CDC on boot" setting in Arduino and upload mode set to "internal USB". I've found similar settings for platformio, but I'm not really sure if they are the correct ones;

My Platformio.ini file:

Code: Select all

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = espidf
board_build.f_cpu = 40000000L
upload_port = /dev/cu.usbmodem1101
build_flags = 
    ; enable USB serial
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON
Platformio debug log:

Code: Select all

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (3.3.2) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 40MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf 3.40300.0 (4.3.0) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - tool-mkspiffs 2.230.0 (2.30) 
 - tool-ninja 1.9.0 
 - toolchain-riscv-esp 1.80400.0 (8.4.0)
WARNING: You are using pip version 21.0.1; however, version 21.3.1 is available.
You should consider upgrading via the '/Users/xxx/.platformio/penv/bin/python -m pip install --upgrade pip' command.
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32-c3-devkitm-1/firmware.elf
Checking size .pio/build/esp32-c3-devkitm-1/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.2% (used 10556 bytes from 327680 bytes)
Flash: [==        ]  15.3% (used 160572 bytes from 1048576 bytes)
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Use manually specified: /dev/cu.usbmodem1101
Uploading .pio/build/esp32-c3-devkitm-1/firmware.bin
esptool.py v3.1
Serial port /dev/cu.usbmodem1101
Connecting...
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:b4:2a:08
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 2MB
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x00037fff...
Flash params set to 0x001f
Compressed 19104 bytes to 11256...
Writing at 0x00000000... (100 %)
Wrote 19104 bytes (11256 compressed) at 0x00000000 in 0.5 seconds (effective 291.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 328.0 kbit/s)...
Hash of data verified.
Compressed 160704 bytes to 79970...
Writing at 0x00010000... (20 %)
Writing at 0x00019aa5... (40 %)
Writing at 0x000209c2... (60 %)
Writing at 0x00027868... (80 %)
Writing at 0x00030576... (100 %)
Wrote 160704 bytes (79970 compressed) at 0x00010000 in 2.4 seconds (effective 546.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
========================================================================================= [SUCCESS] Took 15.46 seconds =========================================================================================
main.c:

Code: Select all

/* Blink Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

/* Can use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
   or you can edit the following line and set a number here.
*/
#define BLINK_GPIO 0

void app_main(void)
{
    /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
       muxed to GPIO on reset already, but some default to other
       functions and need to be switched to GPIO. Consult the
       Technical Reference for a list of pads and their default
       functions.)
    */
    gpio_reset_pin(BLINK_GPIO);
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    while(1) {
    //     /* Blink off (output low) */
        printf("Turning off the LEDDD\n");
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    //     /* Blink on (output high) */
        printf("Turning on the LED\n");
        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}
Serial output (screen /dev/tty.usbmodem1101 115200):

Code: Select all

ESP-ROM:esp32c3-api1-20210207
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42
SPIWP:0xee
mode:QIO, clock div:1
load:0x3fcd6100,len:0x1838
ets_loader.c 78 
xxx@xxx ~ %
There are 2 buttons on the devboard, Reset and Boot, but pressing them in many combinations before/during uploading didn't help.

Thank you very much for any advice.