ESP8266 Developer Zone The Official ESP8266 Forum 2016-03-08T14:02:00+08:00 https://bbs.espressif.com:443/feed.php?f=61 2016-03-08T14:02:00+08:00 2016-03-08T14:02:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1882&p=6030#p6030 <![CDATA[FAQs • Q: 为什么云端升级 (OTA) 在更新 SDK 后会失败?]]> Q: 为什么云端升级 (OTA) 在更新 SDK 后会失败?

目前云端升级分为三个步骤,
步骤一:发送 HEAD 指令到云端服务器,询问待升级的 bin 文件长度,服务器回复的 HTTP 包头中要求带有 bin 文件的长度信息。
步骤二:根据步骤一查询到的长度,在 ESP8266 模块的 Flash 待升级区域,擦除该指定长度 (spi_flash_erase_sector),等待下载。
步骤三:发送 GET 指令,从服务器下载 bin 文件,写入到 Flash 的待升级区域。

因此,如果开发者使用自己的服务器,则要求服务器支持步骤一中返回 bin 文件长度信息的功能,和步骤三下载 bin 文件的功能,否则无法进行云端升级。

另请注意,user1.bin 和 user2.bin 应该是不同的两个 bin 文件,编译步骤:
1. 编译 user1.bin
2. make clean 清除上次编译生成的临时文件
3. 与步骤 1 中的其他编译选项均一致,区别仅在于选择编译 user2

不能运行 user1.bin 又下载 user1.bin,应该是运行 user1.bin 下载 user2.bin;运行 user2.bin 下载 user1.bin。

Statistics: Posted by ESP_Faye — Tue Mar 08, 2016 2:02 pm


]]>
2015-12-07T18:58:57+08:00 2015-12-07T18:58:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1496&p=4939#p4939 <![CDATA[FAQs • Q: GPIO electrical level status]]> Q: GPIO electrical level status

XPD_DCDC is output as high level. Except it, rest GPIO can config as input high level.
About GPIO default status after booting: except 6 SDIO/GPIO4/GPIO5/GPIO16, rest GPIO all have internal pull-up resistor.
If config as low level, need external pull-low or inverting circuits triode.

PS: GPIO can't connect to 5V.
GPIO4/5can't be full-up to high level with external 1M resistor; you need 100K resistor instead. As attachment showed.
Screenshot at 12月 07 18-10-59.png

Statistics: Posted by Guest — Mon Dec 07, 2015 6:58 pm


]]>
2015-12-07T18:16:51+08:00 2015-12-07T18:16:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1495&p=4938#p4938 <![CDATA[FAQs • Q: GPIO电平状态]]> Q: GPIO电平状态

除了XPD_DCDC,GPIO可以配置上拉;
关于 GPIO 的上电 IO 口默认状态为:除了 SDIO 6 根线+GPIO4+GPIO5+GPIO16 上电 IO 默认无上拉,其他的 GPIO 口均有上拉。
由于是内部配置上拉,所以如需下拉,需外部加下拉方式或者加一个三级管的反相电路。

PS: GPIO不能到5V。
GPIO4/5外接1M电阻不能上拉到高电平;需100K电阻。
Screenshot at 12月 07 18-10-59.png

Statistics: Posted by Guest — Mon Dec 07, 2015 6:16 pm


]]>
2015-12-07T17:26:08+08:00 2015-12-07T17:26:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1494&p=4936#p4936 <![CDATA[FAQs • Q: How to set Tx power]]> Q: How to set Tx power

1.system_phy_set_max_tpw can be used to set maximum value of RF TX Power.

2. We also recommend you to use flash download tool_V1.2 to do the settings and click GenInitBin to generate esp_init_data_default.bin and then burn it into the spi flash.

LowPowerEn: Set Tx Power for each mode.
BackOffEn: Reduce the same value of Tx power in each mode.
PowerLimiten: Set the limitation of maxium Tx power.

Click GenInitBin to generate default_init_data.bin, and replace default one.
Screenshot at 12月 07 17-20-18.png

Statistics: Posted by Guest — Mon Dec 07, 2015 5:26 pm


]]>
2015-12-07T17:22:26+08:00 2015-12-07T17:22:26+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1493&p=4935#p4935 <![CDATA[FAQs • Q: 如何调整 Tx Power]]> Q: 如何调整 Tx Power

1.“system_phy_set_max_tpw”
用于设置 RF TX Power 最大值,单位:0.25dBm。

2.目前 flash download tool_V1.2 中已开放给客户自行配置并生成 INIT_DATA_DEFAULT.BIN。其中关于 Tx power 的调整如下所示:

LowPowerEn:同时设置每个模式下的 Tx Power.
BackOffEn:同时设置每个模式下 TX Power 需要减小的值。
PowerLimiten:限制 Tx Power 的最大值。

设置确认之后点击 GenInitBin,并替换原先的 default_init_data.bin。
Screenshot at 12月 07 17-20-18.png

Statistics: Posted by Guest — Mon Dec 07, 2015 5:22 pm


]]>
2015-12-03T16:46:46+08:00 2015-12-03T16:46:46+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1468&p=4879#p4879 <![CDATA[FAQs • Q: Which API need to call in user_init]]> Q: Which API need to call in user_init

wifi_set_ip_info and wifi_set_macaddr can only be called in user_init, it will be valid if called at anywhere else.

system_timer_reinit is suggested to call in user_init. If it's called anywhere else, need to arm all timer again.

wifi_station_set_config, if it's called in user_init, phy layer will connect router automatically, no need to call wifi_station_connect again. Or need to call wifi_station_connect if you want to set a connection.

wifi_station_set_auto_connect will set if need to connect to router automatically. For example, if you want to close automatically connection, a) you call wifi_station_set_auto_connect in user_init, then automatically connection will close this time; b) you call wifi_station_set_auto_connect somewhere else, automatically connection will close after next boot.

Statistics: Posted by Guest — Thu Dec 03, 2015 4:46 pm


]]>
2015-12-03T16:03:19+08:00 2015-12-03T16:03:19+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1466&p=4877#p4877 <![CDATA[FAQs • Q: 哪些接口需要在 user_init 中调用,否则容易出现问题,或者不生效?]]> Q: 哪些接口需要在 user_init 中调用,否则容易出现问题,或者不生效?

wifi_set_ip_info、wifi_set_macaddr 仅在 user_init 中调用生效,其他地方调用不生效。

system_timer_reinit 建议在 user_init 中调用,否则调用后,需要重新 arm 所有 timer。

wifi_station_set_config 如果在 user_init 中调用,底层会自动连接对应路由,不需要再调用 wifi_station_connect 来进行连接。否则,需要调用 wifi_station_connect 进行连接。

wifi_station_set_auto_connect 设置上电启动时是否自动连接已记录的路由;例如,关闭自动连接功能,如果在 user_init 中调用,则当前这次上电就不会自动连接路由,如果在其他位置调用,则是下次上电启动不会自动连接路由。

Statistics: Posted by Guest — Thu Dec 03, 2015 4:03 pm


]]>
2015-11-17T12:20:34+08:00 2015-11-17T12:20:34+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1394&p=4626#p4626 <![CDATA[FAQs • [ESP8266 AT] UART-WiFi Passthrough mode]]> If users want to porting it on TCP server mode, there are some samples may help.
How to add user-define AT commands ?
UART-TCP Passthrough Demo
Sample codes of creating a TCP server
Documentation about AT commands

ESP8266 AT 指令固件中,UART-WiFi 透传仅支持 ESP8266 作为 TCP client 单连接模式和 UDP 传输。
如果开发者希望实现 TCP server 的 UART-WiFi 透传,以下这些示例可供参考。
如何新增自定义 AT 指令?
ESP8266 UART-TCP 透传示例代码
ESP8266 创建 TCP server 示例代码
AT 指令文档

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Tue Nov 17, 2015 12:20 pm


]]>
2015-08-13T11:00:35+08:00 2015-08-13T11:00:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=179&p=3193#p3193 <![CDATA[FAQs • Re: Error Occur after "AT+CIUPDATE"]]>
In order to upgrade, you have to download boot.bin + user1.bin + blank.bin.

