esp32_nat_router_plus icon indicating copy to clipboard operation
esp32_nat_router_plus copied to clipboard

Error when Building - The component esp_driver_uart could not be found.

Open jimbeam128 opened this issue 3 months ago • 7 comments

Hi,

I tried to compile and flash for a ESP32 S3.

First I tried the binaries to download and flash but no success.

So I tried to compile it and flash afterwards. But when I build, I get component esp_driver_uart could not be found...

I also builded the esp32 nat router from martin-ger (from who you forked). When I compile the source from his code it´s working... And that code also depends on uart...

Do you have an Idea why it´s "missing"?

jimbeam128 avatar Aug 29 '25 08:08 jimbeam128

Hi @jimbeam128

Please share the log i know the issue but i need to confirm it once.

gjroots avatar Aug 31 '25 07:08 gjroots

hi @gjroots ,

thanks for your reply! Here the logs which were written.

idf_py_stderr_output_12268.log idf_py_stdout_output_12268.log

jimbeam128 avatar Aug 31 '25 11:08 jimbeam128

Clone my repo and replace these files and check once.

Esp32s3.zip

gjroots avatar Aug 31 '25 16:08 gjroots

In actual case the driver component missing means may be replaced by something naming it so if you are using vscode then navigate to sdk like .pio folder check and update in cmake CMakeLists.txt like while building the stage we inform to include the driver.

So first experiment on my above attachment in previous and let know if it works or not.

Actually s3 board has two ways of communication like JTAG and UART. so check your board model type update via 'menu config'

gjroots avatar Aug 31 '25 17:08 gjroots

Hi @gjroots ,

I just use esp-idf (version 5.2.5) alone for trying to compile. No vscode involved.

I even get this error when the target is set to "esp32".

Also when I run idf.py menuconfig, I get the error

-- Building ESP-IDF components for target esp32 CMake Error at C:/Espressif/Espressif/frameworks/esp-idf-v5.2.5/tools/cmake/build.cmake:288 (message): Failed to resolve component 'esp_driver_uart'.

I mirrored your repo again and replaced the files. I tried to build again, but same error...

When I do it via vscode, I get the same errors. Doesn´t matter if it´s set to esp32 or esp32s3

jimbeam128 avatar Sep 01 '25 05:09 jimbeam128

Hello again,

had an intensive Session with chatgpt to try to "fix" the compilation errors.

In general there seems to be mix-ups with Code which works only in Version 4 and only in Version 5...

Here my procedure:

  1. mirrored the repo clean again
  2. tried to set target to esp32s3 with set-target esp32s3. Error: esp_driver_uart could not be found. removed "esp_driver_uart" from file components/console_handler/cmakelists.txt
  3. Error: esp_driver_usb_serial_jtag could not be found. removed "esp_driver_usb_serial_jtag" from file components/console_handler/cmakelists.txt added the component "driver" to the file. Why?: Chatgpt told me that these components are not separated in Version 5 of esp-idf any more, I should use "driver"

Then I was able to set esp32s3 as target. Then I tried to build. 4. Error: error "IP_NAPT must be defined" Chatgpt gave me the hint to go to menuconfig: config → LWIP → IP forwarding So I enabled the options "Enable IP forwarding" and sub-option "Enable NAT (new/experiemental"). Then this error went away.

  1. Error: console_handler.c:16:10: fatal error: driver/uart_vfs.h: No such file or directory 16 | #include "driver/uart_vfs.h" Chatgpt told me this: that error means the code you’re building is including a header that no longer exists in ESP-IDF v5.x: So I commented this line out. Because it is "included" in esp_vfs_dev.h and driver/uart.h which are already used.

furthermore I should replace the function calls (for Version 4) with the calls in version 5. If the code uses: uart_vfs_dev_init(); uart_vfs_dev_use_driver();

