ESP8266 development journey Advanced articles ② chat Arduino IDE For ESP8266 burning configuration

1 Introduction

    In the process of learning ESP8266 development, many novice developers are prone to the following questions:

  • It suggested that the lack ESP8266WiFi compiled code library (one of the reasons is to choose a non-ESP8266 board compiler, such as Arduino UNO);
  • ESP8266 programming failed (one of the reasons is the wrong configuration of the burning options, such as target board is NodeMcu but chose another board);
  • ESP8266 burning success, but garbled display serial port (one of the reasons is the wrong configuration of the burning options, configuration errors FlashMode);

    In the final analysis, is the beginners do not understand the meaning of the various compiler options, it is easy to select the wrong configuration options. So, Bo Lord in Benpian explain Arduino IDE For ESP8266 burning configuration.

2. What is burning configuration

    To know burn configuration in which the position and role, take a look at the configuration burn bloggers understand, see below:

2340221-19ea0994c2ead599.png
image

    As can be seen:

  • When we click on the ArduinoIDE compiler option when the system will compile profiles boards.txt to compile link project code we write.
  • boards.txt is generated by running boards.txt.py, we need to go before the compiled code is configured, which means we need to change ArduinoIDE-> options under the tool before compilation.
2340221-8d89d9b4bb840f5f.png
image

Here is what we need to understand the developer's build configurations, respectively, can be seen:

  • Development board (To program the final target board)
  • Upload Speed ​​(serial upload speed)
  • CPU Frequency (CPU Frequency)
  • Crystal Frequency (vibration frequency oscillator)
  • Flash Size(flash大小)
  • Flash Mode (flash transfer mode)
  • Flash Frequency (flash transmission frequency)
  • Reset Method (restarting method)
  • Debug port (port print debug information)
  • Debug Level (print debug information level)
  • lwIP Variant
  • VTables (virtual function)
  • Exceptions
  • Builtin Led (onboard led)
  • Erase Flash(擦除flash方式)

接下来博主会仔细讲解里面具体的用法。

注意:博主建议学习这篇的时候,请打开ArduinoIDE

3.详解编译配置

3.1 开发板 —— 烧写目标板

    表示我们代码最终烧录的目标板子,目前支持如下:

2340221-1c96d1209ff4418c.png
image
  1. 可以看到这个库其实已经非常完善了(感谢开源精神),支持了众多的ESP8266板子。
  2. 虽然板子众多,但是我们重点关注一下我们常用的几款:
  • Generic ESP8266 Module(通用的8266模块,其他的一些板子也可以通过这个来配置,其实可以理解为自定义配置):