Please download the corresponding bin files into Flash, according to "readme.txt" in \esp_iot_sdk\bin\at

Statistics: Posted by ESP_Faye — Thu Aug 13, 2015 11:00 am


]]>
2015-08-08T03:28:27+08:00 2015-08-08T03:28:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=179&p=3084#p3084 <![CDATA[FAQs • Re: Error Occur after "AT+CIUPDATE"]]>

wdt reset
load 0x40100000, len 25052, room 16
tail 12
chksum 0x0b
ho 0 tail 12 room 4
load 0x3ffe8000, len 3312, room 12
tail 4
chksum 0x53
load 0x3ffe8cf0, len 6576, room 4
tail 12
chksum 0x0d
csum 0x0d
Fatal exception (0):
epc1=0x402411b4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x0
0000000

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 25052, room 16
tail 12
chksum 0x0b
ho 0 tail 12 room 4
load 0x3ffe8000, len 3312, room 12
tail 4
chksum 0x53
load 0x3ffe8cf0, len 6576, room 4
tail 12
chksum 0x0d
csum 0x0d
Fatal exception (0):
epc1=0x402411b4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x0
0000000

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 25052, room 16

Statistics: Posted by jlbachiochi — Sat Aug 08, 2015 3:28 am


]]>
2015-08-03T10:25:01+08:00 2015-08-03T10:25:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=292&p=3020#p3020 <![CDATA[FAQs • Re: "Fatal exception" problem]]>
感谢您对 ESP8266 的关注!

您可以在 eagle.S 中查找您出错的地址,对应的是哪个函数。添加 log,进一步查证问题原因。

Statistics: Posted by ESP_Faye — Mon Aug 03, 2015 10:25 am


]]>
2015-08-02T04:27:18+08:00 2015-08-02T04:27:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=833&p=3000#p3000 <![CDATA[FAQs • Re: Q: Does the chip support HTTP posting? How do we do that?]]>
POSTing data:

[Non-OS SDK]
Use espconn_sent (struct espconn * espconn, uint8 * psent, uint16 length) to POST data.

The structure espconn (TCP communications) specifies the server's IP and Port.

Psent: Buffer address of the http-encoded data to send

Length: Length of the data to be transmitted.

[OS SDK]
Users can do so by calling the send function of the socket.
For more information refer to: Documentation> Sample Codes> ESP8266 as TCP client.

(espressif - please correct where necessary)

Statistics: Posted by kenn2 — Sun Aug 02, 2015 4:27 am


]]>
2015-08-02T04:19:12+08:00 2015-08-02T04:19:12+08:00 https://bbs.espressif.com:443/viewtopic.php?t=838&p=2999#p2999 <![CDATA[FAQs • Re: Q: What is the difference between RTOS and the non-OS SDK?]]> )

The main points of difference are as follows:

[Non-OS SDK]

The Non-OS SDK uses timers and callbacks as the main way to perform the various functions - nested events, functions triggered by certain conditions. The Non-OS SDK uses the espconn network interface; the user needs to develop their software according to the usage rules of the espconn interface.

[RTOS SDK]

1. RTOS version SDK uses the freeRTOS system, a multi-tasking OS. You can use standard interfaces to freeRTOS resource management, recycling operations, execution delay, inter-task messaging and synchronization, task-oriented process design. For the specifics of interface methods, refer to freeRTOS official website instructions or USING THE FREERTOS REAL TIME KERNEL - A Practical Guide introduction.

2. RTOS SDK version of the network operating interface is a standard lwIP API, while providing a package which enables BSD Socket APIsocket interface. Users can directly use the socket API to develop software applications; your code can also be directly compiled to run standard applications on other platforms Socket , effectively reducing the cost of learning platform switching. (possibly flawed translation)

3. RTOS version of the SDK introduces cJSON library, use the library functions to more easily parse JSON packets.

4. RTOS version is compatible with non-OS SDK in the Wi-Fi interface, smart config interfaces, Sniffer related interfaces, system interface, timer interface, FOTA interfaces and peripheral driver interface, but does not support the AT implementation.

(espressif - please make corrections)

Statistics: Posted by kenn2 — Sun Aug 02, 2015 4:19 am


]]>
2015-07-31T12:56:00+08:00 2015-07-31T12:56:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=881&p=2972#p2972 <![CDATA[FAQs • Q: 如何使用 ESP Touch?]]> Q: How to use ESP Touch?
您可以从Android 市场 或者 IOS 商店下载 ESP Touch 的源代码。
然后从 README.md 文件中学习使用方法。

Statistics: Posted by Guest — Fri Jul 31, 2015 12:56 pm


]]>
2015-07-31T12:56:00+08:00 2015-07-31T12:56:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=880&p=2971#p2971 <![CDATA[FAQs • Q: How to use ESP Touch?]]> Q: How to use ESP Touch?
You can download the ESP Touch source code from Android or IOS.
Then read the file README.md to learn how to use the ESP Touch.

Statistics: Posted by Guest — Fri Jul 31, 2015 12:56 pm


]]>
2015-07-31T12:56:00+08:00 2015-07-31T12:56:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=879&p=2970#p2970 <![CDATA[FAQs • Q: 我该如何下载 APK 和源代码?]]> Q: 我该如何下载 APK 和源代码?

[APK]
Google Play: 点击下载
百度市场: 点击下载
91 市场: 点击下载
Hiapk 市场: 点击下载
[源代码]
GitHub: 点击下载

Statistics: Posted by Guest — Fri Jul 31, 2015 12:56 pm


]]>
2015-07-31T12:56:00+08:00 2015-07-31T12:56:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=878&p=2969#p2969 <![CDATA[FAQs • Q: How can I download the APKs and the source code?]]> Q: How can I download the APKs and the source code?

[APK]
Google Play: Click to Download
Baidu Market: Click to Download
91 Market: Click to Download
Hiapk Market: Click to Download
[Source Code]
GitHub: Click to Download

Statistics: Posted by Guest — Fri Jul 31, 2015 12:56 pm


]]>
2015-07-31T12:35:50+08:00 2015-07-31T12:35:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=877&p=2967#p2967 <![CDATA[FAQs • [Release] FAQ List]]> QAnswer

Q1: Which version of ESP8266 firmware should I download? what are the differences?Click here

Q2: How do I flash the program into the chip?Click here

Q3: How do I program the GPIO? Do you have an example? Click here

Q4: What is the power consumption of the chip in operating modes? Can I use a battery? Click here

Q5: What is the difference between RTOS and the non-OS SDK? Click here

Q6: How do I define my own functions in the AT+ commands? How do I pass parameters between them? Click here

Q7: Can I disable the watchdog reset? Click here

Q8: My program triggers the watchdog reset. Why is this so? Click here

Q9: How to put the chip into sleep mode? and what conditions do we need? Click here

Q10: Does the chip support HTTP posting? How do we do that? Click here

Statistics: Posted by Guest — Fri Jul 31, 2015 12:35 pm


]]>
2015-07-31T12:35:16+08:00 2015-07-31T12:35:16+08:00 https://bbs.espressif.com:443/viewtopic.php?t=876&p=2966#p2966 <![CDATA[FAQs • [最新发布] FAQ 列表]]> 常见问题解答

Q1: 我应该下载ESP8266固件的哪个版本? 几个版本之间有什么不同吗?点击这里

Q2: 我如何将程序刷进芯片中?点击这里

Q3: 怎样进行GPIO编程?你能举个例子吗?点击这里

Q4: 这个芯片在运行模式下的功耗是多少? 我可以用电池吗?点击这里

Q5: RTOS SDK 和Non-OS SDK有何区别?点击这里

Q6: 如何在AT+指令中定义自己的函数?如何在函数之间传递参数?点击这里

Q7: 我可以禁止看门狗复位吗?点击这里

Q8: 编程时出现了看门狗复位的问题,为什么会出现这一问题?点击这里

