文章目录
如何判断芯片是 ESP32 or ESP8266 ?
ESP32
detect_chip 0x60000078
UART_DATE_REG_ADDR = 0x60000078 # used to differentiate ESP8266 vs ESP32*
UART_DATE_REG2_ADDR = 0x3f400074 # used to differentiate ESP32S2 vs other models
uart_register.h` 中定义如下所示:(这里为何读取0x60000078, REG_UART_BASE( i )的确定在哪里)
#define DR_REG_UART_BASE 0x3ff40000
#define REG_UART_BASE( i ) (DR_REG_UART_BASE + (i) * 0x10000 + ( (i) > 1 ? 0xe000 : 0 ) )
#define REG_UART_AHB_BASE(i) (0x60000000 + (i) * 0x10000 + ( (i) > 1 ? 0xe000 : 0 ) )
#define UART_FIFO_AHB_REG(i) (REG_UART_AHB_BASE(i) + 0x0)
#define UART_FIFO_REG(i) (REG_UART_BASE(i) + 0x0)
#define UART_DATE_REG(i) (REG_UART_BASE(i) + 0x78)
/* UART_DATE : R/W ;bitpos:[31:0] ;default: 32'h15122500 ; */
(1) 从esp32 的技术手册未查找到的 0x60000078 的内容
(2) 该寄存器在 esptool.py 的注释
“”" Use serial access to detect the chip type.
We use the UART’s datecode register for this, it’s mapped at
the same address on ESP8266 & ESP32 so we can use one
memory read and compare to the datecode register for each chip
type.
This routine automatically performs ESPLoader.connect() (passing
connect_mode parameter) as part of querying the chip.
“”"
而在 esp32.peripherals.ld
中,UART 的外设地址如下:
PROVIDE ( UART0 = 0x3ff40000 );
PROVIDE ( UART1 = 0x3ff50000 );
PROVIDE ( UART2 = 0x3ff6E000 );
则,读该寄存器,内容为 0x15122500
,那么识别此芯片为 ESP32.
ESP8266
detect_chip 0x60000078
UART_DATE_REG_ADDR = 0x60000078 # used to differentiate ESP8266 vs ESP32*
uart_register.h
中定义如下所示:
#define REG_UART_BASE(i) (0x60000000 + (i)*0xf00)
//version value:32'h062000
...
#define UART_DATE(i) (REG_UART_BASE(i) + 0x78)
esp8266 的技术手册中描述如下:
则,读该寄存器,内容为 0x60000200
,那么识别此芯片为 ESP8266.
如何判断芯片是 ESP8285 or ESP8286 ?
ESP8266 技术手册中只有 GPIO, SPI, UART 寄存器的介绍, 然而并没有将介绍 efuse 寄存器,只能从代码中获取此部分信息。
esp8266/efuse_register.h
的定义如下图所示:
#define DR_REG_EFUSE_BASE 0x3FF00050
#define EFUSE_DATA0_REG (DR_REG_EFUSE_BASE +