On 03/20/18 20:45, Grant Likely wrote: > I've refactored the patch to preserve datatype information when parsing > the dts format, and reproducing it when emitting .dts source. I did this > as part of working with a YAML encoding, but the change is independently > useful when round tripping through DTC. > > All of the existing test cases continue to pass. You can see an example > of a DTC round trip using one of the test .dts files: > > $ dtc -o tests/test01-roundtrip.dts tests/test01.dts > $ diff tests/test01.dts tests/test01-roundtrip.dts > > I've got another patch that builds on this to emit YAML. You can find it > in my github tree at https://github.com/glikely/dtc if you're > interested. > > data.c | 4 +- > dtc-parser.y | 15 ++-- > dtc.h | 8 ++ > treesource.c | 227 +++++++++++++++++++++++++++++++-------------------------- > 4 files changed, 145 insertions(+), 109 deletions(-) > > -- > To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > How much difference should I expect to see after a round trip? (Less is reported by 'diff -w', which is shown second.) With the patches applied on top of: $ git log -n1 commit 46df1fb1b211ec65b004c79b0f7adae25fb49dc3 Author: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> Date: Fri Mar 9 13:55:17 2018 +1100 .travis.yml: Run valgrind checks via Travis To improve our coverage, run the testsuite under Valgrind via Travis. $ ./dtc -o tests/test01-roundtrip.dts tests/test01.dts $ diff tests/test01.dts tests/test01-roundtrip.dts 3,6c3,5 < /memreserve/ 0x1000000000000000 0x0000000002000000; < /memreserve/ 0x2000000000000000 0x0100000000000000; < /memreserve/ 0x0000000000000000 0x0000000000000014; < --- > /memreserve/ 0x1000000000000000 0x0000000002000000; > /memreserve/ 0x2000000000000000 0x0100000000000000; > /memreserve/ 0x0000000000000000 0x0000000000000014; 10,11c9,10 < #address-cells = <2>; < #size-cells = <2>; --- > #address-cells = < 0x02 >; > #size-cells = < 0x02 >; 14,16c13,16 < linux,phandle = <0x1>; < #address-cells = <1>; < #size-cells = <0>; --- > linux,phandle = < 0x01 >; > #address-cells = < 0x01 >; > #size-cells = < 0x00 >; > 18d17 < name = "PowerPC,970"; 20,22c19,21 < reg = <0x00000000>; < clock-frequency = <1600000000>; < timebase-frequency = <33333333>; --- > reg = < 0x00 >; > clock-frequency = < 0x5f5e1000 >; > timebase-frequency = < 0x1fca055 >; 24,25c23,24 < i-cache-size = <65536>; < d-cache-size = <32768>; --- > i-cache-size = < 0x10000 >; > d-cache-size = < 0x8000 >; 29d27 < name = "PowerPC,970"; 31,35c29,33 < reg = <0x00000001>; < clock-frequency = <1600000000>; < timebase-frequency = <33333333>; < i-cache-size = <65536>; < d-cache-size = <32768>; --- > reg = < 0x01 >; > clock-frequency = < 0x5f5e1000 >; > timebase-frequency = < 0x1fca055 >; > i-cache-size = < 0x10000 >; > d-cache-size = < 0x8000 >; 37d34 < 41,44c38,41 < string = "\xff\0stuffstuff\t\t\t\n\n\n"; < blob = [0a 0b 0c 0d de ea ad be ef]; < ref = < &{/memory@0} >; < mixed = "abc", [1234], <0xa 0xb 0xc>; --- > string = "\xffffffff", "stuffstuff\t\t\t\n\n\n"; > blob = [ 0a 0b 0c 0d de ea ad be ef ]; > ref = < 0x02 >; > mixed = "abc", [ 12 34 ], < 0x0a 0x0b 0x0c >; 49c46,47 < memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; --- > memreg: reg = < 0x00 0x00 0x00 0x20000000 >; > phandle = < 0x02 >; 54c52 < linux,platform = <0x600>; --- > linux,platform = < 0x600 >; 56d53 < $ diff -w tests/test01.dts tests/test01-roundtrip.dts 6d5 < 10,11c9,10 < #address-cells = <2>; < #size-cells = <2>; --- > #address-cells = < 0x02 >; > #size-cells = < 0x02 >; 14,16c13,16 < linux,phandle = <0x1>; < #address-cells = <1>; < #size-cells = <0>; --- > linux,phandle = < 0x01 >; > #address-cells = < 0x01 >; > #size-cells = < 0x00 >; > 18d17 < name = "PowerPC,970"; 20,22c19,21 < reg = <0x00000000>; < clock-frequency = <1600000000>; < timebase-frequency = <33333333>; --- > reg = < 0x00 >; > clock-frequency = < 0x5f5e1000 >; > timebase-frequency = < 0x1fca055 >; 24,25c23,24 < i-cache-size = <65536>; < d-cache-size = <32768>; --- > i-cache-size = < 0x10000 >; > d-cache-size = < 0x8000 >; 29d27 < name = "PowerPC,970"; 31,35c29,33 < reg = <0x00000001>; < clock-frequency = <1600000000>; < timebase-frequency = <33333333>; < i-cache-size = <65536>; < d-cache-size = <32768>; --- > reg = < 0x01 >; > clock-frequency = < 0x5f5e1000 >; > timebase-frequency = < 0x1fca055 >; > i-cache-size = < 0x10000 >; > d-cache-size = < 0x8000 >; 37d34 < 41c38 < string = "\xff\0stuffstuff\t\t\t\n\n\n"; --- > string = "\xffffffff", "stuffstuff\t\t\t\n\n\n"; 43,44c40,41 < ref = < &{/memory@0} >; < mixed = "abc", [1234], <0xa 0xb 0xc>; --- > ref = < 0x02 >; > mixed = "abc", [ 12 34 ], < 0x0a 0x0b 0x0c >; 49c46,47 < memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; --- > memreg: reg = < 0x00 0x00 0x00 0x20000000 >; > phandle = < 0x02 >; 56d53 < -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html