Blinky ESP-IDF example does not work

/* Blink Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

/* Can run 'make menuconfig' to choose the GPIO to blink,
   or you can edit the following line and set a number here.

void blink_task(void *pvParameter)
    /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
       muxed to GPIO on reset already, but some default to other
       functions and need to be switched to GPIO. Consult the
       Technical Reference for a list of pads and their default
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    while(1) {
        /* Blink off (output low) */
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        /* Blink on (output high) */
        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(1000 / portTICK_PERIOD_MS);

void app_main()
    xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);

ini file

; PlatformIO Project Configuration File
;   Build options: build flags, source filter, extra scripting
;   Upload options: custom port, speed and extra flags
;   Library options: dependencies, extra library storages
; Please visit documentation for the other options and examples

home_dir = "/Users/Solid Snake/.platformio"

platform = espressif32
framework = espidf
board = esp-wrover-kit
monitor_speed = 115200
build_flags =

And it gave this

Configuring upload protocol...
AVAILABLE: esp-prog, esptool, ftdi, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM5
Uploading .pioenvs\esp-wrover-kit\firmware.bin
usage: esptool write_flash [-h] [--flash_freq {keep,40m,26m,20m,80m}]
[--flash_mode {keep,qio,qout,dio,dout}]
[--flash_size FLASH_SIZE]
[--spi-connection SPI_CONNECTION] [--no-progress]
[--verify] [--compress | --no-compress]
<address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: 'c:\\Users\\Solid'
*** [upload] Error 2
================================================================= [ERROR] Took 136.65 seconds =================================================================
Le processus du terminal s'est achevé avec le code de sortie 1

Le terminal sera réutilisé par les tâches, appuyez sur une touche pour le fermer.

I have a space in my PC name, there is a know this is a known issue with platformIO&ESPTOOL
But what canI do ? Look at the ini file I’ve put home_dir = "/Users/Solid Snake/.platformio" but without success.

note that the arduino blinky example worked totally with the same configuration

Looks like there’s also the same type of error in PIO where flashing occurs, i.e. non-shell-escaped argument, something like <file> but contains a space and so it breaks off early.

The only thing you could try is to create the project in a path which does not contains spaces. Then the flash command should be good.

On the other hand, are you sure you have the latest PIO version? (pio --version, pio upgrade --dev)

My PIO version is:
PlatformIO, version 3.6.1a5

I’ll upgrade it to the dev version then do the test

Same problem after upgrading

<address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: 'c:\\Users\\Solid'
*** [upload] Error 2

This is my PC username which has a space in the name.

So then I’ll have to wait for the resolution of the bug ? When it will be solved in your or Ivan’s opinion ?

Is this the same known issue or it’s a new one ?

We are working on reproducing of this issue. Temporary solution is to move PLATFORMIO_HOME_DIR to a location without path.

For example, home_dir = /Users/.platformio

Total newbie. I have a similar problem but I’m not sure about what to fix. Admittedly the paths are ugly. I’m using the installation defaults:
C:\Users\Name.Domain\AppData\Local\Programs\Microsoft VS Code\Code.exe

This is my Blink build output:

Compiling .pioenvs\esp32dev\src\main.o
src\main.cpp: In function 'void blink_task(void*)':
src\main.cpp:19:22: error: 'CONFIG_BLINK_GPIO' was not declared in this scope
src\main.cpp:30:26: note: in expansion of macro 'BLINK_GPIO'

Try using

build_flags = -D CONFIG_BLINK_GPIO=2

in your platform.ini file. Depending on the Hardware you have you might need to change the 2 to the GPIO number that your LED is connected to.

Well that gets me a little further, but there must be some path thing I don’t get. Here are the new errors:

argument of type “int” is incompatible with parameter of type “gpio_num_t”
invalid conversion from ‘int’ to ‘gpio_num_t’ [-fpermissive]

for the line below (all the gpio lines actually):
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);

Oh, and these are the includes:

#include <stdio.h>
#include “freertos/FreeRTOS.h”
#include “freertos/task.h”
#include “driver/gpio.h”
#include “sdkconfig.h”

OK, so for the time being I just added a definition to main.cpp that gets me past that error:


The build proceeds and only dies at the end:

Linking .pioenvs\esp32dev\firmware.elf
.pioenvs\esp32dev\libesp32.a(cpu_start.o):(.literal.main_task+0x20): undefined reference to `app_main'
.pioenvs\esp32dev\libesp32.a(cpu_start.o): In function `main_task':
cpu_start.c:(.text.main_task+0x84): undefined reference to `app_main'
collect2.exe: error: ld returned 1 exit status

I think I found a solution to my last error. (If I can use main.c instead of main.cpp I might just do that instead.) Not sure. Anyway I am about to test this on the DevKitC but I need to see what pin I can use for the LED or just to scope the slow square wave.

//void app_main()
extern “C” void app_main(void)

@grantb @HiBert I think that our issues are not really the same. Isn’t it ?

what do you mean by a “location without path” ? any location have a path

no, grantb’s issue pretty sure is a different one, I was just letting him know how to fix his undeclared macro problem, hoping that was his only problem.

Sorry, I didn’t mean to steer the thread so far away from the original. The title sucked me in. :slight_smile: (BTW, I can build mine now, thanks).