Différences entre versions de « FEATHER-CHARGER-MICROPYTHON-ESP8266-EN »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
 
(25 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
This page is currently under translation
 
 
 
== Pre-requisites ==
 
== Pre-requisites ==
Note: [[FEATHER-CHARGER-MICROPYTHON-ESP8266-EN|cette page existe également en anglais]]
+
Note: [[FEATHER-CHARGER-MICROPYTHON-ESP8266|This page also exists in French]]
  
Avant d'utiliser MicroPython avec un ESP8266 il sera nécessaire de reflasher l'ESP8266 avec la dernière version de du firmware MicroPython.
+
Before using MicroPython on ESP8266, you will need to reflash the ESP8266 with the last version of the MicroPython firmware.
  
Nous vous proposons ce tutoriel condensé (abordable) mais vous pouvez également [http://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html#deploying-the-firmware suivre les instructions officielles] (''micropython.org, anglais'') pour charger MicroPython sur un ESP8266.
+
Here is a compact and afordable tutorial but you can also find the [http://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html#deploying-the-firmware official instructions] (''micropython.org, english'') to loads MicroPython on an ESP8266.
  
En tout premier lieu vous aurez également besoin [https://www.python.org/downloads/ d'installer Python 2.7] (n'oubliez pas de sélectionner l'option qui ajoute le programme python dans le PATH de recherche de windows).
+
Firstly, you will need [https://www.python.org/downloads/ to install a Python environment]. Previously, Python 2.7 was required but it should work with more recent 3.x version. If you are running under Windows, do not forget to add the PATH to the search path. Python is usually available out-of-the-box on Linux based machine.
  
Ensuite, il est nécessaire d'installer le logiciel {{fname|esptool.py}} qui permet de flasher un firmware sur ESP8266. La façon la plus simple d'installer ce logiciel est d'utiliser '''pip''' (l'installateur de paquet python).
+
Next, you will need to install the {{fname|esptool.py}} software. It is used to send firmware to the ESP8266. A quick and easy is to use the '''pip''' (or pip3 for Python 3.x setups) Python Package Installer.
  
Saisissez la commande suivante dans un terminal:
+
Key-in the following line into a terminal:
  
 
  <nowiki>pip install esptool</nowiki>
 
  <nowiki>pip install esptool</nowiki>
  
{{underline|Note pour les utilisateurs de Mac OSX et Linux:}} vous pourriez avoir besoin d'exécuter cette commande en tant que root à l'aide d'un {{fname|sudo}} comme ceci:
+
{{underline|Note for Mac OSX & Linux:}} you may need to run this command as '''root''' with {{fname|sudo}} for the software to be installed property:
  
 
  <nowiki>sudo pip install esptool</nowiki>
 
  <nowiki>sudo pip install esptool</nowiki>
Ligne 22 : Ligne 20 :
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-20.png}}
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-20.png}}
  
Si '''pip''' vous informe que {{fname|esptool.py}} ne fonctionne qu'avec Python 2.x alors essayer une nouvelle fois en utilisant '''pip2''' dans la commande à la place de pip (si votre système utilise Python 3 par défaut alors la commande pip pourrait conduire à une situation un peu confuse).
+
{{underline|Tricky note from the past days:}}
 +
 
 +
If '''pip''' informs you that {{fname|esptool.py}} doesn't work with Python x.x then you may also try to install it with the '''pip2''' command instead of regular pip (if Python 3.x is the default interpreter then the pip command should be link to pip3... this may be confusing and leading to strange situation). It should no more exists in 2021.
  
 
== Download MicroPython ==
 
== Download MicroPython ==
  
Ensuite, [http://micropython.org/download/esp8266/ téléchargez la dernière version du binaire du Firmware MicroPython pour ESP8266]. Ces firmwares sont généralement compilés journellement depuis le code source sur Github. Si vous voulez réaliser votre propre compilation du firmware MicroPython ESP8266 (like if you're customizing it or including other modules & scripts) alors voyez le tutoriel "[https://learn.adafruit.com/building-and-running-micropython-on-the-esp8266/overview Building and Running MicroPython on the ESP8266] (''Adafruit, anglais''), un guide bien pratique qui explique comment compiler le firmware sur une machine virtuelle spéciale.
+
Next, [http://micropython.org/download/esp8266/ download the last binary version of the MicroPython firmware for ESP8266]. Such are also compiled everyday from the GitHub souce code but we do not recommend to use them unless you know what you are doing.  
 +
 
 +
The following screen capture shows the list of links, we just click on the most recent version to download it on the computer.
  
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-21.png}}
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-21.png}}
  
 
== Wiring + activates Flash mode on ESP8266 ==
 
== Wiring + activates Flash mode on ESP8266 ==
Maintenant nous allons placer notre ESP8266 en mode "Flashage Firmware". Cette opération est nécessaire aussi bien pour l'effacement de la mémoire Flash que pour le téléversement d'un nouveau FirmWare.
+
Now, we need to wire our ESP8266 on a computer and make it ready to receive the new firmware (called "Flash" mode).  
  
C'est un peu différent pour chaque carte ESP8266
+
Some board do already have USB connector, some not.
 +
 
 +
Some board do automagically start the flash mode, some not.
 +
 
 +
Here are the "Wiring + Flash mode" operation for many of the ESP8266 plateforms.
  
 
=== Common use case ===
 
=== Common use case ===
 +
You have a RAW ESP8266 without serial-to-usb interface. In most common-case, they offer a FTDI pin-out to attach a FTDI Friend (an USB-to-Serial adapter).
 +
 
[[Fichier:ESP8266-HUZZA.png|400px]]  
 
[[Fichier:ESP8266-HUZZA.png|400px]]  
  
* '''Pour le module ESP8266 brute''' ou '''NodeMCU Lolin''' vous aurez besoin de brancher un bouton pour ramener le GPIO0 à la masse et un deuxième bouton pour ramener la broche RESET à la masse. Maintenez le bouton GPIO0 enfoncé (ou connectez le à la masse) ET pressez puis relachez le bouton RESET pendant que vous maintenez GPIO0 à la masse. Relâcher finalement la broche GPIO0.
+
* for the '''raw ESP8266''' or '''NodeMCU Lolin''' you will need to wire the GPIO0 to the GROUND with a push-button THEN do the same with the RESET line.
* Pour le {{pl|733|breakout HUZZAH ESP8266}} les boutons GPIO0 et RESET sont déjà inclus sur la carte. Maintenez le bouton GPIO0 enfoncé (ou connectez le à la masse) ET pressez puis relâchez le bouton RESET pendant que vous maintenez GPIO0 à la masse. Relâcher finalement la broche GPIO0.
+
* Maintain the GPIO0 button down (to connect it to the Ground) THEN press and release the RESET button (while still maintaining GPIO0).
 +
* AFTER release the GPIO0 button. => you just activated the Flash mode.
 +
 
 +
On some board like {{pl|733|breakout HUZZAH ESP8266}} the GPIO0 and RESET button are already available on the board. This will ease the operation.
  
 
=== Feather HUZZAH ESP8266, Wemos D1 ===
 
=== Feather HUZZAH ESP8266, Wemos D1 ===
Ces modules dispose de la possibilité d'activer automatiquement le Flash Mode au moment de la programmation. Cela évite des manipulation supplémentaires.
+
Such module can automatically start the Flash mode thank to an hardware trick.  
 +
 
 +
That will avoids additionnal handling to start the Flash mode.
  
 
[[Fichier:FEATHER-ESP8266-02.jpg|240px]] [[Fichier:Wemos-D1-Mini-ESP8266.jpg|120px]]
 
[[Fichier:FEATHER-ESP8266-02.jpg|240px]] [[Fichier:Wemos-D1-Mini-ESP8266.jpg|120px]]
  
Pour le {{pl|846|Feather HUZZAH ESP8266}}, {{pl|1221|Wemos D1 Mini}}, {{pl|1222|Wemos D1 Pro}} c'est encore plus simple. Vous n'avez pas besoin de faire quoi que ce soit pour activer le mode "flashage Firmware". Cette carte est conçue pour détecter lorsque le port série est ouvert en vue de flasher le module. Il passe donc automatiquement en mode flashage en configurant automatiquement le module ESP8266 pour recevoir le firmware.
+
The {{pl|846|Feather HUZZAH ESP8266}}, {{pl|1221|Wemos D1 Mini}}, {{pl|1222|Wemos D1 Pro}} detects when the serial line is opened and automatically reset and start the Flash mode.  
* '''Sur Windows, vous devez préalablement [https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx installer le pilote CP210x de SiLabs] on Windows pour rendre visible le port série de la carte.<br />Sur Windows, il vaudra installer le pilote VCP standard (''normal VCP driver'') et non celui prenant en charge l'énumération des ports séries (''with Serial Enumeration'')
+
 
* '''Sur MacOS X, vous devez préalablement [https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx installer le pilote CP210x de SiLabs] on Windows pour rendre visible le port série de la carte.
+
You just need to send the firmware to the ESP8266 module, it will be automagically programmed.
{{ambox|text=Sur la gamme Wemos ESP8266, le convertisseur USB Série est basé sur un CH340D. Il est donc nécessaire d'installer le pilote approprié.}}
+
* '''On Windows''': you will have to install the [https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx CP210x SiLabs driver] to make the Serial-to-USB available on the board.<br />For Windows, it will be necessary to install the standard VCP driver (''normal VCP driver''), do not select the driver ''with Serial Enumeration'' (it will not work).
 +
* '''On MacOS X''': the driver should already be supported.
 +
* '''On Linux''': no driver needed, it work out of the box.
 +
 
 +
{{ambox|text=The Wemos ESP8266 do use another Serial-to-USB chip based on '''CH340D'''. You will need to install the appropriate driver on Windows/Mac.}}
  
 
=== ESP8266-DEV (only) ===
 
=== ESP8266-DEV (only) ===
Il est possible de programmer un module {{pl|667|ESP8266-DEV}} en utilisant un {{pl|144|câble console (USB-Série-TTL)}} exploitant des signaux en logique 3.3V .
+
You can flash a {{pl|667|ESP8266-DEV}} module by using a {{pl|144|console cable (USB-Série-TTL)}} using 3V logic for RX/TX .
  
Voici comment effectuer le raccordement.
+
Here how to wire the board.
  
 
[[Fichier:OLI-ESP8266-DEV-Wiring.jpg|453px]]
 
[[Fichier:OLI-ESP8266-DEV-Wiring.jpg|453px]]
  
Pour activer le FlashMode sur un {{pl|667|ESP8266-DEV}} (version Olimex):
+
To activates the Flash Mode on the {{pl|667|ESP8266-DEV}} (from Olimex):
* Il faut presser le bouton GPIO 0 (le petit bouton bouton utilisateur présent sur l'ESP8266-DEV, qui est également branché sur le GPIO 0)
+
* Press the GPIO 0 button (the small user button on the board is wired to GPIO 0)
* Puis mettre le module sous tension
+
* Then power-up the module.
* Enfin relâcher le bouton GPIO 0.
+
* Release the GPIO 0 button.
 +
 
 +
Voila, the ESP8266-DEV is set to Flash mode.
  
 
=== ESP8266-EVB (evaluation board) ===
 
=== ESP8266-EVB (evaluation board) ===
 
[[Fichier:OLI-ESP8266-EVB.jpg|180px]]
 
[[Fichier:OLI-ESP8266-EVB.jpg|180px]]
  
Pour activer le FlashMode sur un {{pl|668|ESP8266-EVB}} (évaluation board d'Olimex), {{pl|667|ESP8266-DEV}} (version Olimex):
+
To activate the Flash Mode on the {{pl|668|ESP8266-EVB}} (Evaluation Board from Olimex) (using a {{pl|667|ESP8266-DEV}}):
* Il faut presser le bouton GPIO 0 (le bouton utilisateur de l'ESP8266-EVB est également branché sur le GPIO 0)
+
* Presse the USER button on the board (this button is wired to the small push-button on the ESP8266-EVB, himself wired to the GPIO 0)
* Puis mettre le module sous tension
+
* Plug the power cord on the evaluation board (5V max)
* Enfin relâcher le bouton GPIO 0.  
+
* Then release the GPIO 0 button.  
  
A noter que l'{{pl|668|ESP8266-EVB}} et {{pl|667|ESP8266-DEV}} ne disposent pas de convertisseur USB-Série, il faut donc utiliser un {{pl|144|cable console (USB-Série-TTL)}} pour communiquer avec la carte ESP8266.
+
Please note that {{pl|668|ESP8266-EVB}} and {{pl|667|ESP8266-DEV}} do not have USB-to-Serial converter, you will have to use a {{pl|144|console cable (USB-Série-TTL)}} to communicates with the ESP8266 board.
  
 
[[Fichier:UEXT-SERIAL-wiring2.jpg|240px]] [[Fichier:UEXT-SERIAL-wiring.jpg|240px]]
 
[[Fichier:UEXT-SERIAL-wiring2.jpg|240px]] [[Fichier:UEXT-SERIAL-wiring.jpg|240px]]
  
 
== Erase the Flash ==
 
== Erase the Flash ==
Il est recommander d'effacer entièrement le contenu de la mémoire Flash d'une carte ESP8266 avant de téléverser un nouveau FirmWare. Exécutez le code suivant dans un terminal pour effectuer cette opération:
+
It is recommanded to completely erase the Flash memory of the ESP8266 board before to download the new FirmWare onto it. Execute the following code inside a terminal:
  
  <nowiki>esptool.py --port /chemin/vers/ESP8266 erase_flash</nowiki>
+
  <nowiki>esptool.py --port /path/to/ESP8266 erase_flash</nowiki>
  
{{fname|/chemin/vers/ESP8266}} est le chemin ou nom du port série connecté sur l'ESP8266. Le nom exacte du périhérique varie en fonction du type de convertisseur USB-vers-série. Lister vis port série avant de connecter le module ESP826 puis répétez l'opération avec le port série connecté. Le port qui vient d'apparaître est celui correspondant à votre ESP8266.
+
Where {{fname|/path/to/ESP8266}} is the path to the serial port attached on the ESP8266. The exact name of the peripheral depend of the USB-to-Serial converter used. List down the serial port before to connext you ESP module then repeat the operation with the serial port connected. The new port appearing is the one corresponding to the ESP8266.
  
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-22.png}}
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-22.png}}
Ligne 86 : Ligne 105 :
 
== Flashing MicroPython on ESP8266 ==
 
== Flashing MicroPython on ESP8266 ==
 
=== ESP8266 from Adafruit Industries ===
 
=== ESP8266 from Adafruit Industries ===
Pour le {{pl|733|breakout HUZZAH ESP8266}} et le {{pl|846|Feather HUZZAH ESP8266}} + {{pl|77|FTDI Friend}}:
+
For the {{pl|733|breakout HUZZAH ESP8266}} and the {{pl|846|Feather HUZZAH ESP8266}} + {{pl|77|FTDI Friend}}:
  
 
[[Fichier:FEATHER-ESP8266-02.jpg|240px]] [[Fichier:ESP8266-HUZZA.png|400px]]  
 
[[Fichier:FEATHER-ESP8266-02.jpg|240px]] [[Fichier:ESP8266-HUZZA.png|400px]]  
  
Remettez votre ESP8266 en "mode Flashage" et exécutez la commande suivante pour charger le nouveau firmware (celui que vous avez déjà téléchargé sur votre ordinateur):
+
Place our ESP8266 in "mode Flashage" and execute the following command to load the firmware (already downloaded):
  
 
  <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
 
  <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
  
{{ambox|text=Depuis la version 1.3 d'EspTool, il est possible d'utiliser Python 2.7 et Python 3.5.  
+
{{ambox|text=Since EspTool V1.3, you can use either 2.7 or Python 3.5.  
 +
 
 +
From EspTool version 2.x, you can use the option --flash_size=detect to avoir error on flash size.}}
  
Depuis la version du 2.x d'EspTool, il est possible d'utiliser l'option --flash_size=detect pour éviter les erreurs taille de flash.}}
+
Once again, {{fname|/path/to/ESP8266}} is the path (identification) of the serial port connected to the ESP8266. Remplace {{fname|firmware.bin}} with the real name (and access path) to the firmware file to upload to the ESP8266.
  
Encore une fois, {{fname|/chemin/vers/ESP8266}} est le chemin ou nom du port série connecté sur l'ESP8266. Remplacez {{fname|firmware.bin}} avec le vrai nom (et chemin d'accès) du fichier firmware que vous voulez téléverser sur l'ESP8266.
 
  
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-23.png}}
 
{{ADFImage|FEATHER-CHARGER-MICROPYTHON-ESP8266-23.png}}
  
 
=== ESP8266 WEMOS D1 Mini ===
 
=== ESP8266 WEMOS D1 Mini ===
Pour le {{pl|1221|Wemos D1}} dispose de 4MB de Flash comme pour la plupart des ESP8266 disponible sur le marché.  
+
The {{pl|1221|Wemos D1}} do have 4MB of Flash as many of ESP8266 available on the market.  
  
 
[[Fichier:Wemos-D1-Mini-ESP8266.jpg|180px]]   
 
[[Fichier:Wemos-D1-Mini-ESP8266.jpg|180px]]   
  
Exécutez la commande suivante pour charger le nouveau firmware (celui que vous avez déjà téléchargé sur votre ordinateur):
+
Execute le following command to load the MicroPython firmware (already downloaded on the computer):
  
 
   <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
 
   <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
  
 
=== ESP8266 WEMOS D1 PRO ===
 
=== ESP8266 WEMOS D1 PRO ===
Pour le {{pl|1222|Wemos D1 '''Pro'''}} dispose de 16MB de Flash, la commande de Flash est donc différente:
+
The {{pl|1222|Wemos D1 '''Pro'''}} do have 16MB of Flash, the command to execute:
  
 
[[Fichier:Wemos-D1-Pro-Mini-ESP8266.jpg|180px]]
 
[[Fichier:Wemos-D1-Pro-Mini-ESP8266.jpg|180px]]
  
Exécutez la commande suivante pour charger le nouveau firmware (celui que vous avez déjà téléchargé sur votre ordinateur):
+
Execute the following command to upload the MicroPython firmware:
  
 
  <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --fm dio --fs=32m 0 firmware.bin</nowiki>
 
  <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --fm dio --fs=32m 0 firmware.bin</nowiki>
  
{{ambox|text=Bien que le module n'embarque que 16MB, il est nécessaire de mentionner une Flash Size de '''32m''' ! Flasher le module avec une Flash Size de 16m laisse celui dans un état instable après le redémarrage.}}
+
{{ambox|text=This module is fitted with 16MB but we have to stipulate a Flash Size of '''32m''' ! Flasher the module with 16m Flash Size did creates an unstable situation where the ESP8266 doesn't reboot.}}
  
 
=== ESP8266-EVB & ESP8266-DEV ===
 
=== ESP8266-EVB & ESP8266-DEV ===
Pour le {{pl|668|ESP8266-EVB}} evaluation board et {{pl|667|ESP8266-DEV}} carte de développement placée sur la carte ESP8266-EVB:
+
For the {{pl|668|ESP8266-EVB}} evaluation board and the {{pl|667|ESP8266-DEV}} development board like following:
  
 
[[Fichier:OLI-ESP8266-EVB.jpg|180px]] [[Fichier:OLI-ESP8266-DEV.jpg|110px]]
 
[[Fichier:OLI-ESP8266-EVB.jpg|180px]] [[Fichier:OLI-ESP8266-DEV.jpg|110px]]
  
Exécutez la commande suivante pour charger le nouveau firmware (celui que vous avez déjà téléchargé sur votre ordinateur):
+
Please execute the following command to upload the MicroPython firmware (previously downloaded):
  
 
   <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
 
   <nowiki>esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin</nowiki>
  
Appliquer un cycle d'alimentation sur l'ESP8266-EVB pour réinitialiser la plateforme.
+
Do power cycle the plateform to properly restart the microcontroler.
  
 
== After Flash operation ==
 
== After Flash operation ==
Pressez le bouton RESET de votre carte une fois que l'outil à terminé le flashage du Firmware (la LED bleue clignote durant le flashage). Si vous ne possédez pas de bouton RESET, vous pouvez également déconnecter et reconnecter l'ESP8266 sur votre ordinateur.
+
Press tge RESET when available or power cycle the board.
 +
 
 +
Voila, you just have you MicroPython firmware running on your ESP!
 +
 
 +
You can now establish a [[FEATHER-CHARGER-MICROPYTHON-SERIAL-REPL|serial REPL]] with a software like [https://www.putty.org/ Putty] (Freeware, running on Linux, Windows, Mac).
 +
 
 +
When started, just write mention the path to serial device attached to the ESP8266.
 +
 
 +
 
 +
[[Fichier:FEATHER-CHARGER-MICROPYTHON-ESP8266-EN-10a.jpg]]
  
Voila, vous venez de flasher votre ESP8266 avec la dernière version du firmware MicroPython!
 
  
Vous pouvez sauter sur la section [[FEATHER-CHARGER-MICROPYTHON-SERIAL-REPL|REPL série]] de ce guide pour apprendre comment obtenir l'invite de commande de votre carte MicroPython.
+
[[Fichier:FEATHER-CHARGER-MICROPYTHON-ESP8266-EN-11.jpg]]
  
 
== Ressources ==
 
== Ressources ==
 
=== Error message ===
 
=== Error message ===
'''J'ai le message d'erreur "read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?" !'''
+
'''I do have the following error message "read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?" !'''
  
Nous avons rencontré ce problème lorsque le câble console était branché sur un HUB USB externe. Essayez de brancher le câble console directement sur l'ESP8266.
+
We do meet that problem when the console cable (USB/Serial) where connected through an external USB HUB. Try to plug the console cable directly on the ESP8266.
  
 
=== EspTool Upgrade ===
 
=== EspTool Upgrade ===
Les firmwares récents nécessitent une version récente d'EspTool pour être flasher l'ESP8266.
+
Recent version of the MicroPython firmwares do requires a more recent version of the EspTool to be flashed on the ESP8266.
  
Pour notre grand malheur, nous avons essayé de flasher un firmware 1.8.x avec un EspTool 1.0.1. Inutile de dire que nous n'avons plus grand chose de fonctionnel sur notre ESP8266 !
+
Since tghe release 1.8.x of MicroPython, the EspTool 1.0.1 doesn't make the job anymore.
  
Un upgrade d'EspTool à la version la plus récente (2.0.1 en l’occurrence, voir [https://pypi.python.org/pypi/esptool ici sur pypi.python.org]) à résolu notre problème grâce à l'option --flash_size=detect
+
An upgrade to a more recent EspTool (version 2.0.1) will help to fix with --flash_size=detect .
  
Pour forcer la mise-à-jour d'EspTool à une version donnée, il faut saisir:
+
The following command line can be used to force the upgrade to a given version of EspTool :
  
 
  sudo apt-get install esptool==2.0.1
 
  sudo apt-get install esptool==2.0.1

Version actuelle datée du 19 mai 2021 à 20:41

Pre-requisites

Note: This page also exists in French

Before using MicroPython on ESP8266, you will need to reflash the ESP8266 with the last version of the MicroPython firmware.

Here is a compact and afordable tutorial but you can also find the official instructions (micropython.org, english) to loads MicroPython on an ESP8266.

Firstly, you will need to install a Python environment. Previously, Python 2.7 was required but it should work with more recent 3.x version. If you are running under Windows, do not forget to add the PATH to the search path. Python is usually available out-of-the-box on Linux based machine.

Next, you will need to install the esptool.py software. It is used to send firmware to the ESP8266. A quick and easy is to use the pip (or pip3 for Python 3.x setups) Python Package Installer.

Key-in the following line into a terminal:

pip install esptool

Note for Mac OSX & Linux: you may need to run this command as root with sudo for the software to be installed property:

sudo pip install esptool

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Tricky note from the past days:

If pip informs you that esptool.py doesn't work with Python x.x then you may also try to install it with the pip2 command instead of regular pip (if Python 3.x is the default interpreter then the pip command should be link to pip3... this may be confusing and leading to strange situation). It should no more exists in 2021.

Download MicroPython

Next, download the last binary version of the MicroPython firmware for ESP8266. Such are also compiled everyday from the GitHub souce code but we do not recommend to use them unless you know what you are doing.

The following screen capture shows the list of links, we just click on the most recent version to download it on the computer.

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Wiring + activates Flash mode on ESP8266

Now, we need to wire our ESP8266 on a computer and make it ready to receive the new firmware (called "Flash" mode).

Some board do already have USB connector, some not.

Some board do automagically start the flash mode, some not.

Here are the "Wiring + Flash mode" operation for many of the ESP8266 plateforms.

Common use case

You have a RAW ESP8266 without serial-to-usb interface. In most common-case, they offer a FTDI pin-out to attach a FTDI Friend (an USB-to-Serial adapter).

ESP8266-HUZZA.png

  • for the raw ESP8266 or NodeMCU Lolin you will need to wire the GPIO0 to the GROUND with a push-button THEN do the same with the RESET line.
  • Maintain the GPIO0 button down (to connect it to the Ground) THEN press and release the RESET button (while still maintaining GPIO0).
  • AFTER release the GPIO0 button. => you just activated the Flash mode.

On some board like breakout HUZZAH ESP8266 the GPIO0 and RESET button are already available on the board. This will ease the operation.

Feather HUZZAH ESP8266, Wemos D1

Such module can automatically start the Flash mode thank to an hardware trick.

That will avoids additionnal handling to start the Flash mode.

FEATHER-ESP8266-02.jpg Wemos-D1-Mini-ESP8266.jpg

The Feather HUZZAH ESP8266, Wemos D1 Mini, Wemos D1 Pro detects when the serial line is opened and automatically reset and start the Flash mode.

You just need to send the firmware to the ESP8266 module, it will be automagically programmed.

  • On Windows: you will have to install the CP210x SiLabs driver to make the Serial-to-USB available on the board.
    For Windows, it will be necessary to install the standard VCP driver (normal VCP driver), do not select the driver with Serial Enumeration (it will not work).
  • On MacOS X: the driver should already be supported.
  • On Linux: no driver needed, it work out of the box.

ESP8266-DEV (only)

You can flash a ESP8266-DEV module by using a console cable (USB-Série-TTL) using 3V logic for RX/TX .

Here how to wire the board.

OLI-ESP8266-DEV-Wiring.jpg

To activates the Flash Mode on the ESP8266-DEV (from Olimex):

  • Press the GPIO 0 button (the small user button on the board is wired to GPIO 0)
  • Then power-up the module.
  • Release the GPIO 0 button.

Voila, the ESP8266-DEV is set to Flash mode.

ESP8266-EVB (evaluation board)

OLI-ESP8266-EVB.jpg

To activate the Flash Mode on the ESP8266-EVB (Evaluation Board from Olimex) (using a ESP8266-DEV):

  • Presse the USER button on the board (this button is wired to the small push-button on the ESP8266-EVB, himself wired to the GPIO 0)
  • Plug the power cord on the evaluation board (5V max)
  • Then release the GPIO 0 button.

Please note that ESP8266-EVB and ESP8266-DEV do not have USB-to-Serial converter, you will have to use a console cable (USB-Série-TTL) to communicates with the ESP8266 board.

UEXT-SERIAL-wiring2.jpg UEXT-SERIAL-wiring.jpg

Erase the Flash

It is recommanded to completely erase the Flash memory of the ESP8266 board before to download the new FirmWare onto it. Execute the following code inside a terminal:

esptool.py --port /path/to/ESP8266 erase_flash

Where /path/to/ESP8266 is the path to the serial port attached on the ESP8266. The exact name of the peripheral depend of the USB-to-Serial converter used. List down the serial port before to connext you ESP module then repeat the operation with the serial port connected. The new port appearing is the one corresponding to the ESP8266.

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Flashing MicroPython on ESP8266

ESP8266 from Adafruit Industries

For the breakout HUZZAH ESP8266 and the Feather HUZZAH ESP8266 + FTDI Friend:

FEATHER-ESP8266-02.jpg ESP8266-HUZZA.png

Place our ESP8266 in "mode Flashage" and execute the following command to load the firmware (already downloaded):

esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin

Once again, /path/to/ESP8266 is the path (identification) of the serial port connected to the ESP8266. Remplace firmware.bin with the real name (and access path) to the firmware file to upload to the ESP8266.


{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

ESP8266 WEMOS D1 Mini

The Wemos D1 do have 4MB of Flash as many of ESP8266 available on the market.

Wemos-D1-Mini-ESP8266.jpg

Execute le following command to load the MicroPython firmware (already downloaded on the computer):

 esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin

ESP8266 WEMOS D1 PRO

The Wemos D1 Pro do have 16MB of Flash, the command to execute:

Wemos-D1-Pro-Mini-ESP8266.jpg

Execute the following command to upload the MicroPython firmware:

esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --fm dio --fs=32m 0 firmware.bin

ESP8266-EVB & ESP8266-DEV

For the ESP8266-EVB evaluation board and the ESP8266-DEV development board like following:

OLI-ESP8266-EVB.jpg OLI-ESP8266-DEV.jpg

Please execute the following command to upload the MicroPython firmware (previously downloaded):

 esptool.py --port /chemin/vers/ESP8266 --baud 115200 write_flash --flash_size=detect -fm dio 0 firmware.bin

Do power cycle the plateform to properly restart the microcontroler.

After Flash operation

Press tge RESET when available or power cycle the board.

Voila, you just have you MicroPython firmware running on your ESP!

You can now establish a serial REPL with a software like Putty (Freeware, running on Linux, Windows, Mac).

When started, just write mention the path to serial device attached to the ESP8266.


FEATHER-CHARGER-MICROPYTHON-ESP8266-EN-10a.jpg


FEATHER-CHARGER-MICROPYTHON-ESP8266-EN-11.jpg

Ressources

Error message

I do have the following error message "read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?" !

We do meet that problem when the console cable (USB/Serial) where connected through an external USB HUB. Try to plug the console cable directly on the ESP8266.

EspTool Upgrade

Recent version of the MicroPython firmwares do requires a more recent version of the EspTool to be flashed on the ESP8266.

Since tghe release 1.8.x of MicroPython, the EspTool 1.0.1 doesn't make the job anymore.

An upgrade to a more recent EspTool (version 2.0.1) will help to fix with --flash_size=detect .

The following command line can be used to force the upgrade to a given version of EspTool :

sudo apt-get install esptool==2.0.1

More information

Voyez la page "MicroPython ESP8266 tutorial - deploying".