Skip to contentSkip to conversation

Correct output from memreserve in fdtdump

PATCH Applied Simon Glass 3 participants 9 messages Jun 18, 2014 – Jun 23, 2014 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Correct output from memreserve in fdtdump

This currently displays a hex value without the 0x prefix. Add the prefix as dtc requires it.

---
 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fdtdump.c +1 -1
index 723770d..a29aa5e 100644
@@ -88,7 +88,7 @@ static void dump_blob(void *blob, bool debug)
 		if (addr == 0 && size == 0)
 			break;
 
-		printf("/memreserve/ %llx %llx;\n",
+		printf("/memreserve/ %#llx %#llx;\n",
 		       (unsigned long long)addr, (unsigned long long)size);
 	}
 
Signature · 6 lines
2.0.0.526.g5318336

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1403074825-5069-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

#2 lore raw

PATCH 2/3 Tweak code to display cell values

Move the division out of the loop; this seems slightly cleaner.

---
 util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
util.c +3 -3
index 1ce8b97..9d65226 100644
@@ -371,9 +371,9 @@ void utilfdt_print_data(const char *data, int len)
 		const uint32_t *cell = (const uint32_t *)data;
 
 		printf(" = <");
-		for (i = 0; i < len; i += 4)
-			printf("0x%08x%s", fdt32_to_cpu(cell[i / 4]),
-			       i < (len - 4) ? " " : "");
+		for (i = 0, len /= 4; i < len; i++)
+			printf("0x%08x%s", fdt32_to_cpu(cell[i]),
+			       i < (len - 1) ? " " : "");
 		printf(">");
 	} else {
 		printf(" = [");
Signature · 6 lines
2.0.0.526.g5318336

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1403074825-5069-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

Applied
#4 lore raw

Re: [PATCH 2/3] Tweak code to display cell values

Quoted 1 line · Simon Glass

Move the division out of the loop; this seems slightly cleaner.

Applied.

Signature · 4 lines
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
#5 lore raw

PATCH 3/3 Add a basic test for fdtdump

In reply to a message not in the archive

We can test fdtdump by comparing its output with the source file that was compiled by dtc. Add a simple test that should at least catch regressions in basic functionality.

---
 tests/fdtdump-runtest.sh | 30 ++++++++++++++++++++++++++++++
 tests/fdtdump.dts        | 37 +++++++++++++++++++++++++++++++++++++
 tests/run_tests.sh       | 29 +++++++++++++++++++++++++++++
 tests/tests.sh           |  1 +
 4 files changed, 97 insertions(+)
 create mode 100644 tests/fdtdump-runtest.sh
 create mode 100644 tests/fdtdump.dts
tests/fdtdump-runtest.sh new file +30 -0
new file mode 100644
index 0000000..a0796da
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# Arguments:
+#   $1 - source file to compile and compare with fdtdump output of the
+#	  compiled file.
+
+. ./tests.sh
+
+dts="$1"
+dtb="${dts}.dtb"
+out="${dts}.out"
+LOG=tmp.log.$$
+
+files="$dtb $out $LOG"
+
+rm -f $files
+trap "rm -f $files" 0
+
+verbose_run_log_check "$LOG" $VALGRIND $DTC -O dtb $dts -o $dtb
+$FDTDUMP ${dtb} | grep -v "//" >${out}
+
+if diff -w $dts $out >/dev/null; then
+    PASS
+else
+    if [ -z "$QUIET_TEST" ]; then
+	echo "DIFF :-:"
+	diff -w $dts $out
+    fi
+    FAIL "Results differ from expected"
+fi
tests/fdtdump.dts new file +37 -0
new file mode 100644
index 0000000..b9d917b
@@ -0,0 +1,37 @@
+/dts-v1/;
+
+/memreserve/ 0 0xe;
+/ {
+	model = "MyBoardName";
+	compatible = "MyBoardName", "MyBoardFamilyName";
+	#address-cells = <0x00000002>;
+	#size-cells = <0x00000002>;
+	cpus {
+		linux,phandle = <0x00000001>;
+		#address-cells = <0x00000001>;
+		#size-cells = <0x00000000>;
+		PowerPC,970@0 {
+			device_type = "cpu";
+			reg = <0x00000000>;
+			linux,boot-cpu;
+			};
+		PowerPC,970@1 {
+			device_type = "cpu";
+			reg = <0x00000001>;
+		};
+	};
+	randomnode {
+		string =  "foo", "stuff";
+		bytes = [61 62 63 64 65];
+		child {
+		};
+	};
+	memory@0 {
+		device_type = "memory";
+		reg = <0x00000000 0x00000123 0x00000456 0x87654321>;
+	};
+	chosen {
+		bootargs = "root=/dev/sda2";
+		linux,platform = <0x00000600>;
+	};
+};
tests/run_tests.sh +29 -0
index f205ce6..8273abf 100755
@@ -138,6 +138,13 @@ run_fdtput_test () {
     base_run_test sh fdtput-runtest.sh "$expect" "$@"
 }
 
+run_fdtdump_test() {
+    file="$1"
+    shorten_echo fdtdump-runtest.sh "$file"
+    echo -n ":	"
+    base_run_test sh fdtdump-runtest.sh "$file"
+}
+
 tree1_tests () {
     TREE=$1
 
@@ -602,6 +609,25 @@ utilfdt_tests () {
     run_test utilfdt_test
 }
 
+fdtdump_tests () {
+    run_fdtdump_test fdtdump.dts
+    return
+
+    local dts=fdtdump.dts
+    local dtb=fdtdump.dts.dtb
+    local out=fdtdump.dts.out
+    run_dtc_test -O dtb $dts -o ${dtb}
+    $FDTDUMP ${dtb} | grep -v "//" >${out}
+    if cmp $dts $out >/dev/null; then
+	PASS
+    else
+	if [ -z "$QUIET_TEST" ]; then
+	    diff -w fdtdump.dts $out
+	fi
+	FAIL "Results differ from expected"
+    fi
+}
+
 while getopts "vt:me" ARG ; do
     case $ARG in
 	"v")
@@ -646,6 +672,9 @@ for set in $TESTSETS; do
 	"fdtput")
 	    fdtput_tests
 	    ;;