Q9: 怎样使芯片进入休眠模式?需要满足什么条件?点击这里

Q10: ESP8266 支持 HTTP 协议吗?如何实现?点击这里

Statistics: Posted by Guest — Fri Jul 31, 2015 12:35 pm


]]>
2015-07-29T15:20:36+08:00 2015-07-29T15:20:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=292&p=2913#p2913 <![CDATA[FAQs • Re: "Fatal exception" problem]]> Fatal exception (28):
epc1=0x401015e0, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
rm match
我烧录的文件是flash.bin + irom0text.bin ,请问怎样解决?

Statistics: Posted by TOPARM — Wed Jul 29, 2015 3:20 pm


]]>
2015-07-28T13:07:32+08:00 2015-07-28T13:07:32+08:00 https://bbs.espressif.com:443/viewtopic.php?t=872&p=2955#p2955 <![CDATA[FAQs • Q: 我应该下载ESP8266固件的哪个版本? 几个版本之间有什么不同吗?]]> Q: 我应该下载ESP8266固件的哪个版本? 几个版本之间有什么不同吗?
每一版SDK 更新的 Release note 中都有列出修复了哪些问题,该版本做了哪些优化,新添加了哪些API 及功能。您可以根据功能需求进行选择。
SDK的下载请参考 【最新发布】ESP8266 SDK

Statistics: Posted by Guest — Tue Jul 28, 2015 1:07 pm


]]>
2015-07-28T13:07:32+08:00 2015-07-28T13:07:32+08:00 https://bbs.espressif.com:443/viewtopic.php?t=843&p=2896#p2896 <![CDATA[FAQs • Q: Which version of ESP8266 firmware should I download? what are the differences?]]> Q: Which version of ESP8266 firmware should I download? what are the differences?
The Release Note updated on each version of SDK will list the issues that have been fixed, versions that have been updated, and APIs and their respective functions that have been added. You can choose the version according to its functions. Relevant Demo projects are provided on the Example of SDK, and you can choose it based on actual applications.
For SDK download, please refer to [Latest Release] ESP8266 SDK.

Statistics: Posted by Guest — Tue Jul 28, 2015 1:07 pm


]]>
2015-07-28T13:06:13+08:00 2015-07-28T13:06:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=873&p=2956#p2956 <![CDATA[FAQs • Q: 我如何将程序刷进芯片中?]]> Q: 我如何将程序刷进芯片中?
  • 保证 3.3V 电源供应,一般要求外部电源输出电流需在 500mA 及以上。
  • CH_EN 芯片使能管脚拉高。
  • 将 ESP8266 配置为 UART Download Boot 模式:MTDO->0, GPIO0->0, GPIO2->1。
  • 将 GND、U0RXD 和 U0TXD 通过串口线连接至 PC。然后使用 Flash Download Tool 完成固件下载。
    下载时需注意:
    1.请根据实际选用的晶振型号对应选择 CrystalFreq(26MHz/40MHz/24MHz).
    2.请根据实际选用的 flash 对应选择 SPI mode(QIO/QOUT/DIO/DOUT)
    3.请根据实际编译时配置的 flash size 对应选择 flash size.
  • 下载完成后,请将 ESP8266 的 boot 模式切换到 flash boot,即 MTDO->0, GPIO0->1, GPIO2->1。
  • 可通过串口调试工具查看 log 打印或进行串口指令交互。

Statistics: Posted by Guest — Tue Jul 28, 2015 1:06 pm


]]>
2015-07-28T13:06:13+08:00 2015-07-28T13:06:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=842&p=2895#p2895 <![CDATA[FAQs • Q: How do I flash the program into the chip?]]> Q: How do I flash the program into the chip?
  • 3.3V Power supply is needed and it’s generally required that the output current of external power supply be 500 mA and above.
  • Pull the chip-enable pin high.
  • Configure ESP8266 in UART Download Boot mode: MTDO->0, GPIO0->0, GPIO2->1.
  • Connect GND, U0RXD and U0TXD to PC via serial ports. Then use Flash Download Tool to download the firmware.
    Please note while downloading it:
    1.Choose CrystalFreq(26MHz/40MHz/24MHz) based on the model of crystal vibration that is actually used.
    2.Choose SPI mode(QIO/QOUT/DIO/DOUT) based on the flash that is actually used.
    3.Choose flash size based on that configured in the actual compilation process.
  • When the download is complete, switch ESP8266 to flash boot mode, namely, MTDO->0, GPIO0->1, GPIO2->1.
  • Check the log or make instructions via serial debugging tools.

Statistics: Posted by Guest — Tue Jul 28, 2015 1:06 pm


]]>
2015-07-28T13:03:54+08:00 2015-07-28T13:03:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=882&p=2973#p2973 <![CDATA[FAQs • Q: 怎样进行GPIO编程?你能举个例子吗?]]> Q: 怎样进行GPIO编程?你能举个例子吗?
关于非 OS 版本和 OS 版本 GPIO 的操作有些不同。
【非 OS 版本】
设置 MTDO 为输入模式,并且配置为下降沿触发中断方式。

Code:

void ICACHE_FLASH_ATTR gpio_init(void)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15);                //GPIO 选择功能
    GPIO_DIS_OUTPUT(GPIO_ID_PIN(15));                                  //配置为输入模式
    ETS_GPIO_INTR_DISABLE();                                           //关闭 GPIO 中断
    ETS_GPIO_INTR_ATTACH(GPIO_INTERRUPT,NULL);                         //注册中断函数
    gpio_pin_intr_state_set(GPIO_ID_PIN(15),GPIO_PIN_INTR_NEGEDGE);    //下降沿触发
    ETS_GPIO_INTR_ENABLE() ;                                           //使能 GPIO 中断
}

【OS 版本】
设置MTDO为输入模式,并且配置为下降沿触发中断方式。
void ICACHE_FLASH_ATTR gpio_init(void)

Code:

{
    GPIO_ConfigTypeDef gpio_in_cfg;                                    //定义 GPIO 初始化结构体
    gpio_in_cfg.GPIO_IntrType = GPIO_PIN_INTR_NEGEDGE;                 //下降沿触发
    gpio_in_cfg.GPIO_Mode = GPIO_Mode_Input;                           //输入模式
    gpio_in_cfg.GPIO_Pin  = GPIO_Pin_15;                               //GPIO 选择使能
    gpio_config(&gpio_in_cfg);                                         //初始化函数
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(GPIO_UART_IN_NUM));
    gpio_intr_handler_register(interrupt_GPIO_UART);                   //注册中断函数
    _xt_isr_unmask(1 << ETS_GPIO_INUM);                                //使能 GPIO 中断
}

【配置说明】
请参考 开发指南文档清单 中的 “0D-ESP8266__Pin_List__Release_15-11-2014.xlsx” 文档。
  • 在 Reg 页签可以查阅到 GPIO 功能选择相关的寄存器。
  • 在 Digital Die Pin List 页签中可以查到通用的 GPIO 以及复用功能,其中 FUNCTION 列就是功能的配置选项。
    如果需要配置为 FUNCTION3,应该往寄存器对应的位中写2,如果需要配置为 FUNCTION2,应该往寄存器对应的位中写 1,以此类推。
    例如:代码中 PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15); 这里的FUNC_GPIO15 的值为 3,根据表格中 FUNCTION4 列可知,这是将 PERIPHS_IO_MUX_MTDO_U 配置为 GPIO 功能。

Statistics: Posted by Guest — Tue Jul 28, 2015 1:03 pm


]]>
2015-07-28T13:03:54+08:00 2015-07-28T13:03:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=841&p=2894#p2894 <![CDATA[FAQs • Q: How do I program the GPIO? Do you have an example?]]> Q: How do I program the GPIO? Do you have an example?
Difference exists between non-OS and OS version in the programming process.
[Non-OS Version]
Set the input mode to MTDO and configure it in falling edge trigger mode.

Code:

