Skip to contentSkip to conversation

Add script for version upgrades

PATCH In review Peter Hoyes 3 participants 7 messages Sep 16, 2022 – Sep 21, 2022

lore
Share & tools
lore
#0 lore raw

cover Add script for version upgrades

From: Peter Hoyes <[email protected]>

This patch chain has been developed on top of the 2.7.3 upgrade patch.

Add a script, generate-version.py, which can be used to automatically generate configuration for new Zephyr versions. Regenerate configuration for 2.7.3 and 3.1.0 using this script.

This script includes a constant version-specific declaration of ZEPHYR_MODULES, so the build-time logic to extract ZEPHYR_MODULES is no longer required. Remove the do_get_zmods task and the West recipe.

Peter Hoyes (4):
zephyr-core/scripts: Introduce script to generate new versions zephyr-core/zephyr-kernel: Migrate to script-driven version files zephyr-core/classes: Remove West-based logic from zephyr.bbclass zephyr-core/zephyr-kernel: Update dtc.patch Upstream-Status

 README.txt                                    |  17 ++
 meta-zephyr-core/classes/zephyr.bbclass       |  32 +--
 .../recipes-devtools/west/west_0.12.99.bb     |  22 --
 ...y-generation-issue-in-cross-compila.patch} |   0
 .../zephyr-kernel/files/dtc.patch             |   2 +-
 .../zephyr-kernel/zephyr-kernel-src-2.7.3.inc | 202 +++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src-3.1.0.inc | 220 +++++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src.inc       |  43 ----
 meta-zephyr-core/scripts/generate-version.py  |  73 ++++++
 .../scripts/zephyr-kernel-src.inc.jinja       |  35 +++
 10 files changed, 474 insertions(+), 172 deletions(-)
 delete mode 100644 meta-zephyr-core/recipes-devtools/west/west_0.12.99.bb
 rename meta-zephyr-core/recipes-kernel/zephyr-kernel/files/{0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch => 0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch} (100%)
 create mode 100755 meta-zephyr-core/scripts/generate-version.py
 create mode 100644 meta-zephyr-core/scripts/zephyr-kernel-src.inc.jinja
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 zephyr-core/scripts: Introduce script to generate new versions

From: Peter Hoyes <[email protected]>

Add a Python script which can be used to automatically generate configuration for new Zephyr versions. This script:
* Takes the Zephyr version as a single argument
* Uses the Github API to find the version tag's SHA1
* Uses West as a library to parse the version's manifest file
* Uses a Jinja template to generate a .inc file for the version
* Outputs the .inc file directly into the zephyr-kernel directory

The generated .inc file includes:
* SRCREVs for all modules
* Separate SRC_URI_x variables for each module, to make it easier to swap out a specific URL for a fork or mirror
* A version-specific SRC_URI, containing only the modules defined in the release
* A list of the ZEPHYR_MODULES

---
 README.txt                                    | 17 +++++
 meta-zephyr-core/scripts/generate-version.py  | 73 +++++++++++++++++++
 .../scripts/zephyr-kernel-src.inc.jinja       | 35 +++++++++
 3 files changed, 125 insertions(+)
 create mode 100755 meta-zephyr-core/scripts/generate-version.py
 create mode 100644 meta-zephyr-core/scripts/zephyr-kernel-src.inc.jinja
README.txt +17 -0
index 4776a8a..ea129ba 100644
@@ -125,6 +125,23 @@ you will need to run the above, copy the conf files from the deploy dir to the
 machine conf directory and then run your build. This shouldn't need to happen 
 often.
 
+Generating new Zephyr recipe versions
+=====================================
+The script meta-zephyr-core/scripts/generate-version.py is used to generate
+Yocto configuration for a Zephyr version from the West configuration in the
+Zephyr repository. It requires the west and jinja2 Python packages to be
+installed on the host. Run it as follows:
+
+    $ ./meta-zephyr-core/scripts/generate-version.py x.x.x
+
+where x.x.x is the Zephyr version.
+
+The patch files added to SRC_URI in the generated file should be validated and
+modified if required.
+
+The new version should be committed and submitted to the mailing list as
+described in "Contributing".
+
 Contributing
 ============
 
meta-zephyr-core/scripts/generate-version.py new file +73 -0

73 lines not on this page · raw message

