我正在尝试编译我的第一个 ESP32 示例项目。我使用所有最新工具设置 Visual Studio Code。(Python、工具链等)。我不确定我到底需要什么,因为我是这个环境的新手,所以也许我错过了一些东西。
我遵循了关于如何创建和编译第一个项目的用户指南,我使用了示例文件夹中的 Blink 项目。
这是我得到的。
> Executing task: cmake -G Ninja .. <
-- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32s2
-- Checking Python dependencies...
Python requirements from C:\Users\dmitryke\esp\esp-idf\requirements.txt are satisfied.
-- Project sdkconfig file C:/ESP32_projects/blink/sdkconfig
Loading defaults file C:/ESP32_projects/blink/sdkconfig.defaults...
-- Components:
-- Component paths:
-- Configuring done
-- Generating done
-- Build files have been written to C:/ESP32_projects/blink/build
The terminal will be reused by tasks, press any key to close it.
> Executing task: cmake --build . <
[1/1] Linking C executable blink.elf
FAILED: blink.elf
cmd.exe /C "cd . && C:\Users\dmitryke\.espressif\tools\xtensa-esp32s2-elf\esp-2020r3-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-gcc.exe -mlongcalls CMakeFiles/blink.elf.dir/project_elf_src.c.obj -o blink.elf -Wl,--cref -Wl,--Map=C:/ESP32_projects/blink/build/blink.map -fno-rtti -fno-lto && cd ."
c:/users/dmitryke/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: c:/users/dmitryke/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/lib/no-rtti/crt0.o:(.literal+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command cmake --build ." terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
我从 blink.c 中删除了所有内容以避免代码错误。
眨眼.c
#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 0x01
void app_main(void)
{
while(1) { }
}
另一个问题,有一个运行选项 idf.py menuconfig
。有时它有效,有时它说:
C:\ESP32_projects\blink>idf.py menuconfig
'idf.py' is not recognized as an internal or external command,
operable program or batch file.
任何帮助将不胜感激!