I should replace with: esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); Hint from chatgpt: If you see uart_vfs_dev_config_t or similar, those have been merged into esp_vfs_dev_uart_use_driver(). "uart_vfs_dev_use_driver" existed in console_handler.c, replaced with "esp_vfs_dev_uart_use_driver"

  1. Error: console_handler.c:17:10: fatal error: driver/usb_serial_jtag_vfs.h: No such file or directory 17 | #include "driver/usb_serial_jtag_vfs.h" Similar error as in 5. so I commented the line out Hint: If the code uses: usb_serial_jtag_vfs_dev_use_driver(); replace with: esp_vfs_dev_usb_serial_jtag_use_driver();

  2. Error: implicit declaration of function 'uart_vfs_dev_port_set_rx_line_endings'; did you mean 'esp_vfs_dev_uart_set_rx_line_endings' So I replaced in console_handler.c the function-calls "uart_vfs_dev_port_set_rx_line_endings(); uart_vfs_dev_port_set_tx_line_endings();" with "esp_vfs_dev_uart_port_set_rx_line_endings" and "esp_vfs_dev_uart_port_set_tx_line_endings"

  3. Here´s my final error where I´m stuck...

Error: [1006/1009] Linking CXX executable esp32_nat_router+.elf FAILED: esp32_nat_router+.elf components/freertos/app_startup.c:206:(.text.main_task+0xa8): undefined reference to `app_main' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

See attached log file...

Maybe someone has a hint?

idf_py_stdout_output_9600.log

jimbeam128 avatar Sep 09 '25 06:09 jimbeam128

After another intensive Session with Chatgpt I finally got it to work! Yessssss!!! - @gjroots

The remaining steps were:

  1. Regarding "undefined reference to app_main"

I couldn´t find a clue why appMain was not found because it is configured the same as on the project of martinger. So I copied the content of folder "src" and pasted it in a new folder "main" in the root of the project folder.

  1. Errors with component_targets

Then I got errors with Component_Targets like "index.html.gz"

Problem was that the targets were located in the wrong file.

removed the following lines from CMakeLists.txt in folder src (now main):

target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/index.html.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/settings.html.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/info.html.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/error_404.html.gz" TEXT)

target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/main.css.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/dark.css.gz" TEXT)

target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/scan.js.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/settings.js.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/info.js.gz" TEXT) target_add_binary_data(${COMPONENT_TARGET} "../components/web_server/www/output/gzip/functions.js.gz" TEXT)

and pasted (replace whole content) the following content in the file components/web_server/CMakeLists.txt

idf_component_register(SRCS request_handler.c response_handler.c get_data_handler.c storage_handler.c auth_handler.c web_server.c INCLUDE_DIRS include EMBED_FILES "www/output/gzip/index.html.gz" "www/output/gzip/settings.html.gz" "www/output/gzip/info.html.gz" "www/output/gzip/error_404.html.gz" "www/output/gzip/main.css.gz" "www/output/gzip/dark.css.gz" "www/output/gzip/scan.js.gz" "www/output/gzip/settings.js.gz" "www/output/gzip/info.js.gz" "www/output/gzip/functions.js.gz" REQUIRES esp_http_server esp-tls json esp_http_client utils cmd_router cmd_nvs ota_handler wifi_handler)

  1. problems with partition table // firmware too big.

the compiler told me that it could not find the partition "factory".

So the first change was to exchange line

ota_0, app, ota_0, 0x100000, 0x140000,

with

factory, app, factory, 0x100000, 0x140000,

in partitions.csv.

But the build was still unsuccessful.

  1. partitions.csv not used

So I still got the same error. Went to menuconfig -> partition table and selected custom partition table (CSV) and selected partitions.csv as custom partition CSV file.

  1. flash size error

that´s the last error.

Again in menuconfig went to Serial flasher config and set Flash size to 4 MB.

Then builded and flashed the ESP32S3. After that I got a working and responding ESP.

I´ve attached my built binaries for everyone if desired.

esp32S3-binaries.zip

jimbeam128 avatar Sep 17 '25 07:09 jimbeam128