查看ESP8266 Boot的源代码
←
ESP8266 Boot
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== ESP8266 启动 == ;;Reset 入口在: 0x40000080 ESP8266 启动时,将从 UART0 以波特率 74880 打印: <source lang=bash> 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 </source> ;;Reset Cause: <pre> 1 ---> Power On 2 ---> External Reset 4 ---> Hardware Watchdog Reset </pre> ;;chksum 与 csum 值相等,表示启动过程中 Flash 读取正确 写入时: <pre> localhost:hello comcat$ ls -l build/ total 1488 -rw-r--r-- 1 comcat staff 31712 12 5 11:09 0x00000.bin -rw-r--r-- 1 comcat staff 190596 12 5 11:09 0x40000.bin -rwxr-xr-x 1 comcat staff 516521 12 5 11:09 app.out -rw-r--r-- 1 comcat staff 4632 12 5 11:09 app_app.a -rw-r--r-- 1 comcat staff 4480 12 5 11:09 main.o localhost:hello comcat$ 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 ................................................................................................................. </pre> <br><br> == Boot Mode == ESP8266 Reset 后,通过判断如下管脚的状态来决定启动模式: <pre> MTDO GPIO0 GPIO2 Mode Description L L H UART 串口刷机 L H H Flash SPI Flash 正常启动 H x x SDIO SD-card 启动 </pre> MTDO 为 GPIO15 启动时串口输出的 'boot mode:(x, y)' , x 的低三位对应 {MTDO, GPIO0, GPIO2} <br><br> == 代码流程 == <source lang=bash> 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 </source> <br><br> == 详细分析 == SPI Flash 非 OTA 系统,两部分: 0x00000 --- 启动自动加载到 RAM 的部分 0x40000 --- 运行需要后再加载的部分 OTA 系统: 0x00000 --- 启动自动加载到 RAM 的部分,boot.bin (OTA 核心实现在这里) 0x01000 --- 4KB 开始,为运行需要后再加载的部分,user1.bin 所有这两个部分,都是 ESP Firmware 格式 (Little Endian): ;;File header <pre> Byte Description 0 Always 0xE9 1 Number of segments 2 SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) 3 High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz 4-7 Entry point 8-n Segments </pre> * https://github.com/tommie/esptool * https://github.com/igrr/esptool-ck * https://github.com/esp8266/Arduino/blob/master/bootloaders/eboot/rom.ld * [https://github.com/fermatliu/open-ath9k-htc-firmware/blob/master/target_firmware/magpie_fw_dev/build/magpie_1_1/sboot/athos/src/xtos/reset-vector.S XTOS Reset Vector] * https://github.com/espressif/ESP8266_MP3_DECODER/blob/master/mp3/make.sh <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br>
返回到
ESP8266 Boot
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面