Message ID | 728deb9bbeab491a728da077aa5e47c0e01bccf8.1384798508.git.jason@lakedaemon.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 11/18/2013 11:38 AM, Jason Cooper wrote: > Consumers of the Linux kernel's build products are beginning to hardcode > the filenames of the dtbs generated. Since the dtb filenames are > currently the dts filename s/dts/dtb/, this prevents the kernel > community from renaming dts files as needed. > > Let's provide a consistent naming structure for consumers to script > against. Or at least, as consistent as the dts properties themselves. > > With this patch, adding the '-O compat' option to the dtc commandline > will cause dtc to parse the provided file, and print out the board > compatible string to stdout. > > This will facilitate an 'installdtbs.sh' script in the kernel for naming > dtb files by their compatible string, eg: > > $ dtc -I dtb -O compat arch/arm/boot/dts/armada-370-mirabox.dtb > globalscale,mirabox > > This change will also simplify distribution install scripts that need to > search through many dtbs to find the right one for a target board. > > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > --- > changes since v1: > - made patch against in-tree dtc code to facilitate testing I assume this patch would first get applied to the upstream dtc, then back-ported into the kernel though? I wonder if dtc is the correct place to put this feature at all though. It seems like a tiny standalone utility using libfdt would be better. Actually, perhaps the existing fdtget utility (which seems to be scripts/dtc/fdtget.c in the kernel although I don't know if it's built by the kernel yet) can be used rather than creating a new one? Using fdtget seems like it'd allow more flexibility later, if the naming rules change, via scripting rather than having to edit the dtc source code.
On Mon, Nov 18, 2013 at 12:01:02PM -0700, Stephen Warren wrote: > On 11/18/2013 11:38 AM, Jason Cooper wrote: > > Consumers of the Linux kernel's build products are beginning to hardcode > > the filenames of the dtbs generated. Since the dtb filenames are > > currently the dts filename s/dts/dtb/, this prevents the kernel > > community from renaming dts files as needed. > > > > Let's provide a consistent naming structure for consumers to script > > against. Or at least, as consistent as the dts properties themselves. > > > > With this patch, adding the '-O compat' option to the dtc commandline > > will cause dtc to parse the provided file, and print out the board > > compatible string to stdout. > > > > This will facilitate an 'installdtbs.sh' script in the kernel for naming > > dtb files by their compatible string, eg: > > > > $ dtc -I dtb -O compat arch/arm/boot/dts/armada-370-mirabox.dtb > > globalscale,mirabox > > > > This change will also simplify distribution install scripts that need to > > search through many dtbs to find the right one for a target board. > > > > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > > --- > > changes since v1: > > - made patch against in-tree dtc code to facilitate testing > > I assume this patch would first get applied to the upstream dtc, then > back-ported into the kernel though? Yes. > I wonder if dtc is the correct place to put this feature at all though. > It seems like a tiny standalone utility using libfdt would be better. > Actually, perhaps the existing fdtget utility (which seems to be > scripts/dtc/fdtget.c in the kernel although I don't know if it's built > by the kernel yet) can be used rather than creating a new one? Using > fdtget seems like it'd allow more flexibility later, if the naming rules > change, via scripting rather than having to edit the dtc source code. Ah, neat. I missed fdtget.c. I'll take a look at that, it sounds promising. thx, Jason.
On Mon, Nov 18, 2013 at 12:01:02PM -0700, Stephen Warren wrote: > On 11/18/2013 11:38 AM, Jason Cooper wrote: > > Consumers of the Linux kernel's build products are beginning to hardcode > > the filenames of the dtbs generated. Since the dtb filenames are > > currently the dts filename s/dts/dtb/, this prevents the kernel > > community from renaming dts files as needed. > > > > Let's provide a consistent naming structure for consumers to script > > against. Or at least, as consistent as the dts properties themselves. > > > > With this patch, adding the '-O compat' option to the dtc commandline > > will cause dtc to parse the provided file, and print out the board > > compatible string to stdout. > > > > This will facilitate an 'installdtbs.sh' script in the kernel for naming > > dtb files by their compatible string, eg: > > > > $ dtc -I dtb -O compat arch/arm/boot/dts/armada-370-mirabox.dtb > > globalscale,mirabox > > > > This change will also simplify distribution install scripts that need to > > search through many dtbs to find the right one for a target board. > > > > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > > --- > > changes since v1: > > - made patch against in-tree dtc code to facilitate testing > > I assume this patch would first get applied to the upstream dtc, then > back-ported into the kernel though? > > I wonder if dtc is the correct place to put this feature at all though. > It seems like a tiny standalone utility using libfdt would be better. > Actually, perhaps the existing fdtget utility (which seems to be > scripts/dtc/fdtget.c in the kernel although I don't know if it's built > by the kernel yet) can be used rather than creating a new one? Using > fdtget seems like it'd allow more flexibility later, if the naming rules > change, via scripting rather than having to edit the dtc source code. yep, just tested it. It was easier to build fdtget in the dtc source tree, but the result was suitable: $ ./fdtget ../linux/arch/arm/boot/dts/armada-370-mirabox.dtb / compatible globalscale,mirabox marvell,armada370 marvell,armada-370-xp Thanks for the pointer. thx, Jason.
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index a375683c1534..89264bb0a3dd 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c @@ -68,6 +68,7 @@ static void __attribute__ ((noreturn)) usage(void) fprintf(stderr, "\t\tOutput formats are:\n"); fprintf(stderr, "\t\t\tdts - device tree source text\n"); fprintf(stderr, "\t\t\tdtb - device tree blob\n"); + fprintf(stderr, "\t\t\tcompat - print board compatible string\n"); fprintf(stderr, "\t\t\tasm - assembler source\n"); fprintf(stderr, "\t-V <output version>\n"); fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); @@ -250,6 +251,8 @@ int main(int argc, char *argv[]) dt_to_blob(outf, bi, outversion); } else if (streq(outform, "asm")) { dt_to_asm(outf, bi, outversion); + } else if (streq(outform, "compat")) { + dt_to_compat(bi); } else if (streq(outform, "null")) { /* do nothing */ } else { diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 3e42a071070e..d4e47c697c2f 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h @@ -255,6 +255,7 @@ void process_checks(int force, struct boot_info *bi); void dt_to_blob(FILE *f, struct boot_info *bi, int version); void dt_to_asm(FILE *f, struct boot_info *bi, int version); +void dt_to_compat(struct boot_info *bi); struct boot_info *dt_from_blob(const char *fname); diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index 665dad7bb465..bdbd3d7e8964 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c @@ -577,6 +577,15 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) data_free(strbuf); } +void dt_to_compat(struct boot_info *bi) +{ + struct property *prop; + + prop = get_property(bi->dt, "compatible"); + + printf("%s\n", prop->val.val); +} + struct inbuf { char *base, *limit, *ptr; };
Consumers of the Linux kernel's build products are beginning to hardcode the filenames of the dtbs generated. Since the dtb filenames are currently the dts filename s/dts/dtb/, this prevents the kernel community from renaming dts files as needed. Let's provide a consistent naming structure for consumers to script against. Or at least, as consistent as the dts properties themselves. With this patch, adding the '-O compat' option to the dtc commandline will cause dtc to parse the provided file, and print out the board compatible string to stdout. This will facilitate an 'installdtbs.sh' script in the kernel for naming dtb files by their compatible string, eg: $ dtc -I dtb -O compat arch/arm/boot/dts/armada-370-mirabox.dtb globalscale,mirabox This change will also simplify distribution install scripts that need to search through many dtbs to find the right one for a target board. Signed-off-by: Jason Cooper <jason@lakedaemon.net> --- changes since v1: - made patch against in-tree dtc code to facilitate testing - dtc prints compatible string to stdout now, instead of creating symlink - should be more flexible for end-users scripts/dtc/dtc.c | 3 +++ scripts/dtc/dtc.h | 1 + scripts/dtc/flattree.c | 9 +++++++++ 3 files changed, 13 insertions(+)