ESP8266 Boot
来自Jack's Lab
(版本间的差异)
(→ESP8266 启动) |
(→ESP8266 启动) |
||
第33行: | 第33行: | ||
-rw-r--r-- 1 gaga staff 4480 12 5 11:09 main.o | -rw-r--r-- 1 gaga staff 4480 12 5 11:09 main.o | ||
localhost:hello gaga$ make flash | localhost:hello gaga$ make flash | ||
− | ../../.. | + | ../../../toolchain/bin/esptool -cd nodemcu -cb 115200 -cp /dev/cu.SLAB_USBtoUART -ca 0x00000 -cf build/0x00000.bin |
-ca 0x40000 -cf build/0x40000.bin | -ca 0x40000 -cf build/0x40000.bin | ||
Uploading 31712 bytes from build/0x00000.bin to flash at 0x00000000 | Uploading 31712 bytes from build/0x00000.bin to flash at 0x00000000 |
2015年12月5日 (六) 11:32的版本
1 ESP8266 启动
- Reset 入口在: 0x40000080
ESP8266 启动时,将从 UART0 以波特率 74880 打印:
ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x40100000, len 30372, room 16 tail 4 chksum 0xe6 load 0x3ffe8000, len 900, room 4 tail 0 chksum 0x0a load 0x3ffe8388, len 392, room 8 tail 0 chksum 0x14 csum 0x14
写入时:
localhost:hello gaga$ ls -l build/ total 1488 -rw-r--r-- 1 gaga staff 31712 12 5 11:09 0x00000.bin -rw-r--r-- 1 gaga staff 190596 12 5 11:09 0x40000.bin -rwxr-xr-x 1 gaga staff 516521 12 5 11:09 app.out -rw-r--r-- 1 gaga staff 4632 12 5 11:09 app_app.a -rw-r--r-- 1 gaga staff 4480 12 5 11:09 main.o localhost:hello gaga$ make flash ../../../toolchain/bin/esptool -cd nodemcu -cb 115200 -cp /dev/cu.SLAB_USBtoUART -ca 0x00000 -cf build/0x00000.bin -ca 0x40000 -cf build/0x40000.bin Uploading 31712 bytes from build/0x00000.bin to flash at 0x00000000 ............................... Uploading 190596 bytes from build/0x40000.bin to flash at 0x00040000 ...........................................................................................................................................................................................
2 启动模式
ESP8266 Reset 后,通过判断如下管脚的状态来决定启动模式:
MTDO GPIO0 GPIO2 Mode Description L L H UART 串口刷机 L H H Flash SPI Flash 正常启动 H x x SDIO SD-card 启动
MTDO 为 GPIO15
启动时串口输出的 'boot mode:(x, y)' , x 的低三位对应 {MTDO, GPIO0, GPIO2}
3 代码流程
ResetHandler (0x40000080) Set interrupt level 1 Set processor modes (see separate section) Copy SROM data to SRAM Goto _start _start Set Ring 0 Clear callback vector Set up stack at 3FFFFFFFh Call main main Initialize UART0 115,200 bps, 8N1 iomux.u0txd &= 0xE4F iomux.gpio2 = (iomux.gpio2 & 0xECF) | 0x100 Processor Modes Only Ring 0 used TLBs (D and I) are set to 00000000h-1FFFFFFFh: Illegal 20000000h-5FFFFFFFh: RWX, Cache Write-Through 60000000h-FFFFFFFFh: RWX, Bypass Cache