Blinky ESP-IDF example does not work


#1
/* 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.
*/
#define BLINK_GPIO CONFIG_BLINK_GPIO

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
       functions.)
    */
    gpio_pad_select_gpio(BLINK_GPIO);
    /* 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
; http://docs.platformio.org/page/projectconf.html


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


[env:esp-wrover-kit]
platform = espressif32
framework = espidf
board = esp-wrover-kit
monitor_speed = 115200
build_flags =
	; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
	-D CONFIG_BLINK_GPIO=2

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.


#2

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


#3

Looks like there’s also the same type of error in PIO where flashing occurs, i.e. non-shell-escaped argument, something like esptoo.py <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)


#4

My PIO version is:
PlatformIO, version 3.6.1a5

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


#5

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 ?


#6

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


#7

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

http://docs.platformio.org/en/latest/faq.html#unicodedecodeerror-non-ascii-characters-found-in-build-environment


#8

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
C:\Users\Name.Domain.platformio
C:\Users\Name.Domain.platformio\python27
C:\Users\Name.Domain\Documents\PlatformIO\Projects

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
#define  BLINK_GPIO  CONFIG_BLINK_GPIO
^
src\main.cpp:30:26: note: in expansion of macro 'BLINK_GPIO'
gpio_pad_select_gpio(BLINK_GPIO);

#9

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.


#10

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”


#11

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

#define CONFIG_BLINK_GPIO GPIO_NUM_2

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

#12

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)


#13

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


#14

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


#15

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.