diff mbox series

[v3,01/10] dt-bindings: mtd: partitions: add OpenWrt defined U-Boot Image

Message ID 20210120143527.14434-2-bjorn@mork.no
State Changes Requested
Headers show
Series kernel: mtdsplit_uimage: use device tree properties for non-standard uimage parsing | expand

Commit Message

Bjørn Mork Jan. 20, 2021, 2:35 p.m. UTC
Add devicetree bindings for vendor specific variants of U-Boot
Images, as defined by OpenWrt.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 .../mtd/partitions/openwrt,uimage.yaml        |  91 +++++++++
 .../dt-bindings/mtd/partitions/uimage.h       | 191 ++++++++++++++++++
 2 files changed, 282 insertions(+)
 create mode 100644 target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
 create mode 100644 target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h

Comments

Rafał Miłecki Jan. 20, 2021, 3:16 p.m. UTC | #1
On 20.01.2021 15:35, Bjørn Mork wrote:
> @@ -0,0 +1,91 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mtd/partitions/openwrt,uimage.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: OpenWrt variations of U-Boot Image partitions
> +
> +maintainers:
> +  - Bjørn Mork <bjorn@mork.no>
> +
> +description: |
> +  The image format defined by the boot loader "Das U-Boot" is often
> +  modified or extended by device vendors. This defines a few optional
> +  properties which can be used to describe such modifications.
> +
> +# partition.txt defines common properties, but has not yet been
> +# converted to YAML
> +#allOf:
> +#  - $ref: ../partition.yaml#
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - openwrt,uimage
> +      - const: denx,uimage
> +
> +  openwrt,padding:
> +    description: Number of padding bytes between header and data
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +
> +  openwrt,ih-magic:
> +    description: U-Boot Image Header magic number.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0x27051956 # IH_MAGIC
> +
> +  openwrt,ih-type:
> +    description: U-Boot Image type
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 2 # IH_TYPE_KERNEL
> +
> +  openwrt,offset:
> +    description:
> +      Offset between partition start and U-Boot Image in bytes
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +
> +  openwrt,partition-magic:
> +    description:
> +      Magic number found at the start of the partition. Will only be
> +      validated if both this property and openwrt,offset is non-zero
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +
> +required:
> +  - compatible
> +  - reg
> +
> +#unevaluatedProperties: false
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    // device with non-default magic
> +    partition@300000 {
> +          compatible = "openwrt,uimage", "denx,uimage";
> +          reg = <0x00300000 0xe80000>;
> +          label = "firmware";
> +          openwrt,ih-magic = <0x4e474520>;
> +    };
> +  - |
> +    // device with U-Boot Image at an offset, with a partition magic value
> +    partition@70000 {
> +          compatible = "openwrt,uimage", "denx,uimage";
> +          reg = <0x00070000 0x00790000>;
> +          label = "firmware";
> +          openwrt,offset = <20>;
> +          openwrt,partition-magic = <0x43535953>;
> +    };
> +  - |
> +    // device using a non-default image type
> +    #include "dt-bindings/mtd/partitions/uimage.h"
> +    partition@6c0000 {
> +          compatible = "openwrt,uimage", "denx,uimage";
> +          reg = <0x6c0000 0x1900000>;
> +          label = "firmware";
> +          openwrt,ih-magic = <0x33373033>;
> +          openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
> +    };

Did you check that binding with the dt_binding_check?

Something like:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
(you may need arch too, e.g. ARCH=arm64)

I think preferred license for yaml (that dt_binding_check checks for) is
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
Bjørn Mork Jan. 20, 2021, 3:44 p.m. UTC | #2
Rafał Miłecki <zajec5@gmail.com> writes:

> Did you check that binding with the dt_binding_check?
>
> Something like:
> make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
> (you may need arch too, e.g. ARCH=arm64)

Yes, I actually did since I'm not exactly used to writing these files
(or any docs, really :-)

So I used
https://www.kernel.org/doc/html/latest/devicetree/writing-schema.html
and tried my best to follow all the instructions.

Retested it now, just to be sure.  Need to add the "^openwrt,.*" vendor
opbviously if this should go upstream:

