Dopo aver introdotto, nel precedente articolo, il chip ESP32 e la scheda di sviluppo ufficiale di Espressif, oggi vediamo come installare e utilizzare l’ambiente di sviluppo ufficiale.
Il framework di sviluppo ufficiale per il chip ESP32 è stato rilasciato da Espressif su Github, con licenza opensource (Apache 2.0) e chiamato Espressif IoT Development Framework (idf per brevità).
Per poterlo utilizzare su S.O. Windows, è necessario avere a disposizione una suite di comandi e toolchains GNU (make, bash…). Espressif ha scelto di fornire una versione di MSYS2 già preconfigurata.
Scarichiamo quindi l’archivio ZIP dal sito di Espressif e scompattiamolo nella root del disco C, in modo che tutto venga installato nella sottocartella C:\msys32:
Facciamo doppio click su minigw32.exe per eseguire una shell bash:
Possiamo ora clonare il repository Github di idf in modo da averne una copia locale. Dobbiamo scegliere una cartella locale dove memorizzare tale copia locale, per semplicità utilizziamo la home dell’utente.
Spostiamoci quindi in tale cartella e lanciamo il comando di clone:
$ cd $ git clone --recursive https://github.com/espressif/esp-idf.git
Al termine del processo, l’ambiente di sviluppo è disponibile nella sottocartella esp32-idf:
Per poterlo utilizzare durante la compilazione dei nostri progetti, dobbiamo esportare tale path come variabile di ambiente IDF-PATH:
$ export IDF_PATH=~/esp-idf
Colleghiamo la scheda!
Siamo ora pronti per collegare la nostra development board al computer.
Se abbiamo già i drivers corretti, una volta collegata apparirà tra i dispositivi del computer come nuova porta seriale:
In caso contrario, i drivers necessari si trovano sul sito ufficiale di Silicon Labs.
Hello World
Come da prassi, proviamo a compilare e caricare sulla nostra scheda di sviluppo un programmino che stampa a video (tramite la connessione seriale-usb) la scritta Hello world.
Tra gli esempi distribuiti insieme all’ambiente di sviluppo, è compreso proprio 01_hello_world. Per compilarlo, spostiamoci nella sua cartella e lanciamo il comando make:
$ cd $ cd esp-idf/examples/01_hello_world/ $ make
Ci apparirà un menu di configurazione, di cui parleremo diffusamente in un prossimo articolo. Per ora dobbiamo semplicemente indicare al flasher la porta USB alla quale è collegata la nostra scheda.
Selezioniamo quindi Serial flasher config, quindi /dev/ttyUSB0 (che è quella di default):
Inseriamo il nome della porta corretta (identificata sopra), quindi confermiamo con Ok, Save ed Exit:
Al termine della compilazione, è possibile caricare il programma sulla scheda utilizzando il comando:
make flash
Se ora ci colleghiamo, tramite un emulatore terminale, alla porta seriale della scheda di sviluppo con la corretta velocità (115200) dovremmo vedere il programma in esecuzione:
(il programma stampa la scritta “Hello world!”, conta 10 secondi e riavvia il chip…)
Presumably the Espressif ZIP archive you mentioned will occasionally get updated. As I can find no quick and obvious path to this zip from either github or espressif (I’ve spent the past half-hour looking), could you provide a URL on espressif’s site that points you to their latest zip – on the grounds that such a URL might change less frequently than that to which it refers 🙂
Hi Paul, you’re right… the best way to find the link is the official documentation. I’ll update the article accordingly
Thanks. But unhappily there is more. Not that it matters to me, but I cannot find any trace of 01_hello_world in the esp-idf gittery (gittage?).
More seriously, I’m looking to make one of their wifi examples but the make – after several rumblings – just ends up saying that
… yada yada yada …
CC flash_qio_mode.o
CC bootloader_start.o
AR libmain.a
LD bootloader.elf
/bin/sh: python: command not found
And indeed the distribution shows an absence of python in /usr/bin. Thing is I already have python (both 2.7 and 3) installed under a separate cygwin environment but MSYS2 isn’t in the same universe (its / is not the same as my cygwin’s) and cannot see it. I have so many different IDEs (MPLAB, Atmel, Xilinx, not to mention GNU) living on this machine it’s hard to keep track of which one’s being used for what piece of hardware. :). I suppose I’ll have to install yet another python just for MSYS2. Gaah!
Just thought I’d mention a first-world problem!
Hi Paul! Try running the “minigw32.exe” executable instead of “msys2.exe”… it should solve your issue
mingw32.exe works – python appears to be known on that route, so thanks! But – although I get a bootloader.bin out of it, it just won’t go via (in my case) /dev/ttyS20 onto the board, Boot buttion has no effect. All I get is
serial.serialutil.SerialException: could not open port ‘/??/COM21’: WindowsError(123, ‘The filename, directory name, or volume label syntax is incorrect.’)
As it happens I have a prior prog flashed onto it (via the arduino ide) and I can see its output coming in with a ‘cat < /dev/ttyS20' so I'm pretty confident the mingw config is correct.
Paul if you are under Windows, in menuconfig enter “COM21” (without quotes) as serial port for the flasher
$ git clone –recursive https://github.com/expressif/esp-idf.git
Cloning into ‘esp-idf’…
Username for ‘https://github.com’:
Password for ‘https://abhayrjoshi@github.com’:
remote: Repository not found.
fatal: repository ‘https://github.com/expressif/esp-idf.git/’ not found
Why is it asking for a username and password?
did you configure git with your account? Are you using Github also for your projects?
thanks, works perfect
Next ESP32 (3)
MINGW32 ~/esp-idf/examples/get-started/hello_world
$ make flash
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-61-gab8375a
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
Compiler version: 5.2.0
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-61-gab8375a
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
Please run the following command to install MSYS2’s MINGW Python cryptography package:
pacman -Sy mingw-w64-i686-python2-cryptography
make: *** [/home/ashenafi/esp-idf/make/project.mk:476: check_python_dependencies] Error 1
how can i solve this problem?
follow the instruction to update your environment –> https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html
share it:
The following command can simply add the current path of idf to the environment variable.
$ export IDF_PATH=$PWD
Hi, the whole esp-idf was updated, I am not even sure how using “make” can be viable anymore. The project is dependent on cmake now and has a completely different approach to the build system as far as I understand.