Skip to content

Commit 36325fd

Browse files
committed
feat(espsecure): Unify all commands and options to use dash instead of underscore
1 parent 69950b2 commit 36325fd

File tree

5 files changed

+120
-62
lines changed

5 files changed

+120
-62
lines changed

docs/en/espsecure/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ You must install ``esptool.py`` package with the ``hsm`` extra using the command
2121

2222
The following command should be used to get an image signed using an external HSM. ::
2323

24-
python espsecure.py sign_data --version 2 --hsm --hsm-config <hsm_config_file> --output <signed_image> <datafile>
24+
espsecure.py sign-data --version 2 --hsm --hsm-config <hsm_config_file> --output <signed_image> <datafile>
2525

2626
The above command first extracts the public key from the HSM, generates a signature for an image using the HSM, and then creates a signature block and appends it to the image to generate a signed image.
2727

2828
If the public key is not stored in the external HSM, you can specify the ``--pub-key`` argument to supply the public key. ::
2929

30-
python espsecure.py sign_data --version 2 --hsm --hsm-config <hsm_config_file> --pub-key <public_key> --output <signed_image> <datafile>
30+
espsecure.py sign-data --version 2 --hsm --hsm-config <hsm_config_file> --pub-key <public_key> --output <signed_image> <datafile>
3131

3232
.. note::
3333
In case you are using ESP-IDF, then an unsigned application can be generated by disabling ``CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES`` configuration option in the project settings.
@@ -37,11 +37,11 @@ Verifying the Signed Image
3737

3838
Once the signed image is generated, we can verify it using the following command: ::
3939

40-
python espsecure.py verify_signature --version 2 --hsm --hsm-config <hsm_config_file> <signed_image>
40+
espsecure.py verify-signature --version 2 --hsm --hsm-config <hsm_config_file> <signed_image>
4141

4242
If the public key is not stored in the external HSM, you can specify the ``--keyfile`` argument to supply the public key. ::
4343

44-
python espsecure.py verify_signature --version 2 --keyfile <public_key> <signed_image>
44+
espsecure.py verify-signature --version 2 --keyfile <public_key> <signed_image>
4545

4646

4747
HSM Config File

docs/en/migration-guide.rst

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
.. _migration:
22

3-
esptool.py ``v5`` Migration Guide
4-
=================================
3+
``v5`` Migration Guide
4+
======================
55

6-
This document describes the breaking changes made to esptool.py in the major release ``v5``. It provides guidance on adapting existing workflows and scripts to ensure compatibility when updating from ``v4.*``.
6+
This document describes the breaking changes made to esptool.py, espsecure.py and espefuse.py in the major release ``v5``. It provides guidance on adapting existing workflows and scripts to ensure compatibility when updating from ``v4.*``.
77

8+
esptool.py ``v5`` Migration Guide
9+
*********************************
810

911
``image-info`` Output Format Change
10-
***********************************
12+
###################################
1113

1214
The output format of the :ref:`image-info <image-info>` command has been **updated in v5**. The original format (``--version 1``) is **deprecated** and replaced by the updated format (``--version 2``). The ``--version`` argument has been **removed entirely**, and the new format is now the default and only option.
1315

@@ -23,7 +25,7 @@ The output format of the :ref:`image-info <image-info>` command has been **updat
2325
2. Remove any ``--version`` arguments from ``image-info`` commands.
2426

2527
Output Logging
26-
**************
28+
##############
2729

2830
The esptool ``v5`` release introduces a centralized logging mechanism to improve output management and allow redirection.
2931

@@ -42,7 +44,7 @@ The esptool ``v5`` release introduces a centralized logging mechanism to improve
4244
See the :ref:`logging <logging>` section for more details on available logger methods and custom logger implementation.
4345

4446
``write-flash`` ``--verify`` Argument
45-
*************************************
47+
#####################################
4648

4749
The ``--verify`` option for the :ref:`write-flash <write-flash>` command has been **deprecated in v5**. Flash verification is performed automatically after every successful write operation when technically feasible.
4850

@@ -58,7 +60,7 @@ The ``--verify`` option for the :ref:`write-flash <write-flash>` command has bee
5860
2. Update scripts/CI pipelines to remove ``--verify`` flags.
5961

6062
Error Output Handling
61-
*********************
63+
#####################
6264

6365
In ``v5``, error handling and output behavior have been improved to provide better user experience and script compatibility.
6466

