[ESP32] Quickly build a vscode development environment (convenient)

Publisher:Lihua521Latest update time:2022-08-16 Source: csdnKeywords:ESP32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Download address: https://pan.baidu.com/s/1-oGcJ0p-iV4WZ9d6lL0KaA

Extraction code: 7v35


Espressif4_4_1 streamlined portable: https://download.csdn.net/download/qq_29246181/86399639

VSCode1.61_Embedded Convenient_Including essential plug-ins: https://download.csdn.net/download/qq_29246181/86244991


1. Unzip the compressed file to the root directory of drive C

C:prog

insert image description here

Copy [settings.json] to "C:UsersUsernameAppDataRoamingCodeUser"

2.

2. Install the VScode plugin Espressif IDF

insert image description here
insert image description here

3. Compile the routine and debug

Use VScode to open C:progEspressifesp-idfexamplesperipheralsgpiogeneric_gpio


Select the corresponding chip model and then execute the compilationinsert image description here
insert image description here

After compiling, execute burninginsert image description here
insert image description here

Open the observation window and view the serial port loginsert image description here
insert image description here

The second method: Change any drive letter

Portable vscode v1.69.1, integrated embedded common plug-ins (unzip and use) Download:

Portable Espressif v4.4.1, after decompression, write the environment variables. Download:

The environment variables that need to be added are as follows:

insert image description here
Method 1: Add
Method 2: Paste directly at the end

IDF_PATH                   D:progEspressif

IDF_PYTHON_ENV_PATH        %IDF_PATH%toolspython_envidf4.4_py3.8_env

IDF_TOOLS_PATH             %IDF_PATH%tools


Add the following to PATH:

Manually add once

%IDF_PATH%;

%IDF_TOOLS_PATH%toolsidf-python3.8.7;

%IDF_TOOLS_PATH%toolsxtensa-esp32-elfesp-2021r2-patch3-8.4.0xtensa-esp32-elfbin;

%IDF_TOOLS_PATH%toolsxtensa-esp32s2-elfesp-2021r2-patch3-8.4.0xtensa-esp32s2-elfbin;

%IDF_TOOLS_PATH%toolsxtensa-esp32s3-elfesp-2021r2-patch3-8.4.0xtensa-esp32s3-elfbin;

%IDF_TOOLS_PATH%toolsriscv32-esp-elfesp-2021r2-patch3-8.4.0riscv32-esp-elfbin;

%IDF_TOOLS_PATH%toolsesp32ulp-elf2.28.51-esp-20191205esp32ulp-elf-binutilsbin;

%IDF_TOOLS_PATH%toolsesp32s2ulp-elf2.28.51-esp-20191205esp32s2ulp-elf-binutilsbin;

%IDF_TOOLS_PATH%toolscmake3.20.3bin;

%IDF_TOOLS_PATH%toolsopenocd-esp32v0.11.0-esp32-20211220openocd-esp32bin;

%IDF_TOOLS_PATH%toolsninja1.10.2;

%IDF_TOOLS_PATH%toolsidf-exe1.0.3;

%IDF_TOOLS_PATH%toolsccache4.3ccache-4.3-windows-64;

%IDF_TOOLS_PATH%toolsdfu-util.9dfu-util-0.9-win64;

%IDF_TOOLS_PATH%python_envidf4.4_py3.8_envScripts;


At the end; add

%IDF_PATH%;%IDF_PATH%tools;%IDF_TOOLS_PATH%toolsidf-python3.8.7;%IDF_TOOLS_PATH%toolsxtensa-esp32-elfesp-2021r2-patch3-8.4.0xtensa-esp32-elfbin;%IDF_TOOLS_PATH%toolsxtensa-esp32s2-elfesp-2021r2-patch3-8.4.0xtensa-esp32s2-elfbin;%IDF_TOOLS_PATH%toolsxtensa-esp32s3-elfesp-2021r2-patch3-8.4.0xtensa-esp32s3-elfbin;%IDF_TOOLS_PATH%toolsriscv32-esp-elfesp-2021r2-patch3-8.4.0riscv32-esp-elfbin;%IDF_TOOLS_PATH%toolsesp32ulp-elf2.28.51-esp-20191205esp32ulp-elf-binutilsbin;%IDF_TOOLS_PATH%toolsesp32s2ulp-elf2.28.51-esp-20191205esp32s2ulp-elf-binutilsbin;%IDF_TOOLS_PATH%toolscmake3.20.3bin;%IDF_TOOLS_PATH%toolsopenocd-esp32v0.11.0-esp32-20211220openocd-esp32bin;%IDF_TOOLS_PATH%toolsninja1.10.2;%IDF_TOOLS_PATH%toolsidf-exe1.0.3;%IDF_TOOLS_PATH%toolsccache4.3ccache-4.3-windows-64;%IDF_TOOLS_PATH%toolsdfu-util.9dfu-util-0.9-win64;%IDF_TOOLS_PATH%python_envidf4.4_py3.8_envScripts;


