Skip to contentSkip to conversation

arm/trusted-firmware-m: use python3-cbor2 instead of python3-cbor

PATCH New Ross Burton 1 participant 3 messages Nov 10, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 arm/trusted-firmware-m: use python3-cbor2 instead of python3-cbor

Backport a patch to switch from the unmaintained python3-cbor module to the active python3-cbor2 module.

---
 .../trusted-firmware-m/files/cbor2.patch      | 80 +++++++++++++++++++
 .../trusted-firmware-m_1.4.0.bb               |  3 +-
 2 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 meta-arm/recipes-bsp/trusted-firmware-m/files/cbor2.patch
meta-arm/recipes-bsp/trusted-firmware-m/files/cbor2.patch new file +80 -0
new file mode 100644
index 00000000..ec5749d4
@@ -0,0 +1,80 @@
+Upstream-Status: Backport [https://github.com/mcu-tools/mcuboot/commit/a6df132b68f8e08c2b0ab428377d478436376556]
+Signed-off-by: Ross Burton <[email protected]>
+
+From a5f747643e3a51b8dfce192203b9b84e033728b9 Mon Sep 17 00:00:00 2001
+From: Ross Burton <[email protected]>
+Date: Tue, 2 Nov 2021 11:12:04 +0000
+Subject: [PATCH] imgtool: prefer cbor2 over cbor
+
+The cbor module is unmaintained, with the last release in 2016[1]. The
+cbor2 module however is under active development and was last released
+just last month[2].
+
+As the APIs are identical, we can import cbor2 and if that fails fall
+back to cbor.
+
+[1] https://pypi.org/project/cbor/#history
+[2] https://pypi.org/project/cbor2/#history
+
+Closes #1189
+
+Signed-off-by: Ross Burton <[email protected]>
+Change-Id: Iaf2d0df625a200a5cebf72dec4a89877a26194ea
+---
+ scripts/imgtool.nix            | 2 +-
+ scripts/imgtool/boot_record.py | 9 ++++++---
+ scripts/requirements.txt       | 2 +-
+ scripts/setup.py               | 2 +-
+ 4 files changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/scripts/imgtool.nix b/scripts/imgtool.nix
+index 9ac41bc..ea9ba8b 100644
+diff --git a/scripts/imgtool/boot_record.py b/scripts/imgtool/boot_record.py
+index ac433aa..8ab2f60 100644
+--- a/scripts/imgtool/boot_record.py
++++ b/scripts/imgtool/boot_record.py
+@@ -14,8 +14,11 @@
+ # limitations under the License.
+ 
+ from enum import Enum
+-import cbor
+ 
++try:
++    from cbor2 import dumps
++except ImportError:
++    from cbor import dumps
+ 
+ class SwComponent(int, Enum):
+     """
+@@ -46,4 +49,4 @@ def create_sw_component_data(sw_type, sw_version, sw_measurement_description,
+     #       list because later it will be modified by the bootloader.
+     properties[SwComponent.MEASUREMENT_VALUE] = sw_measurement_value
+ 
+-    return cbor.dumps(properties)
++    return dumps(properties)
+diff --git a/scripts/requirements.txt b/scripts/requirements.txt
+index 9481e2c..2446928 100644
+--- a/scripts/requirements.txt
++++ b/scripts/requirements.txt
+@@ -1,4 +1,4 @@
+ cryptography>=2.6
+ intelhex
+ click
+-cbor>=1.0.0
++cbor2
+diff --git a/scripts/setup.py b/scripts/setup.py
+index a228ea3..692cfb7 100644
+--- a/scripts/setup.py
++++ b/scripts/setup.py
+@@ -15,7 +15,7 @@ setuptools.setup(
+         'cryptography>=2.4.2',
+         'intelhex>=2.2.1',
+         'click',
+-        'cbor>=1.0.0',
++        'cbor2',
+     ],
+     entry_points={
+         "console_scripts": ["imgtool=imgtool.main:imgtool"]
+-- 
+2.25.1
+
meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.4.0.bb +2 -1
index 14fcbb1b..326b5a66 100644
@@ -19,6 +19,7 @@ SRC_URI  = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=h
             git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https;branch=master;name=tfm-tests;destsuffix=${S}/../tf-m-tests \
             git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=master;name=mbedtls;destsuffix=${S}/../mbedtls \
             git://github.com/mcu-tools/mcuboot.git;protocol=https;branch=main;name=mcuboot;destsuffix=${S}/../mcuboot \
+            file://cbor2.patch;patchdir=${S}/../mcuboot \
             "
 
 # The required dependencies are documented in tf-m/config/config_default.cmake
@@ -52,7 +53,7 @@ DEPENDS += "cmake-native \
             python3-click-native \
             python3-cryptography-native \
             python3-pyasn1-native \
-            python3-cbor-native"
+            python3-cbor2-native"
 
 S = "${WORKDIR}/git/tfm"
 B = "${WORKDIR}/build"
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 arm-bsp/python3-imgtool: remove, this is now in meta-python

A newer version of this recipe is now in meta-python[1]

[1] https://git.openembedded.org/meta-openembedded/commit/?id=94fc0589b50f43afd1a19303a40389652929bf38

---
 .../corstone1000-imgtool/python3-imgtool_1.7.1.bb  | 14 --------------
 1 file changed, 14 deletions(-)
 delete mode 100644 meta-arm-bsp/recipes-devtool/corstone1000-imgtool/python3-imgtool_1.7.1.bb
meta-arm-bsp/recipes-devtool/corstone1000-imgtool/python3-imgtool_1.7.1.bb deleted +0 -14
deleted file mode 100644
index 06d52d09..00000000
@@ -1,14 +0,0 @@
-SUMMARY = "MCUboot's image signing and key management"
-LICENSE = "Apache-2.0"
-AUTHOR = "The MCUboot committers <[email protected]>, \
-          Abdellatif El Khlifi <[email protected]>"
-
-LIC_FILES_CHKSUM = "file://PKG-INFO;md5=e32b214fd9c204b77a99a97aa903757b"
-
-SRC_URI[md5sum] = "de0005dc13ce9e5e6aecdedfd0956286"
-
-DEPENDS:corstone1000 = "python3-cryptography python3-intelhex python3-click python3-cbor"
-
-inherit pypi setuptools3
-
-BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 arm/python3-cbor: remove, cbor2 is used now

In reply to Ross Burton

This recipe was used by trusted-firmware-m and python3-imgtool, both of which now use python3-cbor2.

---
 .../python/python3-cbor_1.0.0.bb                 | 16 ----------------
 1 file changed, 16 deletions(-)
 delete mode 100644 meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb
meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb deleted +0 -16
deleted file mode 100644
index 1df062bc..00000000
@@ -1,16 +0,0 @@
-DESCRIPTION = "An implementation of RFC 7049 - Concise Binary Object Representation (CBOR)."
-HOMEPAGE = "https://github.com/brianolson/cbor_py"
-
-LICENSE = "Apache-2.0"
-# Use a line from setup.py until LICENSE is distributed
-# (https://github.com/brianolson/cbor_py/issues/20)
-LIC_FILES_CHKSUM = "file://setup.py;beginline=88;endline=88;md5=267392b618a88b03e5987f69d9b98699"
-
-SRC_URI[md5sum] = "22b03b59784fd78cb6c27aa498af0db6"
-SRC_URI[sha256sum] = "13225a262ddf5615cbd9fd55a76a0d53069d18b07d2e9f19c39e6acb8609bbb6"
-
-PYPI_PACKAGE = "cbor"
-
-inherit pypi setuptools3
-
-BBCLASSEXTEND = "native"
Signature · 1 line
2.25.1