Skip to content

Commit 800f141

Browse files
committed
Merge branch 'feat/esptool_v5' into 'master'
Update esptool to v5: replace deprecated commands, documentation updates and cleanup Closes IDF-12564 See merge request espressif/esp-idf!41176
2 parents 9ba0b37 + 4c53f42 commit 800f141

File tree

143 files changed

+1351
-1396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+1351
-1396
lines changed

.github/ISSUE_TEMPLATE/02_runtime_bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ body:
2626
id: chip_revision
2727
attributes:
2828
label: Espressif SoC revision.
29-
description: On which Espressif SoC revision does your application run on? Run `esptool chip_id` to find it.
29+
description: On which Espressif SoC revision does your application run on? Run `esptool chip-id` to find it.
3030
placeholder: ex. ESP32-C3 (QFN32) (revision v0.3)
3131
validations:
3232
required: true

COMPATIBILITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NOTE: This document on release branches may be out-of-date. Check the [Compatibi
1010

1111
See [Compatibility Advisory for Chip Revision Numbering Scheme](https://www.espressif.com/sites/default/files/advisory_downloads/AR2022-005%20Compatibility%20Advisory%20for%20Chip%20Revision%20Numbering%20%20Scheme.pdf) on the versioning of Espressif SoC revisions.
1212

13-
You can run `esptool chip_id` to detect the series and revision of an SoC. See [SoC Errata](https://www.espressif.com/en/support/documents/technical-documents?keys=errata) for more on how to distinguish between chip revisions, and the improvements provided by chip revisions. And run `idf.py --version` to know the version of current ESP-IDF.
13+
You can run `esptool chip-id` to detect the series and revision of an SoC. See [SoC Errata](https://www.espressif.com/en/support/documents/technical-documents?keys=errata) for more on how to distinguish between chip revisions, and the improvements provided by chip revisions. And run `idf.py --version` to know the version of current ESP-IDF.
1414

1515
## ESP-IDF Support for Different Chip Revisions
1616

COMPATIBILITY_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
有关乐鑫芯片版本的编码方式,请参考 [关于芯片版本 (Chip Revision) 编码方式的兼容性公告](https://www.espressif.com/sites/default/files/advisory_downloads/AR2022-005%20%E5%85%B3%E4%BA%8E%E8%8A%AF%E7%89%87%E7%89%88%E6%9C%AC%E7%BC%96%E7%A0%81%E6%96%B9%E5%BC%8F%20%28Chip%20Revision%29%20%E7%9A%84%E5%85%BC%E5%AE%B9%E6%80%A7%E5%85%AC%E5%91%8A.pdf)
1212

13-
运行 `esptool chip_id` 可查看芯片系列及其版本。有关区分芯片版本及版本改进内容的更多信息,请参考 [芯片勘误表](https://www.espressif.com.cn/zh-hans/support/documents/technical-documents?keys=%E5%8B%98%E8%AF%AF%E8%A1%A8)。运行 `idf.py --version` 可查看当前的 ESP-IDF 版本。
13+
运行 `esptool chip-id` 可查看芯片系列及其版本。有关区分芯片版本及版本改进内容的更多信息,请参考 [芯片勘误表](https://www.espressif.com.cn/zh-hans/support/documents/technical-documents?keys=%E5%8B%98%E8%AF%AF%E8%A1%A8)。运行 `idf.py --version` 可查看当前的 ESP-IDF 版本。
1414

1515
## ESP-IDF 对各芯片版本的支持
1616

Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
219219

220220
When loading the BIN with UART, the ROM will jump to ram and run the app after finishing the ROM
221221
startup code, so there's no additional startup initialization required. You can use the
222-
`load_ram` in esptool.py to load the generated .bin file into ram and execute.
222+
`load-ram` in esptool to load the generated .bin file into ram and execute.
223223

224224
Example:
225-
esptool.py --chip {chip} -p {port} -b {baud} --no-stub load_ram {app.bin}
225+
esptool --chip {chip} -p {port} -b {baud} --no-stub load-ram {app.bin}
226226

227227
Recommended sdkconfig.defaults for building loadable ELF files is as follows.
228228
CONFIG_APP_BUILD_TYPE_RAM is required, other options help reduce application

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ See the Getting Started guide links above for a detailed setup guide. This is a
8383

8484
## Flashing the Project
8585

86-
When the build finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this automatically by running:
86+
When the build finishes, it will print a command line to use `esptool` to flash the chip. However you can also do this automatically by running:
8787

8888
`idf.py -p PORT flash`
8989

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ESP-IDF 中的子模块采用相对路径([详见 .gitmodules 文件](.gitmodu
8383

8484
## 烧写项目
8585

86-
当构建结束,终端会打印出一条命令行,告知如何使用 esptool.py 工具烧写项目到芯片中。但你也可以运行下面这条命令来自动烧写:
86+
当构建结束,终端会打印出一条命令行,告知如何使用 `esptool` 工具烧写项目到芯片中。但你也可以运行下面这条命令来自动烧写:
8787

8888
`idf.py -p PORT flash`
8989

components/app_update/otatool.py

Lines changed: 84 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
# otatool is used to perform ota-level operations - flashing ota partition
44
# erasing ota partition and switching ota partition
55
#
6-
# SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
6+
# SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
77
# SPDX-License-Identifier: Apache-2.0
8-
from __future__ import division, print_function
9-
108
import argparse
119
import binascii
1210
import collections
@@ -16,12 +14,18 @@
1614
import tempfile
1715

1816
try:
19-
from parttool import PARTITION_TABLE_OFFSET, PartitionName, PartitionType, ParttoolTarget
17+
from parttool import PARTITION_TABLE_OFFSET
18+
from parttool import PartitionName
19+
from parttool import PartitionType
20+
from parttool import ParttoolTarget
2021
except ImportError:
2122
COMPONENTS_PATH = os.path.expandvars(os.path.join('$IDF_PATH', 'components'))
2223
PARTTOOL_DIR = os.path.join(COMPONENTS_PATH, 'partition_table')
2324
sys.path.append(PARTTOOL_DIR)
24-
from parttool import PARTITION_TABLE_OFFSET, PartitionName, PartitionType, ParttoolTarget
25+
from parttool import PARTITION_TABLE_OFFSET
26+
from parttool import PartitionName
27+
from parttool import PartitionType
28+
from parttool import ParttoolTarget
2529

2630
__version__ = '2.0'
2731

@@ -35,15 +39,31 @@ def status(msg):
3539
print(msg)
3640

3741

38-
class OtatoolTarget():
39-
42+
class OtatoolTarget:
4043
OTADATA_PARTITION = PartitionType('data', 'ota')
4144

42-
def __init__(self, port=None, baud=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None,
43-
spi_flash_sec_size=SPI_FLASH_SEC_SIZE, esptool_args=[], esptool_write_args=[],
44-
esptool_read_args=[], esptool_erase_args=[]):
45-
self.target = ParttoolTarget(port, baud, partition_table_offset, partition_table_file, esptool_args,
46-
esptool_write_args, esptool_read_args, esptool_erase_args)
45+
def __init__(
46+
self,
47+
port=None,
48+
baud=None,
49+
partition_table_offset=PARTITION_TABLE_OFFSET,
50+
partition_table_file=None,
51+
spi_flash_sec_size=SPI_FLASH_SEC_SIZE,
52+
esptool_args=[],
53+
esptool_write_args=[],
54+
esptool_read_args=[],
55+
esptool_erase_args=[],
56+
):
57+
self.target = ParttoolTarget(
58+
port,
59+
baud,
60+
partition_table_offset,
61+
partition_table_file,
62+
esptool_args,
63+
esptool_write_args,
64+
esptool_read_args,
65+
esptool_erase_args,
66+
)
4767
self.spi_flash_sec_size = spi_flash_sec_size
4868

4969
temp_file = tempfile.NamedTemporaryFile(delete=False)
@@ -71,8 +91,8 @@ def _get_otadata_info(self):
7191
for i in range(2):
7292
start = i * (self.spi_flash_sec_size >> 1)
7393

74-
seq = bytearray(self.otadata[start:start + 4])
75-
crc = bytearray(self.otadata[start + 28:start + 32])
94+
seq = bytearray(self.otadata[start : start + 4])
95+
crc = bytearray(self.otadata[start + 28 : start + 32])
7696

7797
seq = struct.unpack('I', seq)
7898
crc = struct.unpack('I', crc)
@@ -118,7 +138,9 @@ def is_otadata_info_valid(status):
118138

119139
try:
120140
if isinstance(ota_id, int):
121-
ota_partition_next = filter(lambda p: p.subtype - gen.MIN_PARTITION_SUBTYPE_APP_OTA == ota_id, ota_partitions)
141+
ota_partition_next = filter(
142+
lambda p: p.subtype - gen.MIN_PARTITION_SUBTYPE_APP_OTA == ota_id, ota_partitions
143+
)
122144
else:
123145
ota_partition_next = filter(lambda p: p.name == ota_id, ota_partitions)
124146

@@ -192,8 +214,8 @@ def is_otadata_info_valid(status):
192214
def read_ota_partition(self, ota_id, output):
193215
self.target.read_partition(self._get_partition_id_from_ota_id(ota_id), output)
194216

195-
def write_ota_partition(self, ota_id, input):
196-
self.target.write_partition(self._get_partition_id_from_ota_id(ota_id), input)
217+
def write_ota_partition(self, ota_id, input_file):
218+
self.target.write_partition(self._get_partition_id_from_ota_id(ota_id), input_file)
197219

198220
def erase_ota_partition(self, ota_id):
199221
self.target.erase_partition(self._get_partition_id_from_ota_id(ota_id))
@@ -205,8 +227,10 @@ def _read_otadata(target):
205227
otadata_info = target._get_otadata_info()
206228

207229
print(' {:8s} \t {:8s} | \t {:8s} \t {:8s}'.format('OTA_SEQ', 'CRC', 'OTA_SEQ', 'CRC'))
208-
print('Firmware: 0x{:08x} \t0x{:08x} | \t0x{:08x} \t 0x{:08x}'.format(otadata_info[0].seq, otadata_info[0].crc,
209-
otadata_info[1].seq, otadata_info[1].crc))
230+
print(
231+
f'Firmware: {otadata_info[0].seq:#08x} \t{otadata_info[0].crc:#08x} | '
232+
f'\t{otadata_info[1].seq:#08x} \t {otadata_info[1].crc:#08x}'
233+
)
210234

211235

212236
def _erase_otadata(target):
@@ -220,12 +244,12 @@ def _switch_ota_partition(target, ota_id):
220244

221245
def _read_ota_partition(target, ota_id, output):
222246
target.read_ota_partition(ota_id, output)
223-
status('Read ota partition contents to file {}'.format(output))
247+
status(f'Read ota partition contents to file {output}')
224248

225249

226-
def _write_ota_partition(target, ota_id, input):
227-
target.write_ota_partition(ota_id, input)
228-
status('Written contents of file {} to ota partition'.format(input))
250+
def _write_ota_partition(target, ota_id, input_file):
251+
target.write_ota_partition(ota_id, input_file)
252+
status(f'Written contents of file {input_file} to ota partition')
229253

230254

231255
def _erase_ota_partition(target, ota_id):
@@ -240,20 +264,28 @@ def main():
240264

241265
parser.add_argument('--quiet', '-q', help='suppress stderr messages', action='store_true')
242266
parser.add_argument('--esptool-args', help='additional main arguments for esptool', nargs='+')
243-
parser.add_argument('--esptool-write-args', help='additional subcommand arguments for esptool write_flash', nargs='+')
244-
parser.add_argument('--esptool-read-args', help='additional subcommand arguments for esptool read_flash', nargs='+')
245-
parser.add_argument('--esptool-erase-args', help='additional subcommand arguments for esptool erase_region', nargs='+')
267+
parser.add_argument(
268+
'--esptool-write-args', help='additional subcommand arguments for esptool write-flash', nargs='+'
269+
)
270+
parser.add_argument('--esptool-read-args', help='additional subcommand arguments for esptool read-flash', nargs='+')
271+
parser.add_argument(
272+
'--esptool-erase-args', help='additional subcommand arguments for esptool erase-region', nargs='+'
273+
)
246274

247275
# There are two possible sources for the partition table: a device attached to the host
248276
# or a partition table CSV/binary file. These sources are mutually exclusive.
249277
parser.add_argument('--port', '-p', help='port where the device to read the partition table from is attached')
250278

251279
parser.add_argument('--baud', '-b', help='baudrate to use', type=int)
252280

253-
parser.add_argument('--partition-table-offset', '-o', help='offset to read the partition table from', type=str)
281+
parser.add_argument('--partition-table-offset', '-o', help='offset to read the partition table from', type=str)
254282

255-
parser.add_argument('--partition-table-file', '-f', help='file (CSV/binary) to read the partition table from; \
256-
overrides device attached to specified port as the partition table source when defined')
283+
parser.add_argument(
284+
'--partition-table-file',
285+
'-f',
286+
help='file (CSV/binary) to read the partition table from; '
287+
'overrides device attached to specified port as the partition table source when defined',
288+
)
257289

258290
subparsers = parser.add_subparsers(dest='operation', help='run otatool -h for additional help')
259291

@@ -269,15 +301,25 @@ def main():
269301
slot_or_name_parser_args.add_argument('--slot', help='slot number of the ota partition', type=int)
270302
slot_or_name_parser_args.add_argument('--name', help='name of the ota partition')
271303

272-
subparsers.add_parser('switch_ota_partition', help='switch otadata partition', parents=[slot_or_name_parser, spi_flash_sec_size])
304+
subparsers.add_parser(
305+
'switch_ota_partition', help='switch otadata partition', parents=[slot_or_name_parser, spi_flash_sec_size]
306+
)
273307

274-
read_ota_partition_subparser = subparsers.add_parser('read_ota_partition', help='read contents of an ota partition', parents=[slot_or_name_parser])
275-
read_ota_partition_subparser.add_argument('--output', help='file to write the contents of the ota partition to', required=True)
308+
read_ota_partition_subparser = subparsers.add_parser(
309+
'read_ota_partition', help='read contents of an ota partition', parents=[slot_or_name_parser]
310+
)
311+
read_ota_partition_subparser.add_argument(
312+
'--output', help='file to write the contents of the ota partition to', required=True
313+
)
276314

277-
write_ota_partition_subparser = subparsers.add_parser('write_ota_partition', help='write contents to an ota partition', parents=[slot_or_name_parser])
315+
write_ota_partition_subparser = subparsers.add_parser(
316+
'write_ota_partition', help='write contents to an ota partition', parents=[slot_or_name_parser]
317+
)
278318
write_ota_partition_subparser.add_argument('--input', help='file whose contents to write to the ota partition')
279319

280-
subparsers.add_parser('erase_ota_partition', help='erase contents of an ota partition', parents=[slot_or_name_parser])
320+
subparsers.add_parser(
321+
'erase_ota_partition', help='erase contents of an ota partition', parents=[slot_or_name_parser]
322+
)
281323

282324
args = parser.parse_args()
283325

@@ -324,7 +366,7 @@ def main():
324366
target = OtatoolTarget(**target_args)
325367

326368
# Create the operation table and execute the operation
327-
common_args = {'target':target}
369+
common_args = {'target': target}
328370

329371
ota_id = []
330372

@@ -338,18 +380,18 @@ def main():
338380
pass
339381

340382
otatool_ops = {
341-
'read_otadata':(_read_otadata, []),
342-
'erase_otadata':(_erase_otadata, []),
343-
'switch_ota_partition':(_switch_ota_partition, ota_id),
344-
'read_ota_partition':(_read_ota_partition, ['output'] + ota_id),
345-
'write_ota_partition':(_write_ota_partition, ['input'] + ota_id),
346-
'erase_ota_partition':(_erase_ota_partition, ota_id)
383+
'read_otadata': (_read_otadata, []),
384+
'erase_otadata': (_erase_otadata, []),
385+
'switch_ota_partition': (_switch_ota_partition, ota_id),
386+
'read_ota_partition': (_read_ota_partition, ['output'] + ota_id),
387+
'write_ota_partition': (_write_ota_partition, ['input'] + ota_id),
388+
'erase_ota_partition': (_erase_ota_partition, ota_id),
347389
}
348390

349391
(op, op_args) = otatool_ops[args.operation]
350392

351393
for op_arg in op_args:
352-
common_args.update({op_arg:vars(args)[op_arg]})
394+
common_args.update({op_arg: vars(args)[op_arg]})
353395

354396
try:
355397
common_args['ota_id'] = common_args.pop('name')

components/bootloader/Kconfig.bootloader_rollback

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ menu "Recovery Bootloader and Rollback"
2020
Flash address where the recovery bootloader is stored.
2121
This value must be written to the eFuse field (ESP_EFUSE_RECOVERY_BOOTLOADER_FLASH_SECTOR)
2222
to activate the recovery bootloader in the ROM bootloader. The eFuse can be programmed
23-
using espefuse.py or in the user application with the API esp_efuse_set_recovery_bootloader_offset().
23+
using espefuse or in the user application with the API esp_efuse_set_recovery_bootloader_offset().
2424
Setting this value in the config allows parttool.py to verify that it does not overlap with existing
2525
partitions in the partition table.
2626

0 commit comments

Comments
 (0)