summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@siemens.com>2025-06-03 10:23:12 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-06-05 11:02:21 +0100
commit437043d9f3cdcadb9b9898a25a9216323066e250 (patch)
tree5b3399814dee408fe1e5f0f44d49a0891eef1398
parent5b006dbc3d8669e0530ec3d633982617923ae215 (diff)
downloadpoky-437043d9f3cdcadb9b9898a25a9216323066e250.tar.gz
devicetree: minor improvements
- Do not use the ${} bitbake syntax for shell internal variables - Fix shellcheck SC2045 warning: Iterating over ls output is fragile. Use globs. - Improve error handling for dtc. Print the output, not only the exit value. (From OE-Core rev: f33ee0cfb3c664c4857c18271dd55981bc369cc1) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/devicetree.bbclass22
1 files changed, 16 insertions, 6 deletions
diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-recipe/devicetree.bbclass
index 1806cb62cb..2a2ac93e9b 100644
--- a/meta/classes-recipe/devicetree.bbclass
+++ b/meta/classes-recipe/devicetree.bbclass
@@ -109,7 +109,11 @@ def devicetree_compile(dtspath, includes, d):
109 ppargs.append("-I{0}".format(i)) 109 ppargs.append("-I{0}".format(i))
110 ppargs += ["-o", "{0}.pp".format(dts), dtspath] 110 ppargs += ["-o", "{0}.pp".format(dts), dtspath]
111 bb.note("Running {0}".format(" ".join(ppargs))) 111 bb.note("Running {0}".format(" ".join(ppargs)))
112 subprocess.run(ppargs, check = True) 112 try:
113 subprocess.run(ppargs, check=True, capture_output=True)
114 except subprocess.CalledProcessError as e:
115 bb.fatal(f"Command '{' '.join(ppargs)}' failed with return code {e.returncode}\nstdout: {e.stdout.decode()}\nstderr: {e.stderr.decode()}\ndtspath: {os.path.abspath(dtspath)}")
116
113 117
114 # determine if the file is an overlay or not (using the preprocessed file) 118 # determine if the file is an overlay or not (using the preprocessed file)
115 isoverlay = devicetree_source_is_overlay("{0}.pp".format(dts)) 119 isoverlay = devicetree_source_is_overlay("{0}.pp".format(dts))
@@ -125,7 +129,11 @@ def devicetree_compile(dtspath, includes, d):
125 dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")] 129 dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")]
126 dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)] 130 dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)]
127 bb.note("Running {0}".format(" ".join(dtcargs))) 131 bb.note("Running {0}".format(" ".join(dtcargs)))
128 subprocess.run(dtcargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 132 try:
133 subprocess.run(dtcargs, check=True, capture_output=True)
134 except subprocess.CalledProcessError as e:
135 bb.fatal(f"Command '{' '.join(dtcargs)}' failed with return code {e.returncode}\nstdout: {e.stdout.decode()}\nstderr: {e.stderr.decode()}\ndtname: {dtname}")
136
129 137
130python devicetree_do_compile() { 138python devicetree_do_compile() {
131 import re 139 import re
@@ -144,14 +152,16 @@ python devicetree_do_compile() {
144} 152}
145 153
146devicetree_do_install() { 154devicetree_do_install() {
147 for DTB_FILE in `ls *.dtb *.dtbo`; do 155 for dtb_file in *.dtb *.dtbo; do
148 install -Dm 0644 ${B}/${DTB_FILE} ${D}/boot/devicetree/${DTB_FILE} 156 [ -e "$dtb_file" ] || continue
157 install -Dm 0644 "${B}/$dtb_file" "${D}/boot/devicetree/$dtb_file"
149 done 158 done
150} 159}
151 160
152devicetree_do_deploy() { 161devicetree_do_deploy() {
153 for DTB_FILE in `ls *.dtb *.dtbo`; do 162 for dtb_file in *.dtb *.dtbo; do
154 install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/devicetree/${DTB_FILE} 163 [ -e "$dtb_file" ] || continue
164 install -Dm 0644 "${B}/$dtb_file" "${DEPLOYDIR}/devicetree/$dtb_file"
155 done 165 done
156} 166}
157addtask deploy before do_build after do_install 167addtask deploy before do_build after do_install