3. Make IDF support C++17

xEspressiftoolscmakebuild.cmake

insert image description here

Four indefinite length receiving serial port data

Four indefinite length receiving serial port data

xEspressifcomponentsdriveruart.c


//read any size, only added two line to fucntion uart_read_bytes, marked with mk

int uart_read_frame(uart_port_t uart_num, uint8_t* buf, TickType_t ticks_to_wait) {

    //mk: set to 1 so that it will pass the while

    uint32_t length = 1;


    uint8_t* data = NULL;

    size_t size;

    size_t copy_len = 0;

    int len_tmp;

    if(xSemaphoreTake(p_uart_obj[uart_num]->rx_mux,(portTickType)ticks_to_wait) != pdTRUE) {

        return -1;

    }

    while(length) {

        if(p_uart_obj[uart_num]->rx_cur_remain == 0) {

            data = (uint8_t*) xRingbufferReceive(p_uart_obj[uart_num]->rx_ring_buf, &size, (portTickType) ticks_to_wait);

            //mk: get actual length received

            length = p_uart_obj[uart_num]->rx_buffered_len;

            if(data) {

                p_uart_obj[uart_num]->rx_head_ptr = data;

                p_uart_obj[uart_num]->rx_ptr = data;

                p_uart_obj[uart_num]->rx_cur_remain = size;

            } else {

                //When using dual cores, `rx_buffer_full_flg` may read and write on different cores at same time,

                //which may lose synchronization. So we also need to call `uart_check_buf_full` once when ringbuffer is empty

                //to solve the possible asynchronous issues.

                if(uart_check_buf_full(uart_num)) {

                    //This condition will never be true if `uart_read_bytes`

                    //and `uart_rx_intr_handler_default` are scheduled on the same core.

                    continue;

                } else {

                    xSemaphoreGive(p_uart_obj[uart_num]->rx_mux);

                    return copy_len;

                }

            }

        }

        if(p_uart_obj[uart_num]->rx_cur_remain > length) {

            len_tmp = length;

        } else {

            len_tmp = p_uart_obj[uart_num]->rx_cur_remain;

        }

        memcpy((uint8_t *)buf + copy_len, p_uart_obj[uart_num]->rx_ptr, len_tmp);

        UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock));

        p_uart_obj[uart_num]->rx_buffered_len -= len_tmp;

        uart_pattern_queue_update(uart_num, len_tmp);

        p_uart_obj[uart_num]->rx_ptr += len_tmp;

        UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock));

        p_uart_obj[uart_num]->rx_cur_remain -= len_tmp;

        copy_len += len_tmp;

        length -= len_tmp;

        if(p_uart_obj[uart_num]->rx_cur_remain == 0) {

            vRingbufferReturnItem(p_uart_obj[uart_num]->rx_ring_buf, p_uart_obj[uart_num]->rx_head_ptr);

            p_uart_obj[uart_num]->rx_head_ptr = NULL;

            p_uart_obj[uart_num]->rx_ptr = NULL;

            uart_check_buf_full(uart_num);

        }

    }


    xSemaphoreGive(p_uart_obj[uart_num]->rx_mux);

    return copy_len;

}

Keywords:ESP32 Reference address:[ESP32] Quickly build a vscode development environment (convenient)

Previous article:[ESP32] Quickly build a vscode development environment (convenient)
Next article:[nrf51][nrf52] sd_power_gpregret_set special register

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号