meta-zephyr-core/scripts/zephyr-kernel-src.inc.jinja new file +35 -0
new file mode 100644
index 0000000..e7981ed
@@ -0,0 +1,35 @@
+# Auto-generated from zephyr-kernel-src.inc.jinja
+{%- set short_version = '.'.join(version.split('.')[0:2]) %}
+
+SRCREV_FORMAT = "default"
+
+SRCREV_default = "{{ tag_sha }}"
+{% for project in projects -%}
+SRCREV_{{ project.name }} = "{{ project.revision }}"
+{% endfor %}
+SRC_URI_ZEPHYR ?= "git://github.com/zephyrproject-rtos/zephyr.git;protocol=https"
+{%- for project in projects %}
+SRC_URI_{{ project.name | bitbake_var }} ?= "{{ project.url | git_url_to_bitbake }}"
+{%- endfor %}
+
+SRC_URI_PATCHES ?= "\
+    file://0001-{{ short_version }}-cmake-add-yocto-toolchain.patch;patchdir=zephyr \
+    file://0001-{{ short_version }}-x86-fix-efi-binary-generation-issue-in-cross-compila.patch;patchdir=zephyr \
+"
+
+SRC_URI = "\
+    ${SRC_URI_ZEPHYR};branch=${ZEPHYR_BRANCH};name=default;destsuffix=git/zephyr \
+{%- for project in projects %}
+    ${SRC_URI_{{ project.name | bitbake_var }}};name={{ project.name }};nobranch=1;destsuffix=git/{{ project.path }} \
+{%- endfor %}
+    ${SRC_URI_PATCHES} \
+"
+
+ZEPHYR_MODULES = "\{% for project in projects %}
+${S}/{{ project.path }}\;\
+{%- endfor %}
+"
+
+ZEPHYR_BRANCH = "v{{ short_version }}-branch"
+PV = "{{ version }}+git${SRCPV}"
+
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/4 zephyr-core/zephyr-kernel: Migrate to script-driven version files

In reply to Peter Hoyes

From: Peter Hoyes <[email protected]>

This commit uses the output of meta-zephyr-core/scripts/generate-version.py for both the 2.7.3 and 3.1.0 versions.

Rename a patch for for v2.7.3 to match the filename expected by the generated configuration.

---
 ...y-generation-issue-in-cross-compila.patch} |   0
 .../zephyr-kernel/zephyr-kernel-src-2.7.3.inc | 202 +++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src-3.1.0.inc | 220 +++++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src.inc       |  43 ----
 4 files changed, 347 insertions(+), 118 deletions(-)
 rename meta-zephyr-core/recipes-kernel/zephyr-kernel/files/{0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch => 0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch} (100%)
meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch renamed from meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch +0 -0
similarity index 100%
rename from meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch
rename to meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch
meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src-2.7.3.inc +164 -38

220 lines not on this page · raw message

meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src-3.1.0.inc +183 -37

237 lines not on this page · raw message

meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src.inc +0 -43

49 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/4 zephyr-core/classes: Remove West-based logic from zephyr.bbclass

In reply to Peter Hoyes

From: Peter Hoyes <[email protected]>

For a given release tag, ZEPHYR_MODULES is constant. It is therefore now populated by the generate-version.py script, the output of which is stored in the repository, so the build-time logic to populate ZEPHYR_MODULES is no longer needed.

Remove the do_get_zmods task, but retain the Python dependencies which are still required by Python scripts in the Zephyr repository that are trigerred by CMake.

The above means that West is now only required as a host dependency to run generate-version.py, so remove the West Yocto recipe.

---
 meta-zephyr-core/classes/zephyr.bbclass       | 32 +------------------
 .../recipes-devtools/west/west_0.12.99.bb     | 22 -------------
 2 files changed, 1 insertion(+), 53 deletions(-)
 delete mode 100644 meta-zephyr-core/recipes-devtools/west/west_0.12.99.bb
meta-zephyr-core/classes/zephyr.bbclass +1 -31
index 8030456..5b71bda 100644
@@ -2,6 +2,7 @@ inherit terminal
 inherit python3native
 
 PYTHONPATH="${STAGING_DIR_HOST}${libdir}/${PYTHON_DIR}/site-packages"
+DEPENDS += "python3-pyelftools-native python3-pyyaml-native python3-pykwalify-native"
 
 OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC"
 HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}"
@@ -24,39 +25,8 @@ python () {
     d.setVar('BOARD',board)
 }
 