void ICACHE_FLASH_ATTR gpio_init(void)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15);                //GPIO Alternate Function
    GPIO_DIS_OUTPUT(GPIO_ID_PIN(15));                                  //Configure it in input mode.
    ETS_GPIO_INTR_DISABLE();                                           //Close the GPIO interrupt
    ETS_GPIO_INTR_ATTACH(GPIO_INTERRUPT,NULL);                         //Register the interrupt function
    gpio_pin_intr_state_set(GPIO_ID_PIN(15),GPIO_PIN_INTR_NEGEDGE);    //Falling edge trigger
    ETS_GPIO_INTR_ENABLE() ;                                           //Enable the GPIO interrupt
}

[OS Version]
Set the input mode to MTDO and configure it in falling edge trigger mode.
void ICACHE_FLASH_ATTR gpio_init(void)

Code:

{
    GPIO_ConfigTypeDef gpio_in_cfg;                                    //Define GPIO Init Structure
    gpio_in_cfg.GPIO_IntrType = GPIO_PIN_INTR_NEGEDGE;                 //Falling edge trigger
    gpio_in_cfg.GPIO_Mode = GPIO_Mode_Input;                           //Input mode
    gpio_in_cfg.GPIO_Pin  = GPIO_Pin_15;                               // Enable GPIO
    gpio_config(&gpio_in_cfg);                                         //Initialization function
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(GPIO_UART_IN_NUM));
    gpio_intr_handler_register(interrupt_GPIO_UART);                   // Register the interrupt function
    _xt_isr_unmask(1 << ETS_GPIO_INUM);                                //Enable the GPIO interrupt
}

[Configuration Instructions]
Please refer to "0D-ESP8266__Pin_List__Release_15-11-2014.xlsx" in the Documentation List of Development Guides.
  • You can refer to GPIO alternate function registers in the Reg tabs.
  • You can refer to GPIO and its multiplexing functions in the Digital Die Pin List tabs, during which the column of FUNCTION provides configuration options for functions.
    Type 2 in the corresponding bit of the register if it’s needed to configure it in FUNCTION3; type 1 in the corresponding bit if it’s needed to configure it in FUNCTION2, and so on.
    For example, in the code of PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15), the value of FUNC_GPIO15 is three and according to FUNCTION4 in the list, this means that PERIPHS_IO_MUX_MTDO_U is configured to GPIO function.

Statistics: Posted by Guest — Tue Jul 28, 2015 1:03 pm


]]>
2015-07-28T13:03:00+08:00 2015-07-28T13:03:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=883&p=2976#p2976 <![CDATA[FAQs • Q: 这个芯片在运行模式下的功耗是多少? 我可以用电池吗?]]> Q: 这个芯片在运行模式下的功耗是多少? 我可以用电池吗?

TX(MCS7)电流为:150mA~200mA,RX 电流为:60mA。
三种低功耗模式下的电流功耗如下表所示。
Snip20150730_1.png

说明:
DTIM1 的定义就是每 100ms 醒来 3ms 接收 AP 的 Beacon 包。
DTIM3 的定义就是每 300ms 醒来 3ms 接收 AP 的 Beacon 包。
DTIM10 的定义就是每 1s 醒来 3ms 接收 AP 的 Beacon 包。
DTIM n 的定义就是每 n*100ms 醒来 3ms 接收 AP 的 Beacon 包。
支持 2 节 1.5V 干电池供电。 在使用电池供电的应用场合,建议采用 Deep-sleep 的低功耗模式。
更多低功耗传感器的应用示例参考 ESP8266 Low Power Sensor Demo on github

Statistics: Posted by Guest — Tue Jul 28, 2015 1:03 pm


]]>
2015-07-28T13:03:00+08:00 2015-07-28T13:03:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=840&p=2893#p2893 <![CDATA[FAQs • Q: What is the power consumption of the chip in operating modes? Can I use a battery?]]> Q: What is the power consumption of the chip in operating modes? Can I use a battery?

The current of TX (MCS7) is 150mA~200mA and that of RX is 60mA.
The current power consumption in three low power consumption modes is shown in table below.
Snip20150730_1.png

Remark:
DTIM1 means that, in the DTIM period of 1, devises will wake up to receive the beacons within 3 ms after sleeping for 100ms.
DTIM3 means that, in the DTIM period of 3, devises will wake up to receive the beacons within 3 ms after sleeping for 300ms.
DTIM10 means that, in the DTIM period of 10, devises will wake up to receive the beacons within 3 ms after sleeping for 1s.
DTIM n means that, in the DTIM period of n, devises will wake up to receive the beacons within 3 ms after sleeping for n*100ms.
It is practicable that two 1.5V dry batteries deliver the power supply. It’s recommended to select Deep-sleep, the low power consumption mode, while powered by batteries.
For more applications of low power consumption sensors, please refer to ESP8266 Low Power Sensor Demo on github.

Statistics: Posted by Guest — Tue Jul 28, 2015 1:03 pm


]]>
2015-07-28T12:59:25+08:00 2015-07-28T12:59:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=884&p=2977#p2977 <![CDATA[FAQs • Q: RTOS SDK 和 Non-OS SDK 有何区别?]]> Q: RTOS SDK 和 Non-OS SDK 有何区别?
主要差异点如下:
【Non-OS SDK】
Non-OS SDK 主要使用定时器和回调函数的方式实现各个功能事件的嵌套,达到特定条件下触发特定功能函数的目的。Non-OS SDK 使用 espconn 接口实现网络操作,用户需要按 照 espconn 接口的使用规则进行软件开发。
【RTOS SDK】
    1. RTOS 版本 SDK 使用 freeRTOS 系统,引入 OS 多任务处理的机制,用户可以使用 freeRTOS 的标准接口实 现资源管理、循环操作、任务内延时、任 务间信息传递和同步等面向任务流程的设计方式。具体接口使用方法参考 freeRTOS 官方网站的使用说明或者 USING THE FREERTOS REAL TIME KERNEL--A Practical Guide 介绍。
    2. RTOS 版本 SDK 的网络操作接口是标准 lwIP API,同时提供了 BSD Socket APIsocket 接口的封装实现,用户可以直接按照socket API的使用方式来开发软件应用,也可以直接编译运行其他平台的标准 Socket 应用,有效降低平台切换的学习成本。
    3. RTOS 版本 SDK 引入了 cJSON 库,使用该库函数可以更加方便的实现对 JSON 数据包的解析。
    4. RTOS 版本兼容non-OS SDK中的Wi-Fi接 口、smart config接口、Sniffer相关接口、系统接口、定时器接 口、FOTA接口和外围驱动接口,不支持AT实现。

Statistics: Posted by Guest — Tue Jul 28, 2015 12:59 pm


]]>
2015-07-28T12:59:25+08:00 2015-07-28T12:59:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=838&p=2891#p2891 <![CDATA[FAQs • Q: What is the difference between RTOS and the non-OS SDK?]]> Q: What is the difference between RTOS and the non-OS SDK?
The main differences are listed below:
【Non-OS SDK】
Non-OS SDK enables features or events to be embedded via timers and call-back functions. In this regard, specific functions will be triggered in specific conditions. In the Non-OS SDK, espconn is utilized to operate the network. The users need to develop softwares based on the usage rules for espconn.
【RTOS SDK】
    1. FreeRTOS is utilized in the RTOS SDK that features multitasking operation. Designed in this way, this system enables users to utilize the standard interface for resource management, cyclic operation, time delay within a task, and inter-task information delivery and synchronization. For specific usage methods for interfaces, please refer to the official website of freeRTOS or USING THE FREERTOS REAL TIME KERNEL--A Practical Guide.
    2. lwIP API, a standard interface, is utilized in the RTOS SDK to operate the network. In the RTOS SDK, SD Socket API is encapsulated. Users may develop software applications in the same way that they apply socket API, or compile the standard Socket applications that run on other platforms. This helps reduce costs incurred in switching from one platform to another.
    3. cJSON library is added into the RTOS SDK. This library facilitates its functions to parse the contents of JSON data packet.
    4. RTOS is compatible with Wi-fi interfaces, smart config interfaces, Sniffer related interfaces, system interfaces, timer interface, FOTA interfaces and peripheral driver interfaces in the non-OS SDK, but does not support the AT commands.