bjorn@miraculix:/usr/local/src/git/linux$ git diff Documentation/devicetree/bindings/vendor-prefixes.yaml
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 041ae90b0d8f..bb70d31ec380 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -812,6 +812,8 @@ patternProperties:
     description: OpenCores.org
   "^openrisc,.*":
     description: OpenRISC.io
+  "^openwrt,.*":
+    description: OpenWrt
   "^option,.*":
     description: Option NV
   "^oranth,.*":


And I get some warnings I really don't understand:

bjorn@miraculix:/usr/local/src/git/linux$ make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
  CHKDT   Documentation/devicetree/bindings/processed-schema-examples.json
  SCHEMA  Documentation/devicetree/bindings/processed-schema-examples.json
  DTC     Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml
  CHECK   Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml
/usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@300000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
        From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
/usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@70000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
        From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
/usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@6c0000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
        From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml


> I think preferred license for yaml (that dt_binding_check checks for) is
> # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause

Wondered about that, but didn't find any specific recommendation.  And
there are all plenty of both:

bjorn@miraculix:/usr/local/src/git/linux$ git grep -h SPDX-License-Identifier Documentation/devicetree/bindings/|sort|uniq -c
      6 # SPDX-License-Identifier: (GPL-2.0)
    378 # SPDX-License-Identifier: GPL-2.0
     10 # SPDX-License-Identifier: GPL-2.0+
      4 .. SPDX-License-Identifier: GPL-2.0
      1 # SPDX-License-Identifier: (GPL-2.0-only)
     71 # SPDX-License-Identifier: GPL-2.0-only
     15 # SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
      3 # SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
    539 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
     79 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
    307 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
      7 # SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
      9 # SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause)
      1 # SPDX-License-Identifier: (GPL-2.0-or-later)
      4 # SPDX-License-Identifier: GPL-2.0-or-later
      5 # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
      3 # SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
      3 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
      3 # SPDX-License-Identifier: (GPL-2.0+ OR MIT)
      3 # SPDX-License-Identifier: (GPL-2.0+ OR X11)


But I won't object to changing it if you think that is better somehow.
It's not like I see the real differnece here..  Why would anyone want to
distibute a modified version of this schema in any other form than yaml
source?


Bjørn
Rafał Miłecki Jan. 20, 2021, 9:17 p.m. UTC | #3
On 20.01.2021 16:44, Bjørn Mork wrote:
> Rafał Miłecki <zajec5@gmail.com> writes:
> 
>> Did you check that binding with the dt_binding_check?
>>
>> Something like:
>> make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
>> (you may need arch too, e.g. ARCH=arm64)
> 
> Yes, I actually did since I'm not exactly used to writing these files
> (or any docs, really :-)
> 
> So I used
> https://www.kernel.org/doc/html/latest/devicetree/writing-schema.html
> and tried my best to follow all the instructions.
> 
> Retested it now, just to be sure.  Need to add the "^openwrt,.*" vendor
> opbviously if this should go upstream:
> 
> bjorn@miraculix:/usr/local/src/git/linux$ git diff Documentation/devicetree/bindings/vendor-prefixes.yaml
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> index 041ae90b0d8f..bb70d31ec380 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> @@ -812,6 +812,8 @@ patternProperties:
>       description: OpenCores.org
>     "^openrisc,.*":
>       description: OpenRISC.io
> +  "^openwrt,.*":
> +    description: OpenWrt
>     "^option,.*":
>       description: Option NV
>     "^oranth,.*":
> 
> 
> And I get some warnings I really don't understand:
> 
> bjorn@miraculix:/usr/local/src/git/linux$ make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
>    CHKDT   Documentation/devicetree/bindings/processed-schema-examples.json
>    SCHEMA  Documentation/devicetree/bindings/processed-schema-examples.json
>    DTC     Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml
>    CHECK   Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml
> /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@300000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
>          From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
> /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@70000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
>          From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
> /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.example.dt.yaml: partition@6c0000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
>          From schema: /usr/local/src/git/linux/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml

This means you used unexpected (unmentioned in .yaml) properties (label and reg).

It's an interesting timing as I just backported one slightly related patch:
[PATCH] dt-bindings: mtd: convert "fixed-partitions" to the json-schema
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=7495acb555730b56ca85e259c1565d141220674a

I'm also working on reusing partitions .yaml for other parsers, see:
[PATCH 1/3] dt-bindings: mtd: move partition binding to its own file
https://patchwork.ozlabs.org/project/linux-mtd/patch/20210115153901.31052-1-zajec5@gmail.com/
[PATCH 2/3] dt-bindings: mtd: add binding from BCM4908 partitions
https://patchwork.ozlabs.org/project/linux-mtd/patch/20210115153901.31052-2-zajec5@gmail.com/


>> I think preferred license for yaml (that dt_binding_check checks for) is
>> # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> 
> Wondered about that, but didn't find any specific recommendation.  And
> there are all plenty of both:
> 
> bjorn@miraculix:/usr/local/src/git/linux$ git grep -h SPDX-License-Identifier Documentation/devicetree/bindings/|sort|uniq -c
>        6 # SPDX-License-Identifier: (GPL-2.0)
>      378 # SPDX-License-Identifier: GPL-2.0
>       10 # SPDX-License-Identifier: GPL-2.0+
>        4 .. SPDX-License-Identifier: GPL-2.0
>        1 # SPDX-License-Identifier: (GPL-2.0-only)
>       71 # SPDX-License-Identifier: GPL-2.0-only
>       15 # SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
>        3 # SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
>      539 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>       79 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
>      307 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>        7 # SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
>        9 # SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause)
>        1 # SPDX-License-Identifier: (GPL-2.0-or-later)
>        4 # SPDX-License-Identifier: GPL-2.0-or-later
>        5 # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
>        3 # SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
>        3 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
>        3 # SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>        3 # SPDX-License-Identifier: (GPL-2.0+ OR X11)
> 
> 
> But I won't object to changing it if you think that is better somehow.
> It's not like I see the real differnece here..  Why would anyone want to
> distibute a modified version of this schema in any other form than yaml
> source?

I personally don't have any strong preferences, I'm just trying to follow
upstream rules. If you use license preferred by upstream developers, it'll
make it easier for someone (maybe me) to upstream your work later.

If you check Documentation/devicetree/bindings/submitting-patches.txt , it
says you should use GPL-2.0-only OR BSD-2-Clause. That rule was added by Rob
in the commit 70145d16b3c1 ("dt: submitting-patches: Document requirements
for DT schema"). No extra explanation on "why". I would prefer not having
to argue with Rob though ;)
diff mbox series

Patch

