[PATCH 5/6] build: Add mkimage support for powerpc/qoriq

Chris Johns chrisj at rtems.org
Mon Mar 4 07:22:31 UTC 2024


On 28/2/2024 2:15 am, Sebastian Huber wrote:
> Update #4272.
> ---
>  spec/build/bsps/optpython.yml             | 14 ++++++++
>  spec/build/bsps/optubootmkimage.yml       | 20 ++++++++++++
>  spec/build/bsps/powerpc/qoriq/grp.yml     |  6 ++++
>  spec/build/bsps/powerpc/qoriq/mkimage.yml | 39 +++++++++++++++++++++++
>  4 files changed, 79 insertions(+)
>  create mode 100644 spec/build/bsps/optpython.yml
>  create mode 100644 spec/build/bsps/optubootmkimage.yml
>  create mode 100644 spec/build/bsps/powerpc/qoriq/mkimage.yml
> 
> diff --git a/spec/build/bsps/optpython.yml b/spec/build/bsps/optpython.yml
> new file mode 100644
> index 0000000000..15e0e500e6
> --- /dev/null
> +++ b/spec/build/bsps/optpython.yml
> @@ -0,0 +1,14 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +actions:
> +- script: |
> +    value = sys.executable
> +- env-assign: PYTHON
> +build-type: option
> +copyrights:
> +- Copyright (C) 2024 embedded brains GmbH & Co. KG
> +default: []
> +description: ''
> +enabled-by: true
> +links: []
> +name: PYTHON
> +type: build
> diff --git a/spec/build/bsps/optubootmkimage.yml b/spec/build/bsps/optubootmkimage.yml
> new file mode 100644
> index 0000000000..65a996be50
> --- /dev/null
> +++ b/spec/build/bsps/optubootmkimage.yml
> @@ -0,0 +1,20 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +actions:
> +- get-string: null
> +- substitute: null
> +- find-optional-program: null
> +- env-assign: U_BOOT_MKIMAGE
> +build-type: option
> +copyrights:
> +- Copyright (C) 2024 embedded brains GmbH & Co. KG
> +default:
> +- enabled-by: true
> +  value: mkimage
> +description: |
> +  This build option defines the name of the U-Boot boot loader tool to make an
> +  image.
> +enabled-by: true
> +format: '{}'
> +links: []
> +name: U_BOOT_MKIMAGE
> +type: build
> diff --git a/spec/build/bsps/powerpc/qoriq/grp.yml b/spec/build/bsps/powerpc/qoriq/grp.yml
> index 65e623fdbd..cb96682722 100644
> --- a/spec/build/bsps/powerpc/qoriq/grp.yml
> +++ b/spec/build/bsps/powerpc/qoriq/grp.yml
> @@ -18,6 +18,10 @@ links:
>    uid: ../../objirq
>  - role: build-dependency
>    uid: ../../optconsolebaud
> +- role: build-dependency
> +  uid: ../../optobjcopy
> +- role: build-dependency
> +  uid: ../../optubootmkimage
>  - role: build-dependency
>    uid: ../crti
>  - role: build-dependency
> @@ -114,6 +118,8 @@ links:
>    uid: optuartirq
>  - role: build-dependency
>    uid: start
> +- role: build-dependency
> +  uid: mkimage
>  - role: build-dependency
>    uid: ../../bspopts
>  type: build
> diff --git a/spec/build/bsps/powerpc/qoriq/mkimage.yml b/spec/build/bsps/powerpc/qoriq/mkimage.yml
> new file mode 100644
> index 0000000000..712fd237b1
> --- /dev/null
> +++ b/spec/build/bsps/powerpc/qoriq/mkimage.yml
> @@ -0,0 +1,39 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +build-type: mkimage
> +content: |
> +  #!${PYTHON}
> +
> +  import gzip
> +  import os
> +  import shutil
> +  import subprocess
> +  import sys
> +  import tempfile
> +
> +  with tempfile.TemporaryDirectory() as tmp_dir:
> +      bin_path = os.path.join(tmp_dir, "bin")
> +      gz_path = os.path.join(tmp_dir, "gz")
> +      subprocess.run([
> +          "${OBJCOPY}",
> +          "-O", "binary", sys.argv[1], bin_path
> +      ],
> +                     check=True)
> +      with open(bin_path, "rb") as f_bin:
> +          with gzip.open(gz_path, "wb") as f_gz:
> +              shutil.copyfileobj(f_bin, f_gz)
> +      subprocess.run([
> +          "${U_BOOT_MKIMAGE}",
> +          "-A", "ppc", "-O", "linux", "-T", "kernel", "-a", "0x4000", "-e",
> +          "0x4000", "-n", "RTEMS", "-d", gz_path, sys.argv[2]
> +      ],
> +                     check=True)

Sorry this patch is a no from me and adding python like this with such limited
error checking is something I am not comfortable with.

I am OK wih a python module that something robust can import and validate giving
the user consistent and meaningful error messages but as I have just said whole
programs in spec files like this, sorry thet is no from me.

Chris

> +copyrights:
> +- Copyright (C) 2024 embedded brains GmbH & Co. KG
> +enabled-by:
> +  and:
> +  - HAVE_OBJCOPY
> +  - HAVE_U_BOOT_MKIMAGE
> +links:
> +- role: build-dependency
> +  uid: ../../optpython
> +type: build


More information about the devel mailing list