我无法使用system_upgrade_start
函数编译自己的固件版本。 SDK示例中的IoT_Demo正在编译成功。在我的情况下,编译器仅在我使用system_upgrade_start
时才删除错误,当我仅删除此函数(而不是system_upgrade_userbin_check()
)时,它编译时没有错误。制作固件需要做什么?
我的用户主要是例如:
/* main.c -- MQTT client example
*
* Copyright (c) 2014-2015, Tuan PM <tuanpm at live dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "ets_sys.h"
#include "driver/uart.h"
#include "driver/hw_timer.h"
#include "osapi.h"
#include "mqtt.h"
#include "wifi.h"
#include "debug.h"
#include "gpio.h"
#include "user_interface.h"
#include "mem.h"
#include "os_type.h"
// #include "driver/key.h"
#include "config.h"
#include "espconn.h"
#include "upgrade.h"
LOCAL void ICACHE_FLASH_ATTR
user_esp_platform_upgrade_rsp(void *arg)
{
struct upgrade_server_info *server = arg;
struct espconn *pespconn = server->pespconn;
char *action = NULL;
if (server->upgrade_flag == true) {
INFO("user_esp_platform_upgarde_successfully\n");
action = "device_upgrade_success";
} else {
INFO("user_esp_platform_upgrade_failed\n");
}
os_free(server->url);
server->url = NULL;
os_free(server);
server = NULL;
}
/******************************************************************************
* FunctionName : user_esp_platform_upgrade_begin
* Description : Processing the received data from the server
* Parameters : pespconn -- the espconn used to connetion with the host
* server -- upgrade param
* Returns : none
*******************************************************************************/
LOCAL void ICACHE_FLASH_ATTR
user_esp_platform_upgrade_begin(struct espconn *pespconn, struct upgrade_server_info *server)
{
uint8 user_bin[9] = {0};
uint8 devkey[41] = {0};
server->pespconn = pespconn;
// os_memcpy(devkey, esp_param.devkey, 40);
os_memcpy(server->ip, pespconn->proto.tcp->remote_ip, 4);
#ifdef UPGRADE_SSL_ENABLE
server->port = 443;
#else
server->port = 80;
#endif
server->check_cb = user_esp_platform_upgrade_rsp;
server->check_times = 120000;
if (server->url == NULL) {
server->url = (uint8 *)os_zalloc(512);
}
if (system_upgrade_userbin_check() == UPGRADE_FW_BIN1) {
os_memcpy(user_bin, "user2.bin", 10);
} else if (system_upgrade_userbin_check() == UPGRADE_FW_BIN2) {
os_memcpy(user_bin, "user1.bin", 10);
}
os_sprintf(server->url,
"GET /v1/device/rom/?action=download_rom&version=%s&filename=%s "
"HTTP/1.0\r\nHost: %s:%d\r\n%s",
server->upgrade_version, user_bin, IP2STR(server->ip),
server->port, "devkey");
INFO("%s\n",server->url);
#ifdef UPGRADE_SSL_ENABLE
if (system_upgrade_start_ssl(server) == false) {
#else
if (system_upgrade_start(server) == false) {
#endif
INFO("upgrade is already started\n");
}
}
static void ICACHE_FLASH_ATTR app_init(void) {
}
void ICACHE_FLASH_ATTR user_init(void) {
}
编译输出:
make firmware/user1.bin
Makefile:322: warning: overriding recipe for target 'firmware'
Makefile:275: warning: ignoring old recipe for target 'firmware'
/home/fdistorted/esp8266/SDK_GCC/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -Iuser -Idriver -Imqtt -Imodules -Iuser/include -Idriver/include -Imqtt/include -Imodules/include -Iinclude -I/home/fdistorted/esp8266/SDK_GCC/ESP8266_NONOS_SDK-2.1.0/include-I/home/fdistorted/esp8266/SDK_GCC/ESP8266_NONOS_SDK-2.1.0/include/json -g -Wpointer-arith -Wundef -Wl,-EL -Wno-implicit-function-declaration -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -DICACHE_FLASH -DBUID_TIME=\"2017-Nov-05_23:12:26_EET\" -DMQTT_DEBUG_ON -DDEBUG_ON -D_STDINT_H -DLOCAL_CONFIG_AVAILABLE -c user/user_main.c -o build/user/user_main.o
/home/fdistorted/esp8266/SDK_GCC/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru build/esp_mqtt.a build/user/rfinit.obuild/user/user_main.o build/user/user_json.o build/driver/hw_timer.o build/driver/uart.o build/driver/key.o build/mqtt/mqtt.o build/mqtt/ringbuf.o build/mqtt/mqtt_msg.o build/mqtt/queue.o build/mqtt/proto.o build/mqtt/utils.o build/modules/config.o build/modules/wifi.o
/home/fdistorted/esp8266/SDK_GCC/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -L/home/fdistorted/esp8266/SDK_GCC/ESP8266_NONOS_SDK-2.1.0/lib -Tbuild/eagle.esphttpd1.v6.ld -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -g -O2 -Wl,--start-group -lc -lgcc -lphy -lpp -lnet80211 -lwpa -lmain -llwip -lcrypto -lssl -ljson -ldriver build/esp_mqtt.a -Wl,--end-group -o build/esp_mqtt.user1.out
build/esp_mqtt.a(user_main.o): In function `user_esp_platform_upgrade_rsp':
user_main.c:(.irom0.text+0xa0): undefined reference to `system_upgrade_start'
build/esp_mqtt.a(user_main.o): In function `user_esp_platform_upgrade_begin':
/home/fdistorted/esp8266/esp_mqtt/user/user_main.c:114: undefined reference to `system_upgrade_start'
collect2: error: ld returned 1 exit status
Makefile:263: recipe for target 'build/esp_mqtt.user1.out' failed
make: *** [build/esp_mqtt.user1.out] Error 1
答案 0 :(得分:2)
需要将-lupgrade
参数添加到编译器命令中。
如果编译器命令自动生成,则变量SDK_LIBS
必须具有upgrade
字面值,例如:
SDK_LIBS = c gcc phy pp net80211 wpa main lwip crypto ssl json driver upgrade