( 'generic', {
        'name': 'Generic ESP8266 Module',
        'opts': {
            '.build.board': 'ESP8266_GENERIC',
            },
        'macro': [
            'resetmethod_menu',
            'resetmethod_menu_extra',
            'crystalfreq_menu',
            'flashfreq_menu',
            'flashmode_menu',
            '512K', '1M', '2M', '4M', '8M', '16M',
            'led',
            ],
        'desc': [ 'These modules come in different form factors and pinouts. See the page at ESP8266 community wiki for more info: `ESP8266 Module Family <http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family>`__.',
                  '',
                  'Usually these modules have no bootstapping resistors on board, insufficient decoupling capacitors, no voltage regulator, no reset circuit, and no USB-serial adapter. This makes using them somewhat tricky, compared to development boards which add these features.',
                  '',
                  'In order to use these modules, make sure to observe the following:',
                  '',
                  '-  **Provide sufficient power to the module.** For stable use of the ESP8266 a power supply with 3.3V and >= 250mA is required. Using the power available from USB to Serial adapter is not recommended, these adapters typically do not supply enough current to run ESP8266 reliably in every situation. An external supply or regulator alongwith filtering capacitors is preferred.',
                  '',
                  '-  **Connect bootstapping resistors** to GPIO0, GPIO2, GPIO15 according to the schematics below.',
                  '',
                  '-  **Put ESP8266 into bootloader mode** before uploading code.',
                  '',
                  'Serial Adapter',
                  '--------------',
                  '',
                  'There are many different USB to Serial adapters / boards. To be able to put ESP8266 into bootloader mode using serial handshaking lines, you need the adapter which breaks out RTS and DTR outputs. CTS and DSR are not useful for upload (they are inputs). Make sure the adapter can work with 3.3V IO voltage: it should have a jumper or a switch to select between 5V and 3.3V, or be marked as 3.3V only.',
                  '',
                  'Adapters based around the following ICs should work:',
                  '',
                  '-  FT232RL',
                  '-  CP2102',
                  '-  CH340G',
                  '',
                  'PL2303-based adapters are known not to work on Mac OS X. See https://github.com/igrr/esptool-ck/issues/9 for more info.',
                  '',
                  'Minimal Hardware Setup for Bootloading and Usage',
                  '------------------------------------------------',
                  '',
                  '+-----------------+------------+------------------+',
                  '| PIN             | Resistor   | Serial Adapter   |',
                  '+=================+============+==================+',
                  '| VCC             |            | VCC (3.3V)       |',
                  '+-----------------+------------+------------------+',
                  '| GND             |            | GND              |',
                  '+-----------------+------------+------------------+',
                  '| TX or GPIO2\*   |            | RX               |',
                  '+-----------------+------------+------------------+',
                  '| RX              |            | TX               |',
                  '+-----------------+------------+------------------+',
                  '| GPIO0           | PullUp     | DTR              |',
                  '+-----------------+------------+------------------+',
                  '| Reset\*         | PullUp     | RTS              |',
                  '+-----------------+------------+------------------+',
                  '| GPIO15\*        | PullDown   |                  |',
                  '+-----------------+------------+------------------+',
                  '| CH\_PD          | PullUp     |                  |',
                  '+-----------------+------------+------------------+',
                  '',
                  '-  Note',
                  '-  GPIO15 is also named MTDO',
                  '-  Reset is also named RSBT or REST (adding PullUp improves the',
                  '   stability of the module)',
                  '-  GPIO2 is alternative TX for the boot loader mode',
                  '-  **Directly connecting a pin to VCC or GND is not a substitute for a',
                  '   PullUp or PullDown resistor, doing this can break upload management',
                  '   and the serial console, instability has also been noted in some',
                  '   cases.**',
                  '',
                  'ESP to Serial',
                  '-------------',
                  '',
                  '.. figure:: ESP_to_serial.png',
                  '   :alt: ESP to Serial',
                  '',
                  '   ESP to Serial',
                  '',
                  'Minimal Hardware Setup for Bootloading only',
                  '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
                  '',
                  'ESPxx Hardware',
                  '',
                  '+---------------+------------+------------------+',
                  '| PIN           | Resistor   | Serial Adapter   |',
                  '+===============+============+==================+',
                  '| VCC           |            | VCC (3.3V)       |',
                  '+---------------+------------+------------------+',
                  '| GND           |            | GND              |',
                  '+---------------+------------+------------------+',
                  '| TX or GPIO2   |            | RX               |',
                  '+---------------+------------+------------------+',
                  '| RX            |            | TX               |',
                  '+---------------+------------+------------------+',
                  '| GPIO0         |            | GND              |',
                  '+---------------+------------+------------------+',
                  '| Reset         |            | RTS\*            |',
                  '+---------------+------------+------------------+',
                  '| GPIO15        | PullDown   |                  |',
                  '+---------------+------------+------------------+',
                  '| CH\_PD        | PullUp     |                  |',
                  '+---------------+------------+------------------+',
                  '',
                  '-  Note',
                  '-  if no RTS is used a manual power toggle is needed',
                  '',
                  'Minimal Hardware Setup for Running only',
                  '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
                  '',
                  'ESPxx Hardware',
                  '',
                  '+----------+------------+----------------+',
                  '| PIN      | Resistor   | Power supply   |',
                  '+==========+============+================+',
                  '| VCC      |            | VCC (3.3V)     |',
                  '+----------+------------+----------------+',
                  '| GND      |            | GND            |',
                  '+----------+------------+----------------+',
                  '| GPIO0    | PullUp     |                |',
                  '+----------+------------+----------------+',
                  '| GPIO15   | PullDown   |                |',
                  '+----------+------------+----------------+',
                  '| CH\_PD   | PullUp     |                |',
                  '+----------+------------+----------------+',
                  '',
                  'Minimal',
                  '-------',
                  '',
                  '.. figure:: ESP_min.png',
                  '   :alt: ESP min',
                  '',
                  '   ESP min',
                  '',
                  'Improved Stability',
                  '------------------',
                  '',
                  '.. figure:: ESP_improved_stability.png',
                  '   :alt: ESP improved stability',
                  '',
                  '   ESP improved stability',
                  '',
                  'Boot Messages and Modes',
                  '-----------------------',
                  '',
                  'The ESP module checks at every boot the Pins 0, 2 and 15. based on them its boots in different modes:',
                  '',
                  '+----------+---------+---------+------------------------------------+',
                  '| GPIO15   | GPIO0   | GPIO2   | Mode                               |',
                  '+==========+=========+=========+====================================+',
                  '| 0V       | 0V      | 3.3V    | Uart Bootloader                    |',
                  '+----------+---------+---------+------------------------------------+',
                  '| 0V       | 3.3V    | 3.3V    | Boot sketch (SPI flash)            |',
                  '+----------+---------+---------+------------------------------------+',
                  '| 3.3V     | x       | x       | SDIO mode (not used for Arduino)   |',
                  '+----------+---------+---------+------------------------------------+',
                  '',
                  'at startup the ESP prints out the current boot mode example:',
                  '',
                  '::',
                  '',
                  '    rst cause:2, boot mode:(3,6)',
                  '',
                  'note: - GPIO2 is used as TX output and the internal Pullup is enabled on boot.',
                  '',
                  'rst cause',
                  '~~~~~~~~~',
                  '',
                  '+----------+------------------+',
                  '| Number   | Description      |',
                  '+==========+==================+',
                  '| 0        | unknown          |',
                  '+----------+------------------+',
                  '| 1        | normal boot      |',
                  '+----------+------------------+',
                  '| 2        | reset pin        |',
                  '+----------+------------------+',
                  '| 3        | software reset   |',
                  '+----------+------------------+',
                  '| 4        | watchdog reset   |',
                  '+----------+------------------+',
                  '',
                  'boot mode',
                  '~~~~~~~~~',
                  '',
                  'the first value respects the pin setup of the Pins 0, 2 and 15.',
                  '',
                  '+----------+----------+---------+---------+-------------+',
                  '| Number   | GPIO15   | GPIO0   | GPIO2   | Mode        |',
                  '+==========+==========+=========+=========+=============+',
                  '| 0        | 0V       | 0V      | 0V      | Not valid   |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 1        | 0V       | 0V      | 3.3V    | Uart        |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 2        | 0V       | 3.3V    | 0V      | Not valid   |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 3        | 0V       | 3.3V    | 3.3V    | Flash       |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 4        | 3.3V     | 0V      | 0V      | SDIO        |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 5        | 3.3V     | 0V      | 3.3V    | SDIO        |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 6        | 3.3V     | 3.3V    | 0V      | SDIO        |',
                  '+----------+----------+---------+---------+-------------+',
                  '| 7        | 3.3V     | 3.3V    | 3.3V    | SDIO        |',
                  '+----------+----------+---------+---------+-------------+',
                  '',
                  'note: - number = ((GPIO15 << 2) \| (GPIO0 << 1) \| GPIO2);',
                  ],
    })
  • Generic ESP8285 Module(8266芯片+1MB flash):