Statistics: Posted by Guest — Tue Jul 28, 2015 12:59 pm


]]>
2015-07-28T12:57:41+08:00 2015-07-28T12:57:41+08:00 https://bbs.espressif.com:443/viewtopic.php?t=892&p=3022#p3022 <![CDATA[FAQs • Q: 如何在AT+指令中定义自己的函数?如何在函数之间传递参数?]]> Q: 如何在AT+指令中定义自己的函数?如何在函数之间传递参数?
在 \ESP8266_NONOS_SDK\examples\at\user\user_main.c 示例中有提供如何实现一条自定义的 AT 指令 “AT+TEST”。
结构体 at_funcationType 用于定义一条指令的四种类型,例如指令名称 “AT+TEST”。
  • 类型at_testCmd :测试指令,对应指令为 AT+TEST=?,AT 示例中注册的实现回调为 at_testCmdTest,测试指令可以设计为返回参数的取值范围;注册为 NULL,则无测试指令。
  • 类型 at_queryCmd:查询指令,对应指令为 AT+TEST?,AT 示例中注册的实现回调为 at_queryCmdTest,查询指令可以设计为返回当前值;注册为 NULL,则无查询指令。
  • 类型at_setupCmd:设置指令,对应指令格式为 AT+TEST=parameter1,parameter2,......,AT 示例中注册的实现回调为at_setupCmdTest,设置指令可以设计用于设置参数值;注册为 NULL,则无设置指令。
  • 类型at_exeCmd:执行指令,对应指令为AT+TEST,AT 示例中注册的实现回调为 at_exeCmdTest,执行指令可以设计用于执行某项操作;注册为 NULL,则无执行指令。

Statistics: Posted by Guest — Tue Jul 28, 2015 12:57 pm


]]>
2015-07-28T12:57:41+08:00 2015-07-28T12:57:41+08:00 https://bbs.espressif.com:443/viewtopic.php?t=837&p=2890#p2890 <![CDATA[FAQs • Q: How do I define my own functions in the AT+ commands? How do I pass parameters between them?]]> Q: How do I define my own functions in the AT+ commands? How do I pass parameters between them?
In the example of \ESP8266_NONOS_SDK\examples\at\user\user_main.c, ways are delivered on how to implement a self-defined AT Command, "AT+TEST".
The structure, at_funcationType, is used to define four types of a command, e.g., "AT+TEST".
  • "at_testCmd" is a testing command and it’s formatted as AT+TEST=?. In the example of AT, the registered callback is "at_testCmdTest"; the testing demand could be designed as the value range of the return parameter. If registered as NULL, there will be no testing command.
  • "at_queryCmd" is a query command and it’s formatted as AT+TEST?.In the example of AT, the registered callback is "at_queryCmdTest"; the query command could be designed as returning the current value. If registered as NULL, there will be no query command.
  • "at_setupCmd" is a setup command and it’s formatted as AT+TEST=parameter1,parameter2,........ In the example of AT, the registered callback is "at_setupCmdTest"; the setup command could be designed as the value of the parameter; if registered as NULL, there will be no setup command.
  • "at_exeCmd" is an execution command and it’s formatted as AT+TEST. In the example of AT, the registered callback is "at_exeCmdTest"; if registered as NULL, there will be no execution command.

Statistics: Posted by Guest — Tue Jul 28, 2015 12:57 pm


]]>
2015-07-28T12:55:18+08:00 2015-07-28T12:55:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=893&p=3026#p3026 <![CDATA[FAQs • Q: 我可以禁止看门狗复位吗?]]> Q: 我可以禁止看门狗复位吗?
在non-OS SDK中用户可以通过创建 timer 和 call_back 函数代替 while(1) 循环。
如果某段代码连续执行时间必须超过3.2s,用户用下面的方式解决看门狗复位的问题。
  • 在执行该代码段前调用systerm_soft_wdt_stop() 函数,从关闭 wdt 到硬 wdt 触发,有6s的时间。
  • 在代码段里执行若干次喂狗操作 systerm_soft_wdt_feed()。
  • 在代码段执行完毕后,调用 systerm_soft_wdt_restart() 函数。

Statistics: Posted by Guest — Tue Jul 28, 2015 12:55 pm


]]>
2015-07-28T12:55:18+08:00 2015-07-28T12:55:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=836&p=2889#p2889 <![CDATA[FAQs • Q: Can I disable the watchdog reset?]]> Q: Can I disable the watchdog reset?
You can create functions of timer and call_back to replace while(1) loop in the non-OS SDK.
If the consecutive execution time of a piece of code exceeds 3.2s, you can disable the watchdog reset through the following methods:
  • Call the function of systerm_soft_wdt_stop() before executing this piece of code. It takes 6s from closing wdt to wdt hard trigger.
  • Execute watchdog feed several times, i.e., systerm_soft_wdt_feed().
  • After completing the execution, call the function of systerm_soft_wdt_restart().

Statistics: Posted by Guest — Tue Jul 28, 2015 12:55 pm


]]>
2015-07-28T12:53:57+08:00 2015-07-28T12:53:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=894&p=3027#p3027 <![CDATA[FAQs • Q: 编程时出现了看门狗复位的问题,为什么会出现这一问题?]]> Q: 编程时出现了看门狗复位的问题,为什么会出现这一问题?
【Non-OS SDK】
用户的某段代码的连续执行时间如果大于 3.2 s,会发生看门狗复位。因为喂狗的任务是在 task 中执行, 超过 3.2 s 的时间如果该 task 无法执行,就会发生看门狗复位。
【OS SDK】
用户应当注意临界保护或者挂起调度器的时间不能超过 3.2s。

Statistics: Posted by Guest — Tue Jul 28, 2015 12:53 pm


]]>
2015-07-28T12:53:57+08:00 2015-07-28T12:53:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=835&p=2888#p2888 <![CDATA[FAQs • Q: My program triggers the watchdog reset. Why is this so?]]> Q: My program triggers the watchdog reset. Why is this so?
[Non-OS SDK]
If the consecutive execution time of a piece of code exceeds 3.2s, the watchdog will reset. The watchdog feed is executed in task, and if it cannot be executed when the execution time passes over 3.2 s, the watchdog will reset .
[OS SDK]
Note that the time for critical protection or hanging the scheduler cannot exceed 3.2s.

Statistics: Posted by Guest — Tue Jul 28, 2015 12:53 pm


]]>
2015-07-28T12:50:58+08:00 2015-07-28T12:50:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=905&p=3046#p3046 <![CDATA[FAQs • Q: 怎样使芯片进入休眠模式?需要满足什么条件?]]> Q: 怎样使芯片进入休眠模式?需要满足什么条件?
ESP8266 支持三种休眠方式:Modem-sleep,Light-sleep 和 Deep-sleep。ESP8266 进入 Modem-sleep 或者 Light-sleep 必须满足以下的条件。
  • ESP8266 被设置为 Station_only 模式。
  • ESP8266 链接到路由器获得 IP 地址。
  • 系统处于空闲态。
【函数调用】
  • 调用 wifi_set_sleep_type 函数,选择 ESP8266 进入 Modem-sleep 或 Light-sleep 方式。
  • 调用 system_deep_sleep 函数,设置8266 进入Deep_sleep 的休眠时间。
【应用场景】
  • Modem-sleep 一般用于必须打开芯片 CPU 的应用场景,例如 PWM 彩灯,需要 CPU 实时控制。
  • Light-sleep 模式可用于需要保持与路由器的连接,可以实时响应路由器发来的数据的场景。并且在未接收到命令时,CPU 可以处于空闲状态。如Wi-Fi 开关的应用,部分时间 CPU 都是空闲的,直到收到控制命令,CPU 才需要进行GPIO 的操作。
  • Deep-sleep 可以用于低功耗的传感器应用或者部分时间都不需要进行数据传输的场景。设备可以每隔一段时间从 Deep-sleep 状态醒来测量数据并上传,之后继续进行 Deep-sleep。也可以将多个数据存储于 RTC memory(RTC memory 在Deep-sleep 模式下仍然可以保存数据),然后一次发送出去。