-do_get_zmods() {
-
-    export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/${libdir}/${PYTHON_DIR}/site-packages:${RECIPE_SYSROOT_NATIVE}/${libdir}/${PYTHON_DIR}"
-    cd ${S}
-    
-    # I really dislike how tied in this is to west, but without reimplementing their script, this seems to be the
-    # easiest way to do this
-    rm -rf .west; mkdir .west
-    cat << EOF >> ${S}/.west/config
-[manifest]
-path = zephyr
-file = west.yml
-EOF
-
-    # Get all available modules and add them to ZEPHYR_MODULES
-    for i in $(west list|awk 'NR>1 {print $2}'); do
-        ZEPHYR_MODULES="${S}/$i\;${ZEPHYR_MODULES}"
-    done
-    export ZEPHYR_MODULES
-}
-
-do_get_zmods[nostamp] = "1"
-do_get_zmods[dirs] = "${B}"
-
 EXTRA_OECMAKE:append = " -DZEPHYR_MODULES=${ZEPHYR_MODULES}"
 
-addtask get_zmods after do_patch before do_configure
-do_get_zmods[depends] += "west-native:do_populate_sysroot"
-do_get_zmods[depends] += "python3-pyyaml-native:do_populate_sysroot"
-do_get_zmods[depends] += "python3-pykwalify-native:do_populate_sysroot"
-do_get_zmods[depends] += "python3-colorama-native:do_populate_sysroot"
-do_get_zmods[depends] += "python3-pyelftools-native:do_populate_sysroot"
-
 python do_menuconfig() {
     os.chdir(d.getVar('ZEPHYR_SRC_DIR', True))
     configdir = d.getVar('ZEPHYR_SRC_DIR', True) + '/outdir/' + d.getVar('BOARD', True)
meta-zephyr-core/recipes-devtools/west/west_0.12.99.bb deleted +0 -22
deleted file mode 100644
index 6a9f8bc..0000000
@@ -1,22 +0,0 @@
-# SPDX-FileCopyrightText: Huawei Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-SUMMARY = "Zephyr RTOS Project meta-tool"
-HOMEPAGE = "https://github.com/zephyrproject-rtos/west"
-LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
-
-SRC_URI = "git://github.com/zephyrproject-rtos/west;protocol=https;branch=main"
-
-PV = "0.12.99"
-SRCREV = "38e656b05ea8f4c8d80b953f6d88b1ed604d11f8"
-PROVIDES = "virtual/west"
-
-S = "${WORKDIR}/git"
-
-inherit setuptools3 python3native
-
-DEPENDS_${PN} += "python3-pyyaml python3-core python3-packaging python3-colorama python3-pyparsing"
-RDEPENDS_${PN} += "python3-pyyaml python3-core python3-packaging python3-colorama python3-pyparsing"
-BBCLASSEXTEND = "native nativesdk"
-TOOLCHAIN_HOST_TASK:append = " nativesdk-west"
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/4 zephyr-core/zephyr-kernel: Update dtc.patch Upstream-Status

In reply to Peter Hoyes

From: Peter Hoyes <[email protected]>

The patch dtc.patch used by 2.7.3 has been accepted upstream, so it is now a Backport.

---
 meta-zephyr-core/recipes-kernel/zephyr-kernel/files/dtc.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-zephyr-core/recipes-kernel/zephyr-kernel/files/dtc.patch +1 -1
index f23a438..971995b 100644
@@ -1,4 +1,4 @@
-Upstream-Status: Submitted [https://github.com/zephyrproject-rtos/zephyr/pull/40364]
+Upstream-Status: Backport [https://github.com/zephyrproject-rtos/zephyr/commit/a4da64033dac55108215857659831b7d027513de]
 Signed-off-by: Ross Burton <[email protected]>
 
 From deb6e9b29d77f0d86eb188fb3c5fc6f470277d3d Mon Sep 17 00:00:00 2001
Signature · 1 line
2.25.1
Tested-by on the v1 series
#5 lore raw
In reply to Peter Hoyes
Quoted 12 lines · Peter Hoyes

From: Peter Hoyes <[email protected]>

This patch chain has been developed on top of the 2.7.3 upgrade patch.

Add a script, generate-version.py, which can be used to automatically generate configuration for new Zephyr versions. Regenerate configuration for 2.7.3 and 3.1.0 using this script.

This script includes a constant version-specific declaration of ZEPHYR_MODULES, so the build-time logic to extract ZEPHYR_MODULES is no longer required. Remove the do_get_zmods task and the West recipe.

Quoted 5 lines

Peter Hoyes (4):
zephyr-core/scripts: Introduce script to generate new versions zephyr-core/zephyr-kernel: Migrate to script-driven version files zephyr-core/classes: Remove West-based logic from zephyr.bbclass zephyr-core/zephyr-kernel: Update dtc.patch Upstream-Status

Series passes CI (on top of the v2.7.3 patch). See
https://gitlab.com/jonmason00/meta-zephyr/-/pipelines/645914527

Quoted 21 lines
 README.txt                                    |  17 ++
 meta-zephyr-core/classes/zephyr.bbclass       |  32 +--
 .../recipes-devtools/west/west_0.12.99.bb     |  22 --
 ...y-generation-issue-in-cross-compila.patch} |   0
 .../zephyr-kernel/files/dtc.patch             |   2 +-
 .../zephyr-kernel/zephyr-kernel-src-2.7.3.inc | 202 +++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src-3.1.0.inc | 220 +++++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src.inc       |  43 ----
 meta-zephyr-core/scripts/generate-version.py  |  73 ++++++
 .../scripts/zephyr-kernel-src.inc.jinja       |  35 +++
 10 files changed, 474 insertions(+), 172 deletions(-)
 delete mode 100644 meta-zephyr-core/recipes-devtools/west/west_0.12.99.bb
 rename meta-zephyr-core/recipes-kernel/zephyr-kernel/files/{0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch => 0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch} (100%)
 create mode 100755 meta-zephyr-core/scripts/generate-version.py
 create mode 100644 meta-zephyr-core/scripts/zephyr-kernel-src.inc.jinja
Signature · 1 line
2.25.1
#6 lore raw

Thanks Jon. Merged.

Regards,
Naveen

Quoted 59 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jon Mason
Sent: Wednesday, September 21, 2022 6:34 AM
To: Peter Hoyes <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [yocto] [meta-zephyr][PATCH 0/4] Add script for version upgrades

Quoted 12 lines · Peter Hoyes

From: Peter Hoyes <[email protected]>

This patch chain has been developed on top of the 2.7.3 upgrade patch.

Add a script, generate-version.py, which can be used to automatically generate configuration for new Zephyr versions. Regenerate configuration for 2.7.3 and 3.1.0 using this script.

This script includes a constant version-specific declaration of ZEPHYR_MODULES, so the build-time logic to extract ZEPHYR_MODULES is no longer required. Remove the do_get_zmods task and the West recipe.

Quoted 5 lines

Peter Hoyes (4):
zephyr-core/scripts: Introduce script to generate new versions zephyr-core/zephyr-kernel: Migrate to script-driven version files zephyr-core/classes: Remove West-based logic from zephyr.bbclass zephyr-core/zephyr-kernel: Update dtc.patch Upstream-Status

Series passes CI (on top of the v2.7.3 patch). See
https://gitlab.com/jonmason00/meta-zephyr/-/pipelines/645914527

Quoted 26 lines
 README.txt                                    |  17 ++
 meta-zephyr-core/classes/zephyr.bbclass       |  32 +--
 .../recipes-devtools/west/west_0.12.99.bb     |  22 --
 ...y-generation-issue-in-cross-compila.patch} |   0
 .../zephyr-kernel/files/dtc.patch             |   2 +-
 .../zephyr-kernel/zephyr-kernel-src-2.7.3.inc | 202 +++++++++++++---
.../zephyr-kernel/zephyr-kernel-src-3.1.0.inc | 220 +++++++++++++++---
 .../zephyr-kernel/zephyr-kernel-src.inc       |  43 ----
 meta-zephyr-core/scripts/generate-version.py  |  73 ++++++
 .../scripts/zephyr-kernel-src.inc.jinja       |  35 +++
 10 files changed, 474 insertions(+), 172 deletions(-)  delete mode

100644 meta-zephyr-core/recipes-devtools/west/west_0.12.99.bb
rename
meta-zephyr-core/recipes-kernel/zephyr-kernel/files/{0001-x86-fix-efi- binary-generation-issue-in-cross-compila.patch => 0001-2.7-x86-fix-efi-binary-generation-issue-in-cross-compila.patch} (100%) create mode 100755 meta-zephyr-core/scripts/generate-version.py

 create mode 100644

meta-zephyr-core/scripts/zephyr-kernel-src.inc.jinja

--
2.25.1