From patchwork Fri Sep 7 05:36:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 11218 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CE8A523F25 for ; Fri, 7 Sep 2012 05:37:02 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6A16CA1960D for ; Fri, 7 Sep 2012 05:37:02 +0000 (UTC) Received: by ieak11 with SMTP id k11so4125540iea.11 for ; Thu, 06 Sep 2012 22:37:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=8T7cEJ0ZVy3S2LY1yhE6WA40jzpaPRvrtOUkrvsA9/Y=; b=bBjjfeuH2XpbzjGvOsYDELDIOsefgHAxi4LCnZ4HuBc85chirDN8fPHG3XeGkPr6fm quqcSLOJhq/URGM3PYFsc9SV3uPsub5R4KVbGQ6XPY7rBeeawLTMpXdLzfrHbKUplz3H 5AFDwKWSu8q8ngO3Q60bI51lYEIwnJjpFoyFlV3ZtdH7Mg7rWbb8vMwUCkgBBUgzP4d1 JB5ve4dY9umFOZbiQrdxtACpBN0LzYcmTCh8B2CaWU4tLKmvnHAgPbwLz3VUIs9XUDoJ Wr2Ggdnl9Zq99tGqEQdti/HULj031WJR8xA+xL+WVmqTMiF49f7h3wJ8kdGwy8HbZq3i CXWA== Received: by 10.50.45.162 with SMTP id o2mr6661373igm.0.1346996221645; Thu, 06 Sep 2012 22:37:01 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp360904igc; Thu, 6 Sep 2012 22:37:01 -0700 (PDT) Received: by 10.66.74.195 with SMTP id w3mr7008970pav.64.1346996219704; Thu, 06 Sep 2012 22:36:59 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id ip5si7152116pbc.348.2012.09.06.22.36.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 22:36:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of chander.kashyap@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of chander.kashyap@linaro.org) smtp.mail=chander.kashyap@linaro.org Received: by pbcmd12 with SMTP id md12so3862415pbc.37 for ; Thu, 06 Sep 2012 22:36:58 -0700 (PDT) Received: by 10.68.240.138 with SMTP id wa10mr8376983pbc.145.1346996218520; Thu, 06 Sep 2012 22:36:58 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id tt6sm2545326pbc.51.2012.09.06.22.36.55 (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 22:36:57 -0700 (PDT) From: Chander Kashyap To: u-boot@lists.denx.de Cc: jason.hobbs@calxeda.com, patches@linaro.org, Chander Kashyap Subject: [PATCH v4] PXE: FDT: Add support for fdt in PXE Date: Fri, 7 Sep 2012 11:06:31 +0530 Message-Id: <1346996191-14555-1-git-send-email-chander.kashyap@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmaJEuGpw/LXYG8MDhwPGKD0NmrgMP/cycvLk2lmrtMnwnCvQ0QoVuO5OmexfdU1kydLSY9 Now DT support is becoming common for all new SoC's. Hence it is better to have option for getting specific FDT from the remote server. This patch adds support for new label i.e. 'fdt'. This will allow to retrieve 'fdt blob' from the remote server. This patch take care for the following scenarios. The usage of fdt is optional. The 'fdt blob' can be retrieved from tftp or can be available locally or can be absent. If 'fdt_addr_r' environment variable is set and 'fdt' label is defined retrieve 'fdt blob' from tftp. 'fdt_addr_r' is then passed along bootm command. If 'fdt_addr' is set and 'fdt blob' is not retrieved from the tftp pass 'fdt_addr' to bootm command. In this case 'fdt blob' will be available at 'fdt_addr'. If 'fdt_addr' is not set and 'fdt blob' is not retrieve from tftp pass NULL to boot command. In this case 'fdt blob' is not required and absent. Signed-off-by: Chander Kashyap Acked-by: Jason Hobbs --- Changes in v2: - Removed the duplicate code. changes in v3: - Added documentation for "fdt" lable in doc/README.pxe changes in v4: - Added New environment variable 'fdt_addr_r' for 'fdt blob' - Add more descriptive documentation for the 'fdt' retrieval. common/cmd_pxe.c | 39 ++++++++++++++++++++++++++++++++++++--- doc/README.pxe | 14 ++++++++++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 6b31dea..ee75db9 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -450,6 +450,7 @@ struct pxe_label { char *kernel; char *append; char *initrd; + char *fdt; int attempted; int localboot; struct list_head list; @@ -517,6 +518,9 @@ static void label_destroy(struct pxe_label *label) if (label->initrd) free(label->initrd); + if (label->fdt) + free(label->fdt); + free(label); } @@ -541,6 +545,9 @@ static void label_print(void *data) if (label->initrd) printf("\t\tinitrd: %s\n", label->initrd); + + if (label->fdt) + printf("\tfdt: %s\n", label->fdt); } /* @@ -628,10 +635,29 @@ static void label_boot(struct pxe_label *label) bootm_argv[1] = getenv("kernel_addr_r"); /* - * fdt usage is optional. If there is an fdt_addr specified, we will - * pass it along to bootm, and adjust argc appropriately. + * fdt usage is optional: + * It handles the following scenarios. All scenarios are exclusive + * + * Scenario 1: If fdt_addr_r specified and "fdt" label is defined in + * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm, + * and adjust argc appropriately. + * + * Scenario 2: If there is an fdt_addr specified, pass it along to + * bootm, and adjust argc appropriately. + * + * Scenario 3: fdt blob is not available. */ - bootm_argv[3] = getenv("fdt_addr"); + bootm_argv[3] = getenv("fdt_addr_r"); + + /* if fdt label is defined then get fdt from server */ + if (bootm_argv[3] && label->fdt) { + if (get_relfile_envaddr(label->fdt, "fdt_addr_r") < 0) { + printf("Skipping %s for failure retrieving fdt\n", + label->name); + return; + } + } else + bootm_argv[3] = getenv("fdt_addr"); if (bootm_argv[3]) bootm_argc = 4; @@ -658,6 +684,7 @@ enum token_type { T_DEFAULT, T_PROMPT, T_INCLUDE, + T_FDT, T_INVALID }; @@ -685,6 +712,7 @@ static const struct token keywords[] = { {"append", T_APPEND}, {"initrd", T_INITRD}, {"include", T_INCLUDE}, + {"fdt", T_FDT}, {NULL, T_INVALID} }; @@ -1074,6 +1102,11 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_sliteral(c, &label->initrd); break; + case T_FDT: + if (!label->fdt) + err = parse_sliteral(c, &label->fdt); + break; + case T_LOCALBOOT: err = parse_integer(c, &label->localboot); break; diff --git a/doc/README.pxe b/doc/README.pxe index 2bbf53d..f00f280 100644 --- a/doc/README.pxe +++ b/doc/README.pxe @@ -93,8 +93,13 @@ pxe boot be passed to the bootm command to boot the kernel. These environment variables are required to be set. - fdt_addr - the location of a fdt blob. If this is set, it will be passed - to bootm when booting a kernel. + fdt_addr_r - location in RAM at which 'pxe boot' will store the fdt blob it + retrieves from tftp. The retrieval is possible if 'fdt' label is defined in + pxe file and 'fdt_addr_r' is set. If retrieval is possible, 'fdt_addr_r' + will be passed to bootm command to boot the kernel. + + fdt_addr - the location of a fdt blob. 'fdt_addr' will be passed to bootm + command if it is set and 'fdt_addr_r' is not passed to bootm command. pxe file format =============== @@ -156,6 +161,11 @@ initrd - if this label is chosen, use tftp to retrieve the initrd the initrd_addr_r environment variable, and that address will be passed to bootm. +fdt - if this label is chosen, use tftp to retrieve the fdt blob + at . it will be stored at the address indicated in + the fdt_addr_r environment variable, and that address will + be passed to bootm. + localboot - Run the command defined by "localcmd" in the environment. is ignored and is only here to match the syntax of PXELINUX config files.