【注意事项】
  • Light-sleep 在用户程序中不能有轮巡的timer 定时器,否则cpu 无法进入休眠。
  • 仅 Deep-sleep 要求XPD_DCDC(GPIO16) 或是外部 MCU 的 GPIO 口连接至 EXT_RSTB 进行唤醒。其他的休眠方式硬件上无特殊要求。
详细内容可参考 “9B-ESP8266__Sleep__Function Description” 文档

Statistics: Posted by Guest — Tue Jul 28, 2015 12:50 pm


]]>
2015-07-28T12:50:58+08:00 2015-07-28T12:50:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=834&p=2887#p2887 <![CDATA[FAQs • Q: How to put the chip into sleep mode? and what conditions do we need?]]> Q: How to put the chip into sleep mode? and what conditions do we need?
ESP8266 supports three sleep modes, i.e., Modem-sleep, Light-sleep and Deep-sleep. For Modem-sleep and Light-sleep, ESP8266 must meet the following requirements:
  • ESP8266 is set to Station_only mode.
  • ESP8266 links to Router to obtain IP address.
  • The system is in idle state.
[Function Callback]
  • Call the function of wifi_set_sleep_type and set ESP8266 to Modem-sleep or Light-sleep.
  • Call the function of system_deep_sleep and set ESP8266 to Deep-sleep mode.
[Context of Use]
  • Modem-sleep is generally used when CPU runs. For example, PWM lights needs CPU’s real-time control.
  • Light-sleep mode can be used to maintain the link between ESP8266 and Router. This mode enable ESP8266 to give a real-time response to data sent by Router. CPU can be idle state before it receives commands. For example, in Wi-Fi switches, CPU is in idle state until it receives the control command and begins to operate GPIO.
  • Deep-sleep mode can be used in low power generation sensors or in the context in which data transmission is not needed in part of the execution time. Devices can wake up to measure data and update them in a periodic way and then re-enter the Deep-sleep mode. Data could also be stored in RTC memory (this applies in Deep-sleep mode) and be sent out all at once.
[Notes]
  • Your program cannot have a round robin timer in the program, or its CPU will fail to enter the sleep mode.
  • It is only required in the Deep-sleep mode that XPD_DCDC(GPIO16) or GPIO in the MCU should be connected to EXT_RSTB to wake up the chip. There are no special requirements in the other modes.
Refer to“9B-ESP8266__Sleep__Function Description” for more information.

Statistics: Posted by Guest — Tue Jul 28, 2015 12:50 pm


]]>
2015-07-28T12:44:05+08:00 2015-07-28T12:44:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=833&p=2886#p2886 <![CDATA[FAQs • Q: ESP8266 支持 HTTP 协议吗?如何实现?]]> Q: ESP8266 支持 HTTP 协议吗?如何实现?
ESP8266 可以支持 HTTP 协议。
【non-OS SDK】
通过 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length) 实现
该函数中 espconn 为 TCP 通信的结构体,里面指定服务器的 IP 和 Port。
  • Psent:为发送数据的 Buffer 地址,用户需要将要发送的 Http 数据放到该psent 指向的 Buffer 中。
  • Length:要发送的数据的长度。
【OS SDK】
调用 socket 的 send 函数可以实现。
更多资料参考:Documentation > Sample Codes > ESP8266 as TCP client

Statistics: Posted by Guest — Tue Jul 28, 2015 12:44 pm


]]>
2015-07-20T14:57:01+08:00 2015-07-20T14:57:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=778&p=2749#p2749 <![CDATA[FAQs • Pointer conversion has to be 4 bytes aligned 指针强制转换必须 4 字节对齐]]> :!: :!:

请注意,内存必须 4 字节对齐读取,指针做转换时请确保为 4 字节对齐,否则转换失败,不能正常使用。
例如,请勿直接指针转换 float temp = *((float*)data); 而是使用 os_memcpy (memcpy) 实现。

Read and write RAM has to be aligned by 4 bytes, so please do not cast pointer directly, for example, please use os_memcpy (memcpy) instead of float temp = *((float*)data);.

Statistics: Posted by ESP_Faye — Mon Jul 20, 2015 2:57 pm


]]>
2015-06-08T11:43:40+08:00 2015-06-08T11:43:40+08:00 https://bbs.espressif.com:443/viewtopic.php?t=560&p=2091#p2091 <![CDATA[FAQs • A simple example of send HTTP packet by AT command]]> :!: :!:

How to send HTTP packet based on esp_iot_sdk http://bbs.espressif.com/viewtopic.php?f=21&t=232

How to send HTTP packet by AT command
1. AT+CWMODE=3 // set softAP+station mode

2. AT+CWJAP="SSID","password" // ESP8266 station connect to router

3. create a TCP connection and send HTTP packet which is marked in red, notice that the new line [(0x0d 0x0a) or (CR LF)] is needed.

Code:

