Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41A3BC43334 for ; Sun, 12 Jun 2022 22:16:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 825E184471; Mon, 13 Jun 2022 00:14:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="erF1hLpK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF98D84420; Mon, 13 Jun 2022 00:14:35 +0200 (CEST) Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1299E8443E for ; Mon, 13 Jun 2022 00:14:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf2e.google.com with SMTP id t6so1958437qvh.1 for ; Sun, 12 Jun 2022 15:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3GuHB5Xj63f7Oct+uPXR/IrG82FwjjgEhX7TGbj31M4=; b=erF1hLpKt4ZgXK4WbnYkIBdr9kFFR+3AjuU98buuoPJBzdx7LR0wpzjXLjBVJcjq9D syxaUj/2qcmB5GXL/6HnGyD5VZ0QniZc62daloyaAoKsprbg6kckGs+POgzBCbg7abEC benfBwuOER40ufsvRvFrkjm6UL9OJNF+MmfUTkP8UR70+yjcAkyfN/QgGM/O+6wNLnW/ J0cMKP2PqFSFMElIrgbMn4CwsWcpS+7BPka3GQK+gSJcuIBf/ETPdS0hzYqcRnaCk+Hj DRkw2SLbfUms7SfXsMI7WCHDKGdyFmWprcSEzlIorQgdLAf9wjFxFlJEJfmnAqvqMhAQ fRrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3GuHB5Xj63f7Oct+uPXR/IrG82FwjjgEhX7TGbj31M4=; b=G2b9vSTSVrMsprnIXnj1zaJegSlV1As8jI+Y19q1oMWcuyd+HCnpPXGdQkFJOW4VBe wgQl5dc79uz0u6ZjMSV5Ma39EdrA2elKce7PsCt2Iwurn9IzCumz+xC0gbvAl8skJVlR O/S+GK/Pr9NFi99nOWZJqoMNOFreCW5ZJ2S2yIcQ8SKZiqTQ/Y48NorUHpY1Y186HeeV cTPTmt56ZB6OCMQ8VK2IvgY+HvcjuirLU38C/DkWb/PZk+qjkzotclmRF25owcXv3sCP ykRLMLB1cbYvCh+eGToBzxknxa0qFnzSgwHm+NoJoNx2OA4giboRZSD40BfqkEzWmh2K w2Ow== X-Gm-Message-State: AOAM532pILF3AvhbUsY6rf9JmeZpl470PA7JaoXXLJkBeAJ/Kqi3ODVn BQAQA24dcrAYT0XkAPnRqGzU+AU5WbuPZEif X-Google-Smtp-Source: ABdhPJzRtHiAygqoBkCYOIW4oLOHmT9gD6x0BOo2PSfV/EDL8FAJvcFFJazVYpTXUkn4eNy1qOaSLw== X-Received: by 2002:a05:6214:c82:b0:46a:b677:e284 with SMTP id r2-20020a0562140c8200b0046ab677e284mr32356532qvr.28.1655072066376; Sun, 12 Jun 2022 15:14:26 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id ew14-20020a05622a514e00b00304ef46c06dsm3835854qtb.57.2022.06.12.15.14.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jun 2022 15:14:26 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Heinrich Schuchardt Cc: Simon Glass , Sean Anderson Subject: [PATCH v2 12/14] mkimage: Add long options Date: Sun, 12 Jun 2022 18:14:09 -0400 Message-Id: <20220612221411.1608406-13-seanga2@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220612221411.1608406-1-seanga2@gmail.com> References: <20220612221411.1608406-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The mkimage command has had many options added over the years. Unfortunately, we are starting to run out of short options. Recent options don't have any obvious relation to their meaning (e.g. -o/-g). Fortunately, long options exist. Add long options for each current short option. For the curious, the remaining short options are HIkLmMPQSuUwWXyYzZ. Signed-off-by: Sean Anderson --- Changes in v2: - New doc/mkimage.1 | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/mkimage.c | 45 +++++++++++++++++++++++++++++++-- 2 files changed, 109 insertions(+), 2 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index f2ccb9d464..d48de7e777 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -57,20 +57,28 @@ checksums. It also supports verified boot. . .TP .B \-h +.TQ +.B \-\-help Print a help message and exit. . .TP .B \-l +.TQ +.B \-\-list .B mkimage lists the information contained in the header of an existing U-Boot image. . .TP .B \-s +.TQ +.B \-\-no\-copy Don't copy in the image data. Depending on the image type, this may create just the header, everything but the image data, or nothing at all. . .TP .BI \-T " image-type" +.TQ +.BI \-\-type " image-type" Parse image file as .IR image-type . Pass @@ -82,26 +90,36 @@ autodetected. . .TP .B \-q +.TQ +.B \-\-quiet Quiet. Don't print the image header. . .TP .B \-v +.TQ +.B \-\-verbose Verbose. Print file names as they are added to the image. . .TP .B \-V +.TQ +.B \-\-version Print version information and exit. . .SS Options for creating legacy or \(lqauto\(rq images . .TP .BI \-A " architecture" +.TQ +.BI \-\-architecture " architecture" Set the architecture. Pass .B \-h as the architecture to see the list of supported architectures. . .TP .BI \-O " os" +.TQ +.BI \-\-os " os" Set the operating system. The U-Boot .I bootm command changes boot method based on the OS type. @@ -113,6 +131,8 @@ to see the list of supported OSs. . .TP .BI \-C " compression-type" +.TQ +.BI \-\-compression " compression-type" Set the compression type. The image data should have already been compressed using this compression type. .B mkimage @@ -125,12 +145,16 @@ to see the list of supported compression types. . .TP .BI \-a " load-address" +.TQ +.BI \-\-load\-address " load-address" Set the absolute address to load the image data to. .I load-address will be interpreted as a hexadecimal number. . .TP .BI \-e " entry-point" +.TQ +.BI \-\-entry\-point " entry-point" Set the absolute address of the image entry point. The U-Boot .I bootm command will jump to this address after loading the image. @@ -139,11 +163,15 @@ will be interpreted as a hexadecimal number. . .TP .BI \-n " image-name" +.TQ +.BI \-\-primary\-image " image-name" Set the image name to .IR image-name . . .TP .BI \-R " secondary-image-name" +.TQ +.BI \-\-secondary\-image " image-name" Some image types support a second image for additional data. For these types, use .B \-R @@ -175,6 +203,8 @@ T} . .TP .BI \-d " image-data-file" +.TQ +.BI \-\-image " image-data-file" Use image data from .IR image-data-file . If the @@ -189,6 +219,8 @@ then multiple images may be specified, separated by colons: . .TP .B \-x +.TQ +.B \-\-xip Set the .I XIP (execute in place) flag. The U-Boot @@ -200,15 +232,21 @@ accessible at the load address (such as via memory-mapped flash). . .TP .BI \-b " device-tree-file" +.TQ +.BI \-\-device\-tree " device-tree-file" Appends the device tree binary file (.dtb) to the FIT. . .TP .BI \-c " comment" +.TQ +.BI \-\-comment " comment" Specifies a comment to be added when signing. This is typically a message which describes how the image was signed or some other useful information. . .TP .BI \-D " dtc-options" +.TQ +.BI \-\-dtcopts " dtc-options" Provide additional options to the device tree compiler when creating the image. See .BR dtc (1) @@ -216,6 +254,8 @@ for documentation of possible options. . .TP .BI \-E +.TQ +.BI \-\-external After processing, move the image data outside the FIT and store a data offset in the FIT. Images will be placed one after the other immediately after the FIT, with each one aligned to a 4-byte boundary. The existing \(oqdata\(cq property @@ -225,11 +265,15 @@ properties. A \(oqdata-offset\(cq of 0 indicates that it starts in the first . .TP .BI \-B " alignment" +.TQ +.BI \-\-alignment " alignment" The alignment, in hexadecimal, that external data will be aligned to. This option only has an effect when \-E is specified. . .TP .BI \-p " external-position" +.TQ +.BI \-\-position " external-position" Place external data at a static external position. Instead of writing a \(oqdata-offset\(cq property defining the offset from the end of the FIT, .B \-p @@ -240,6 +284,8 @@ for details on using external data. . .TP \fB\-f \fIimage-tree-source-file\fR | \fBauto +.TQ +\fB\-\-fit \fIimage-tree-source-file\fR | \fBauto Image tree source file that describes the structure and contents of the FIT image. .IP @@ -255,6 +301,8 @@ is required. . .TP .B \-F +.TQ +.B \-\-update Indicates that an existing FIT image should be modified. No dtc compilation will be performed and .B \-f @@ -263,10 +311,14 @@ after initial image creation. . .TP .BI \-i " ramdisk-file" +.TQ +.BI \-\-initramfs " ramdisk-file" Append a ramdisk or initramfs file to the image. . .TP .BI \-k " key-directory" +.TQ +.BI \-\-key\-dir " key-directory" Specifies the directory containing keys to use for signing. This directory should contain a private key file .IR name .key @@ -282,11 +334,15 @@ but may be overridden using . .TP .BI \-G " key-file" +.TQ +.BI \-\-key\-file " key-file" Specifies the private key file to use when signing. This option may be used instead of \-k. . .TP .BI \-K " key-destination" +.TQ +.BI \-\-key\-dest " key-destination" Specifies a compiled device tree binary file (typically .dtb) to write public key information into. When a private key is used to sign an image, the corresponding public key is written into this file for for run-time @@ -295,6 +351,8 @@ CONFIG_OF_CONTROL in U-Boot. . .TP .BI \-g " key-name-hint" +.TQ +.BI \-\-key\-name\-hint " key-name-hint" Overrides the signature node's \(oqkey-name-hint\(cq property. This is especially useful when signing an image with .BR "\-f auto" . @@ -309,6 +367,8 @@ must be specified as well. . .TP .BI \-o " crypto" , checksum +.TQ +.BI \-\-algo " crypto" , checksum Specifies the algorithm to be used for signing a FIT image. The default is taken from the signature node's \(oqalgo\(cq property. The valid values for @@ -341,18 +401,24 @@ sha512 . .TP .B \-r +.TQ +.B \-\-key\-required Specifies that keys used to sign the FIT are required. This means that they must be verified for the image to boot. Without this option, the verification will be optional (useful for testing but not for release). . .TP .BI \-N " engine" +.TQ +.BI \-\-engine " engine" The openssl engine to use when signing and verifying the image. For a complete list of available engines, refer to .BR engine (1). . .TP .B \-t +.TQ +.B \-\-touch Update the timestamp in the FIT. .IP Normally the FIT timestamp is created the first time mkimage runs, diff --git a/tools/mkimage.c b/tools/mkimage.c index 0e1198b411..597cb3a5ce 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -11,6 +11,7 @@ #include "mkimage.h" #include "imximage.h" #include +#include #include #include #ifdef __linux__ @@ -134,6 +135,7 @@ static void usage(const char *msg) fprintf(stderr, " %s -V ==> print version information and exit\n", params.cmdname); fprintf(stderr, "Use '-T list' to see a list of available image types\n"); + fprintf(stderr, "Long options are available; read the man page for details\n"); exit(EXIT_FAILURE); } @@ -156,6 +158,45 @@ static int add_content(int type, const char *fname) return 0; } +static const char optstring[] = + "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx"; + +static const struct option longopts[] = { + { "load-address", required_argument, NULL, 'a' }, + { "architecture", required_argument, NULL, 'A' }, + { "device-tree", required_argument, NULL, 'b' }, + { "alignment", required_argument, NULL, 'B' }, + { "comment", required_argument, NULL, 'c' }, + { "compression", required_argument, NULL, 'C' }, + { "image", required_argument, NULL, 'd' }, + { "dtcopts", required_argument, NULL, 'D' }, + { "entry-point", required_argument, NULL, 'e' }, + { "external", no_argument, NULL, 'E' }, + { "fit", required_argument, NULL, 'f' }, + { "update", no_argument, NULL, 'F' }, + { "key-name-hint", required_argument, NULL, 'g' }, + { "key-file", required_argument, NULL, 'G' }, + { "help", no_argument, NULL, 'h' }, + { "initramfs", required_argument, NULL, 'i' }, + { "key-dir", required_argument, NULL, 'k' }, + { "key-dest", required_argument, NULL, 'K' }, + { "list", no_argument, NULL, 'l' }, + { "config", required_argument, NULL, 'n' }, + { "engine", required_argument, NULL, 'N' }, + { "algo", required_argument, NULL, 'o' }, + { "os", required_argument, NULL, 'O' }, + { "position", required_argument, NULL, 'p' }, + { "quiet", no_argument, NULL, 'q' }, + { "key-required", no_argument, NULL, 'r' }, + { "secondary-config", required_argument, NULL, 'R' }, + { "no-copy", no_argument, NULL, 's' }, + { "touch", no_argument, NULL, 't' }, + { "type", required_argument, NULL, 'T' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "xip", no_argument, NULL, 'x' }, +}; + static void process_args(int argc, char **argv) { char *ptr; @@ -163,8 +204,8 @@ static void process_args(int argc, char **argv) char *datafile = NULL; int opt; - while ((opt = getopt(argc, argv, - "a:A:b:B:c:C:d:D:e:Ef:Fg:G:k:i:K:ln:N:p:o:O:rR:qstT:vVx")) != -1) { + while ((opt = getopt_long(argc, argv, optstring, + longopts, NULL)) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); -- 2.35.1