mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 17:47:04 +08:00
Merge branch 'bugfix/fix_combine_binary_overwrite_check_v3.1' into 'release/v3.1'
Fix combine binary overwrite checking (backport v3.1) See merge request sdk/ESP8266_RTOS_SDK!823
This commit is contained in:
@ -217,7 +217,7 @@ config ESP8266_OTA_FROM_OLD
|
|||||||
bool "(**Expected**)ESP8266 update from old SDK by OTA"
|
bool "(**Expected**)ESP8266 update from old SDK by OTA"
|
||||||
default n
|
default n
|
||||||
depends on TARGET_PLATFORM_ESP8266
|
depends on TARGET_PLATFORM_ESP8266
|
||||||
select ESP8266_BOOT_COPY_APP
|
select ESP8266_BOOT_COPY_APP if ESPTOOLPY_FLASHSIZE_1MB
|
||||||
help
|
help
|
||||||
The function is not released.
|
The function is not released.
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ endif
|
|||||||
|
|
||||||
ifdef CONFIG_ESP8266_OTA_FROM_OLD
|
ifdef CONFIG_ESP8266_OTA_FROM_OLD
|
||||||
$(OTA_V2_TO_V3_BIN):
|
$(OTA_V2_TO_V3_BIN):
|
||||||
@python $(IDF_PATH)/tools/pack_fw.py --output $(OTA_V2_TO_V3_BIN) pack3 $(ESPTOOL_ALL_FLASH_ARGS)
|
@python $(IDF_PATH)/tools/pack_fw.py --output $(OTA_V2_TO_V3_BIN) --app $(PROJECT_NAME).bin pack3 $(ESPTOOL_ALL_FLASH_ARGS)
|
||||||
@echo [GEN] $(OTA_V2_TO_V3_BIN)
|
@echo [GEN] $(OTA_V2_TO_V3_BIN)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -434,7 +434,8 @@ int esp_patition_table_init_data(void *partition_info)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
const uint32_t boot_base = 0x1000;
|
const uint32_t boot_base = 0x1000;
|
||||||
const uint32_t boot_size = s_v2_flash_bin_size / 2 - boot_base - 4 * SPI_FLASH_SEC_SIZE;
|
const bootloader_state_t *bs = (const bootloader_state_t *)partition_info;
|
||||||
|
const uint32_t boot_size = bs->ota[0].offset + bs->ota[0].size - boot_base;
|
||||||
|
|
||||||
if (!esp_sdk_update_from_v2())
|
if (!esp_sdk_update_from_v2())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -32,6 +32,24 @@
|
|||||||
#define BUFFSIZE 1500
|
#define BUFFSIZE 1500
|
||||||
#define TEXT_BUFFSIZE 1024
|
#define TEXT_BUFFSIZE 1024
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP8266_OTA_FROM_OLD
|
||||||
|
/*
|
||||||
|
* Users should add your real firmware information here.
|
||||||
|
* And the real infoarmation will be generated by "script".
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB
|
||||||
|
/*
|
||||||
|
* The configuration is related to file "partitions_two_ota_v2tov3.1MB".
|
||||||
|
*/
|
||||||
|
#define OTA_EXAMPLE_APP_OFFSET 0x6000UL
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* The configuration is related to file "partitions_two_ota_v2tov3.2MB".
|
||||||
|
*/
|
||||||
|
#define OTA_EXAMPLE_APP_OFFSET 0xf000UL
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum esp_ota_firm_state {
|
typedef enum esp_ota_firm_state {
|
||||||
ESP_OTA_INIT = 0,
|
ESP_OTA_INIT = 0,
|
||||||
ESP_OTA_PREPARE,
|
ESP_OTA_PREPARE,
|
||||||
@ -76,6 +94,10 @@ static EventGroupHandle_t wifi_event_group;
|
|||||||
to the AP with an IP? */
|
to the AP with an IP? */
|
||||||
const int CONNECTED_BIT = BIT0;
|
const int CONNECTED_BIT = BIT0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP8266_OTA_FROM_OLD
|
||||||
|
static const uint32_t s_ota_app_offset = OTA_EXAMPLE_APP_OFFSET;
|
||||||
|
#endif
|
||||||
|
|
||||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||||
{
|
{
|
||||||
switch (event->event_id) {
|
switch (event->event_id) {
|
||||||
@ -185,12 +207,17 @@ bool _esp_ota_firm_parse_http(esp_ota_firm_t *ota_firm, const char *text, size_t
|
|||||||
memset(length_str, 0, sizeof(length_str));
|
memset(length_str, 0, sizeof(length_str));
|
||||||
memcpy(length_str, ptr, ptr2 - ptr);
|
memcpy(length_str, ptr, ptr2 - ptr);
|
||||||
ota_firm->content_len = atoi(length_str);
|
ota_firm->content_len = atoi(length_str);
|
||||||
|
#ifdef CONFIG_ESP8266_OTA_FROM_OLD
|
||||||
|
ota_firm->ota_size = ota_firm->content_len - s_ota_app_offset;
|
||||||
|
ota_firm->ota_offset = s_ota_app_offset;
|
||||||
|
#else
|
||||||
#if defined(CONFIG_ESPTOOLPY_FLASHSIZE_1MB) && !defined(CONFIG_ESP8266_BOOT_COPY_APP)
|
#if defined(CONFIG_ESPTOOLPY_FLASHSIZE_1MB) && !defined(CONFIG_ESP8266_BOOT_COPY_APP)
|
||||||
ota_firm->ota_size = ota_firm->content_len / ota_firm->ota_num;
|
ota_firm->ota_size = ota_firm->content_len / ota_firm->ota_num;
|
||||||
ota_firm->ota_offset = ota_firm->ota_size * ota_firm->update_ota_num;
|
ota_firm->ota_offset = ota_firm->ota_size * ota_firm->update_ota_num;
|
||||||
#else
|
#else
|
||||||
ota_firm->ota_size = ota_firm->content_len;
|
ota_firm->ota_size = ota_firm->content_len;
|
||||||
ota_firm->ota_offset = 0;
|
ota_firm->ota_offset = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "parse Content-Length:%d, ota_size %d", ota_firm->content_len, ota_firm->ota_size);
|
ESP_LOGI(TAG, "parse Content-Length:%d, ota_size %d", ota_firm->content_len, ota_firm->ota_size);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,9 @@ import inspect
|
|||||||
import sys
|
import sys
|
||||||
import binascii
|
import binascii
|
||||||
import struct
|
import struct
|
||||||
|
import logging
|
||||||
|
|
||||||
__version__ = "1.0.1"
|
__version__ = "1.0.2"
|
||||||
|
|
||||||
FLASH_SECTOR_SIZE = 0x1000
|
FLASH_SECTOR_SIZE = 0x1000
|
||||||
|
|
||||||
@ -52,6 +53,8 @@ class proc_addr_file(argparse.Action):
|
|||||||
for i in range(0, len(values) ,2):
|
for i in range(0, len(values) ,2):
|
||||||
try:
|
try:
|
||||||
address = int(values[i], 0)
|
address = int(values[i], 0)
|
||||||
|
if address == 0:
|
||||||
|
address = 0x1000
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise argparse.ArgumentError(self, 'Address "%s" must be a number' % values[i])
|
raise argparse.ArgumentError(self, 'Address "%s" must be a number' % values[i])
|
||||||
try:
|
try:
|
||||||
@ -83,10 +86,10 @@ def pack3(args):
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
end_addr = None
|
end_addr = None
|
||||||
|
prev_addr = 0
|
||||||
|
prec_file = ''
|
||||||
|
app_offset = 0
|
||||||
for address, argfile in args.addr_filename:
|
for address, argfile in args.addr_filename:
|
||||||
if address == 0:
|
|
||||||
address = 4096
|
|
||||||
|
|
||||||
if end_addr is not None and address > end_addr:
|
if end_addr is not None and address > end_addr:
|
||||||
data = (address - end_addr) * ['ff']
|
data = (address - end_addr) * ['ff']
|
||||||
filled = binascii.a2b_hex(''.join(data))
|
filled = binascii.a2b_hex(''.join(data))
|
||||||
@ -98,10 +101,20 @@ def pack3(args):
|
|||||||
fw_data += data
|
fw_data += data
|
||||||
|
|
||||||
argfile.seek(0, 2)
|
argfile.seek(0, 2)
|
||||||
|
prev_addr = address
|
||||||
|
prec_file = argfile.name
|
||||||
end_addr = address + argfile.tell()
|
end_addr = address + argfile.tell()
|
||||||
|
if app_offset is not 0:
|
||||||
|
raise Exception('Partition %s can be put behind %s'%(argfile.name, args.app))
|
||||||
|
else:
|
||||||
|
if args.app in argfile.name:
|
||||||
|
app_offset = address - 0x1000
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
if app_offset is 0:
|
||||||
|
raise Exception('Failed to find application binary %s in all arguments'%args.app)
|
||||||
|
|
||||||
crc32 = esp8266_crc32(fw_data)
|
crc32 = esp8266_crc32(fw_data)
|
||||||
fw_data += struct.pack('<I', crc32)
|
fw_data += struct.pack('<I', crc32)
|
||||||
|
|
||||||
@ -111,6 +124,7 @@ def pack3(args):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
print('\r\n\033[1;31;40mOTA example should use following macro:\r\n\r\n #define OTA_EXAMPLE_APP_OFFSET 0x%x\r\n\033[0m'%(app_offset))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='pack_fw v%s - ESP8266 ROM Bootloader Utility' % __version__, prog='pack_fw')
|
parser = argparse.ArgumentParser(description='pack_fw v%s - ESP8266 ROM Bootloader Utility' % __version__, prog='pack_fw')
|
||||||
@ -120,6 +134,11 @@ def main():
|
|||||||
help='Output file name with full path',
|
help='Output file name with full path',
|
||||||
default=None)
|
default=None)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--app', '-a',
|
||||||
|
help='application binary file name',
|
||||||
|
default=None)
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(
|
subparsers = parser.add_subparsers(
|
||||||
dest='operation',
|
dest='operation',
|
||||||
help='Run pack_fw {command} -h for additional help')
|
help='Run pack_fw {command} -h for additional help')
|
||||||
|
Reference in New Issue
Block a user