Install PlatformIO on Visual Studio Code to program ESP32-C6 in ESP-IDF.

It's a fresh new Linux Mint with Visual Studio Code installed, no esptool or ESP-IDF installed. This video show steps to install PlatformIO on Visual Studio Code, to program YD-ESP32-C6-N16.



It's quite straightforward, except that:

If following error reported while installing:
PlatformIO: can not find working Python 3.6+ Interpreter.

Click on Abort PlatformIO IDE Installation, and check available solutions:
https://github.com/platformio/platformio-core-installer/issues/1774

Solution for Linux, install the following package and restart IDE.
sudo apt-get install python3-venv

If fail in accessing USB port:
A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist.

Grant permission to user, enter the command in Terminal, log out and log in:
sudo usermod -a -G dialout <user>
Code:

Edit platformio.ini to add the last three line about monitor_ setting:
[env:esp32-c6-devkitc-1]
platform = espressif32
board = esp32-c6-devkitc-1
framework = espidf
monitor_speed = 115200
monitor_dtr = 0
monitor_rts = 0
main.c
#include <stdio.h>
#include "esp_chip_info.h"
#include "esp_flash.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>

void app_main() {

    printf("\n");
    printf("==============================\n");
    printf("Hello ESP32-C6\n");
    printf("==============================\n");
    
    esp_chip_info_t chip_info;
    uint32_t flash_size;
    esp_chip_info(&chip_info);
    printf("%s with %d core(s).\n",
        CONFIG_IDF_TARGET,
        chip_info.cores);
    
    unsigned major_rev = chip_info.revision  / 100;
    unsigned minor_rev = chip_info.revision  % 100;
    printf("Silicon revision v%d.%d.\n", major_rev, minor_rev);

    esp_flash_get_size(NULL, &flash_size);
    printf("%ld MB %s flash\n", flash_size/(uint32_t)(1024*1024),
        (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");

    printf("------------------------------\n");

    for(int i =0; i<=20; i++){
        printf("\rHello %d", i);
        fflush(stdout);
        vTaskDelay(1000/portTICK_PERIOD_MS);
    }

    printf("\n=== bye ======================\n");
}


Comments

  1. is it worth ? last year ive tried but was tooo complicated... I hope with esp32 is easier to get it running.. thanks for the info

    ReplyDelete

Post a Comment

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.