NodeMCU文档中文翻译 4 烧写固件

一、译文 

Adafruit 提供了非常好的固件烧写教程 。下面你会发现两个流行的基本工具esptool和NodeMCU Flasher。
注意:记住ESP8266在烧写新固件前需要放入烧写模块

1、esptool

一个用于连接Espressif ESP8266 ROM引导装载程序的工具。它的目的是替代XTCOM成为一个简单的、跨平台的开源项目。
支持平台有:OS X, Linux, Windows等支持运行Python的平台
运行 esptool.py
运行以下命令来烧写云端构建服务或者Docker镜像中产生的二进制文件。
esptool.py --port <USB-port-with-ESP8266> write_flash -fm <mode> -fs <size> 0x00000 <nodemcu-firmware>.bin
(PS:笔者用的是nodemcu_flasher,所以对esptool的mode和size参数不甚了解)
更详细的说明和其他设置请查看 esptool flash modes documentation

2、NodeMCU Flasher

一个NodeMCU固件烧写工具。我们正在开发下一个版本并且将使用QT框架。它将支持跨平台和开源。
支持平台:Windows

3、将烧写模块放入设备

为了能够支持ESP8266固件烧写,在设备复位前GPIO0引脚电平必须下拉。相反,正常启动GPIO0引脚电平必须上拉或浮空。
如果你有一个NodeMCU开发套件,那么你不需要做任何事,因为USB连接能够通过中断DTR引脚把GPIO0拉低,并通过中断RTS引脚复位你的开发板。
如果你有一个ESP-01或者不带USB接口的其他设备,你将需要自己拉低GPIO0或按"flash"开关。

4、烧写哪些文件

如果你是通过云端服务或Docker镜像来构建你的固件,或者其他方法产生的整合二进制文件,那么你可以直接把文件烧写到0x00000地址。
否则,如果你是自己通过源码来构建的固件:
  • bin/0x00000.bin 文件烧写到地址 0x00000
  • bin/0x10000.bin 文件烧写到地址 0x10000
(PS:下面的资料用得较少在此不作翻译,有需要的朋友可参阅原文)


Adafruit provides a really nice firmware flashing tutorial. Below you'll find just the basics for the two popular tools esptool and NodeMCU Flasher.

Note:

Keep in mind that the ESP8266 needs to be put into flash modebefore you can flash a new firmware!

esptool

A cute Python utility to communicate with the ROM bootloader in Espressif ESP8266. It is intended to be a simple, platform independent, open source replacement for XTCOM.

Source: https://github.com/themadinventor/esptool

Supported platforms: OS X, Linux, Windows, anything that runs Python

Running esptool.py

Run the following command to flash an aggregated binary as is produced for example by the cloud build service or the Docker image.

esptool.py --port <USB-port-with-ESP8266> write_flash -fm <mode> -fs <size> 0x00000 <nodemcu-firmware>.bin

  • mode is qio for 512 kByte modules and dio for 4 MByte modules (qio might work as well, YMMV).
  • size is given in bits. Specify 4m for 512 kByte and 32m for 4 MByte.

Check the esptool flash modes documentation for details and other options.

NodeMCU Flasher

A firmware Flash tool for NodeMCU...We are working on next version and will use QT framework. It will be cross platform and open-source.

Source: https://github.com/nodemcu/nodemcu-flasher

Supported platforms: Windows

Putting Device Into Flash Mode

To enable ESP8266 firmware flashing GPIO0 pin must be pulled low before the device is reset. Conversely, for a normal boot, GPIO0 must be pulled high or floating.

If you have a NodeMCU dev kit then you don't need to do anything, as the USB connection can pull GPIO0 low by asserting DTR and reset your board by asserting RTS.

If you have an ESP-01 or other device without built-in USB, you will need to enable flashing yourself by pulling GPIO0 low or pressing a "flash" switch.

Which Files To Flash

If you build your firmware with the cloud builder or the Docker image, or any other method that produces a combined binary, then you can flash that file directly to address 0x00000.

Otherwise, if you built your own firmware from source code:

  • bin/0x00000.bin to 0x00000
  • bin/0x10000.bin to 0x10000

Also, in some special circumstances, you may need to flash blank.binor esp_init_data_default.bin to various addresses on the flash (depending on flash size and type), see below.

If upgrading from SPIFFS version 0.3.2 to 0.3.3 or later, or after flashing any new firmware (particularly one with a much different size), you may need to run file.format() to re-format your flash filesystem. You will know if you need to do this if your flash files disappeared, or if they exist but seem empty, or if data cannot be written to new files.

Upgrading from SDK 0.9.x Firmware

If you flash a recent NodeMCU firmware for the first time, it's advisable that you get all accompanying files right. A typical case that often fails is when a module is upgraded from a 0.9.x firmware to the latest version built from the NodeMCU build service. It might look like the brand new firmware is broken, but the reason for the missing Lua prompt is related to the big jump in SDK versions: Espressif changed the esp_init_data_default.bin for their devices along the way with the SDK 1.4.0 release. So things break when a NodeMCU firmware with SDK 1.4.0 or above is flashed to a module which contains old init data from a previous SDK.

Download a recent SDK release, e.g. esp_iot_sdk_v1.4.0_15_09_18.zipor later and extract esp_init_data_default.bin from there. Use this file together with the new firmware during flashing.

esptool

For esptool you specify another file to download at the command line.

esptool.py write_flash <flash options> 0x00000 <nodemcu-firmware>.bin 0x7c000 esp_init_data_default.bin

Note:

The address for esp_init_data_default.bin depends on the size of your module's flash. ESP-01, -03, -07 etc. with 512 kByte flash require 0x7c000. Init data goes to 0x3fc000 on an ESP-12E with 4 MByte flash.

NodeMCU Flasher

The NodeMCU Flasher will download init data using a special path:

INTERNAL://DEFAULT

Replace the provided (old) esp_init_data_default.bin with the one extracted above and use the flasher like you're used to.

References


posted @ 2016-06-20 20:04  Leytton  阅读(555)  评论(0编辑  收藏  举报