+	"fdtdump")
+	    fdtdump_tests
+	    ;;
     esac
 done
 
tests/tests.sh +1 -0
index 31530d5..818fd09 100644
@@ -21,6 +21,7 @@ FAIL_IF_SIGNAL () {
 DTC=../dtc
 DTGET=../fdtget
 DTPUT=../fdtput
+FDTDUMP=../fdtdump
 
 verbose_run () {
     if [ -z "$QUIET_TEST" ]; then
Signature · 6 lines
2.0.0.526.g5318336

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1403074825-5069-3-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

#7 lore raw

Re: [PATCH 3/3] Add a basic test for fdtdump

Quoted 3 lines · Simon Glass

We can test fdtdump by comparing its output with the source file that was compiled by dtc. Add a simple test that should at least catch regressions in basic functionality.

Never really bothered, since fdtdump is basically a hack tool.

Applied with a few changes:
* Added fdtdump to TESTS_BIN, so it gets made for a "make check"
* Added the fdtdump test to the default set of tests run by run_tests.sh
* Changed to a unified diff in fdtdump-runtest.sh

Signature · 4 lines
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
#8 lore raw
In reply to a message not in the archive
Quoted 13 lines · Simon Glass

This currently displays a hex value without the 0x prefix. Add the prefix as dtc requires it.

---
 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fdtdump.c +0 -0
index 723770d..a29aa5e 100644

fdtdump.c static void dump_blob(void *blob, bool debug) · line 91

Quoted 5 lines
fdtdump.c +1 -1
@@ -88,7 +88,7 @@ static void dump_blob(void *blob, bool debug)
 		if (addr == 0 && size == 0)
 			break;
 
-		printf("/memreserve/ %llx %llx;\n",
+		printf("/memreserve/ %#llx %#llx;\n",

Is the # modifier and its behaviour standardized? I couldn't quickly find a reference.

Might be safer to do it as an explicit 0x%llx.

Signature · 4 lines
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

A message that is not in the archive (sent off-list or not yet received): [email protected]

Applied
#10 lore raw
Quoted 17 lines · David Gibson
Quoted 16 lines · Simon Glass

This currently displays a hex value without the 0x prefix. Add the prefix as dtc requires it.

---
 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fdtdump.c +0 -0
index 723770d..a29aa5e 100644
@@ -88,7 +88,7 @@ static void dump_blob(void *blob, bool debug)
 		if (addr == 0 && size == 0)
 			break;
 
Quoted 5 lines

fdtdump.c static void dump_blob(void *blob, bool debug) · line 91

Quoted 2 lines
fdtdump.c +1 -1
-		printf("/memreserve/ %llx %llx;\n",
+		printf("/memreserve/ %#llx %#llx;\n",

Is the # modifier and its behaviour standardized? I couldn't quickly find a reference.

Never mind, found the reference, and the # flag's behaviour is there.

Applied.

Signature · 4 lines
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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 5 lines

Never mind, found the reference, and the # flag's behaviour is there.

Applied.

Geeze. You guys generated patches, discussed, and applied them before I even woke up and read them! :-)

jdl
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): E1WxGmt-0004MW-Vk-CYoMK+44s/[email protected]

#14 lore raw

Hi Jon,

Quoted 8 lines · Jon Loeliger
Quoted 5 lines

Never mind, found the reference, and the # flag's behaviour is there.

Applied.

Geeze. You guys generated patches, discussed, and applied them before I even woke up and read them! :-)

Yes that was a bit quicker than my last series!

Regards,
Simon
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html