<1> esp8266 iot 开发环境搭建(AiThinkerIDE_V1.5.2)
Posted 疯狂程序
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了<1> esp8266 iot 开发环境搭建(AiThinkerIDE_V1.5.2)相关的知识,希望对你有一定的参考价值。
目录
一、下载AiThinkerIDE_V1.5.2 IDE
AiThinkerIDE早期版本是v0.5,现在最新版是v1.5.2,下面是安信可官方的介绍:
1.支持 ESP8266 的 NONOS 2.0 和 3.0 版本二次开发; 支持 ESP32 的 IDF 框架开发,支持 ESP-cam;
2.开发板二次开发; 提供支持 天猫精灵IoT平台/阿里物联网生活平台/阿里飞燕/百度天工的模板SDK接入;
3.提供多种多样的demo项目,使开发者快速开发使用自己的业务;
4.SDK资源开发包使用 Git 管理,用户可自行更新;
链接:https://pan.baidu.com/s/1bk_mc-X9Aol9MgiU0gZA0A#list/path=%2F 提取码:shm3
二、安装
双击AiThinkerIDE_V1.5.2 IDE.exe开始安装,安装路径不要含有中文,最好是默认路径。
环境依赖的是 python2.7 环境,IDE已经自带了python2.7的环境的,如果你电脑有py3的环境,建议卸载或共存处理,自此AiThinkerIDE安装完成。
查看系统变量是否加入成功,右键电脑“属性”->“高级系统设置”->“环境变量”。
三、下载SDK
本项目是基于无操作系统的ESP8266_NONOS_SDK-3.0.4开发包继续二次开发,下载地址:https://github.com/espressif/ESP8266_NONOS_SDK
解压ESP8266_NONOS_SDK-3.0.4.zip
四、创建工程模板
ESP8266的ESP8266_NONOS_SDK,采用了SDK和工程文件夹分离的方式,所以我们需要手动创建一个app目录。
将DSK目录下的driver_lib重命名为 app。
拷贝\\examples\\loT_Demo下的所有文件到刚才的 app目录(提示覆盖则确认)。
然后把examples及third_party文件夹删除掉。
打开AiThinkerIDE,设置Workspace路劲到SDK目录
右键导入项目
选择Existing Code as Makefile Project,点击Next
点击Finish导入项目,如下
项目名上右键选择Properties配置工程
选择C/C++ Build->Build command中添加编译规则(make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=4),可以根据实际情况来更改规则,点击OK退出。
项目名上右键Clean Project清除工程缓存
项目名上右键Build Project编译工程
编译成功,输出信息如下:
五、修改工程
删除对于我们无关文件,后续工程基于此模板进行开发。
1. user文件夹
user文件夹我们只保留user_main.c,Makefile文件,其余全部删除,结果如下:
2. include文件夹
include文件夹只保留driver文件夹以及user_config.h文件,其余全部删除,结果如下:
3. 修改user_config.h文件
清空user_config文件内容,只保留头文件的声明,最终如下:
4.修改user_main.c文件
user_main.c文件最终代码如下:
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
#if ((SPI_FLASH_SIZE_MAP == 0) || (SPI_FLASH_SIZE_MAP == 1))
#error "The flash map is not supported"
#elif (SPI_FLASH_SIZE_MAP == 2)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0xfb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0xfc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0xfd000
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR 0x7c000
#elif (SPI_FLASH_SIZE_MAP == 3)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x1fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x1fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x1fd000
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR 0x7c000
#elif (SPI_FLASH_SIZE_MAP == 4)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x3fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x3fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x3fd000
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR 0x7c000
#elif (SPI_FLASH_SIZE_MAP == 5)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x101000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x1fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x1fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x1fd000
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR 0xfc000
#elif (SPI_FLASH_SIZE_MAP == 6)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x101000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x3fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x3fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x3fd000
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR 0xfc000
#else
#error "The flash map is not supported"
#endif
#define SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM SYSTEM_PARTITION_CUSTOMER_BEGIN
uint32 priv_param_start_sec;
static const partition_item_t at_partition_table[] =
SYSTEM_PARTITION_BOOTLOADER, 0x0, 0x1000,
SYSTEM_PARTITION_OTA_1, 0x1000, SYSTEM_PARTITION_OTA_SIZE,
SYSTEM_PARTITION_OTA_2, SYSTEM_PARTITION_OTA_2_ADDR, SYSTEM_PARTITION_OTA_SIZE,
SYSTEM_PARTITION_RF_CAL, SYSTEM_PARTITION_RF_CAL_ADDR, 0x1000,
SYSTEM_PARTITION_PHY_DATA, SYSTEM_PARTITION_PHY_DATA_ADDR, 0x1000,
SYSTEM_PARTITION_SYSTEM_PARAMETER, SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR, 0x3000,
SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM, SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR, 0x1000,
;
void ICACHE_FLASH_ATTR user_pre_init(void)
if(!system_partition_table_regist(at_partition_table, sizeof(at_partition_table)/sizeof(at_partition_table[0]),SPI_FLASH_SIZE_MAP))
os_printf("system_partition_table_regist fail\\r\\n");
while(1);
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_init(void)
partition_item_t partition_item;
os_printf("SDK version:%s\\n", system_get_sdk_version());
if (!system_partition_get_item(SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM, &partition_item))
os_printf("Get partition information fail\\n");
priv_param_start_sec = partition_item.addr/SPI_FLASH_SEC_SIZE;
修改文件后,点击全部保存,清除工程,再次编译,输出如下:
六、AiThinkerIDE常规设置
1.修改文件编码格式为UTF-8
Window->Preferences->General->Workspace->Text file encoding:修改文件编码为UTF-8
2.修改代码编辑字体
Window->Preferences->General->Appearance->Colors and Fonts->Basic->Text Font:修改为自己喜欢的字体
3.其他设置
以上是关于<1> esp8266 iot 开发环境搭建(AiThinkerIDE_V1.5.2)的主要内容,如果未能解决你的问题,请参考以下文章