基本信息 ESP32 版本

ESP32是一个由Espressif提供的热门的WiFi/蓝牙单片机的片上系统(SoC)。

本节需要修改。

各种板

众多不同的模块和电路板都携带了ESP32芯片。MicroPython希望提供一个通用版本, 在尽可能多的板/模块上运行,但仍存在很多局限。星瞳ESP32板被用作参考板(例如,测试即在该板上进行)。 若您还有其他板,请确保您掌握该板的数据手册、电路图以及参考资料,以便查找该板的运作情况。

为了制作通用的ESP32版本,并尽可能的支持更多的电路板,约定了以下的设计思路:

  • GPIO引脚编号基于ESP32芯片编号,而并非某个特定板的”逻辑上”的编号。 请掌握您的板的手册/引脚图,以查找您的板的引脚与实际的ESP32引脚的对应关系。 我们也鼓励使用不同板的用户通过MicroPython论坛分享这种映射,最终即可收集到社区维护的参考资料。
  • (此处待讨论,esp32的的spi flash的引脚暴露了,不知道是因为程序员没考虑到,还是有其他用处) 所有有意义的引脚,都由支持(例如,用来连接SPIFlashROM的引脚没有暴露,因为这种引脚并无其他用途,运行该引脚还会导致板的故障。) 但是,任何特定的板都只显示引脚的子集。请查阅板的参考手册。
  • 某些板可能会缺少ESP32深度睡眠模式的引脚。

技术参数与SoC数据手册

ESP32芯片的数据手册及其他参考资料可从供应商网址中获得: http://www.espressif.com/en/support/download/documents?keys=&field_type_tid%5B%5D=13&field_type_tid%5B%5D=54。 其中包括芯片技术规范、功能、操作模式、内部功能等的官方参考。

为方便您查阅,下面提供了一些主要的技术参数:

  • 架构:Xtensa® 单-/双-核 32-位 LX6 微处理器, 速度高达600 DMIPS (单核微处理器速度高达200 DMIPS)
  • CPU频率:支持240 MHz的时钟频率的7级流水线
  • 总可用内存:520 kB SRAM(其中部分为系统保留)
  • BootROM: 64KB
  • 内部 FlashROM: None
  • 外部 FlashROM: 代码和数据,通过SPIFlashROM。常规规格为4MB。
  • GPIO:22 + 10(GPIO可与其他功能多路复用,包括外部FlashROM、UART、深度睡眠、唤醒等)
  • UART: 3 RX/TX UART.
  • SPI:4 SPI接口(2个用于FlashROM)。
  • I2C: 没有 native 外置 I2C (bitbang 实现可以在任意管教).
  • I2S: 1.
  • 编程:使用来自UART的启动芯片引导程序。由于外部FlashROM和始终可用的引导程序,ESP32不会变砖。

启动过程

On boot, MicroPython EPS32 port executes _boot.py script from internal frozen modules. It mounts filesystem in FlashROM, or if it’s not available, performs first-time setup of the module and creates the filesystem. This part of the boot process is considered fixed, and not available for customization for end users (even if you build from source, please refrain from changes to it; customization of early boot process is available only to advanced users and developers, who can diagnose themselves any issues arising from modifying the standard process).

Once the filesystem is mounted, boot.py is executed from it. The standard version of this file is created during first-time module set up and has commands to start a WebREPL daemon (disabled by default, configurable with webrepl_setup module), etc. This file is customizable by end users (for example, you may want to set some parameters or add other services which should be run on a module start-up). But keep in mind that incorrect modifications to boot.py may still lead to boot loops or lock ups, requiring to reflash a module from scratch. (In particular, it’s recommended that you use either webrepl_setup module or manual editing to configure WebREPL, but not both).

As a final step of boot procedure, main.py is executed from filesystem, if exists. This file is a hook to start up a user application each time on boot (instead of going to REPL). For small test applications, you may name them directly as main.py, and upload to module, but instead it’s recommended to keep your application(s) in separate files, and have just the following in main.py:

import my_app
my_app.main()

This will allow to keep the structure of your application clear, as well as allow to install multiple applications on a board, and switch among them.