( 'esp8285', {
        'name': 'Generic ESP8285 Module',
        'opts': {
            '.build.board': 'ESP8266_ESP01',
            },
        'macro': [
            'resetmethod_menu',
            'resetmethod_menu_extra',
            'crystalfreq_menu',
            'flashmode_dout',
            'flashfreq_40',
            '1M',
            'led',
            ],
        'desc': [ 'ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) is a multi-chip package which contains ESP8266 and 1MB flash. All points related to bootstrapping resistors and recommended circuits listed above apply to ESP8285 as well.',
                  '',
                  'Note that since ESP8285 has SPI flash memory internally connected in DOUT mode, pins 9 and 10 may be used as GPIO / I2C / PWM pins.',
                  ],
    })
  • ESPDuino(ESP-13 Module):
( 'espduino', {
        'name': 'ESPDuino (ESP-13 Module)',
        'opts': collections.OrderedDict([
            ( '.build.board', 'ESP8266_ESP13' ),
            ( '.build.variant', 'ESPDuino' ),
            ( '.menu.ResetMethod.v2', 'ESPduino-V2' ),
            ( '.menu.ResetMethod.v2.upload.resetmethod', 'nodemcu' ),
            ( '.menu.ResetMethod.v1', 'ESPduino-V1' ),
            ( '.menu.ResetMethod.v1.upload.resetmethod', 'ck' ),
            ( '.menu.UploadTool.esptool', 'Serial' ),
            ( '.menu.UploadTool.esptool.upload.tool', 'esptool' ),
            ( '.menu.UploadTool.esptool.upload.verbose', '-vv' ),
            ( '.menu.UploadTool.espota', 'OTA' ),
            ( '.menu.UploadTool.espota.upload.tool', 'espota' ),
            ]),
        'macro': [
            'flashmode_dio',
            'flashfreq_40',
            '4M',
            ],
        'desc': [ '*TODO*' ],
    })
  • NodeMcu 0.9(ESP-12 Module):
