Message ID | 20200113181625.3130-2-alexandre.torgue@st.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add device tree build information | expand |
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). > > 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 information > found in information file given as argument. This file has to be generated > by user and shouldn't exceed 256 bytes. > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> 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 = /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 = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties */ > int generate_symbols; /* enable symbols & fixup support */ > +int generate_build_info; /* Add build information: time, source version ... */ > 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 char *prefix) > fill_fullpaths(child, tree->fullpath); > } > > +static void fill_build_info(struct node *tree, const char *fname) > +{ > + struct data d = empty_data; > + char *tmp; > + FILE *f; > + int len; > + > + tmp = xmalloc(sizeof(char) * 256); > + > + f = fopen(fname, "r"); > + if (!f) { > + printf("Can't open file %s\n", fname); > + return; > + } > + > + len = 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] = '\0'; > + > + d = data_add_marker(d, TYPE_STRING, tmp); > + d = 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[] = "dtc [options] <input file>"; > -static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv"; > +static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AT:B:hv"; > static struct option const usage_long_opts[] = { > {"quiet", no_argument, NULL, 'q'}, > {"in-format", a_argument, NULL, 'I'}, > @@ -69,6 +103,7 @@ static struct option const usage_long_opts[] = { > {"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[] = { > "\n\tEnable generation of symbols", > "\n\tEnable auto-alias of labels", > "\n\tAnnotate output .dts with input source file and line (-T -T for more 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 = NULL; > const char *outname = "-"; > const char *depname = NULL; > + const char *version = NULL; > bool force = false, sort = 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 = optarg; > + generate_build_info = 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 = 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 = dt_from_fs(arg); > - else if(streq(inform, "dtb")) > + } else if (streq(inform, "dtb")) { > dti = dt_from_blob(arg); > - else > + } else { > die("Unknown input format \"%s\"\n", inform); > + } > > dti->outname = outname; >
Hi David On 1/16/20 1:57 AM, David Gibson wrote: > 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). >> >> 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 information >> found in information file given as argument. This file has to be generated >> by user and shouldn't exceed 256 bytes. >> >> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > At the very least, this patch of the series will need to be sent to > upstream dtc first. Ok sorry. I thought that sending all the series would give more information. > > I'm also not terribly clear on what you're trying to accomplish here, > and why it's useful. Let's take Kernel boot at example (but could be extend to other DTB "users" like U-Boot). When Linux kernel booting we get a log that gives useful information about kernel image: source version, build date, people who built the kernel image, compiler version. This information is useful for debug and support. The aim is to get same kind of information but for the DTB. > > Since you're doing this specifically for use with dtbs built in the > kernel build, could you just use a: > Build-info = /incbin/ "build-info.txt"; > in each of the in-kernel .dts files? My first idea was to not modify all existing .dts files. Adding an extra option in dtc is (for me) the softer way to do it. I mean, compile information should come through compiler without modify .dts files outside from dtc. In this way it will be easy to everybody using dtc (inside our outside Linux tree) to add dtb build info (even if they don't how to write a dts file). > > 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". Yes I agree but something like "dtb-info" would be better as this property can be added when dtb is built for Linux but also for U-Boot. > >> 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 = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties */ >> int generate_symbols; /* enable symbols & fixup support */ >> +int generate_build_info; /* Add build information: time, source version ... */ >> 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 char *prefix) >> fill_fullpaths(child, tree->fullpath); >> } >> >> +static void fill_build_info(struct node *tree, const char *fname) >> +{ >> + struct data d = empty_data; >> + char *tmp; >> + FILE *f; >> + int len; >> + >> + tmp = xmalloc(sizeof(char) * 256); >> + >> + f = fopen(fname, "r"); >> + if (!f) { >> + printf("Can't open file %s\n", fname); >> + return; >> + } >> + >> + len = 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. Ok. To fix. > >> + >> + tmp[len - 1] = '\0'; >> + >> + d = data_add_marker(d, TYPE_STRING, tmp); >> + d = data_append_data(d, tmp, len); > > You can essentially do this better with data_copy_file(). I will try with data_copy_file(). Thanks. > >> + >> + add_property(tree, build_property("Build-info", d, NULL)); >> + >> + free(tmp); >> +} >> + >> /* Usage related data. */ >> static const char usage_synopsis[] = "dtc [options] <input file>"; >> -static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv"; >> +static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AT:B:hv"; >> static struct option const usage_long_opts[] = { >> {"quiet", no_argument, NULL, 'q'}, >> {"in-format", a_argument, NULL, 'I'}, >> @@ -69,6 +103,7 @@ static struct option const usage_long_opts[] = { >> {"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[] = { >> "\n\tEnable generation of symbols", >> "\n\tEnable auto-alias of labels", >> "\n\tAnnotate output .dts with input source file and line (-T -T for more 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 = NULL; >> const char *outname = "-"; >> const char *depname = NULL; >> + const char *version = NULL; >> bool force = false, sort = 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 = optarg; >> + generate_build_info = 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 = 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 = dt_from_fs(arg); >> - else if(streq(inform, "dtb")) >> + } else if (streq(inform, "dtb")) { >> dti = dt_from_blob(arg); >> - else >> + } else { >> die("Unknown input format \"%s\"\n", inform); >> + } >> >> dti->outname = outname; >> >
On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > Hi David > > On 1/16/20 1:57 AM, David Gibson wrote: > > 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). > > > > > > 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 information > > > found in information file given as argument. This file has to be generated > > > by user and shouldn't exceed 256 bytes. > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > At the very least, this patch of the series will need to be sent to > > upstream dtc first. > > Ok sorry. I thought that sending all the series would give more > information. That's fair enough, but in order to merge, you'll need to post against upstream dtc. > > I'm also not terribly clear on what you're trying to accomplish here, > > and why it's useful. > > Let's take Kernel boot at example (but could be extend to other DTB "users" > like U-Boot). When Linux kernel booting we get a log that gives useful > information about kernel image: source version, build date, people who built > the kernel image, compiler version. This information is useful for debug and > support. The aim is to get same kind of information but for the DTB. > > > Since you're doing this specifically for use with dtbs built in the > > kernel build, could you just use a: > > Build-info = /incbin/ "build-info.txt"; > > in each of the in-kernel .dts files? > > My first idea was to not modify all existing .dts files. Adding an extra > option in dtc is (for me) the softer way to do it. I mean, compile > information should come through compiler without modify .dts files outside > from dtc. In this way it will be easy to everybody using dtc (inside our > outside Linux tree) to add dtb build info (even if they don't how to write a > dts file). But you're not really having this information coming from the compiler. Instead you're adding a compiler option that just force includes another file into the generated tree, and it's up to your build scripts to put something useful into that file. I don't really see that as preferable to modifying the .dts files. I also dislike the fact that the option as proposed is much more general than the name suggests, but also very similar too, but much more specific than the existing /incbin/ option. What might be better would be to have a dtc option which force appends an extra .dts to the mail .dts compiled. You can then put an overlay template in that file, something like: &{/} { linux,build-info = /incbin/ "build-info.txt; }
On Fri, Jan 17, 2020 at 6:26 AM David Gibson <david@gibson.dropbear.id.au> wrote: > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > Hi David > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > 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). > > > > > > > > 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 information > > > > found in information file given as argument. This file has to be generated > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > At the very least, this patch of the series will need to be sent to > > > upstream dtc first. > > > > Ok sorry. I thought that sending all the series would give more > > information. > > That's fair enough, but in order to merge, you'll need to post against > upstream dtc. > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > and why it's useful. > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > like U-Boot). When Linux kernel booting we get a log that gives useful > > information about kernel image: source version, build date, people who built > > the kernel image, compiler version. This information is useful for debug and > > support. The aim is to get same kind of information but for the DTB. > > > > > Since you're doing this specifically for use with dtbs built in the > > > kernel build, could you just use a: > > > Build-info = /incbin/ "build-info.txt"; > > > in each of the in-kernel .dts files? > > > > My first idea was to not modify all existing .dts files. Adding an extra > > option in dtc is (for me) the softer way to do it. I mean, compile > > information should come through compiler without modify .dts files outside > > from dtc. In this way it will be easy to everybody using dtc (inside our > > outside Linux tree) to add dtb build info (even if they don't how to write a > > dts file). > > But you're not really having this information coming from the > compiler. Instead you're adding a compiler option that just force > includes another file into the generated tree, and it's up to your > build scripts to put something useful into that file. > > I don't really see that as preferable to modifying the .dts files. > > I also dislike the fact that the option as proposed is much more > general than the name suggests, but also very similar too, but much > more specific than the existing /incbin/ option. > > What might be better would be to have a dtc option which force appends > an extra .dts to the mail .dts compiled. You can then put an overlay > template in that file, something like: > > &{/} { > linux,build-info = /incbin/ "build-info.txt; > } I like this suggestion either as an include another dts file or an overlay. The latter could be useful as a way to maintain current dtb files while splitting the source files into base and overlay dts files. But no, let's not prepend this with 'linux'. It's not a property specific for Linux to consume. Rob
David, Rob, On 1/17/20 3:43 PM, Rob Herring wrote: > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > <david@gibson.dropbear.id.au> wrote: >> >> On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: >>> Hi David >>> >>> On 1/16/20 1:57 AM, David Gibson wrote: >>>> 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). >>>>> >>>>> 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 information >>>>> found in information file given as argument. This file has to be generated >>>>> by user and shouldn't exceed 256 bytes. >>>>> >>>>> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> >>>> >>>> At the very least, this patch of the series will need to be sent to >>>> upstream dtc first. >>> >>> Ok sorry. I thought that sending all the series would give more >>> information. >> >> That's fair enough, but in order to merge, you'll need to post against >> upstream dtc. ok >> >>>> I'm also not terribly clear on what you're trying to accomplish here, >>>> and why it's useful. >>> >>> Let's take Kernel boot at example (but could be extend to other DTB "users" >>> like U-Boot). When Linux kernel booting we get a log that gives useful >>> information about kernel image: source version, build date, people who built >>> the kernel image, compiler version. This information is useful for debug and >>> support. The aim is to get same kind of information but for the DTB. >>> >>>> Since you're doing this specifically for use with dtbs built in the >>>> kernel build, could you just use a: >>>> Build-info = /incbin/ "build-info.txt"; >>>> in each of the in-kernel .dts files? >>> >>> My first idea was to not modify all existing .dts files. Adding an extra >>> option in dtc is (for me) the softer way to do it. I mean, compile >>> information should come through compiler without modify .dts files outside >>> from dtc. In this way it will be easy to everybody using dtc (inside our >>> outside Linux tree) to add dtb build info (even if they don't how to write a >>> dts file). >> >> But you're not really having this information coming from the >> compiler. Instead you're adding a compiler option that just force >> includes another file into the generated tree, and it's up to your >> build scripts to put something useful into that file. >> >> I don't really see that as preferable to modifying the .dts files. I agree. I took example on kernel version info. It doesn't come from gcc but from auto-generated file. I thought it was the easier way to process. But I understand your concerns. As it is not generated by dtc itself, dtc should not be modified. >> >> I also dislike the fact that the option as proposed is much more >> general than the name suggests, but also very similar too, but much >> more specific than the existing /incbin/ option. >> >> What might be better would be to have a dtc option which force appends >> an extra .dts to the mail .dts compiled. You can then put an overlay >> template in that file, something like: >> >> &{/} { >> linux,build-info = /incbin/ "build-info.txt; >> } > > I like this suggestion either as an include another dts file or an > overlay. The latter could be useful as a way to maintain current dtb > files while splitting the source files into base and overlay dts > files. First suggestion will imply to modify an huge part of dts file (not a big modification but a lot :)). Second one (dtbo) sounds good. In this case this dtso will be created from build-info.txt and applied when dtb is built. So no impacts on current dts file. I'm right ? Alex > > But no, let's not prepend this with 'linux'. It's not a property > specific for Linux to consume. > > Rob >
On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > <david@gibson.dropbear.id.au> wrote: > > > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > > Hi David > > > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > > 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). > > > > > > > > > > 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 information > > > > > found in information file given as argument. This file has to be generated > > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > > > At the very least, this patch of the series will need to be sent to > > > > upstream dtc first. > > > > > > Ok sorry. I thought that sending all the series would give more > > > information. > > > > That's fair enough, but in order to merge, you'll need to post against > > upstream dtc. > > > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > > and why it's useful. > > > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > > like U-Boot). When Linux kernel booting we get a log that gives useful > > > information about kernel image: source version, build date, people who built > > > the kernel image, compiler version. This information is useful for debug and > > > support. The aim is to get same kind of information but for the DTB. > > > > > > > Since you're doing this specifically for use with dtbs built in the > > > > kernel build, could you just use a: > > > > Build-info = /incbin/ "build-info.txt"; > > > > in each of the in-kernel .dts files? > > > > > > My first idea was to not modify all existing .dts files. Adding an extra > > > option in dtc is (for me) the softer way to do it. I mean, compile > > > information should come through compiler without modify .dts files outside > > > from dtc. In this way it will be easy to everybody using dtc (inside our > > > outside Linux tree) to add dtb build info (even if they don't how to write a > > > dts file). > > > > But you're not really having this information coming from the > > compiler. Instead you're adding a compiler option that just force > > includes another file into the generated tree, and it's up to your > > build scripts to put something useful into that file. > > > > I don't really see that as preferable to modifying the .dts files. > > > > I also dislike the fact that the option as proposed is much more > > general than the name suggests, but also very similar too, but much > > more specific than the existing /incbin/ option. > > > > What might be better would be to have a dtc option which force appends > > an extra .dts to the mail .dts compiled. You can then put an overlay > > template in that file, something like: > > > > &{/} { > > linux,build-info = /incbin/ "build-info.txt; > > } > > I like this suggestion either as an include another dts file or an > overlay. Sorry, to be clear what I'm talking about here is just including another dts file, and using the compile-type overlay syntax. This is not the same as .dtbo style runtime overlays (though the final result is about the same in this case). > The latter could be useful as a way to maintain current dtb > files while splitting the source files into base and overlay dts > files. > > But no, let's not prepend this with 'linux'. It's not a property > specific for Linux to consume. It's not really about who consumes it. It's about defining a namespace for the new property to exist in, since it's not part of a relevant standard (if we wanted to make it such, we should pin down what goes in there with much more precision). This is specific to files built in the Linux tree, hence my suggestion of "linux", whoever ends up consuming them.
On Fri, Jan 17, 2020 at 04:11:19PM +0100, Alexandre Torgue wrote: > David, Rob, > > On 1/17/20 3:43 PM, Rob Herring wrote: > > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > > <david@gibson.dropbear.id.au> wrote: > > > > > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > > > Hi David > > > > > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > > > 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). > > > > > > > > > > > > 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 information > > > > > > found in information file given as argument. This file has to be generated > > > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > > > > > At the very least, this patch of the series will need to be sent to > > > > > upstream dtc first. > > > > > > > > Ok sorry. I thought that sending all the series would give more > > > > information. > > > > > > That's fair enough, but in order to merge, you'll need to post against > > > upstream dtc. > > ok > > > > > > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > > > and why it's useful. > > > > > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > > > like U-Boot). When Linux kernel booting we get a log that gives useful > > > > information about kernel image: source version, build date, people who built > > > > the kernel image, compiler version. This information is useful for debug and > > > > support. The aim is to get same kind of information but for the DTB. > > > > > > > > > Since you're doing this specifically for use with dtbs built in the > > > > > kernel build, could you just use a: > > > > > Build-info = /incbin/ "build-info.txt"; > > > > > in each of the in-kernel .dts files? > > > > > > > > My first idea was to not modify all existing .dts files. Adding an extra > > > > option in dtc is (for me) the softer way to do it. I mean, compile > > > > information should come through compiler without modify .dts files outside > > > > from dtc. In this way it will be easy to everybody using dtc (inside our > > > > outside Linux tree) to add dtb build info (even if they don't how to write a > > > > dts file). > > > > > > But you're not really having this information coming from the > > > compiler. Instead you're adding a compiler option that just force > > > includes another file into the generated tree, and it's up to your > > > build scripts to put something useful into that file. > > > > > > I don't really see that as preferable to modifying the .dts files. > > I agree. I took example on kernel version info. It doesn't come from gcc but > from auto-generated file. I thought it was the easier way to process. But I > understand your concerns. As it is not generated by dtc itself, dtc should > not be modified. > > > > > > > I also dislike the fact that the option as proposed is much more > > > general than the name suggests, but also very similar too, but much > > > more specific than the existing /incbin/ option. > > > > > > What might be better would be to have a dtc option which force appends > > > an extra .dts to the mail .dts compiled. You can then put an overlay > > > template in that file, something like: > > > > > > &{/} { > > > linux,build-info = /incbin/ "build-info.txt; > > > } > > > > I like this suggestion either as an include another dts file or an > > overlay. The latter could be useful as a way to maintain current dtb > > files while splitting the source files into base and overlay dts > > files. > > First suggestion will imply to modify an huge part of dts file (not a big > modification but a lot :)). I'm not exactly sure what you're meaning by the "first suggestion" here. > Second one (dtbo) sounds good. In this case this dtso will be created from > build-info.txt and applied when dtb is built. So no impacts on current dts > file. I'm right ? This is not a dtbo, it's using the compile time overlaying syntax. .dtbo would be useless for this purpose, since the build information would be detached from the built dtb.
On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: >On Fri, Jan 17, 2020 at 6:26 AM David Gibson ><david@gibson.dropbear.id.au> wrote: ... >> What might be better would be to have a dtc option which force appends >> an extra .dts to the mail .dts compiled. You can then put an overlay >> template in that file, something like: >> >> &{/} { >> linux,build-info = /incbin/ "build-info.txt; >> } > >I like this suggestion either as an include another dts file or an >overlay. The latter could be useful as a way to maintain current dtb >files while splitting the source files into base and overlay dts >files. ACK, that sounds like it could be helpful. >But no, let's not prepend this with 'linux'. It's not a property >specific for Linux to consume. Right. We might be seeing the data coming through from U-Boot (or any other random bootloader) too. Cheers,
On Sun, Jan 19, 2020 at 12:41 AM David Gibson <david@gibson.dropbear.id.au> wrote: > > On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: > > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > > <david@gibson.dropbear.id.au> wrote: > > > > > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > > > Hi David > > > > > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > > > 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). > > > > > > > > > > > > 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 information > > > > > > found in information file given as argument. This file has to be generated > > > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > > > > > At the very least, this patch of the series will need to be sent to > > > > > upstream dtc first. > > > > > > > > Ok sorry. I thought that sending all the series would give more > > > > information. > > > > > > That's fair enough, but in order to merge, you'll need to post against > > > upstream dtc. > > > > > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > > > and why it's useful. > > > > > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > > > like U-Boot). When Linux kernel booting we get a log that gives useful > > > > information about kernel image: source version, build date, people who built > > > > the kernel image, compiler version. This information is useful for debug and > > > > support. The aim is to get same kind of information but for the DTB. > > > > > > > > > Since you're doing this specifically for use with dtbs built in the > > > > > kernel build, could you just use a: > > > > > Build-info = /incbin/ "build-info.txt"; > > > > > in each of the in-kernel .dts files? > > > > > > > > My first idea was to not modify all existing .dts files. Adding an extra > > > > option in dtc is (for me) the softer way to do it. I mean, compile > > > > information should come through compiler without modify .dts files outside > > > > from dtc. In this way it will be easy to everybody using dtc (inside our > > > > outside Linux tree) to add dtb build info (even if they don't how to write a > > > > dts file). > > > > > > But you're not really having this information coming from the > > > compiler. Instead you're adding a compiler option that just force > > > includes another file into the generated tree, and it's up to your > > > build scripts to put something useful into that file. > > > > > > I don't really see that as preferable to modifying the .dts files. > > > > > > I also dislike the fact that the option as proposed is much more > > > general than the name suggests, but also very similar too, but much > > > more specific than the existing /incbin/ option. > > > > > > What might be better would be to have a dtc option which force appends > > > an extra .dts to the mail .dts compiled. You can then put an overlay > > > template in that file, something like: > > > > > > &{/} { > > > linux,build-info = /incbin/ "build-info.txt; > > > } > > > > I like this suggestion either as an include another dts file or an > > overlay. > > Sorry, to be clear what I'm talking about here is just including > another dts file, and using the compile-type overlay syntax. This is > not the same as .dtbo style runtime overlays (though the final result > is about the same in this case). Ah, okay. That's probably easier to implement. > > The latter could be useful as a way to maintain current dtb > > files while splitting the source files into base and overlay dts > > files. > > > > But no, let's not prepend this with 'linux'. It's not a property > > specific for Linux to consume. > > It's not really about who consumes it. It's about defining a > namespace for the new property to exist in, since it's not part of a > relevant standard (if we wanted to make it such, we should pin down > what goes in there with much more precision). I can't think of any cases of the 'linux' prefix not being about who consumes it. And we often end up dropping 'linux' because it turns out to not be Linux specific. I don't care to see u-boot,build-info, freebsd,build-info, etc. when a given dtb can only have 1 of those. My intent is this property name is added to the DT spec, but I don't agree we should define what's in it beyond a string. It is information that is useful for humans identifying what the dtb was built from. Rob
On Tue, Jan 21, 2020 at 09:59:44AM -0600, Rob Herring wrote: >On Sun, Jan 19, 2020 at 12:41 AM David Gibson ><david@gibson.dropbear.id.au> wrote: >> >> It's not really about who consumes it. It's about defining a >> namespace for the new property to exist in, since it's not part of a >> relevant standard (if we wanted to make it such, we should pin down >> what goes in there with much more precision). > >I can't think of any cases of the 'linux' prefix not being about who >consumes it. And we often end up dropping 'linux' because it turns out >to not be Linux specific. I don't care to see u-boot,build-info, >freebsd,build-info, etc. when a given dtb can only have 1 of those. Yes, exactly. What would happen if somebody (tried to) fill in more than one of XXXX.build-info? It makes no sense. >My intent is this property name is added to the DT spec, but I don't >agree we should define what's in it beyond a string. It is information >that is useful for humans identifying what the dtb was built from. Nod - defining this as a free-form string lets people put their own information in, without us having to try and agree on a full spec which we'll need to update as ideas change.
Hi On 1/20/20 7:17 PM, Steve McIntyre wrote: > On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: >> On Fri, Jan 17, 2020 at 6:26 AM David Gibson >> <david@gibson.dropbear.id.au> wrote: > > ... > >>> What might be better would be to have a dtc option which force appends >>> an extra .dts to the mail .dts compiled. You can then put an overlay >>> template in that file, something like: >>> >>> &{/} { >>> linux,build-info = /incbin/ "build-info.txt; >>> } >> >> I like this suggestion either as an include another dts file or an >> overlay. The latter could be useful as a way to maintain current dtb >> files while splitting the source files into base and overlay dts >> files. > > ACK, that sounds like it could be helpful. > >> But no, let's not prepend this with 'linux'. It's not a property >> specific for Linux to consume. > > Right. We might be seeing the data coming through from U-Boot (or any > other random bootloader) too. > > Cheers, > Thanks for reviews. I gonna prepare a V2 with David proposition (to use overlay format) by keeping in mind not to modify existing dts(i) files. Remaining questions are: 1- "build-info" or "linux,build-info"? IMO, If information is "generic" then first one should be used. 2- Looking at Franck proposition[1] some years ago and objections on it, do you think that this one could accepted ? regards Alex [1] https://lore.kernel.org/linux-arm-kernel/550A42AC.8060104@gmail.com/
On 1/22/20 12:00 PM, Alexandre Torgue wrote: > Hi > > On 1/20/20 7:17 PM, Steve McIntyre wrote: >> On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: >>> On Fri, Jan 17, 2020 at 6:26 AM David Gibson >>> <david@gibson.dropbear.id.au> wrote: >> >> ... >> >>>> What might be better would be to have a dtc option which force appends >>>> an extra .dts to the mail .dts compiled. You can then put an overlay >>>> template in that file, something like: >>>> >>>> &{/} { >>>> linux,build-info = /incbin/ "build-info.txt; >>>> } >>> >>> I like this suggestion either as an include another dts file or an >>> overlay. The latter could be useful as a way to maintain current dtb >>> files while splitting the source files into base and overlay dts >>> files. >> >> ACK, that sounds like it could be helpful. >> >>> But no, let's not prepend this with 'linux'. It's not a property >>> specific for Linux to consume. >> >> Right. We might be seeing the data coming through from U-Boot (or any >> other random bootloader) too. >> >> Cheers, >> > > Thanks for reviews. I gonna prepare a V2 with David proposition (to use overlay format) by keeping in mind not to modify existing dts(i) files. > > Remaining questions are: > > 1- "build-info" or "linux,build-info"? IMO, If information is > "generic" then first one should be used. I would prefer build-info. The data may be generated by a non-linux build environment, such as uboot. > 2- Looking at Franck proposition[1] some years ago and objections on > it, do you think that this one could accepted ? I think that with the few small changes suggested in this thread, that the old objections are not relevant to your version. > > regards > Alex > > [1] https://lore.kernel.org/linux-arm-kernel/550A42AC.8060104@gmail.com/ > > > > >
On Tue, Jan 21, 2020 at 09:59:44AM -0600, Rob Herring wrote: > On Sun, Jan 19, 2020 at 12:41 AM David Gibson > <david@gibson.dropbear.id.au> wrote: > > > > On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: > > > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > > > <david@gibson.dropbear.id.au> wrote: > > > > > > > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > > > > Hi David > > > > > > > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > > > > 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). > > > > > > > > > > > > > > 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 information > > > > > > > found in information file given as argument. This file has to be generated > > > > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > > > > > > > At the very least, this patch of the series will need to be sent to > > > > > > upstream dtc first. > > > > > > > > > > Ok sorry. I thought that sending all the series would give more > > > > > information. > > > > > > > > That's fair enough, but in order to merge, you'll need to post against > > > > upstream dtc. > > > > > > > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > > > > and why it's useful. > > > > > > > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > > > > like U-Boot). When Linux kernel booting we get a log that gives useful > > > > > information about kernel image: source version, build date, people who built > > > > > the kernel image, compiler version. This information is useful for debug and > > > > > support. The aim is to get same kind of information but for the DTB. > > > > > > > > > > > Since you're doing this specifically for use with dtbs built in the > > > > > > kernel build, could you just use a: > > > > > > Build-info = /incbin/ "build-info.txt"; > > > > > > in each of the in-kernel .dts files? > > > > > > > > > > My first idea was to not modify all existing .dts files. Adding an extra > > > > > option in dtc is (for me) the softer way to do it. I mean, compile > > > > > information should come through compiler without modify .dts files outside > > > > > from dtc. In this way it will be easy to everybody using dtc (inside our > > > > > outside Linux tree) to add dtb build info (even if they don't how to write a > > > > > dts file). > > > > > > > > But you're not really having this information coming from the > > > > compiler. Instead you're adding a compiler option that just force > > > > includes another file into the generated tree, and it's up to your > > > > build scripts to put something useful into that file. > > > > > > > > I don't really see that as preferable to modifying the .dts files. > > > > > > > > I also dislike the fact that the option as proposed is much more > > > > general than the name suggests, but also very similar too, but much > > > > more specific than the existing /incbin/ option. > > > > > > > > What might be better would be to have a dtc option which force appends > > > > an extra .dts to the mail .dts compiled. You can then put an overlay > > > > template in that file, something like: > > > > > > > > &{/} { > > > > linux,build-info = /incbin/ "build-info.txt; > > > > } > > > > > > I like this suggestion either as an include another dts file or an > > > overlay. > > > > Sorry, to be clear what I'm talking about here is just including > > another dts file, and using the compile-type overlay syntax. This is > > not the same as .dtbo style runtime overlays (though the final result > > is about the same in this case). > > Ah, okay. That's probably easier to implement. > > > > The latter could be useful as a way to maintain current dtb > > > files while splitting the source files into base and overlay dts > > > files. > > > > > > But no, let's not prepend this with 'linux'. It's not a property > > > specific for Linux to consume. > > > > It's not really about who consumes it. It's about defining a > > namespace for the new property to exist in, since it's not part of a > > relevant standard (if we wanted to make it such, we should pin down > > what goes in there with much more precision). > > I can't think of any cases of the 'linux' prefix not being about who > consumes it. And we often end up dropping 'linux' because it turns out > to not be Linux specific. I don't care to see u-boot,build-info, > freebsd,build-info, etc. when a given dtb can only have 1 of those. But all other vendor prefixes are about who generated or specified the information, not who consumes it, e.g. "ibm,XXX", "fsl,YYY", etc. > My intent is this property name is added to the DT spec, but I don't > agree we should define what's in it beyond a string. It is information > that is useful for humans identifying what the dtb was built from. > > Rob >
On Wed, Jan 22, 2020 at 11:13 PM David Gibson <david@gibson.dropbear.id.au> wrote: > > On Tue, Jan 21, 2020 at 09:59:44AM -0600, Rob Herring wrote: > > On Sun, Jan 19, 2020 at 12:41 AM David Gibson > > <david@gibson.dropbear.id.au> wrote: > > > > > > On Fri, Jan 17, 2020 at 08:43:23AM -0600, Rob Herring wrote: > > > > On Fri, Jan 17, 2020 at 6:26 AM David Gibson > > > > <david@gibson.dropbear.id.au> wrote: > > > > > > > > > > On Thu, Jan 16, 2020 at 09:58:23AM +0100, Alexandre Torgue wrote: > > > > > > Hi David > > > > > > > > > > > > On 1/16/20 1:57 AM, David Gibson wrote: > > > > > > > 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). > > > > > > > > > > > > > > > > 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 information > > > > > > > > found in information file given as argument. This file has to be generated > > > > > > > > by user and shouldn't exceed 256 bytes. > > > > > > > > > > > > > > > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> > > > > > > > > > > > > > > At the very least, this patch of the series will need to be sent to > > > > > > > upstream dtc first. > > > > > > > > > > > > Ok sorry. I thought that sending all the series would give more > > > > > > information. > > > > > > > > > > That's fair enough, but in order to merge, you'll need to post against > > > > > upstream dtc. > > > > > > > > > > > > I'm also not terribly clear on what you're trying to accomplish here, > > > > > > > and why it's useful. > > > > > > > > > > > > Let's take Kernel boot at example (but could be extend to other DTB "users" > > > > > > like U-Boot). When Linux kernel booting we get a log that gives useful > > > > > > information about kernel image: source version, build date, people who built > > > > > > the kernel image, compiler version. This information is useful for debug and > > > > > > support. The aim is to get same kind of information but for the DTB. > > > > > > > > > > > > > Since you're doing this specifically for use with dtbs built in the > > > > > > > kernel build, could you just use a: > > > > > > > Build-info = /incbin/ "build-info.txt"; > > > > > > > in each of the in-kernel .dts files? > > > > > > > > > > > > My first idea was to not modify all existing .dts files. Adding an extra > > > > > > option in dtc is (for me) the softer way to do it. I mean, compile > > > > > > information should come through compiler without modify .dts files outside > > > > > > from dtc. In this way it will be easy to everybody using dtc (inside our > > > > > > outside Linux tree) to add dtb build info (even if they don't how to write a > > > > > > dts file). > > > > > > > > > > But you're not really having this information coming from the > > > > > compiler. Instead you're adding a compiler option that just force > > > > > includes another file into the generated tree, and it's up to your > > > > > build scripts to put something useful into that file. > > > > > > > > > > I don't really see that as preferable to modifying the .dts files. > > > > > > > > > > I also dislike the fact that the option as proposed is much more > > > > > general than the name suggests, but also very similar too, but much > > > > > more specific than the existing /incbin/ option. > > > > > > > > > > What might be better would be to have a dtc option which force appends > > > > > an extra .dts to the mail .dts compiled. You can then put an overlay > > > > > template in that file, something like: > > > > > > > > > > &{/} { > > > > > linux,build-info = /incbin/ "build-info.txt; > > > > > } > > > > > > > > I like this suggestion either as an include another dts file or an > > > > overlay. > > > > > > Sorry, to be clear what I'm talking about here is just including > > > another dts file, and using the compile-type overlay syntax. This is > > > not the same as .dtbo style runtime overlays (though the final result > > > is about the same in this case). > > > > Ah, okay. That's probably easier to implement. > > > > > > The latter could be useful as a way to maintain current dtb > > > > files while splitting the source files into base and overlay dts > > > > files. > > > > > > > > But no, let's not prepend this with 'linux'. It's not a property > > > > specific for Linux to consume. > > > > > > It's not really about who consumes it. It's about defining a > > > namespace for the new property to exist in, since it's not part of a > > > relevant standard (if we wanted to make it such, we should pin down > > > what goes in there with much more precision). > > > > I can't think of any cases of the 'linux' prefix not being about who > > consumes it. And we often end up dropping 'linux' because it turns out > > to not be Linux specific. I don't care to see u-boot,build-info, > > freebsd,build-info, etc. when a given dtb can only have 1 of those. > > But all other vendor prefixes are about who generated or specified the > information, not who consumes it, e.g. "ibm,XXX", "fsl,YYY", etc. I'd say those are both typically. Those are consumed by IBM and FSL specific drivers. But I think the better argument is what Frank said. If the firmware/bootloader provides the dtb that it built, we'd still want the information printed. Rob
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 = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties */ int generate_symbols; /* enable symbols & fixup support */ +int generate_build_info; /* Add build information: time, source version ... */ 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 char *prefix) fill_fullpaths(child, tree->fullpath); } +static void fill_build_info(struct node *tree, const char *fname) +{ + struct data d = empty_data; + char *tmp; + FILE *f; + int len; + + tmp = xmalloc(sizeof(char) * 256); + + f = fopen(fname, "r"); + if (!f) { + printf("Can't open file %s\n", fname); + return; + } + + len = fread(tmp, sizeof(char), 256, f); + if (!len) { + printf("Can't read file %s\n", fname); + fclose(f); + free(tmp); + } + fclose(f); + + tmp[len - 1] = '\0'; + + d = data_add_marker(d, TYPE_STRING, tmp); + d = data_append_data(d, tmp, len); + + add_property(tree, build_property("Build-info", d, NULL)); + + free(tmp); +} + /* Usage related data. */ static const char usage_synopsis[] = "dtc [options] <input file>"; -static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv"; +static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AT:B:hv"; static struct option const usage_long_opts[] = { {"quiet", no_argument, NULL, 'q'}, {"in-format", a_argument, NULL, 'I'}, @@ -69,6 +103,7 @@ static struct option const usage_long_opts[] = { {"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[] = { "\n\tEnable generation of symbols", "\n\tEnable auto-alias of labels", "\n\tAnnotate output .dts with input source file and line (-T -T for more 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 = NULL; const char *outname = "-"; const char *depname = NULL; + const char *version = NULL; bool force = false, sort = 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 = optarg; + generate_build_info = 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 = 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 = dt_from_fs(arg); - else if(streq(inform, "dtb")) + } else if (streq(inform, "dtb")) { dti = dt_from_blob(arg); - else + } else { die("Unknown input format \"%s\"\n", inform); + } dti->outname = outname;
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). 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 information found in information file given as argument. This file has to be generated by user and shouldn't exceed 256 bytes. Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>