Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7258415ybl; Wed, 15 Jan 2020 18:57:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyKEI/TLL3jGgllORGAnXGxd31JRIvrm4+GFnPKy820ApTVBLwTPHaW0C+OjSBPwmlXUK6d X-Received: by 2002:a05:6808:3b4:: with SMTP id n20mr2438190oie.123.1579143430937; Wed, 15 Jan 2020 18:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579143430; cv=none; d=google.com; s=arc-20160816; b=ePi48wioWGrlmOThLV1JQEpuAa8vNa3eElnfmBEwoyxz99eQuE6veH6GYdu5WsLywe 4YEhj6IbsOlLKrn4GHAxQ2qMUjLGzV7WSoQTmXc4NPtUpUpTscPLXbARZVQy3so7RsJg Sp2lGdKtubiNzWA/AUSphd6WKJJTXKT2xJq/IuJ5LQUsP7ysZH+gInfGkePezLMGJKYn c3bnAUz9yjaZYAVTvtDS0luwReJj89TP416hsz9Dp7oL78IlevRHzqk9qwTZ4jeffzQV RbPqsko7kkxapa3w7Qe+j6VvSEb6Qmxf+9hyMOy8FoKEJh5tBvbygL74DXfOI4+sEZ+A LvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ARExtWnex4SdZkacph5T4DoqZwkog9wYk46v+G2my3U=; b=CuRo80we1PUgQjfk/ER4gwTOBtD/w24jF1yYXPu/noi+y6WcHQG15FYzdn5JvoG17R Lq2MP/iPMRhaZmY9j45VpOU8o6I3LNpJYgCVrTzrqniq+PNvTzxXS0EDDpc7FkqCgVUg QA84bLhdOrp+pfz/nYSK6qSwWRu93kCdP+41WSAQk0iTggg8F743CzTnTkBDckPTmNG6 D/j3PSjPIpA+eBCujf3sF+Tfqxtw20GQYN5k/7PtqcyKb34539VX+GwrZMQuyhs9tiDg Z+FiSteL7NaQ/Uhv/WkRP6birwdtqwIGVd8buwvZLMf9BN6vW7hMKGh7mY4qE9OTHQcf OXFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b="ZPeO/qK4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si10832166oib.61.2020.01.15.18.56.59; Wed, 15 Jan 2020 18:57:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b="ZPeO/qK4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729878AbgAPA5w (ORCPT + 99 others); Wed, 15 Jan 2020 19:57:52 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:33349 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgAPA5w (ORCPT ); Wed, 15 Jan 2020 19:57:52 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47ym581jzNz9sR0; Thu, 16 Jan 2020 11:57:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1579136268; bh=NFWvXfvHC7UESUpRUwyZiWw9YmMUD96laMG2kvm+8QA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZPeO/qK4XhPI8W819KTOvE+cwkwGFXZK4tJT8MyspF3I/AB1QWDzu4z25p+iMtF/S m0rwJw5FHXlbWQUiXE5EfCQuDDhNkY0vnsrXqqdm+DwlKOLkZTHPhha5u2IUT+I4rZ dgMbeYHBGonofYnUPAFRMZltYelNKcHTNbmsnHX0= Date: Thu, 16 Jan 2020 10:57:41 +1000 From: David Gibson To: Alexandre Torgue Cc: robh+dt@kernel.org, Frank Rowand , Masahiro Yamada , Michal Marek , sjg@chromium.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, devicetree-compiler@vger.kernel.org Subject: Re: [RFC PATCH 1/3] dtc: Add dtb build information option Message-ID: <20200116005741.GB54439@umbus> References: <20200113181625.3130-1-alexandre.torgue@st.com> <20200113181625.3130-2-alexandre.torgue@st.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gj572EiMnwbLXET9" Content-Disposition: inline In-Reply-To: <20200113181625.3130-2-alexandre.torgue@st.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --gj572EiMnwbLXET9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 13, 2020 at 07:16:23PM +0100, Alexandre Torgue wrote: > This commit adds the possibility to add build information for a DTB. > Build information can be: build date, DTS version, "who built the DTB" > (same kind of information that we get in Linux with the Linux banner). >=20 > To do this, an extra option "-B" using an information file as argument > has been added. If this option is used, input device tree is appended with > a new string property "Build-info". This property is built with informati= on > found in information file given as argument. This file has to be generated > by user and shouldn't exceed 256 bytes. >=20 > Signed-off-by: Alexandre Torgue At the very least, this patch of the series will need to be sent to upstream dtc first. I'm also not terribly clear on what you're trying to accomplish here, and why it's useful. Since you're doing this specifically for use with dtbs built in the kernel build, could you just use a: Build-info =3D /incbin/ "build-info.txt"; in each of the in-kernel .dts files? Altough you probably shouldn't use "Build-info" since it doesn't match device tree property naming conventions. My suggestion would be "linux,build-info". > diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c > index bdb3f5945699..294828bac20b 100644 > --- a/scripts/dtc/dtc.c > +++ b/scripts/dtc/dtc.c > @@ -18,6 +18,7 @@ int padsize; /* Additional padding to blob */ > int alignsize; /* Additional padding to blob accroding to the alignsize= */ > int phandle_format =3D PHANDLE_EPAPR; /* Use linux,phandle or phandle pr= operties */ > int generate_symbols; /* enable symbols & fixup support */ > +int generate_build_info; /* Add build information: time, source version = =2E.. */ > int generate_fixups; /* suppress generation of fixups on symbol support= */ > int auto_label_aliases; /* auto generate labels -> aliases */ > int annotate; /* Level of annotation: 1 for input source location > @@ -45,9 +46,42 @@ static void fill_fullpaths(struct node *tree, const ch= ar *prefix) > fill_fullpaths(child, tree->fullpath); > } > =20 > +static void fill_build_info(struct node *tree, const char *fname) > +{ > + struct data d =3D empty_data; > + char *tmp; > + FILE *f; > + int len; > + > + tmp =3D xmalloc(sizeof(char) * 256); > + > + f =3D fopen(fname, "r"); > + if (!f) { > + printf("Can't open file %s\n", fname); > + return; > + } > + > + len =3D fread(tmp, sizeof(char), 256, f); > + if (!len) { > + printf("Can't read file %s\n", fname); > + fclose(f); > + free(tmp); > + } > + fclose(f); You have no useful error reporting if the file is larger than the limit. > + > + tmp[len - 1] =3D '\0'; > + > + d =3D data_add_marker(d, TYPE_STRING, tmp); > + d =3D data_append_data(d, tmp, len); You can essentially do this better with data_copy_file(). > + > + add_property(tree, build_property("Build-info", d, NULL)); > + > + free(tmp); > +} > + > /* Usage related data. */ > static const char usage_synopsis[] =3D "dtc [options] "; > -static const char usage_short_opts[] =3D "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E= :@AThv"; > +static const char usage_short_opts[] =3D "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E= :@AT:B:hv"; > static struct option const usage_long_opts[] =3D { > {"quiet", no_argument, NULL, 'q'}, > {"in-format", a_argument, NULL, 'I'}, > @@ -69,6 +103,7 @@ static struct option const usage_long_opts[] =3D { > {"symbols", no_argument, NULL, '@'}, > {"auto-alias", no_argument, NULL, 'A'}, > {"annotate", no_argument, NULL, 'T'}, > + {"build-info", a_argument, NULL, 'B'}, > {"help", no_argument, NULL, 'h'}, > {"version", no_argument, NULL, 'v'}, > {NULL, no_argument, NULL, 0x0}, > @@ -106,6 +141,7 @@ static const char * const usage_opts_help[] =3D { > "\n\tEnable generation of symbols", > "\n\tEnable auto-alias of labels", > "\n\tAnnotate output .dts with input source file and line (-T -T for mo= re details)", > + "\n\tAdd build information (date, version, ...) in the blob", > "\n\tPrint this help and exit", > "\n\tPrint version and exit", > NULL, > @@ -164,6 +200,7 @@ int main(int argc, char *argv[]) > const char *outform =3D NULL; > const char *outname =3D "-"; > const char *depname =3D NULL; > + const char *version =3D NULL; > bool force =3D false, sort =3D false; > const char *arg; > int opt; > @@ -256,9 +293,12 @@ int main(int argc, char *argv[]) > case 'T': > annotate++; > break; > - > case 'h': > usage(NULL); > + case 'B': > + version =3D optarg; > + generate_build_info =3D 1; > + break; > default: > usage("unknown option"); > } > @@ -296,14 +336,17 @@ int main(int argc, char *argv[]) > } > if (annotate && (!streq(inform, "dts") || !streq(outform, "dts"))) > die("--annotate requires -I dts -O dts\n"); > - if (streq(inform, "dts")) > + if (streq(inform, "dts")) { > dti =3D dt_from_source(arg); > - else if (streq(inform, "fs")) > + if (generate_build_info) > + fill_build_info(dti->dt, version); > + } else if (streq(inform, "fs")) { > dti =3D dt_from_fs(arg); > - else if(streq(inform, "dtb")) > + } else if (streq(inform, "dtb")) { > dti =3D dt_from_blob(arg); > - else > + } else { > die("Unknown input format \"%s\"\n", inform); > + } > =20 > dti->outname =3D outname; > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --gj572EiMnwbLXET9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl4ftQIACgkQbDjKyiDZ s5KzNhAA4xu6t0uG6xcZ/G1wNX3HVW1UGJ7aleePRrxOTUFMG3568GE/Cnbj3RmG Y8Is7j9vRJb53GgE4EFPxgneVXzKviAXP7R8cy8AEBzM3esnmleq8WC3bUCQY4AC mVHpsRk1GuAjYdsoXF+k1CSA5agjt5RUlsv/pNFPFfISKck1AuYz+yLt24INAzZH yH+aJMohYZbGq6PYZUPtK/CHZEo7KFP+YdMq214JU4P/zrMc0tQ+auuYDwVBwBBP 7WsuO/agnc+wklSlhjdGXFj48X2ALThqxJzYwYZSPXA0waWngdqDOvHVaufw454K CMm0ISit01OEszGWN6Mh7HZmco2b3w4rrN3Gxvg/BChGBkBEkZw8VqetVHWiEIPi JgjaB3FZQ4vkdOGZQ38OO/gcfkSYn9n9Aq8pVg1YhHcggL3jHqEbRXOe9TK1tU8B QzDbrpYdfGpctnR2aO9bY3znUNNZ4F4UGObX5JBSHR7TnFed2mxC4SN/j/8wRlE4 gH3BhM+4Kbjy9C6q9fcSb+6AaJrg5yTzeJLLiyvdVIhaF0iGNeydE1F9GjdnOhwr bhSaaBqB97qsAszfuN+Moxr4BrVuZePxl+oEy/QdOt+U4MB1cSLQxGl9xlz+J53d V5PF3y2VyfcJrX7I28GY2sGpu2ocWPsXP+7to/G/lxZargPS5/0= =4txu -----END PGP SIGNATURE----- --gj572EiMnwbLXET9--