( 'nodemcu', {
        'name': 'NodeMCU 0.9 (ESP-12 Module)',
        'opts': {
            '.build.board': 'ESP8266_NODEMCU',
            '.build.variant': 'nodemcu',
            },
        'macro': [
            'resetmethod_nodemcu',
            'flashmode_qio',
            'flashfreq_40',
            '4M',
            ],
        'desc': [ 'Pin mapping',
                  '~~~~~~~~~~~',
                  '',
                  'Pin numbers written on the board itself do not correspond to ESP8266 GPIO pin numbers. Constants are defined to make using this board easier:',
                  '',
                  '.. code:: c++',
                  '',
                  '    static const uint8_t D0   = 16;',
                  '    static const uint8_t D1   = 5;',
                  '    static const uint8_t D2   = 4;',
                  '    static const uint8_t D3   = 0;',
                  '    static const uint8_t D4   = 2;',
                  '    static const uint8_t D5   = 14;',
                  '    static const uint8_t D6   = 12;',
                  '    static const uint8_t D7   = 13;',
                  '    static const uint8_t D8   = 15;',
                  '    static const uint8_t D9   = 3;',
                  '    static const uint8_t D10  = 1;',
                  '',
                  'If you want to use NodeMCU pin 5, use D5 for pin number, and it will be translated to \'real\' GPIO pin 14.',
                  ],
    })

可以看出,NodeMcu 0.9 flashmode是qio,这个需要注意一下;

  • NodeMcu 1.0(ESP-12E Module)(目前NodeMcu板子很多都是这个):
( 'nodemcuv2', {
        'name': 'NodeMCU 1.0 (ESP-12E Module)',
        'opts': {
            '.build.board': 'ESP8266_NODEMCU',
            '.build.variant': 'nodemcu',
            },
        'macro': [
            'resetmethod_nodemcu',
            'flashmode_dio',
            'flashfreq_40',
            '4M',
            ],
        'desc': [ 'This module is sold under many names for around $6.50 on AliExpress and it\'s one of the cheapest, fully integrated ESP8266 solutions.',
                  '',
                  'It\'s an open hardware design with an ESP-12E core and 4 MB of SPI flash.',
                  '',
                  'According to the manufacturer, "with a micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any trouble". This is more or less true: the board comes with a CP2102 onboard USB to serial adapter which just works, well, the majority of the time. Sometimes flashing fails and you have to reset the board by holding down FLASH +',
                  'RST, then releasing FLASH, then releasing RST. This forces the CP2102 device to power cycle and to be re-numbered by Linux.',
                  '',
                  'The board also features a NCP1117 voltage regulator, a blue LED on GPIO16 and a 220k/100k Ohm voltage divider on the ADC input pin.',
                  'The ESP-12E usually has a led connected on GPIO2.',
                  '',
                  'Full pinout and PDF schematics can be found `here <https://github.com/nodemcu/nodemcu-devkit-v1.0>`__',
                  ],
    })

    可以看出,NodeMcu 1.0 flashmode是dio,这个需要注意一下;

  • WeMos D1 R1:
( 'd1', {
        'name': 'WeMos D1 R1',
        'opts': {
            '.build.board': 'ESP8266_WEMOS_D1R1',
            '.build.variant': 'd1',
            },
        'macro': [
            'resetmethod_nodemcu',
            'flashmode_dio',
            'flashfreq_40',
            '4M',
            ],
        'serial': '921',
        'desc': [ 'Product page: https://www.wemos.cc/' ],
    })
  • WiFiduino:
( 'wifiduino', {
        'name': 'WiFiduino',
        'opts': {
            '.build.board': 'WIFIDUINO_ESP8266',
            '.build.variant': 'wifiduino',
            },
        'macro': [
            'resetmethod_nodemcu',
            'flashmode_dio',
            'flashfreq_40',
            '4M',
            ],
        'serial': '921',
        'desc': [ 'Product page: https://wifiduino.com/esp8266' ],
    })

    博主建议,尽量用对应开发板,比如我们常用NodeMcu。如果具体开发板不满足要求,再去考虑Generic ESP8266 或者Generic ESP8285。

3.2 Upload Speed —— 串口上传速率

  • 烧写固件对应的串口速率:
 ####################### serial

    's9': collections.OrderedDict([
        ( '.menu.UploadSpeed.9600', '9600' ),
        ( '.menu.UploadSpeed.9600.upload.speed', '9600' ),
        ]),
    's57': collections.OrderedDict([
        ( '.menu.UploadSpeed.57600', '57600' ),
        ( '.menu.UploadSpeed.57600.upload.speed', '57600' ),
        ]),
    's115': collections.OrderedDict([
        ( '.menu.UploadSpeed.115200', '115200' ),
        ( '.menu.UploadSpeed.115200.upload.speed', '115200' ),
        ]),
    's256': collections.OrderedDict([
        ( '.menu.UploadSpeed.256000.windows', '256000' ),
        ( '.menu.UploadSpeed.256000.upload.speed', '256000' ),
        ]),
    's230': collections.OrderedDict([
        ( '.menu.UploadSpeed.230400.linux', '230400' ),
        ( '.menu.UploadSpeed.230400.macosx', '230400' ),
        ( '.menu.UploadSpeed.230400.upload.speed', '230400' ),
        ]),
    's460': collections.OrderedDict([
        ( '.menu.UploadSpeed.460800.linux', '460800' ),
        ( '.menu.UploadSpeed.460800.macosx', '460800' ),
        ( '.menu.UploadSpeed.460800.upload.speed', '460800' ),
        ]),
    's512': collections.OrderedDict([
        ( '.menu.UploadSpeed.512000.windows', '512000' ),
        ( '.menu.UploadSpeed.512000.upload.speed', '512000' ),
        ]),
    's921': collections.OrderedDict([
        ( '.menu.UploadSpeed.921600', '921600' ),
        ( '.menu.UploadSpeed.921600.upload.speed', '921600' ),
        ]),

