diff mbox series

[meta-python,2/2] devtools: add recipe for esptool

Message ID 20230109-esptool-v1-2-a27de84d748a@theobroma-systems.com
State New
Headers show
Series add recipe for esptool and its dependencies | expand

Commit Message

Quentin Schulz Jan. 9, 2023, 5:19 p.m. UTC
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>

esptool Python module is a collection of libs and scripts to interact
with the bootloader on Espressif SoCs. The Python module happens to
provide three useful scripts: esptool, espefuse and espsecure. esptool
is the backbone of communication with the Espressif SoC's bootloader.
espefuse is useful when one needs to burn fuses or read the current fuse
state. Finally, espsecure is a tool for setting up Espressif
implementation of secure boot on their SoC.

espsecure depends on python3-cryptography which is a Rust-based Python
module, making it a heavy tool dependency-wise which is the reason why
the scripts have been split in their own package so that people only
interested in esptool script have the smallest possible dependency
chain.

Cc: Quentin Schulz <foss+yocto@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
 .../python3-esptool/python3-esptool_4.4.bb         | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Quentin Schulz Jan. 10, 2023, 2:53 p.m. UTC | #1
Hi all,

Please do not merge. See comments below.

On 1/9/23 18:19, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> 
> esptool Python module is a collection of libs and scripts to interact
> with the bootloader on Espressif SoCs. The Python module happens to
> provide three useful scripts: esptool, espefuse and espsecure. esptool
> is the backbone of communication with the Espressif SoC's bootloader.
> espefuse is useful when one needs to burn fuses or read the current fuse
> state. Finally, espsecure is a tool for setting up Espressif
> implementation of secure boot on their SoC.
> 
> espsecure depends on python3-cryptography which is a Rust-based Python
> module, making it a heavy tool dependency-wise which is the reason why
> the scripts have been split in their own package so that people only
> interested in esptool script have the smallest possible dependency
> chain.
> 

This unfortunately does not work because all runtime dependencies of all 
packages in a recipe are built regardless if they're included in the 
image or not. So while this allows for slimmer images, it doesn't save 
compile time.

So I can suggest a few things:
  - simple recipe with one package with esptool, espefuse and espsecure,
  - keep it as is, slimmer image when one installs esptool only,
  - one recipe for esptool, another recipe for espefuse and espsecure, 
slimmer image + fastest compile time if esptool-only required, more 
complex upgrade path (need to make sure esptool and espefuse+espsecure 
versions are kept in sync) and less maintainer/user-friendly,
  - make espefuse/espsecure inclusion and their runtime dependencies 
manageable via PACKAGECONFIG, slimmer image + fastest compile time + 
"simple" recipe, PACKAGECONFIG changed via bbappend (so inclusion of a 
layer modifying it changes the package for every image) or configuration 
file (which I'm not sure makes a lot of sense?),

What are your thoughts on this?

> Cc: Quentin Schulz <foss+yocto@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> ---
>   .../python3-esptool/python3-esptool_4.4.bb         | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 
> diff --git a/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb b/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb
> new file mode 100644
> index 0000000000..573e5fbdd1
> --- /dev/null
> +++ b/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb
> @@ -0,0 +1,22 @@
> +SUMMARY = "A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips."
> +HOMEPAGE = "https://urldefense.com/v3/__https://github.com/espressif/esptool__;!!OOPJP91ZZw!ihV4ksMmKOE5_Qb9_LULCaepiK54CU-lr83C1QrA2RKEG-U8FpfWc7hno-2VJtyENI0DdBwNea_iHUTa-WpENW4N7BdbYu4bQ18$ "
> +BUGTRACKER = "https://urldefense.com/v3/__https://github.com/espressif/esptool/issues__;!!OOPJP91ZZw!ihV4ksMmKOE5_Qb9_LULCaepiK54CU-lr83C1QrA2RKEG-U8FpfWc7hno-2VJtyENI0DdBwNea_iHUTa-WpENW4N7Bdb4kL0Ayw$ "
> +LICENSE = "GPL-2.0-or-later"
> +LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
> +
> +SRC_URI[sha256sum] = "8acd4dfe70819b1302861ae92894380fb4700b377f5a4739479a4ec276e0b256"
> +
> +inherit pypi setuptools3
> +
> +# Split the Python package into multiple Yocto packages to avoid bringing in
> +# heavy dependencies like python3-cryptography when only esptool.py might be
> +# needed.
> +PACKAGE_BEFORE_PN += "${PN}-espefuse ${PN}-espsecure"
> +
> +RDEPENDS:${PN} += "python3-core python3-pyserial"

Missing a few runtime dependencies. I had only tested with all packages 
installed and python3-cryptography was bringing those dependencies in.

Cheers,
Quentin
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb b/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb
new file mode 100644
index 0000000000..573e5fbdd1
--- /dev/null
+++ b/meta-python/recipes-devtools/python3-esptool/python3-esptool_4.4.bb
@@ -0,0 +1,22 @@ 
+SUMMARY = "A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips."
+HOMEPAGE = "https://github.com/espressif/esptool"
+BUGTRACKER = "https://github.com/espressif/esptool/issues"
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+SRC_URI[sha256sum] = "8acd4dfe70819b1302861ae92894380fb4700b377f5a4739479a4ec276e0b256"
+
+inherit pypi setuptools3
+
+# Split the Python package into multiple Yocto packages to avoid bringing in
+# heavy dependencies like python3-cryptography when only esptool.py might be
+# needed.
+PACKAGE_BEFORE_PN += "${PN}-espefuse ${PN}-espsecure"
+
+RDEPENDS:${PN} += "python3-core python3-pyserial"
+
+RDEPENDS:${PN}-espsecure += "${PN} python3-cryptography python3-ecdsa"
+FILES:${PN}-espsecure = "${bindir}/espsecure.py ${PYTHON_SITEPACKAGES_DIR}/espsecure/*"
+
+RDEPENDS:${PN}-espefuse += "${PN} python3-bitstring ${PN}-espsecure python3-reedsolo"
+FILES:${PN}-espefuse = "${bindir}/espefuse.py ${PYTHON_SITEPACKAGES_DIR}/espefuse/*"