GET / HTTP/1.1
User-Agent: curl/7.37.0
Host: cn.bing.com
Accept: */*


SEND_HTTP_TEST.png



4.HTTP result
SEND_HTTP_TEST_RESULT.png


Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Mon Jun 08, 2015 11:43 am


]]>
2015-05-26T16:49:33+08:00 2015-05-26T16:49:33+08:00 https://bbs.espressif.com:443/viewtopic.php?t=500&p=1883#p1883 <![CDATA[FAQs • 192.168.4.X connection problem in softAP + station mode]]> So, in softAP + station mode, ESP8266 does NOT support network connection if the ESP8266 station also connects to a router of which IP address is 192.168.4.X.
ESP8266 can not distinguish it if IP address of ESP8266 softAP and station are both in a same subnet (192.168.4.X).

Sorry for the inconvenience.

由于 ESP8266 softAP 默认 IP 为 192.168.4.1。
则如果在 softAP + station 模式下,ESP8266 station 也连接到一个 IP 为 192.168.4.X 的路由,此时再建立网络连接会失败。
因为当 ESP8266 softAP 和 station 的 IP 地址在同一子网范围内 (192.168.4.X) 时,ESP8266 无法区分该从 softAP 还是 station 建立连接。

给您带来不便,深感抱歉。

Statistics: Posted by ESP_Faye — Tue May 26, 2015 4:49 pm


]]>
2015-04-15T20:08:13+08:00 2015-04-15T20:08:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=366&p=1345#p1345 <![CDATA[FAQs • "ICACHE_FLASH_ATTR" macro]]> :!: :!:

Q :
What is the purpose of the ICACHE_FLASH_ATTR macro in ESP8266_NONOS_SDK ? I see that it depends on ICACHE_FLASH, but I don’t know when that symbol should be defined.
When is it necessary to include it?
A :
For ESP8266_NONOS_SDK
Functions decorated with ICACHE_FLASH_ATTR compile to the IROM section; for such functions, the CPU execute the codes in the instruction cache.
Conversely, functions without ICACHE_FLASH_ATTR load into IRAM when the system starts. Hence, using the ICACHE_FLASH_ATTR helps reduce the IRAM requirements.
Do not use ICACHE_FLASH_ATTR-functions in interrupt handler, as it may conflict with the flash R/W operations.

For ESP8266_RTOS_SDK
In this SDK, we have made execution from I-cache to be the default mode. Hence, only functions that need to run from IRAM are to be decorated with IRAM_ATTR.
In another words, functions that are to execute from the I-cache, do not need to be decorated with ICACHE_FLASH_ATTR. They inherit this characteristic by default, unless they are decorated with IRAM_ATTR.

问:
为什么 ESP8266_NONOS_SDK 中有的函数前面添加了 "ICACHE_FLASH_ATTR" 宏?我们应该如何使用它呢?
答:
对于 ESP8266_NONOS_SDK
添加了 "ICACHE_FLASH_ATTR" 宏的函数,将存放在 IROM 中,CPU 仅在调用到它们的时候,将它们读到 cache 中运行;
没有添加 "ICACHE_FLASH_ATTR" 宏的函数,将在一开始上电运行时,就加载到 IRAM 中运行;
由于空间有限,我们无法将所有代码都一次性加载到 IRAM 中运行,因此在大部分函数前添加 "ICACHE_FLASH_ATTR" 宏,放在 IROM 中。
请注意,不要在中断处理函数中调用带有 "ICACHE_FLASH_ATTR" 宏的函数,否则将引起异常。

对于 ESP8266_RTOS_SDK
函数默认存放在 IROM 中,无需再添加"ICACHE_FLASH_ATTR" 宏。
中断处理函数也可以定义在 IROM 中。
如果开发者需要将一些频繁调用的函数定义在 IRAM 中,在函数前添加 “IRAM_ATTR” 宏即可。

Thanks for your intereset in ESP8266 !

Statistics: Posted by ESP_Faye — Wed Apr 15, 2015 8:08 pm


]]>
2015-04-15T11:20:18+08:00 2015-04-15T11:20:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=362&p=1330#p1330 <![CDATA[FAQs • How to use flash download tool?]]>
1.Tool name: Flash download tool
Click to download.


2.Instructions for flash download tool
Instructions for flash download tool.png


Thanks for your interests in ESP8266EX!

Statistics: Posted by Espressif_Kelly — Wed Apr 15, 2015 11:20 am


]]>
2015-04-03T15:57:06+08:00 2015-04-03T15:57:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=324&p=1222#p1222 <![CDATA[FAQs • ESP8266 softAP + station channel configuration]]>
So in softAP + station mode, ESP8266 softAP will adjust its channel configuration to be as same as ESP8266 station.

This limitation may cause some inconvenience in softAP + station mode users need to pay attention, for example:
Case 1.
(1) If user connect ESP8266 station to a router(e.g. router is in channel 6).
(2) Then set ESP8266 softAP by wifi_softap_set_config.
(3) The API may return true, but channel will always be channel 6. Because we have only one hardware channel.
Case 2.
(1) If user set ESP8266 softAP a channel number(e.g. channel 5) by wifi_softap_set_config.
(2) Some stations connected to ESP8266 softAP.
(3) Then connect ESP8266 station to a router of which channel number is different (e.g. channel 6).
(4) ESP8266 softAP has to adjust its channel to be as same as ESP8266 station, in this case, is channel 6.
(5) So the stations that connected to ESP8266 softAP in step 2 will be disconnected because of the channel change.
Case 3.
(1) Other stations are connected to the ESP8266 softAP.
(2) If the ESP8266‘s station interface has been scanning or trying to connect to a target router, the ESP8266 softAP-end connection may break.
This is because the ESP8266 station will try to find its target router in different channels, which means it will keep changing channels, and as a result, the ESP8266 channel is changing, too. Therefore, the ESP8266 softAP-end connection may break.
In cases like this, users can set a timer to call wifi_station_disconnect to stop the ESP8266 station from continuously trying to connect to the router. Or they can call wifi_station_set_reconnect_policy or wifi_station_set_auto_connect to disable the ESP8266 station from reconnecting to the router.

wifi_station_set_reconnect_policy(false); // if the ESP8266 station connected to the router, and then the connection broke, ESP8266 will not try to reconnect to the router.

wifi_station_set_auto_connect(false); //the ESP8266 station will not try to connect to the router automatically when power on until wifi_station_connect is called.

wifi_station_disconnect(); // ESP8266 station disconnects to the router, or ESP8266 station stops trying to connect to the target router.


虽然 ESP8266 支持 softAP + station 共存模式,但它实际上只有一个硬件信道。

因此在 softAP + station 模式时, ESP8266 softAP 动态调整它的信道值与 ESP8266 station 一致。

这个限制会导致 softAP + station 模式时一些行为上的不便,用户需要注意。例如:
情况一
(1)如果 ESP8266 station 连接到一个路由(假设路由信道号为 6)。
(2)通过接口 wifi_softap_set_config 设置 ESP8266 softAP。
(3)如果设置值合法有效 API 会返回 true,但信道号设置后仍然会被 ESP8266 自动调节成与 ESP8266 station 接口一致,在这个例子里也就是信道号为 6。因为 ESP8266 在硬件上就只有一个信道。
情况二
(1)先使用接口 wifi_softap_set_config 设置了 ESP8266 softAP (例如信道号为 5)。
(2)其他 station 连接到 ESP8266 softAP。
(3)将 ESP8266 station 连接到路由 ( 假设路由信道号为 6)。
(4) ESP8266 softAP 会调整信道号与 ESP8266 station 一致(信道 6)。
(5)由于信道改变,之前连接到 ESP8266 softAP 的 station 的 WiFi 连接会断开。
情况三
(1)其他 station 与 ESP8266 softAP 建立连接。
(2)如果 ESP8266 station 一直尝试在扫描或连接某个路由,可能导致 ESP8266 softAP 端的连接断开。
因为 ESP8266 station 会在各个信道查找目标路由,意味着它其实在不停的切换信道,ESP8266 softAP 的信道也因此在不停更改。这有可能导致 ESP8266 softAP 端的连接断开。
在这种情况下,用户可以设置一个定时器,定时调用 wifi_station_disconnect 停止 ESP8266 station 不断连接路由的尝试,或者调用 wifi_station_set_reconnect_policywifi_station_set_auto_connect 禁止 ESP8266 station 尝试重连路由。

wifi_station_set_reconnect_policy(false); // 如果 ESP8266 station 已经连接到某路由,但又从该路由上断开连接了,ESP8266 station 不会自动尝试重新连接该路由。

wifi_station_set_auto_connect(false); //ESP8266 station 在上电时不会自动尝试连接路由,需要调用 wifi_station_connect 才会进行连接路由。

wifi_station_disconnect(); // ESP8266 station 断开与某路由的连接,或者 ESP8266 station 停止尝试连接某路由。

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Fri Apr 03, 2015 3:57 pm


]]>
2015-04-03T15:05:09+08:00 2015-04-03T15:05:09+08:00 https://bbs.espressif.com:443/viewtopic.php?t=323&p=1220#p1220 <![CDATA[FAQs • Watch dog reset problem]]> :arrow: :arrow:

We suggest to use RTOS SDK which is multi-threaded.

ESP8266 SDK without RTOS is single-threaded,so using while(1) or delay_ms() (which is also a while in it) may occupy CPU too long and cause a watchdog reset.
1. If a task occupied CPU for a long time, ESP8266 can't feed the dog, will cause a watchdog reset;
2. Task should not occupy CPU more than 10 ms, otherwise may cause WiFi connection break.

Users have to use a timer to do the checking job, as user_esp_platform_check_ip below.
Notice: os_timer_setfn has to be called to set a callback when using timer.

Code:

LOCAL os_timer_t test_timer;

/******************************************************************************
 * FunctionName : user_esp_platform_check_ip
 * Description  : check whether get ip addr or not
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_esp_platform_check_ip(void)
{
    struct ip_info ipconfig;

   //disarm timer first
    os_timer_disarm(&test_timer);

   //get ip info of ESP8266 station
    wifi_get_ip_info(STATION_IF, &ipconfig);

    if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {

      os_printf("got ip !!! \r\n");

    } else {
       
        if ((wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
                wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
                wifi_station_get_connect_status() == STATION_CONNECT_FAIL)) {
               
         os_printf("connect fail !!! \r\n");
         
        } else {
       
           //re-arm timer to check ip
            os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
            os_timer_arm(&test_timer, 100, 0);
        }
    }
}


/******************************************************************************
 * FunctionName : user_set_station_config
 * Description  : set the router info which ESP8266 station will connect to
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_set_station_config(void)
{
   // Wifi configuration
   char ssid[32] = SSID;
   char password[64] = PASSWORD;
   struct station_config stationConf;

   //need not mac address
   stationConf.bssid_set = 0;
   
   //Set ap settings
   os_memcpy(&stationConf.ssid, ssid, 32);
   os_memcpy(&stationConf.password, password, 64);
   wifi_station_set_config(&stationConf);

   //set a timer to check whether got ip from router succeed or not.
   os_timer_disarm(&test_timer);
    os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
    os_timer_arm(&test_timer, 100, 0);

}


/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
   //Set softAP + station mode
   wifi_set_opmode(STATIONAP_MODE);

   // ESP8266 connect to router.
    user_set_station_config();

}



1.在 非OS SDK 由于是单线程的,任何 task 都不能长期 占用 CPU。
(1)如果 一个 task 占用 CPU 不退出,将导致看门狗的喂狗函数无法执行,导致系统重启。
(2) 建议 一个 task 占用 CPU 不要超过 10mS,否则可能导致 WiFi 连接中断。
2. 建议用定时器来实现长时间的查询功能,定时器也可设置为循环调用,参考代码如上。请注意,使用 timer 时,必须调用os_timer_setfn 设置 timer 到时的 callback。
3. 建议用RTOS SDK,OS 会调度不同 task。每个 task 编程可认为独占 CPU。

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Fri Apr 03, 2015 3:05 pm


]]>
2015-03-23T16:44:28+08:00 2015-03-23T16:44:28+08:00 https://bbs.espressif.com:443/viewtopic.php?t=292&p=1125#p1125 <![CDATA[FAQs • "Fatal exception" problem]]>
For example, the running firmware is user1.bin , and you get a "Fatal exception" as follow:

Code:

Fatal exception (28):
epc1=0x4025bfa6, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0000000f, depc=0x00000000


Open "user1.s" which is generated with user1.bin after compiled, then find "0x4025bfa6" in "user1.s".

If the running firmware is user2.bin, find it in "user2.s".

I hope this is helpful.

Statistics: Posted by ESP_Faye — Mon Mar 23, 2015 4:44 pm


]]>
2015-02-05T16:41:18+08:00 2015-02-05T16:41:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=182&p=643#p643 <![CDATA[FAQs • How to change UART baudrate ? - 修改 UART 波特率]]> :idea: :idea:
ESP8266 default baudrate is 74880, and output from UART0, if we want to change it.
For example, change baudrate to 115200.

call uart_init(115200, 115200); in user_init.

Code:

void ICACHE_FLASH_ATTR
uart_init(UartBautRate uart0_br, UartBautRate uart1_br)
{
    // rom use 74880 baut_rate, here reinitialize
    UartDev.baut_rate = uart0_br;
    uart_config(UART0);
    UartDev.baut_rate = uart1_br;
    uart_config(UART1);
    ETS_UART_INTR_ENABLE();

    // install uart1 putc callback
    os_install_putc1((void *)uart1_write_char);
}


Notice that the last sentence in uart_init, os_install_putc1((void *)uart1_write_char) is going to change "os_printf" to output from UART1.
So if you don't want to use UART1, please delete the last sentence in uart_init.

Code:

 //os_install_putc1((void *)uart1_write_char);


ESP8266 默认波特率为 74880 ,从 UART0 输出。
如果我们想修改波特率,例如改为 115200。

请在 user_init 中调用 uart_init(115200, 115200);

uart_init 中的最后一句 os_install_putc1((void *)uart1_write_char) 设置将 "os_printf" 的打印信息从 UART1 输出 .
如果您不需要使用 UART1,将这最后一句注释掉即可。

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Thu Feb 05, 2015 4:41 pm


]]>
2015-02-05T15:09:18+08:00 2015-02-05T15:09:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=179&p=638#p638 <![CDATA[FAQs • Error Occur after "AT+CIUPDATE"]]>
The most likely reason is that you are not using Espressif Official AT software .

Please test it with Espressif Official AT http://bbs.espressif.com/viewtopic.php?f=46&t=850.

Baudrate is 115200 , AT commands end with CR LF.

"AT+CIUPDATE" succeed or not, depends on network condition. But it will never cause your module goes wrong.

With Espressif official AT, if "AT+CIUPDATE" succeed, it will restart to run the new firmware, if fail, it will just keep running the current firmware.

Thanks for your interest in ESP8266 !

Please feel free to let us know if you have any question.

Statistics: Posted by ESP_Faye — Thu Feb 05, 2015 3:09 pm


]]>
2015-01-30T15:39:51+08:00 2015-01-30T15:39:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=166&p=603#p603 <![CDATA[FAQs • Compile Error: not fit in region`irom0_0_seg']]> :idea: :idea:

If it shows compile error like below when we compile our source code by setting as 512KB flash with FOTA(firmware upgrade through WIFI).

Code:

xtensa-lx106-elf-gcc  -L../lib -nostdlib -T../ld/eagle.app.v6.new.512.app1.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lssl -lupgrade -lsmartconfig user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.irom0.text' will not fit in region `irom0_0_seg'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1


It means your source code is too large to fit in.

We can try follow steps on SDK_v0.9.5 (or later) to solve it:
1. compile with default configuration to generate eagle.flash.bin and eagle.irom0text.bin
(1) size of eagle.flash.bin + size of eagle.irom0text.bin >= 236KBytes:
Sorry, your source code is too large, you need to change to a new flash which size is larger than 512KB.
(2) size of eagle.flash.bin + size of eagle.irom0text.bin < 236KBytes:
OK, try step 2.

2. revise file "eagle.app.v6.new.512.app1.ld" which is in \esp_iot_sdk\ld.

Code:

irom0_0_seg :                         org = 0x40201010, len = 0x2B000

change the value of "len" according to the size of your "eagle.irom0text.bin".
Example: if size of “eagle.irom0text.bin” is 179KB, change the configuration to

Code:

irom0_0_seg :                         org = 0x40201010, len = 0x2D000

3. compile user1.bin by selecting boot_v1.2+

PS.
In your source code,
methods without "ICACHE_FLASH_ATTR" in iram1_0_seg which can be 32KB at most,
methods with "ICACHE_FLASH_ATTR" in irom0_0_seg.

Due to ram is limited,so we have these two parts:
methods in iram1_0_seg will be loaded to ram and run when power on;
methods in irom0_0_seg will be loaded to cache and run only if it is called;


如果在编译 512KB flash 支持云端升级版本的软件时,遇到如下错误:

Code:

xtensa-lx106-elf-gcc  -L../lib -nostdlib -T../ld/eagle.app.v6.new.512.app1.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lssl -lupgrade -lsmartconfig user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.irom0.text' will not fit in region `irom0_0_seg'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1


它表示代码量太大,irom 区域存放不下了。

我们可以在 SDK_v0.9.5(及之后)的软件版本中,尝试如下步骤,解决这个问题:
1. 使用默认设置,编译生成 eagle.flash.bin 和 eagle.irom0text.bin
(1) 如果 size of eagle.flash.bin + size of eagle.irom0text.bin >= 236KBytes:
-> 很抱歉,您的代码量太大了,只能换大些的 flash,或者放弃云端升级功能了。
(2) 如果 size of eagle.flash.bin + size of eagle.irom0text.bin < 236KBytes :
-> 请继续步骤 2

2. 在路径 \esp_iot_sdk\ld 下修改文件 “eagle.app.v6.new.512.app1.ld”

Code:

irom0_0_seg :                         org = 0x40201010, len = 0x2B000

根据步骤1中编译的 “eagle.irom0text.bin” size 大小,改写上述 len 的值
示例:如果 “eagle.irom0text.bin” 大小为 179KB,则可修改配置如下

Code:

irom0_0_seg :                         org = 0x40201010, len = 0x2D000

3. 重新编译 user1.bin 选择 boot_v1.2+

补充说明:
代码中,
函数前未加 ICACHE_FLASH_ATTR 的,编译到 iram 中,最大 32KB;
函数前加了 ICACHE_FLASH_ATTR 的,编译到 irom 中;

因为 ram 的空间有限,因此做了这两个部分的区分:
iram 中的代码,会在上电初始就完整加载到 ram 中;
irom 中的代码是用到的时候才从flash 加载到 cache 中执行;

希望本文对您有所帮助!

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Fri Jan 30, 2015 3:39 pm


]]>