注意,根据目标板的不同,不一定会存在上面所有的数值选项。

  • 该值越高意味着烧写速度越快,但是并非越高越好,容易烧写失败,建议维持系统默认值即可。

3.3 CPU Frequency —— CPU频率

  • CPU运行速率
'cpufreq_menu': collections.OrderedDict([
        ( '.menu.CpuFrequency.80', '80 MHz' ),
        ( '.menu.CpuFrequency.80.build.f_cpu', '80000000L' ),
        ( '.menu.CpuFrequency.160', '160 MHz' ),
        ( '.menu.CpuFrequency.160.build.f_cpu', '160000000L' ),
        ]),
  • 默认是80MHz,当然也可以试试160MHz,但是可能不稳定。

3.4 Crystal Frequency —— 晶振振动频率

  • 模块晶振频率,有26MHz或者40MHz,具体是多少请查阅各自开发板或者模块,一般情况默认26MHz即可:
'crystalfreq_menu': collections.OrderedDict([
        ( '.menu.CrystalFreq.26', '26 MHz' ),
        ( '.menu.CrystalFreq.40', '40 MHz' ),
        ( '.menu.CrystalFreq.40.build.extra_flags', '-DF_CRYSTAL=40000000 -DESP8266' ),
        ]),

3.5 Flash Size —— flash大小

设置目标板子的flash大小。

  • 可以向下兼容,具体大小得看每个具体的esp8266开发板或者模块,目前有以下一些选项:
