Skip to content

Problem using IDF 4.4 with Arduino-Esp32 2.0.6 #7797

@HeadHodge

Description

@HeadHodge

Board

esp32-otg-usb-s3

Device Description

both usb-uart mini and usb-device type-a connected to usb connectors on my Win 10 laptop. usb-host type-a not connected

Hardware Configuration

out of box config

Version

v2.0.6

IDE Name

arduino ide

Operating System

win 10

Flash frequency

default board config

PSRAM enabled

no

Upload speed

115200

Description

i'm using your cdm-acm-host example from esp32-idf v4.4 to create my supplied ported arduino code.

i was under the impression i could use the idf 4.4 library provided with arduino-esp32 2.0.6

but i cant get my ported example to compile. can't figure what the problem is. my 1st guess is i dont really have the idf 4.4 lib as advertised???

thanks for help

Sketch

/*
 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: CC0-1.0
 */
#define US_KEYBOARD 1
#include <Arduino.h>

#include <stdio.h>
#include <string.h>
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "usb/usb_host.h"

#include "esp_log.h"
#include "esp_err.h"
#include "cdc_acm_host.h"

#define EXAMPLE_USB_HOST_PRIORITY 20
#define EXAMPLE_USB_DEVICE_VID    0x303A  // 0x303A:0x4001 (TinyUSB CDC device)
#define EXAMPLE_USB_DEVICE_PID    0x4001

static const char *TAG = "USB-CDC";

/* ------------------------------- Callbacks -------------------------------- */
static void handle_rx(uint8_t *data, size_t data_len, void *arg)
{
    ESP_LOGI(TAG, "Data received");
    ESP_LOG_BUFFER_HEXDUMP(TAG, data, data_len, ESP_LOG_INFO);
}

void usb_lib_task(void *arg)
{
    while (1) {
        //Start handling system events
        uint32_t event_flags;
        usb_host_lib_handle_events(portMAX_DELAY, &event_flags);
        if (event_flags & USB_HOST_LIB_EVENT_FLAGS_NO_CLIENTS) {
            ESP_LOGI(TAG, "All clients deregistered");
            ESP_ERROR_CHECK(usb_host_device_free_all());
        }
        if (event_flags & USB_HOST_LIB_EVENT_FLAGS_ALL_FREE) {
            break;
        }
    }

    //Clean up USB Host
    ESP_ERROR_CHECK(usb_host_uninstall());
    vTaskDelete(NULL);
}

void setup() {

    //Install USB Host driver. Should only be called once in entire application
    ESP_LOGI(TAG, "Installing USB Host");
    usb_host_config_t host_config = {
        .skip_phy_setup = false,
        .intr_flags = ESP_INTR_FLAG_LEVEL1,
    };
    ESP_ERROR_CHECK(usb_host_install(&host_config));
    
    // Create a task that will handle USB library events
    xTaskCreate(usb_lib_task, "usb_lib", 4096, xTaskGetCurrentTaskHandle(), EXAMPLE_USB_HOST_PRIORITY, NULL);

    ESP_LOGI(TAG, "Installing CDC-ACM driver");
    ESP_ERROR_CHECK(cdc_acm_host_install(NULL));

    ESP_LOGI(TAG, "Opening CDC ACM device 0x%04X:0x%04X", EXAMPLE_USB_DEVICE_VID, EXAMPLE_USB_DEVICE_PID);
    cdc_acm_dev_hdl_t cdc_dev;
    
    const cdc_acm_host_device_config_t dev_config = {
      .connection_timeout_ms = 5000,
      .out_buffer_size = 64,
      .event_cb = NULL,
      .data_cb = handle_rx,
      .user_arg = NULL,
    };
    
    ESP_ERROR_CHECK(cdc_acm_host_open(EXAMPLE_USB_DEVICE_VID, EXAMPLE_USB_DEVICE_PID, 0, &dev_config, &cdc_dev));
    assert(cdc_dev);
    cdc_acm_host_desc_print(cdc_dev);
    vTaskDelay(100);

    // Test sending and receiving: Send AT commands, responses are handled in handle_rx callback
    static char text1[] = "AT\r";
    ESP_ERROR_CHECK(cdc_acm_host_data_tx_blocking(cdc_dev, (uint8_t *)text1, strlen(text1), 1000));
    vTaskDelay(100);

    static char text2[] = "AT+GSN\r";
    ESP_ERROR_CHECK(cdc_acm_host_data_tx_blocking(cdc_dev, (uint8_t *)text2, strlen(text2), 1000));
    vTaskDelay(100);

    // Test Line Coding commands: Get current line coding, change it 9600 7N1 and read again
    ESP_LOGI(TAG, "Setting up line coding");

    cdc_acm_line_coding_t line_coding;
    ESP_ERROR_CHECK(cdc_acm_host_line_coding_get(cdc_dev, &line_coding));
    ESP_LOGI(TAG, "Line Get: Rate: %d, Stop bits: %d, Parity: %d, Databits: %d", line_coding.dwDTERate,
             line_coding.bCharFormat, line_coding.bParityType, line_coding.bDataBits);

    line_coding.dwDTERate = 9600;
    line_coding.bDataBits = 7;
    line_coding.bParityType = 1;
    line_coding.bCharFormat = 1;
    ESP_ERROR_CHECK(cdc_acm_host_line_coding_set(cdc_dev, &line_coding));
    ESP_LOGI(TAG, "Line Set: Rate: %d, Stop bits: %d, Parity: %d, Databits: %d", line_coding.dwDTERate,
             line_coding.bCharFormat, line_coding.bParityType, line_coding.bDataBits);

    ESP_ERROR_CHECK(cdc_acm_host_line_coding_get(cdc_dev, &line_coding));
    ESP_LOGI(TAG, "Line Get: Rate: %d, Stop bits: %d, Parity: %d, Databits: %d", line_coding.dwDTERate,
             line_coding.bCharFormat, line_coding.bParityType, line_coding.bDataBits);

    ESP_ERROR_CHECK(cdc_acm_host_set_control_line_state(cdc_dev, true, false));

    ESP_LOGI(TAG, "Example finished successfully!");
}

void loop()
{
    Serial.println("cdcHost::loop Device Connected, send test message.");
    delay(1000);
}

Debug Message

d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x7c): undefined reference to `cdc_acm_host_install'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x80): undefined reference to `cdc_acm_host_open'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x88): undefined reference to `cdc_acm_host_desc_print'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x94): undefined reference to `cdc_acm_host_data_tx_blocking'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x98): undefined reference to `cdc_acm_host_line_coding_get'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0x9c): undefined reference to `cdc_acm_host_line_coding_set'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o:(.literal._Z5setupv+0xa0): undefined reference to `cdc_acm_host_set_control_line_state'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: sketch\cdcHost.ino.cpp.o: in function `setup()':
D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:73: undefined reference to `cdc_acm_host_install'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:76: undefined reference to `cdc_acm_host_open'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:79: undefined reference to `cdc_acm_host_desc_print'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:82: undefined reference to `cdc_acm_host_data_tx_blocking'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:87: undefined reference to `cdc_acm_host_data_tx_blocking'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:94: undefined reference to `cdc_acm_host_line_coding_get'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:101: undefined reference to `cdc_acm_host_line_coding_set'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:106: undefined reference to `cdc_acm_host_line_coding_get'
d:/appdata/documents/arduinodata/packages/esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: D:\APPDATA\Documents\Arduino\cdcHost/cdcHost.ino:110: undefined reference to `cdc_acm_host_set_control_line_state'
collect2.exe: error: ld returned 1 exit status
exit status 1

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions