get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.2/patches/800475/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 800475,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/800475/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/1502441568-22896-4-git-send-email-pantelis.antoniou@konsulko.com/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1502441568-22896-4-git-send-email-pantelis.antoniou@konsulko.com>",
    "list_archive_url": null,
    "date": "2017-08-11T08:52:41",
    "name": "[U-Boot,v2,03/10] fit: Introduce methods for applying overlays on fit-load",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c60d6c32feb787a2c9cb55a3684b25f1d9394f68",
    "submitter": {
        "id": 64098,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/64098/?format=api",
        "name": "Pantelis Antoniou",
        "email": "pantelis.antoniou@konsulko.com"
    },
    "delegate": {
        "id": 3184,
        "url": "http://patchwork.ozlabs.org/api/1.2/users/3184/?format=api",
        "username": "sjg",
        "first_name": "Simon",
        "last_name": "Glass",
        "email": "sjg@chromium.org"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/1502441568-22896-4-git-send-email-pantelis.antoniou@konsulko.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/800475/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/800475/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=konsulko.com header.i=@konsulko.com\n\theader.b=\"l5fD0RuO\"; dkim-atps=neutral"
        ],
        "Received": [
            "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xTJpx2pcJz9t2W\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 11 Aug 2017 18:59:37 +1000 (AEST)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid 1E6F5C21DB3; Fri, 11 Aug 2017 08:57:24 +0000 (UTC)",
            "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id CC1EAC21DE6;\n\tFri, 11 Aug 2017 08:56:03 +0000 (UTC)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid 91D46C21DAB; Fri, 11 Aug 2017 08:55:45 +0000 (UTC)",
            "from mail-wr0-f181.google.com (mail-wr0-f181.google.com\n\t[209.85.128.181])\n\tby lists.denx.de (Postfix) with ESMTPS id 9974DC21DA4\n\tfor <u-boot@lists.denx.de>; Fri, 11 Aug 2017 08:55:41 +0000 (UTC)",
            "by mail-wr0-f181.google.com with SMTP id k71so11172372wrc.2\n\tfor <u-boot@lists.denx.de>; Fri, 11 Aug 2017 01:55:41 -0700 (PDT)",
            "from localhost.localdomain ([195.97.110.117])\n\tby smtp.gmail.com with ESMTPSA id\n\to71sm759811wmg.15.2017.08.11.01.55.39\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 11 Aug 2017 01:55:40 -0700 (PDT)"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=3.4.0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=kaIvg2J+xwLl+TZYi3qZ6o29STXiojR1trf3EnesEBE=;\n\tb=l5fD0RuOPzK2ntXKk+bflK+DbJdYkQzodiZM5DACkydG5XniESP8uR/9tgIwAZKGFP\n\tn3Rq33n/0I/qW3l5/9Pa9w6mzv1V2NM8erZd2MLQXNrTL6xtNvS53/TxkkR5LjVR8+iO\n\tDeTkPtNQeRttBVw7biWbDoG2xlwlHbMDFlfOQ=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=kaIvg2J+xwLl+TZYi3qZ6o29STXiojR1trf3EnesEBE=;\n\tb=SnjUaEah//q22a91S4g908PA34B1EWZw9FacMuX/GpkcvOSoiZjtmWE1wYfxc1QP95\n\tDozTNwiO3Y6jq4zzgHBjVzvJpZCCTAVuHUOT4pAzCGyfIxVdSWgvXPQLgrgw5N4qx/pz\n\tefeJOtBR4SWb/zUDlLqg9w4dPsDMHhGVwI0wORwnvYRCXFG8s8u5ezNI0O5DmUeEz8iV\n\tgFMd3FNfyyZDN2XDQdFj0VHl5onSi2Mj6IIvRWOk9YH68YZ05DudSjUvQiHnYYPA6t4x\n\tA0mRkAFGRKc/Xx8hp7jcXGyZJIgM077oolSJOryPUOuaYS388MUwM0B8thIrjfvGyVEN\n\tgoxg==",
        "X-Gm-Message-State": "AHYfb5gZT5tcuavaPwXBpTA7Oxdw4rJFgdac53Aa6U0mlIswYd6isG9e\n\tkha08py4I76vYM59",
        "X-Received": "by 10.223.141.131 with SMTP id o3mr10201441wrb.110.1502441741126;\n\tFri, 11 Aug 2017 01:55:41 -0700 (PDT)",
        "From": "Pantelis Antoniou <pantelis.antoniou@konsulko.com>",
        "To": "Tom Rini <trini@konsulko.com>",
        "Date": "Fri, 11 Aug 2017 11:52:41 +0300",
        "Message-Id": "<1502441568-22896-4-git-send-email-pantelis.antoniou@konsulko.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1502441568-22896-1-git-send-email-pantelis.antoniou@konsulko.com>",
        "References": "<1502441568-22896-1-git-send-email-pantelis.antoniou@konsulko.com>",
        "Cc": "Marek Vasut <marex@denx.de>,\n\tPantelis Antoniou <pantelis.antoniou@konsulko.com>,\n\tTero Kristo <t-kristo@ti.com>, u-boot@lists.denx.de,\n\tMaxime Ripard <maxime.ripard@free-electrons.com>,\n\tStefan Roese <sr@denx.de>, Alan Ott <alan@signal11.us>",
        "Subject": "[U-Boot] [PATCH v2 03/10] fit: Introduce methods for applying\n\toverlays on fit-load",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.18",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>"
    },
    "content": "Introduce an overlay based method for constructing a base DT blob\nto pass to the kernel.\n\nBoth canned and runtime feature selection is supported.\n\nSigned-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>\n---\n common/image-fdt.c                           |   7 +-\n common/image-fit.c                           | 216 ++++++++++++++++++++++++--\n doc/uImage.FIT/command_syntax_extensions.txt |  12 +-\n doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++\n doc/uImage.FIT/source_file_format.txt        |   6 +-\n include/image.h                              |  10 ++\n 6 files changed, 454 insertions(+), 18 deletions(-)\n create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt",
    "diff": "diff --git a/common/image-fdt.c b/common/image-fdt.c\nindex c6e8832..a59134c 100644\n--- a/common/image-fdt.c\n+++ b/common/image-fdt.c\n@@ -356,17 +356,16 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,\n \t\t\tif (fit_check_format(buf)) {\n \t\t\t\tulong load, len;\n \n-\t\t\t\tfdt_noffset = fit_image_load(images,\n+\t\t\t\tfdt_noffset = boot_get_fdt_fit(images,\n \t\t\t\t\tfdt_addr, &fit_uname_fdt,\n \t\t\t\t\t&fit_uname_config,\n-\t\t\t\t\tarch, IH_TYPE_FLATDT,\n-\t\t\t\t\tBOOTSTAGE_ID_FIT_FDT_START,\n-\t\t\t\t\tFIT_LOAD_OPTIONAL, &load, &len);\n+\t\t\t\t\tarch, &load, &len);\n \n \t\t\t\timages->fit_hdr_fdt = map_sysmem(fdt_addr, 0);\n \t\t\t\timages->fit_uname_fdt = fit_uname_fdt;\n \t\t\t\timages->fit_noffset_fdt = fdt_noffset;\n \t\t\t\tfdt_addr = load;\n+\n \t\t\t\tbreak;\n \t\t\t} else\n #endif\ndiff --git a/common/image-fit.c b/common/image-fit.c\nindex 109ecfa..cb089ea 100644\n--- a/common/image-fit.c\n+++ b/common/image-fit.c\n@@ -19,6 +19,7 @@\n #include <errno.h>\n #include <mapmem.h>\n #include <asm/io.h>\n+#include <malloc.h>\n DECLARE_GLOBAL_DATA_PTR;\n #endif /* !USE_HOSTCC*/\n \n@@ -434,6 +435,10 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)\n \t\t\tprintf(\"0x%08lx\\n\", load);\n \t}\n \n+\t/* optional load address for FDT */\n+\tif (type == IH_TYPE_FLATDT && !fit_image_get_load(fit, image_noffset, &load))\n+\t\tprintf(\"%s  Load Address: 0x%08lx\\n\", p, load);\n+\n \tif ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) ||\n \t    (type == IH_TYPE_RAMDISK)) {\n \t\tret = fit_image_get_entry(fit, image_noffset, &entry);\n@@ -1454,6 +1459,8 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)\n {\n \tint noffset, confs_noffset;\n \tint len;\n+\tconst char *s;\n+\tchar *conf_uname_copy = NULL;\n \n \tconfs_noffset = fdt_path_offset(fit, FIT_CONFS_PATH);\n \tif (confs_noffset < 0) {\n@@ -1475,29 +1482,58 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)\n \t\tdebug(\"Found default configuration: '%s'\\n\", conf_uname);\n \t}\n \n+\ts = strchr(conf_uname, '#');\n+\tif (s) {\n+\t\tlen = s - conf_uname;\n+\t\tconf_uname_copy = malloc(len + 1);\n+\t\tif (!conf_uname_copy) {\n+\t\t\tdebug(\"Can't allocate uname copy: '%s'\\n\",\n+\t\t\t\t\tconf_uname);\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t\tmemcpy(conf_uname_copy, conf_uname, len);\n+\t\tconf_uname_copy[len] = '\\0';\n+\t\tconf_uname = conf_uname_copy;\n+\t}\n+\n \tnoffset = fdt_subnode_offset(fit, confs_noffset, conf_uname);\n \tif (noffset < 0) {\n \t\tdebug(\"Can't get node offset for configuration unit name: '%s' (%s)\\n\",\n \t\t      conf_uname, fdt_strerror(noffset));\n \t}\n \n+\tif (conf_uname_copy)\n+\t\tfree(conf_uname_copy);\n+\n \treturn noffset;\n }\n \n-int fit_conf_get_prop_node(const void *fit, int noffset,\n+int fit_conf_get_prop_node_count(const void *fit, int noffset,\n \t\tconst char *prop_name)\n {\n-\tchar *uname;\n+\treturn fdt_stringlist_count(fit, noffset, prop_name);\n+}\n+\n+int fit_conf_get_prop_node_index(const void *fit, int noffset,\n+\t\tconst char *prop_name, int index)\n+{\n+\tconst char *uname;\n \tint len;\n \n \t/* get kernel image unit name from configuration kernel property */\n-\tuname = (char *)fdt_getprop(fit, noffset, prop_name, &len);\n+\tuname = fdt_stringlist_get(fit, noffset, prop_name, index, &len);\n \tif (uname == NULL)\n \t\treturn len;\n \n \treturn fit_image_get_node(fit, uname);\n }\n \n+int fit_conf_get_prop_node(const void *fit, int noffset,\n+\t\tconst char *prop_name)\n+{\n+\treturn fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);\n+}\n+\n /**\n  * fit_conf_print - prints out the FIT configuration details\n  * @fit: pointer to the FIT format image header\n@@ -1515,7 +1551,7 @@ void fit_conf_print(const void *fit, int noffset, const char *p)\n \tchar *desc;\n \tconst char *uname;\n \tint ret;\n-\tint loadables_index;\n+\tint fdt_index, loadables_index;\n \n \t/* Mandatory properties */\n \tret = fit_get_desc(fit, noffset, &desc);\n@@ -1537,9 +1573,17 @@ void fit_conf_print(const void *fit, int noffset, const char *p)\n \tif (uname)\n \t\tprintf(\"%s  Init Ramdisk: %s\\n\", p, uname);\n \n-\tuname = fdt_getprop(fit, noffset, FIT_FDT_PROP, NULL);\n-\tif (uname)\n-\t\tprintf(\"%s  FDT:          %s\\n\", p, uname);\n+\tfor (fdt_index = 0;\n+\t     uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP,\n+\t\t\t\t\tfdt_index, NULL), uname;\n+\t     fdt_index++) {\n+\n+\t\tif (fdt_index == 0)\n+\t\t\tprintf(\"%s  FDT:          \", p);\n+\t\telse\n+\t\t\tprintf(\"%s                \", p);\n+\t\tprintf(\"%s\\n\", uname);\n+\t}\n \n \tuname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL);\n \tif (uname)\n@@ -1575,8 +1619,8 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)\n \treturn 0;\n }\n \n-int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,\n-\t\t\tulong addr)\n+int fit_get_node_from_config_index(bootm_headers_t *images, const char *prop_name,\n+\t\t\tulong addr, int index)\n {\n \tint cfg_noffset;\n \tvoid *fit_hdr;\n@@ -1593,7 +1637,8 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,\n \t\treturn -EINVAL;\n \t}\n \n-\tnoffset = fit_conf_get_prop_node(fit_hdr, cfg_noffset, prop_name);\n+\tnoffset = fit_conf_get_prop_node_index(fit_hdr, cfg_noffset, prop_name,\n+\t\t\t\t\t       index);\n \tif (noffset < 0) {\n \t\tdebug(\"*  %s: no '%s' in config\\n\", prop_name, prop_name);\n \t\treturn -ENOENT;\n@@ -1602,6 +1647,12 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,\n \treturn noffset;\n }\n \n+int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,\n+\t\t\tulong addr)\n+{\n+\treturn fit_get_node_from_config_index(images, prop_name, addr, 0);\n+}\n+\n /**\n  * fit_get_image_type_property() - get property name for IH_TYPE_...\n  *\n@@ -1689,7 +1740,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,\n \t\t\t\t\tBOOTSTAGE_SUB_NO_UNIT_NAME);\n \t\t\treturn -ENOENT;\n \t\t}\n-\t\tfit_uname_config = fdt_get_name(fit, cfg_noffset, NULL);\n+\t\tif (!fit_uname_config)\n+\t\t\tfit_uname_config = fdt_get_name(fit, cfg_noffset, NULL);\n \t\tprintf(\"   Using '%s' configuration\\n\", fit_uname_config);\n \t\tif (image_type == IH_TYPE_KERNEL) {\n \t\t\t/* Remember (and possibly verify) this config */\n@@ -1841,6 +1893,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,\n \t\tdst = map_sysmem(load, len);\n \t\tmemmove(dst, buf, len);\n \t\tdata = load;\n+\n \t}\n \tbootstage_mark(bootstage_id + BOOTSTAGE_SUB_LOAD);\n \n@@ -1873,3 +1926,144 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,\n \n \treturn ret;\n }\n+\n+#ifndef USE_HOSTCC\n+int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,\n+\t\t   const char **fit_unamep, const char **fit_uname_configp,\n+\t\t   int arch, ulong *datap, ulong *lenp)\n+{\n+\tint fdt_noffset, cfg_noffset, count;\n+\tconst void *fit;\n+\tconst char *fit_uname = NULL;\n+\tconst char *fit_uname_config = NULL;\n+\tchar *fit_uname_config_copy = NULL;\n+\tchar *next_config = NULL;\n+\tulong load, len;\n+#ifdef CONFIG_OF_LIBFDT_OVERLAY\n+\tulong image_start, image_end;\n+\tulong ovload, ovlen;\n+\tconst char *uconfig;\n+\tconst char *uname;\n+\tvoid *base, *ov;\n+\tint i, err, noffset, ov_noffset;\n+#endif\n+\n+\tfit_uname = fit_unamep ? *fit_unamep : NULL;\n+\n+\tif (fit_uname_configp && *fit_uname_configp) {\n+\t\tfit_uname_config_copy = strdup(*fit_uname_configp);\n+\t\tif (!fit_uname_config_copy)\n+\t\t\treturn -ENOMEM;\n+\n+\t\tnext_config = strchr(fit_uname_config_copy, '#');\n+\t\tif (next_config)\n+\t\t\t*next_config++ = '\\0';\n+\t\tif (next_config - 1 > fit_uname_config_copy)\n+\t\t\tfit_uname_config = fit_uname_config_copy;\n+\t}\n+\n+\tfdt_noffset = fit_image_load(images,\n+\t\taddr, &fit_uname, &fit_uname_config,\n+\t\tarch, IH_TYPE_FLATDT,\n+\t\tBOOTSTAGE_ID_FIT_FDT_START,\n+\t\tFIT_LOAD_OPTIONAL, &load, &len);\n+\n+\tif (fdt_noffset < 0)\n+\t\tgoto out;\n+\n+\tdebug(\"fit_uname=%s, fit_uname_config=%s\\n\",\n+\t\t\tfit_uname ? fit_uname : \"<NULL>\",\n+\t\t\tfit_uname_config ? fit_uname_config : \"<NULL>\");\n+\n+\tfit = map_sysmem(addr, 0);\n+\n+\tcfg_noffset = fit_conf_get_node(fit, fit_uname_config);\n+\n+\t/* single blob, or error just return as well */\n+\tcount = fit_conf_get_prop_node_count(fit, cfg_noffset, FIT_FDT_PROP);\n+\tif (count <= 1 && !next_config)\n+\t\tgoto out;\n+\n+\t/* we need to apply overlays */\n+\n+#ifdef CONFIG_OF_LIBFDT_OVERLAY\n+\timage_start = addr;\n+\timage_end = addr + fit_get_size(fit);\n+\t/* verify that relocation took place by load address not being in fit */\n+\tif (load >= image_start && load < image_end) {\n+\t\t/* check is simplified; fit load checks for overlaps */\n+\t\tprintf(\"Overlayed FDT requires relocation\\n\");\n+\t\tfdt_noffset = -EBADF;\n+\t\tgoto out;\n+\t}\n+\n+\tbase = map_sysmem(load, len);\n+\n+\t/* apply extra configs in FIT first, followed by args */\n+\tfor (i = 1; ; i++) {\n+\t\tif (i < count) {\n+\t\t\tnoffset = fit_conf_get_prop_node_index(fit, cfg_noffset,\n+\t\t\t\t\t\t\t       FIT_FDT_PROP, i);\n+\t\t\tuname = fit_get_name(fit, noffset, NULL);\n+\t\t\tuconfig = NULL;\n+\t\t} else {\n+\t\t\tif (!next_config)\n+\t\t\t\tbreak;\n+\t\t\tuconfig = next_config;\n+\t\t\tnext_config = strchr(next_config, '#');\n+\t\t\tif (next_config)\n+\t\t\t\t*next_config++ = '\\0';\n+\t\t\tuname = NULL;\n+\t\t}\n+\n+\t\tdebug(\"%d: using uname=%s uconfig=%s\\n\", i, uname, uconfig);\n+\n+\t\tov_noffset = fit_image_load(images,\n+\t\t\taddr, &uname, &uconfig,\n+\t\t\tarch, IH_TYPE_FLATDT,\n+\t\t\tBOOTSTAGE_ID_FIT_FDT_START,\n+\t\t\tFIT_LOAD_REQUIRED, &ovload, &ovlen);\n+\t\tif (ov_noffset < 0) {\n+\t\t\tprintf(\"load of %s failed\\n\", uname);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tdebug(\"%s loaded at 0x%08lx len=0x%08lx\\n\",\n+\t\t\t\tuname, ovload, ovlen);\n+\t\tov = map_sysmem(ovload, ovlen);\n+\n+\t\tbase = map_sysmem(load, len + ovlen);\n+\t\terr = fdt_open_into(base, base, len + ovlen);\n+\t\tif (err < 0) {\n+\t\t\tprintf(\"failed on fdt_open_into\\n\");\n+\t\t\tfdt_noffset = err;\n+\t\t\tgoto out;\n+\t\t}\n+\t\terr = fdt_overlay_apply(base, ov);\n+\t\tif (err < 0) {\n+\t\t\tprintf(\"failed on fdt_overlay_apply\\n\");\n+\t\t\tfdt_noffset = err;\n+\t\t\tgoto out;\n+\t\t}\n+\t\tfdt_pack(base);\n+\t\tlen = fdt_totalsize(base);\n+\t}\n+#else\n+\tprintf(\"config with overlays but CONFIG_OF_LIBFDT_OVERLAY not set\\n\");\n+\tfdt_noffset = -EBADF;\n+#endif\n+\n+out:\n+\tif (datap)\n+\t\t*datap = load;\n+\tif (lenp)\n+\t\t*lenp = len;\n+\tif (fit_unamep)\n+\t\t*fit_unamep = fit_uname;\n+\tif (fit_uname_configp)\n+\t\t*fit_uname_configp = fit_uname_config;\n+\n+\tif (fit_uname_config_copy)\n+\t\tfree(fit_uname_config_copy);\n+\treturn fdt_noffset;\n+}\n+#endif\ndiff --git a/doc/uImage.FIT/command_syntax_extensions.txt b/doc/uImage.FIT/command_syntax_extensions.txt\nindex 6c99b1c..676f992 100644\n--- a/doc/uImage.FIT/command_syntax_extensions.txt\n+++ b/doc/uImage.FIT/command_syntax_extensions.txt\n@@ -36,7 +36,7 @@ Old uImage:\n New uImage:\n 8.  bootm <addr1>\n 9.  bootm [<addr1>]:<subimg1>\n-10. bootm [<addr1>]#<conf>\n+10. bootm [<addr1>]#<conf>[#<extra-conf[#...]]\n 11. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2>\n 12. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> [<addr3>]:<subimg3>\n 13. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> <addr3>\n@@ -129,6 +129,12 @@ following syntax:\n - new uImage configuration specification\n <addr>#<configuration unit_name>\n \n+- new uImage configuration specification with extra configuration components\n+<addr>#<configuration unit_name>[#<extra configuration unit_name>[#..]]\n+\n+The extra configuration currently is supported only for additional device tree\n+overlays to apply on the base device tree supplied by the first configuration\n+unit.\n \n Examples:\n \n@@ -138,6 +144,10 @@ bootm 200000:kernel@1\n - boot configuration \"cfg@1\" from a new uImage located at 200000:\n bootm 200000#cfg@1\n \n+- boot configuration \"cfg@1\" with extra \"cfg@2\" from a new uImage located\n+  at 200000:\n+bootm 200000#cfg@1#cfg@2\n+\n - boot \"kernel@1\" from a new uImage at 200000 with initrd \"ramdisk@2\" found in\n   some other new uImage stored at address 800000:\n bootm 200000:kernel@1 800000:ramdisk@2\ndiff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt\nnew file mode 100644\nindex 0000000..dbdf2a1\n--- /dev/null\n+++ b/doc/uImage.FIT/overlay-fdt-boot.txt\n@@ -0,0 +1,221 @@\n+U-Boot FDT Overlay usage\n+========================\n+\n+Introduction\n+------------\n+In many cases it is desirable to have a single FIT image support a multitude\n+of similar boards and their expansion options. The same kernel on DT enabled\n+platforms can support this easily enough by providing a DT blob upon boot\n+that matches the desired configuration.\n+\n+Configuration without overlays\n+------------------------------\n+\n+Take a hypothetical board named 'foo' where there are different supported\n+revisions, reva and revb. Assume that both board revisions can use add a bar\n+add-on board, while only the revb board can use a baz add-on board.\n+\n+Without using overlays the configuration would be as follows for every case.\n+\n+\t/dts-v1/;\n+\t/ {\n+\t\timages {\n+\t\t\tkernel@1 {\n+\t\t\t\tdata = /incbin/(\"./zImage\");\n+\t\t\t\ttype = \"kernel\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tos = \"linux\";\n+\t\t\t\tload = <0x82000000>;\n+\t\t\t\tentry = <0x82000000>;\n+\t\t\t};\n+\t\t\tfdt@1 {\n+\t\t\t\tdata = /incbin/(\"./foo-reva.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t\tfdt@2 {\n+\t\t\t\tdata = /incbin/(\"./foo-revb.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t\tfdt@3 {\n+\t\t\t\tdata = /incbin/(\"./foo-reva-bar.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t\tfdt@4 {\n+\t\t\t\tdata = /incbin/(\"./foo-revb-bar.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t\tfdt@5 {\n+\t\t\t\tdata = /incbin/(\"./foo-revb-baz.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t\tfdt@6 {\n+\t\t\t\tdata = /incbin/(\"./foo-revb-bar-baz.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t};\n+\t\t};\n+\n+\t\tconfigurations {\n+\t\t\tdefault = \"foo-reva.dtb;\n+\t\t\tfoo-reva.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\";\n+\t\t\t};\n+\t\t\tfoo-revb.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@2\";\n+\t\t\t};\n+\t\t\tfoo-reva-bar.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@3\";\n+\t\t\t};\n+\t\t\tfoo-revb-bar.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@4\";\n+\t\t\t};\n+\t\t\tfoo-revb-baz.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@5\";\n+\t\t\t};\n+\t\t\tfoo-revb-bar-baz.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@6\";\n+\t\t\t};\n+\t\t};\n+\t};\n+\n+Note the blob needs to be compiled for each case and the combinatorial explosion of\n+configurations. A typical device tree blob is in the low hunderds of kbytes so a\n+multitude of configuration grows the image quite a bit.\n+\n+Booting this image is done by using\n+\n+\t# bootm <addr>#<config>\n+\n+Where config is one of:\n+\tfoo-reva.dtb, foo-revb.dtb, foo-reva-bar.dtb, foo-revb-bar.dtb,\n+\tfoo-revb-baz.dtb, foo-revb-bar-baz.dtb\n+\n+This selects the DTB to use when booting.\n+\n+Configuration using overlays\n+----------------------------\n+\n+Device tree overlays can be applied to a base DT and result in the same blob\n+being passed to the booting kernel. This saves on space and avoid the combinatorial\n+explosion problem.\n+\n+\t/dts-v1/;\n+\t/ {\n+\t\timages {\n+\t\t\tkernel@1 {\n+\t\t\t\tdata = /incbin/(\"./zImage\");\n+\t\t\t\ttype = \"kernel\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tos = \"linux\";\n+\t\t\t\tload = <0x82000000>;\n+\t\t\t\tentry = <0x82000000>;\n+\t\t\t};\n+\t\t\tfdt@1 {\n+\t\t\t\tdata = /incbin/(\"./foo.dtb\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tload = <0x87f00000>;\n+\t\t\t};\n+\t\t\tfdt@2 {\n+\t\t\t\tdata = /incbin/(\"./reva.dtbo\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tload = <0x87fc0000>;\n+\t\t\t};\n+\t\t\tfdt@3 {\n+\t\t\t\tdata = /incbin/(\"./revb.dtbo\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tload = <0x87fc0000>;\n+\t\t\t};\n+\t\t\tfdt@4 {\n+\t\t\t\tdata = /incbin/(\"./bar.dtbo\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tload = <0x87fc0000>;\n+\t\t\t};\n+\t\t\tfdt@5 {\n+\t\t\t\tdata = /incbin/(\"./baz.dtbo\");\n+\t\t\t\ttype = \"flat_dt\";\n+\t\t\t\tarch = \"arm\";\n+\t\t\t\tload = <0x87fc0000>;\n+\t\t\t};\n+\t\t};\n+\n+\t\tconfigurations {\n+\t\t\tdefault = \"foo-reva.dtb;\n+\t\t\tfoo-reva.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@2\";\n+\t\t\t};\n+\t\t\tfoo-revb.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@3\";\n+\t\t\t};\n+\t\t\tfoo-reva-bar.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@2\", \"fdt@4\";\n+\t\t\t};\n+\t\t\tfoo-revb-bar.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@3\", \"fdt@4\";\n+\t\t\t};\n+\t\t\tfoo-revb-baz.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@3\", \"fdt@5\";\n+\t\t\t};\n+\t\t\tfoo-revb-bar-baz.dtb {\n+\t\t\t\tkernel = \"kernel@1\";\n+\t\t\t\tfdt = \"fdt@1\", \"fdt@3\", \"fdt@4\", \"fdt@5\";\n+\t\t\t};\n+\t\t\tbar {\n+\t\t\t\tfdt = \"fdt@4\";\n+\t\t\t};\n+\t\t\tbaz {\n+\t\t\t\tfdt = \"fdt@5\";\n+\t\t\t};\n+\t\t};\n+\t};\n+\n+Booting this image is exactly the same as the non-overlay example.\n+u-boot will retrieve the base blob and apply the overlays in sequence as\n+they are declared in the configuration.\n+\n+Note the minimum amount of different DT blobs, as well as the requirement for\n+the DT blobs to have a load address; the overlay application requires the blobs\n+to be writeable.\n+\n+Configuration using overlays and feature selection\n+--------------------------------------------------\n+\n+Although the configuration in the previous section works is a bit inflexible\n+since it requires all possible configuration options to be laid out before\n+hand in the FIT image. For the add-on boards the extra config selection method\n+might make sense.\n+\n+Note the two bar & baz configuration nodes. To boot a reva board with\n+the bar add-on board enabled simply use:\n+\n+\t# bootm <addr>#foo-reva.dtb#bar\n+\n+While booting a revb with bar and baz is as follows:\n+\n+\t# bootm <addr>#foo-revb.dtb#bar#baz\n+\n+The limitation for a feature selection configuration node is that a single\n+fdt option is currently supported.\n+\n+Pantelis Antoniou\n+pantelis.antoniou@konsulko.com\n+12/6/2017\ndiff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt\nindex 136d3d7..ba8013a 100644\n--- a/doc/uImage.FIT/source_file_format.txt\n+++ b/doc/uImage.FIT/source_file_format.txt\n@@ -235,7 +235,7 @@ o config@1\n   |- description = \"configuration description\"\n   |- kernel = \"kernel sub-node unit name\"\n   |- ramdisk = \"ramdisk sub-node unit name\"\n-  |- fdt = \"fdt sub-node unit-name\"\n+  |- fdt = \"fdt sub-node unit-name\" [, \"fdt overlay sub-node unit-name\", ...]\n   |- fpga = \"fpga sub-node unit-name\"\n   |- loadables = \"loadables sub-node unit-name\"\n \n@@ -249,7 +249,9 @@ o config@1\n   - ramdisk : Unit name of the corresponding ramdisk image (component image\n     node of a \"ramdisk\" type).\n   - fdt : Unit name of the corresponding fdt blob (component image node of a\n-    \"fdt type\").\n+    \"fdt type\"). Additional fdt overlay nodes can be supplied which signify\n+    that the resulting device tree blob is generated by the first base fdt\n+    blob with all subsequent overlays applied.\n   - setup : Unit name of the corresponding setup binary (used for booting\n     an x86 kernel). This contains the setup.bin file built by the kernel.\n   - fpga : Unit name of the corresponding fpga bitstream blob\ndiff --git a/include/image.h b/include/image.h\nindex c6f1513..aef71f3 100644\n--- a/include/image.h\n+++ b/include/image.h\n@@ -592,6 +592,10 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,\n int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,\n \t\t       ulong *setup_start, ulong *setup_len);\n \n+int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,\n+\t\t   const char **fit_unamep, const char **fit_uname_configp,\n+\t\t   int arch, ulong *datap, ulong *lenp);\n+\n /**\n  * fit_image_load() - load an image from a FIT\n  *\n@@ -657,6 +661,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,\n  */\n int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,\n \t\t\tulong addr);\n+int fit_get_node_from_config_index(bootm_headers_t *images, const char *prop_name,\n+\t\t\tulong addr, int index);\n \n int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,\n \t\t bootm_headers_t *images,\n@@ -986,6 +992,10 @@ int fit_check_format(const void *fit);\n int fit_conf_find_compat(const void *fit, const void *fdt);\n int fit_conf_get_node(const void *fit, const char *conf_uname);\n \n+int fit_conf_get_prop_node_count(const void *fit, int noffset,\n+\t\tconst char *prop_name);\n+int fit_conf_get_prop_node_index(const void *fit, int noffset,\n+\t\tconst char *prop_name, int index);\n /**\n  * fit_conf_get_prop_node() - Get node refered to by a configuration\n  * @fit:\tFIT to check\n",
    "prefixes": [
        "U-Boot",
        "v2",
        "03/10"
    ]
}