f512 =      flash_size(0x80000,  '512K', '512K0',   'eagle.flash.512k0.ld',     'no SPIFFS', 499696,   0x7B000)
    f512.update(flash_size(0x80000,  '512K', '512K32',  'eagle.flash.512k32.ld',   '32K SPIFFS', 466928,   0x73000,   0x8000,  4096))
    f512.update(flash_size(0x80000,  '512K', '512K64',  'eagle.flash.512k64.ld',   '64K SPIFFS', 434160,   0x6B000,   0x10000, 4096))
    f512.update(flash_size(0x80000,  '512K', '512K128', 'eagle.flash.512k128.ld', '128K SPIFFS', 368624,   0x5B000,   0x20000, 4096))
    f1m =       flash_size(0x100000,   '1M', '1M0',     'eagle.flash.1m0.ld',       'no SPIFFS', 1023984,  0xFB000)
    f1m.update( flash_size(0x100000,   '1M', '1M64',    'eagle.flash.1m64.ld',     '64K SPIFFS', 958448,   0xEB000,   0x10000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M128',   'eagle.flash.1m128.ld',   '128K SPIFFS', 892912,   0xDB000,   0x20000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M144',   'eagle.flash.1m144.ld',   '144K SPIFFS', 876528,   0xD7000,   0x24000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M160',   'eagle.flash.1m160.ld',   '160K SPIFFS', 860144,   0xD3000,   0x28000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M192',   'eagle.flash.1m192.ld',   '192K SPIFFS', 827376,   0xCB000,   0x30000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M256',   'eagle.flash.1m256.ld',   '256K SPIFFS', 761840,   0xBB000,   0x40000, 4096))
    f1m.update( flash_size(0x100000,   '1M', '1M512',   'eagle.flash.1m512.ld',   '512K SPIFFS', 499696,   0x7B000,   0x80000, 8192))
    f2m =       flash_size(0x200000,   '2M', '2M',      'eagle.flash.2m.ld',        '1M SPIFFS', 1044464, 0x100000,   0xFB000, 8192)
    f4m =       flash_size(0x400000,   '4M', '4M1M',    'eagle.flash.4m1m.ld',      '1M SPIFFS', 1044464, 0x300000,   0xFB000, 8192)
    f4m.update( flash_size(0x400000,   '4M', '4M2M',    'eagle.flash.4m2m.ld',      '2M SPIFFS', 1044464, 0x200000,  0x1FB000, 8192))
    f4m.update( flash_size(0x400000,   '4M', '4M3M',    'eagle.flash.4m.ld',        '3M SPIFFS', 1044464, 0x100000,  0x2FB000, 8192))
    f8m =       flash_size(0x800000,   '8M', '8M7M',    'eagle.flash.8m.ld',        '7M SPIFFS', 1044464, 0x100000,  0x6FB000, 8192)
    f16m =      flash_size(0x1000000, '16M', '16M15M',  'eagle.flash.16m.ld',      '15M SPIFFS', 1044464, 0x100000,  0xEFB000, 8192)

系统会根据我们选择的flashsize然后找到对应的flash映射文件。比如,我们选择了1M 256K SPIFFS,那么系统就会找到 eagle.flash.1m256.ld文件,然后映射里面对应的flash地址。

/* Flash Split for 1M chips */
/* sketch 743KB */
/* spiffs 256KB */
/* eeprom 20KB */

MEMORY
{
  dport0_0_seg :                        org = 0x3FF00000, len = 0x10
  dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
  iram1_0_seg :                         org = 0x40100000, len = 0x8000
  irom0_0_seg :                         org = 0x40201010, len = 0xb9ff0
}

PROVIDE ( _SPIFFS_start = 0x402BB000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x1000 );

INCLUDE "eagle.app.v6.common.ld"

3.6 Flash Mode —— flash传输模式

设置flash传输模式。

  • 不同flash芯片,spi连接方式不同,意味着flashmode不同:
####################### menu.FlashMode

    'flashmode_menu': collections.OrderedDict([
        ( '.menu.FlashMode.qio', 'QIO' ),
        ( '.menu.FlashMode.qio.build.flash_mode', 'qio' ),
        ( '.menu.FlashMode.qout', 'QOUT' ),
        ( '.menu.FlashMode.qout.build.flash_mode', 'qout' ),
        ( '.menu.FlashMode.dio', 'DIO' ),
        ( '.menu.FlashMode.dio.build.flash_mode', 'dio' ),
        ( '.menu.FlashMode.dout', 'DOUT' ),
        ( '.menu.FlashMode.dout.build.flash_mode', 'dout' ),
        ]),

    ####################### default flash_mode

    'flashmode_dio': collections.OrderedDict([
        ( '.build.flash_mode', 'dio' ),
        ]),

    'flashmode_qio': collections.OrderedDict([
        ( '.build.flash_mode', 'qio' ),
        ]),

    'flashmode_dout': collections.OrderedDict([
        ( '.build.flash_mode', 'dout' ),
        ]),

    'flashmode_qout': collections.OrderedDict([
        ( '.build.flash_mode', 'qout' ),
        ]),

那么它们之间的区别在哪里呢?
1)QIO , for flash that support quad r/w operation(e.g. W25Q flash芯片)
2)QOUT, for flash that support quad read operation(e.g. W25Q flash芯片)
3)DIO, for flash that support dual r/w operation(e.g. W25Q &W25X flash芯片)
4)DOUT, for flash that support dual read operation(e.g. W25Q &W25X flash芯片)
它们之间的区别可以简单理解为传输速率的区别,quad是四倍传输速率,dual是两倍传输速率。
经测试:
Winbond 25Q32B 可工作于 DIO / DOUT / QIO /QOUT (Noduino Falcon);
BergMicro 25Q32A 只可工作于 DIO / DOUT (NodeMCU V1.0 可能是 ESP-12E 接线的问题);
MXIC 25L80 (小 K mini)只可工作于 DOUT;

  • Flash Size大于Flash实际大小,最好改成往下兼容Flash实际大小,也就是不能大于Flash实际大小,Flash Size有多种选型,请看下图:
2340221-761d5f7b51234ea5.png
image

注意:
这一点是很多初学者容易忽略的地方,有时候烧写失败或者烧写成功但是显示一堆乱码,往往就是flashmode引起的,这一点需要特别注意。

3.7 Flash Frequency —— flash传输频率

flash的运行频率,一般有40MHz或者80MHz,默认是40MHz。

'flashfreq_menu': collections.OrderedDict([
        ( '.menu.FlashFreq.40', '40MHz' ),
        ( '.menu.FlashFreq.40.build.flash_freq', '40' ),
        ( '.menu.FlashFreq.80', '80MHz' ),
        ( '.menu.FlashFreq.80.build.flash_freq', '80' ),
        ]),

    'flashfreq_40': collections.OrderedDict([
        ( '.build.flash_freq', '40' ),
        ]),

    'flashfreq_80': collections.OrderedDict([
        ( '.build.flash_freq', '80' ),
        ]),

3.8 Reset Method —— 重启方法

模块重启方法。一般选择ck,nodemcu选择nodemcu。