@@ -75,7 +77,7 @@ In ``v5``, error handling and output behavior have been improved to provide bett
7577
2. Ensure scripts handle non-zero exit codes correctly in the case of operations interrupted by the user.
7678

7779
Beta Target Support Removal
78-
***************************
80+
###########################
7981

8082
Support for the following beta targets has been **removed in v5**:
8183

@@ -93,7 +95,7 @@ Support for the following beta targets has been **removed in v5**:
9395
Use esptool ``v4`` for legacy workflows targeting these beta chips.
9496

9597
``verify-flash`` ``--diff`` Argument
96-
*************************************
98+
####################################
9799

98100
The format of the ``--diff`` option of the :ref:`verify-flash <verify-flash>` command has **changed in v5**. Previously, ``--diff=yes/no`` had to be specified to enable or disable the diff output. In the new version, the ``--diff`` option is a simple boolean switch without the need of a ``yes`` or ``no`` value.
99101

@@ -102,7 +104,7 @@ The format of the ``--diff`` option of the :ref:`verify-flash <verify-flash>` co
102104
1. Rewrite the ``--diff=yes`` argument to a simple ``--diff`` in any existing ``verify-flash`` commands in scripts/CI pipelines. Delete ``--diff=no`` completely if detailed diff output is not required.
103105

104106
Using esptool as a Python Module
105-
********************************
107+
################################
106108

107109
All command functions (e.g., ``verify-flash``, ``write-flash``) have been refactored to remove their dependency on the ``args`` object from the argparse module. Instead, all arguments are now passed explicitly as individual parameters. This change, combined with enhancements to the public API, provides a cleaner, more modular interface for programmatic use of esptool in custom scripts and applications (see :ref:`scripting <scripting>`).
108110

@@ -121,7 +123,7 @@ For detailed examples and API reference, see the :ref:`scripting <scripting>` se
121123

122124

123125
Flash Operations from Non-flash Related Commands
124-
************************************************
126+
################################################
125127

126128
When esptool is used as a CLI tool, the following commands no longer automatically attach the flash by default, since flash access is not required for their core functionality:
127129

@@ -145,7 +147,7 @@ The ``--spi-connection`` CLI argument has been **removed** from non-flash relate
145147

146148

147149
Shell Completion
148-
****************
150+
################
149151

150152
The esptool ``v5`` has switched to using `Click <https://click.palletsprojects.com/>`_ for command line argument parsing, which changes how shell completion works.
151153

@@ -155,7 +157,7 @@ The esptool ``v5`` has switched to using `Click <https://click.palletsprojects.c
155157
2. Follow the new shell completion setup instructions in the :ref:`shell-completion` section of the :ref:`installation <installation>` guide.
156158

157159
``merge-bin`` ``--fill-flash-size`` Argument
158-
********************************************
160+
############################################
159161

160162
The ``--fill-flash-size`` option of the :ref:`merge-bin <merge-bin>` command has been renamed to ``--pad-to-size``. This change provides a more intuitive and descriptive name for the argument and is consistent with the naming scheme in other esptool image manipulation commands.
161163

@@ -164,7 +166,7 @@ The ``--fill-flash-size`` option of the :ref:`merge-bin <merge-bin>` command has
164166
1. Rename the ``--fill-flash-size`` to ``--pad-to-size`` in any existing ``merge-bin`` commands in scripts/CI pipelines.
165167

166168
``write-flash`` ``--ignore-flash-encryption-efuse-setting`` Argument
167-
********************************************************************
169+
####################################################################
168170

169171
The ``--ignore-flash-encryption-efuse-setting`` option of the :ref:`write-flash <write-flash>` command has been renamed to ``--ignore-flash-enc-efuse``. This change shortens the argument name to improve readability and consistency with other esptool options.
170172

@@ -173,7 +175,7 @@ The ``--ignore-flash-encryption-efuse-setting`` option of the :ref:`write-flash
173175
1. Rename the ``--ignore-flash-encryption-efuse-setting`` to ``--ignore-flash-enc-efuse`` in any existing ``write-flash`` commands in scripts/CI pipelines.
174176

175177
``make_image`` Command Removal
176-
******************************
178+
##############################
177179

178180
The ``make_image`` command for the ESP8266 has been **removed in v5**. This command has been deprecated in favor of using **objcopy** (or other tools) to generate ELF images and then using ``elf2image`` to create the final ``.bin`` file.
179181