diff --git a/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml b/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
new file mode 100644
index 000000000000..789850f0a263
--- /dev/null
+++ b/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
@@ -0,0 +1,91 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/openwrt,uimage.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OpenWrt variations of U-Boot Image partitions
+
+maintainers:
+  - Bjørn Mork <bjorn@mork.no>
+
+description: |
+  The image format defined by the boot loader "Das U-Boot" is often
+  modified or extended by device vendors. This defines a few optional
+  properties which can be used to describe such modifications.
+
+# partition.txt defines common properties, but has not yet been
+# converted to YAML
+#allOf:
+#  - $ref: ../partition.yaml#
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - openwrt,uimage
+      - const: denx,uimage
+
+  openwrt,padding:
+    description: Number of padding bytes between header and data
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+
+  openwrt,ih-magic:
+    description: U-Boot Image Header magic number.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0x27051956 # IH_MAGIC
+
+  openwrt,ih-type:
+    description: U-Boot Image type
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 2 # IH_TYPE_KERNEL
+
+  openwrt,offset:
+    description:
+      Offset between partition start and U-Boot Image in bytes
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+
+  openwrt,partition-magic:
+    description:
+      Magic number found at the start of the partition. Will only be
+      validated if both this property and openwrt,offset is non-zero
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+
+required:
+  - compatible
+  - reg
+
+#unevaluatedProperties: false
+additionalProperties: false
+
+examples:
+  - |
+    // device with non-default magic
+    partition@300000 {
+          compatible = "openwrt,uimage", "denx,uimage";
+          reg = <0x00300000 0xe80000>;
+          label = "firmware";
+          openwrt,ih-magic = <0x4e474520>;
+    };
+  - |
+    // device with U-Boot Image at an offset, with a partition magic value
+    partition@70000 {
+          compatible = "openwrt,uimage", "denx,uimage";
+          reg = <0x00070000 0x00790000>;
+          label = "firmware";
+          openwrt,offset = <20>;
+          openwrt,partition-magic = <0x43535953>;
+    };
+  - |
+    // device using a non-default image type
+    #include "dt-bindings/mtd/partitions/uimage.h"
+    partition@6c0000 {
+          compatible = "openwrt,uimage", "denx,uimage";
+          reg = <0x6c0000 0x1900000>;
+          label = "firmware";
+          openwrt,ih-magic = <0x33373033>;
+          openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
+    };
diff --git a/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h b/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h
new file mode 100644
index 000000000000..29eec38dd282
--- /dev/null
+++ b/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h
@@ -0,0 +1,191 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *    *** IMPORTANT ***
+ * This file is not only included from C-code but also from devicetree source
+ * files. As such this file MUST only contain comments and defines.
+ *
+ * Based on image.h from U-Boot which is
+ * (C) Copyright 2008 Semihalf
+ * (C) Copyright 2000-2005 Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ */
+
+#ifndef __UIMAGE_H__
+#define __UIMAGE_H__
+
+/*
+ * Operating System Codes
+ *
+ * The following are exposed to uImage header.
+ * New IDs *MUST* be appended at the end of the list and *NEVER*
+ * inserted for backward compatibility.
+ */
+#define	IH_OS_INVALID		0	/* Invalid OS	*/
+#define	IH_OS_OPENBSD		1	/* OpenBSD	*/
+#define	IH_OS_NETBSD		2	/* NetBSD	*/
+#define	IH_OS_FREEBSD		3	/* FreeBSD	*/
+#define	IH_OS_4_4BSD		4	/* 4.4BSD	*/
+#define	IH_OS_LINUX		5	/* Linux	*/
+#define	IH_OS_SVR4		6	/* SVR4		*/
+#define	IH_OS_ESIX		7	/* Esix		*/
+#define	IH_OS_SOLARIS		8	/* Solaris	*/
+#define	IH_OS_IRIX		9	/* Irix		*/
+#define	IH_OS_SCO	       10	/* SCO		*/
+#define	IH_OS_DELL	       11	/* Dell		*/
+#define	IH_OS_NCR	       12	/* NCR		*/
+#define	IH_OS_LYNXOS	       13	/* LynxOS	*/
+#define	IH_OS_VXWORKS	       14	/* VxWorks	*/
+#define	IH_OS_PSOS	       15	/* pSOS		*/
+#define	IH_OS_QNX	       16	/* QNX		*/
+#define	IH_OS_U_BOOT	       17	/* Firmware	*/
+#define	IH_OS_RTEMS	       18	/* RTEMS	*/
+#define	IH_OS_ARTOS	       19	/* ARTOS	*/
+#define	IH_OS_UNITY	       20	/* Unity OS	*/
+#define	IH_OS_INTEGRITY	       21	/* INTEGRITY	*/
+#define	IH_OS_OSE	       22	/* OSE		*/
+#define	IH_OS_PLAN9	       23	/* Plan 9	*/
+#define	IH_OS_OPENRTOS	       24	/* OpenRTOS	*/
+#define	IH_OS_ARM_TRUSTED_FIRMWARE 25    /* ARM Trusted Firmware */
+#define	IH_OS_TEE	       26	/* Trusted Execution Environment */
+#define	IH_OS_OPENSBI	       27	/* RISC-V OpenSBI */
+#define	IH_OS_EFI	       28	/* EFI Firmware (e.g. GRUB2) */
+
+/*
+ * CPU Architecture Codes (supported by Linux)
+ *
+ * The following are exposed to uImage header.
+ * New IDs *MUST* be appended at the end of the list and *NEVER*
+ * inserted for backward compatibility.
+ */
+#define	IH_ARCH_INVALID		0	/* Invalid CPU	*/
+#define	IH_ARCH_ALPHA		1	/* Alpha	*/
+#define	IH_ARCH_ARM		2	/* ARM		*/
+#define	IH_ARCH_I386		3	/* Intel x86	*/
+#define	IH_ARCH_IA64		4	/* IA64		*/
+#define	IH_ARCH_MIPS		5	/* MIPS		*/
+#define	IH_ARCH_MIPS64		6	/* MIPS	 64 Bit */
+#define	IH_ARCH_PPC		7	/* PowerPC	*/
+#define	IH_ARCH_S390		8	/* IBM S390	*/
+#define	IH_ARCH_SH		9	/* SuperH	*/
+#define	IH_ARCH_SPARC	       10	/* Sparc	*/
+#define	IH_ARCH_SPARC64	       11	/* Sparc 64 Bit */
+#define	IH_ARCH_M68K	       12	/* M68K		*/
+#define	IH_ARCH_NIOS	       13	/* Nios-32	*/
+#define	IH_ARCH_MICROBLAZE     14	/* MicroBlaze   */
+#define	IH_ARCH_NIOS2	       15	/* Nios-II	*/
+#define	IH_ARCH_BLACKFIN       16	/* Blackfin	*/
+#define	IH_ARCH_AVR32	       17	/* AVR32	*/
+#define	IH_ARCH_ST200	       18	/* STMicroelectronics ST200  */
+#define	IH_ARCH_SANDBOX	       19	/* Sandbox architecture (test only) */
+#define	IH_ARCH_NDS32	       20	/* ANDES Technology - NDS32  */
+#define	IH_ARCH_OPENRISC       21	/* OpenRISC 1000  */
+#define	IH_ARCH_ARM64	       22	/* ARM64	*/
+#define	IH_ARCH_ARC	       23	/* Synopsys DesignWare ARC */
+#define	IH_ARCH_X86_64	       24	/* AMD x86_64, Intel and Via */
+#define	IH_ARCH_XTENSA	       25	/* Xtensa	*/
+#define	IH_ARCH_RISCV	       26	/* RISC-V */
+
+/*
+ * Image Types
+ *
+ * "Standalone Programs" are directly runnable in the environment
+ *	provided by U-Boot; it is expected that (if they behave
+ *	well) you can continue to work in U-Boot after return from
+ *	the Standalone Program.
+ * "OS Kernel Images" are usually images of some Embedded OS which
+ *	will take over control completely. Usually these programs
+ *	will install their own set of exception handlers, device
+ *	drivers, set up the MMU, etc. - this means, that you cannot
+ *	expect to re-enter U-Boot except by resetting the CPU.
+ * "RAMDisk Images" are more or less just data blocks, and their
+ *	parameters (address, size) are passed to an OS kernel that is
+ *	being started.
+ * "Multi-File Images" contain several images, typically an OS
+ *	(Linux) kernel image and one or more data images like
+ *	RAMDisks. This construct is useful for instance when you want
+ *	to boot over the network using BOOTP etc., where the boot
+ *	server provides just a single image file, but you want to get
+ *	for instance an OS kernel and a RAMDisk image.
+ *
+ *	"Multi-File Images" start with a list of image sizes, each
+ *	image size (in bytes) specified by an "uint32_t" in network
+ *	byte order. This list is terminated by an "(uint32_t)0".
+ *	Immediately after the terminating 0 follow the images, one by
+ *	one, all aligned on "uint32_t" boundaries (size rounded up to
+ *	a multiple of 4 bytes - except for the last file).
+ *
+ * "Firmware Images" are binary images containing firmware (like
+ *	U-Boot or FPGA images) which usually will be programmed to
+ *	flash memory.
+ *
+ * "Script files" are command sequences that will be executed by
+ *	U-Boot's command interpreter; this feature is especially
+ *	useful when you configure U-Boot to use a real shell (hush)
+ *	as command interpreter (=> Shell Scripts).
+ *
+ * The following are exposed to uImage header.
+ * New IDs *MUST* be appended at the end of the list and *NEVER*
+ * inserted for backward compatibility.
+ */
+#define	IH_TYPE_INVALID		0	/* Invalid Image		*/
+#define	IH_TYPE_STANDALONE	1	/* Standalone Program		*/
+#define	IH_TYPE_KERNEL		2	/* OS Kernel Image		*/
+#define	IH_TYPE_RAMDISK		3	/* RAMDisk Image		*/
+#define	IH_TYPE_MULTI		4	/* Multi-File Image		*/
+#define	IH_TYPE_FIRMWARE	5	/* Firmware Image		*/
+#define	IH_TYPE_SCRIPT		6	/* Script file			*/
+#define	IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
+#define	IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
+#define	IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
+#define	IH_TYPE_IMXIMAGE       10	/* Freescale IMXBoot Image	*/
+#define	IH_TYPE_UBLIMAGE       11	/* Davinci UBL Image		*/
+#define	IH_TYPE_OMAPIMAGE      12	/* TI OMAP Config Header Image	*/
+#define	IH_TYPE_AISIMAGE       13	/* TI Davinci AIS Image		*/
+	/* OS Kernel Image, can run from any load address */
+#define	IH_TYPE_KERNEL_NOLOAD  14
+#define	IH_TYPE_PBLIMAGE       15	/* Freescale PBL Boot Image	*/
+#define	IH_TYPE_MXSIMAGE       16	/* Freescale MXSBoot Image	*/
+#define	IH_TYPE_GPIMAGE	       17	/* TI Keystone GPHeader Image	*/
+#define	IH_TYPE_ATMELIMAGE     18	/* ATMEL ROM bootable Image	*/
+#define	IH_TYPE_SOCFPGAIMAGE   19	/* Altera SOCFPGA CV/AV Preloader */
+#define	IH_TYPE_X86_SETUP      20	/* x86 setup.bin Image		*/
+#define	IH_TYPE_LPC32XXIMAGE   21	/* x86 setup.bin Image		*/
+#define	IH_TYPE_LOADABLE       22	/* A list of typeless images	*/
+#define	IH_TYPE_RKIMAGE	       23	/* Rockchip Boot Image		*/
+#define	IH_TYPE_RKSD	       24	/* Rockchip SD card		*/
+#define	IH_TYPE_RKSPI	       25	/* Rockchip SPI image		*/
+#define	IH_TYPE_ZYNQIMAGE      26	/* Xilinx Zynq Boot Image */
+#define	IH_TYPE_ZYNQMPIMAGE    27	/* Xilinx ZynqMP Boot Image */
+#define	IH_TYPE_ZYNQMPBIF      28	/* Xilinx ZynqMP Boot Image (bif) */
+#define	IH_TYPE_FPGA	       29	/* FPGA Image */
+#define	IH_TYPE_VYBRIDIMAGE    30	/* VYBRID .vyb Image */
+#define	IH_TYPE_TEE            31	/* Trusted Execution Environment OS Image */
+#define	IH_TYPE_FIRMWARE_IVT   32	/* Firmware Image with HABv4 IVT */
+#define	IH_TYPE_PMMC           33	/* TI Power Management Micro-Controller Firmware */
+#define	IH_TYPE_STM32IMAGE     34	/* STMicroelectronics STM32 Image */
+#define	IH_TYPE_SOCFPGAIMAGE_V1 35	/* Altera SOCFPGA A10 Preloader	*/
+#define	IH_TYPE_MTKIMAGE       36	/* MediaTek BootROM loadable Image */
+#define	IH_TYPE_IMX8MIMAGE     37	/* Freescale IMX8MBoot Image	*/
+#define	IH_TYPE_IMX8IMAGE      38	/* Freescale IMX8Boot Image	*/
+#define	IH_TYPE_COPRO	       39	/* Coprocessor Image for remoteproc*/
+
+
+/*
+ * Compression Types
+ *
+ * The following are exposed to uImage header.
+ * New IDs *MUST* be appended at the end of the list and *NEVER*
+ * inserted for backward compatibility.
+ */
+#define	IH_COMP_NONE		0	/*  No	 Compression Used	*/
+#define	IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
+#define	IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
+#define	IH_COMP_LZMA		3	/* lzma  Compression Used	*/
+#define	IH_COMP_LZO		4	/* lzo   Compression Used	*/
+#define	IH_COMP_LZ4		5	/* lz4   Compression Used	*/
+
+
+#define LZ4F_MAGIC	0x184D2204	/* LZ4 Magic Number		*/
+#define IH_MAGIC	0x27051956	/* Image Magic Number		*/
+#define IH_NMLEN		32	/* Image Name Length		*/
+
+#endif	/* __UIMAGE_H__ */