####################### menu.resetmethod

    'resetmethod_menu': collections.OrderedDict([
        ( '.menu.ResetMethod.ck', 'ck' ),
        ( '.menu.ResetMethod.ck.upload.resetmethod', 'ck' ),
        ( '.menu.ResetMethod.nodemcu', 'nodemcu' ),
        ( '.menu.ResetMethod.nodemcu.upload.resetmethod', 'nodemcu' ),
        ]),

    'resetmethod_menu_extra': collections.OrderedDict([
        ( '.menu.ResetMethod.none', 'none' ),
        ( '.menu.ResetMethod.none.upload.resetmethod', 'none' ),
        ( '.menu.ResetMethod.dtrset', 'dtrset' ),
        ( '.menu.ResetMethod.dtrset.upload.resetmethod', 'dtrset' ),
        ]),

    ####################### upload.resetmethod

    'resetmethod_ck': collections.OrderedDict([
        ( '.upload.resetmethod', 'ck' ),
        ]),

    'resetmethod_nodemcu': collections.OrderedDict([
        ( '.upload.resetmethod', 'nodemcu' ),
        ]),
    
    'resetmethod_none': collections.OrderedDict([
        ( '.upload.resetmethod', 'none' ),
        ]),

    'resetmethod_dtrset': collections.OrderedDict([
        ( '.upload.resetmethod', 'dtrset' ),
        ]),

3.9 Debug port —— 调试信息打印端口

设置调试信息打印串口端口,disabled表示不打印。有以下选项:

  • Serial
  • Serial1
generic.menu.Debug.Disabled=Disabled
generic.menu.Debug.Disabled.build.debug_port=
generic.menu.Debug.Serial=Serial
generic.menu.Debug.Serial.build.debug_port=-DDEBUG_ESP_PORT=Serial
generic.menu.Debug.Serial1=Serial1
generic.menu.Debug.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1

3.10 Debug Level —— 调试信息打印级别

设置调试信息打印,用于开启需要打印哪些调试信息。常见选项如下:

generic.menu.DebugLevel.None____=None
generic.menu.DebugLevel.None____.build.debug_level=
generic.menu.DebugLevel.SSL=SSL
generic.menu.DebugLevel.SSL.build.debug_level= -DDEBUG_ESP_SSL
generic.menu.DebugLevel.TLS_MEM=TLS_MEM
generic.menu.DebugLevel.TLS_MEM.build.debug_level= -DDEBUG_ESP_TLS_MEM
generic.menu.DebugLevel.HTTP_CLIENT=HTTP_CLIENT
generic.menu.DebugLevel.HTTP_CLIENT.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT
generic.menu.DebugLevel.HTTP_SERVER=HTTP_SERVER
generic.menu.DebugLevel.HTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.SSLTLS_MEM=SSL+TLS_MEM
generic.menu.DebugLevel.SSLTLS_MEM.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM
generic.menu.DebugLevel.SSLHTTP_CLIENT=SSL+HTTP_CLIENT
generic.menu.DebugLevel.SSLHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT
generic.menu.DebugLevel.SSLHTTP_SERVER=SSL+HTTP_SERVER
generic.menu.DebugLevel.SSLHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.TLS_MEMHTTP_CLIENT=TLS_MEM+HTTP_CLIENT
generic.menu.DebugLevel.TLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT
generic.menu.DebugLevel.TLS_MEMHTTP_SERVER=TLS_MEM+HTTP_SERVER
generic.menu.DebugLevel.TLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.HTTP_CLIENTHTTP_SERVER=HTTP_CLIENT+HTTP_SERVER
generic.menu.DebugLevel.HTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENT=SSL+TLS_MEM+HTTP_CLIENT
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT
generic.menu.DebugLevel.SSLTLS_MEMHTTP_SERVER=SSL+TLS_MEM+HTTP_SERVER
generic.menu.DebugLevel.SSLTLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.SSLHTTP_CLIENTHTTP_SERVER=SSL+HTTP_CLIENT+HTTP_SERVER
generic.menu.DebugLevel.SSLHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.TLS_MEMHTTP_CLIENTHTTP_SERVER=TLS_MEM+HTTP_CLIENT+HTTP_SERVER
generic.menu.DebugLevel.TLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER
generic.menu.DebugLevel.CORE=CORE
generic.menu.DebugLevel.CORE.build.debug_level= -DDEBUG_ESP_CORE
generic.menu.DebugLevel.WIFI=WIFI
generic.menu.DebugLevel.WIFI.build.debug_level= -DDEBUG_ESP_WIFI
generic.menu.DebugLevel.HTTP_UPDATE=HTTP_UPDATE
generic.menu.DebugLevel.HTTP_UPDATE.build.debug_level= -DDEBUG_ESP_HTTP_UPDATE
generic.menu.DebugLevel.UPDATER=UPDATER
generic.menu.DebugLevel.UPDATER.build.debug_level= -DDEBUG_ESP_UPDATER
generic.menu.DebugLevel.OTA=OTA
generic.menu.DebugLevel.OTA.build.debug_level= -DDEBUG_ESP_OTA
generic.menu.DebugLevel.OOM=OOM
generic.menu.DebugLevel.OOM.build.debug_level= -DDEBUG_ESP_OOM
generic.menu.DebugLevel.COREWIFIHTTP_UPDATEUPDATEROTAOOM=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM
generic.menu.DebugLevel.COREWIFIHTTP_UPDATEUPDATEROTAOOM.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOM=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM
generic.menu.DebugLevel.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOM.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM
generic.menu.DebugLevel.NoAssert-NDEBUG=NoAssert-NDEBUG
generic.menu.DebugLevel.NoAssert-NDEBUG.build.debug_level= -DNDEBUG
  • DEBUG_ESP_HTTP_CLIENT(ESP8266HTTPClient库调试信息)
  • DEBUG_ESP_OTA(ArduinoOTA库调试信息)
  • DEBUG_ESP_WIFI(ESP8266WiFi库调试信息)
  • DEBUG_ESP_MDNS(ESP8266mDNS库调试信息)
  • DEBUG_ESP_HTTP_UPDATE(ESP8266httpUpdate库调试信息)
  • DEBUG_ESP_HTTP_SERVER(ESP8266WebServer库调试信息)
  • DEBUG_ESP_CORE(esp8266 core核心库的调试信息)

