ESP8266开发问题——V2.0转V3.0版本

走远了吗. 提交于 2020-01-18 03:05:15

1.开发环境

Windows10+安信可一体化开发环境.

2.问题描述

编译结果:
user_main.c:38:2: error: #error "The flash map is not supported"
user_main.c:38:2: error: #error "The flash map is not supported"
user_main.c:38:2: error: #error "The flash map is not supported"
user_main.c:84:58: error: 'SYSTEM_PARTITION_OTA_SIZE' undeclared here (not in a function)
     { SYSTEM_PARTITION_OTA_1,         0x1000,            SYSTEM_PARTITION_OTA_SIZE},
                                                          ^
user_main.c:85:39: error: 'SYSTEM_PARTITION_OTA_2_ADDR' undeclared here (not in a function)
     { SYSTEM_PARTITION_OTA_2,         SYSTEM_PARTITION_OTA_2_ADDR,       SYSTEM_PARTITION_OTA_SIZE},
                                       ^
user_main.c:86:39: error: 'SYSTEM_PARTITION_RF_CAL_ADDR' undeclared here (not in a function)
     { SYSTEM_PARTITION_RF_CAL,        SYSTEM_PARTITION_RF_CAL_ADDR,       0x1000},
                                       ^
user_main.c:87:40: error: 'SYSTEM_PARTITION_PHY_DATA_ADDR' undeclared here (not in a function)
     { SYSTEM_PARTITION_PHY_DATA,       SYSTEM_PARTITION_PHY_DATA_ADDR,      0x1000},
                                        ^
user_main.c:88:46: error: 'SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR' undeclared here (not in a function)
     { SYSTEM_PARTITION_SYSTEM_PARAMETER,     SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR,    0x3000},
                                              ^
user_main.c:89:57: error: 'SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR' undeclared here (not in a function)
     { SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM,             SYSTEM_PARTITION_CUSTOMER_PRIV_PARAM_ADDR,          0x1000},
                                                         ^
make[2]: *** [../../Makefile:348: .output/eagle/debug/obj/user_main.o] Error 1
make[2]: Leaving directory '/cygdrive/f/寮?鍙?/鐗?鑱?缃?/ESP8266鐗?鑱?缃?鏁?绋?/ESP8266_NONOS_SDK-master(0)/app/user'
make[1]: *** [../Makefile:333: .subdirs] Error 2
make[1]: Leaving directory '/cygdrive/f/寮?鍙?/鐗?鑱?缃?/ESP8266鐗?鑱?缃?鏁?绋?/ESP8266_NONOS_SDK-master(0)/app'
make: *** [Makefile:333: .subdirs] Error 2

解决方法:

1.更改首目录下的makefile的25行

BOOT?=none
APP?=0
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=4

更改后,编译结果

!!!
No boot needed.
Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x10000
!!!

--------------------------------编译报错问题解决------------------------------

2.固件升级

但是之前V2.0版本的直接下载V3.0版本的程序可能无法运行,需要进行固件的升级!!!
具体方法:
1.下载乐鑫官方V3.0SDK.

将example下的at目录下的文件全部拷贝到driver_lib文件夹下
在这里插入图片描述
在这里插入图片描述
2.可将driver_lib重命名为app
删除example文件夹,将third_party中的Makefile改为Makefile.bak
在这里插入图片描述
3.在安信可一体化开发环境IDE中打开
将首目录下的Makefile中的25-29行改为如下代码
在这里插入图片描述

BOOT?=none
APP?=0
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=4

编译成功!
在这里插入图片描述
4.将.bin文件下载到对应地址中完成固件的升级在这里插入图片描述
自此,可将由V3.0example中的IoT_Demo中文件按照at文件夹下的文件进行上述操作,得到的工程生成的.bin可直接下载到ESP8266中完美运行
在这里插入图片描述
在这里插入图片描述
注意如果是V2.0版本程序,需在user_main.c中添加如下代码


#if ESP_PLATFORM
#include "user_esp_platform.h"
#endif

#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);
	}
}

结束!!!
at文件夹下文件修改后的工程已上传GitHub.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!