@@ -182,7 +184,7 @@ The ``make_image`` command for the ESP8266 has been **removed in v5**. This comm
182184
1. Replace any ``make_image`` workflows with the recommended way of assembling firmware images using **objcopy** and ``elf2image``.
183185

184186
Using Binary from GitHub Releases on Linux
185-
******************************************
187+
##########################################
186188

187189
The ``esptool.py`` binary from GitHub Releases on Linux is now using Ubuntu 22.04 as the base image. That means the image is using ``glibc`` 2.35, which is not fully compatible with the ``glibc`` 2.28 from Ubuntu 20.04 (the base image for ``v4.*``).
188190

@@ -191,7 +193,7 @@ The ``esptool.py`` binary from GitHub Releases on Linux is now using Ubuntu 22.0
191193
1. Update your operating system to a newer version which bundles ``glibc`` 2.35 or later
192194

193195
Command and Option Renaming
194-
***************************
196+
###########################
195197

196198
All the commands and options have been renamed to use ``-`` instead of ``_`` as a separator (e.g., ``write_flash`` -> ``write-flash``).
197199

@@ -204,10 +206,58 @@ This change affects most of the commands and the following options: ``--flash_si
204206
1. Replace all underscores in command and option names with ``-`` in your scripts and CI pipelines.
205207

206208
Log Format Changes
207-
******************
209+
##################
208210

209211
A significant amount of changes have been made to the log styling and formatting in ``v5``. Some of the messages, warnings, and errors are now formatted differently or reworded to provide more context and improve readability. Exhaustive list of changed messages won't be provided.
210212

211213
**Migration Steps:**
212214

213215
1. Make sure to adjust any of your scripts, asserts, CI workflows, or others to accommodate the new/changed format of messages. If you are parsing the log output (not recommended), consider importing esptool as a module and using the public API (see :ref:`here <scripting>`) to get the information you need.
216+
217+
218+
espsecure.py ``v5`` Migration Guide
219+
***********************************
220+
221+
Command and Option Renaming
222+
###########################
223+
224+
All the commands and options have been renamed to use ``-`` instead of ``_`` as a separator (e.g., ``sign_data`` -> ``sign-data``).
225+
226+
Old command and option names are **deprecated**, meaning they will work for now with a warning, but will be removed in the next major release.
227+
228+
This change affects most of the commands and the following options: ``--aes_xts``, ``--flash_crypt_conf``, ``--append_signatures``.
229+
230+
**Migration Steps:**
231+
232+
1. Replace all underscores in command and option names with ``-`` in your scripts and CI pipelines.
233+
234+
Public API Changes
235+
##################
236+
237+
The public API of ``espsecure.py`` has been updated to provide a more consistent and user-friendly interface for programmatic use in custom scripts and applications.
238+
239+
**Key Changes:**
240+
241+
- All functions now accept individual parameters instead of relying on the ``args`` object from the argparse module. Affected functions are:
242+
- ``digest_secure_bootloader``
243+
- ``generate_signing_key``
244+
- ``digest_secure_bootloader``
245+
- ``generate_signing_key``
246+
- ``sign_data`` including ``sign_secure_boot_v1`` and ``sign_secure_boot_v2``
247+
- ``verify_signature`` including ``verify_signature_v1`` and ``verify_signature_v2``
248+
- ``extract_public_key``
249+
- ``signature_info_v2``
250+
- ``digest_sbv2_public_key`` and ``digest_rsa_public_key``
251+
- ``digest_private_key``
252+
- ``generate_flash_encryption_key``
253+
- ``decrypt_flash_data``
254+
- ``encrypt_flash_data``
255+
- The ``main`` function parameter ``custom_commandline`` has been renamed to ``argv`` to unify the naming convention with esptool.
256+
257+
**Migration Steps:**
258+
259+
1. Update function calls to pass individual parameters instead of the ``args`` object. For example:
260+
``sign_data(args)`` -> ``sign_data(data=args.data, key=args.key, ...)``
261+
or if you were mocking the args object, now you don't have to do that and you can pass parameters directly to the function like:
262+
``sign_data(data=data, key=key, ...)``.
263+
2. Replace the ``custom_commandline`` parameter with ``argv`` in the ``main`` function call.

0 commit comments

Comments
 (0)