默认是不开启打印调试信息。

3.11 lwIP Variant

跟网络协议相关,博主不懂,暂时跳过,默认就好;

3.12 VTables —— 虚函数链

C++中虚函数链存放位置,默认不改。有以下选项:

'vtable_menu': collections.OrderedDict([
        ( '.menu.VTable.flash', 'Flash'),
        ( '.menu.VTable.flash.build.vtable_flags', '-DVTABLES_IN_FLASH'),
        ( '.menu.VTable.heap', 'Heap'),
        ( '.menu.VTable.heap.build.vtable_flags', '-DVTABLES_IN_DRAM'),
        ( '.menu.VTable.iram', 'IRAM'),
        ( '.menu.VTable.iram.build.vtable_flags', '-DVTABLES_IN_IRAM'),
        ]),

3.13 Exceptions

博主没有看到这个选项用于什么地方,猜测跟是否抛出异常相关,默认是关闭。

3.14 Builtin Led —— 板载led

用于设置板载led的引脚位置。我们可以看看NodeMcu的板载灯设置:

/*
  pins_arduino.h - Pin definition functions for Arduino
  Part of Arduino - http://www.arduino.cc/

  Copyright (c) 2007 David A. Mellis
  Modified for ESP8266 platform by Ivan Grokhotkov, 2014-2015.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA

  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
*/

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#define PIN_WIRE_SDA (4)
#define PIN_WIRE_SCL (5)

static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;

#define LED_BUILTIN 16

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

#include "../generic/common.h"

#endif /* Pins_Arduino_h */

LED_BUILTIN就是板载灯的引脚位置,当然如果我们想自定义位置,那么就可以通过这个编译选项去配置。

3.15 Erase Flash —— 擦除flash方式

烧写固件时擦除flash的方式,有以下几种选项:

####################### flash erase

    'flash_erase_menu': collections.OrderedDict([
        ( '.menu.FlashErase.none', 'Only Sketch' ),
        ( '.menu.FlashErase.none.upload.erase_cmd', '' ),
        ( '.menu.FlashErase.sdk', 'Sketch + WiFi Settings' ),
        ( '.menu.FlashErase.sdk.upload.erase_cmd', '-ca "{build.rfcal_addr}" -cz 0x4000' ),
        ( '.menu.FlashErase.all', 'All Flash Contents' ),
        ( '.menu.FlashErase.all.upload.erase_cmd', '-ca 0x0 -cz "{build.flash_size_bytes}"' ),
        ]),

    }
  • Only Sketch 仅仅是覆盖代码区;
  • Sketch + WiFi Settings wifi coverage area code and local configuration (such as ssid and password stored);
  • All Flash Contents whole flash content, equivalent to clear;

As for what kind, depends on the specific needs, because the more clear the contents mean more programming time.

4. Summary

Data in this chapter explain the Arduino IDE For burning configuration 8266, bloggers advice is to try to find the compiler configuration corresponds development board (that is a good first step is to confirm the target board), then we can not find before considering the above self the definition of the compiler options to meet the demand.

Study group definitely live up to your expectations 491,507,716 bloggers private number 2421818708

Reproduced in: https: //www.jianshu.com/p/747dac6ff4c9

Guess you like

Origin blog.csdn.net/weixin_33721344/article/details/91073382