allow control DTB to double as "FIT image"
cover allow control DTB to double as "FIT image"
The commit message for patch 1 explains what it is I'd like to be able to do, but here's some more background:
For a long time, we've embedded the boot script in the U-Boot binary by building a bootscript.itb, and using a .dtsi like
/ {
config {
bootscript = /incbin/("/path/to/bootscript.itb");
};
};which in turn is mentioned in CONFIG_DEVICE_TREE_INCLUDES, that bootscript.itb FIT image has been embedded in U-Boot's control dtb. Running that was then a matter of doing
fdt addr ${fdtcontroladdr} && fdt get addr bsaddr /config bootscript && source ${bsaddr}There are a couple of advantage of having the bootscript (and other script logic) embedded in the U-Boot binary. First, there's no need to figure out some separate partition to store the script in, and making sure that gets updated whenever the bootloader itself does. Second, one doesn't need to worry about verifying the script; whatever steps one needs to take to implement secure boot for U-Boot itself will by necessity also cover the control dtb (if nothing else then because that's where the public key for the kernel verification lives).
Now with the stricter requirements of libfdt starting from v2026.04, the above command no longer worked, or only half the time, because the embedded FIT image may not land on an 8-byte aligned address. So that line had to be changed a little (line breaks added)
fdt addr ${fdtcontroladdr}
&& fdt get addr bsaddr /config bootscript
&& fdt get size bssize /config bootscript
&& cp.b ${bsaddr} ${loadaddr} ${bssize}
&& source ${loadaddr}which is getting quite unwieldy.
Then it struck me that one could perhaps simplify all of this quite a
lot: Cut out the intermediate bootscript.itb, just create a .dtsi which directly puts a /images node inside the control dtb
/ {
images {
default = "bootscript";
bootscript {
description = "Boot script";
data = /incbin/("/path/to/bootscript.sh");
type = "script";
compression = "none";
};
};
};and treat the control dtb itself as a FIT image; so the command to put in $bootcmd becomes simply
source ${fdtcontroladdr}:bootscriptand embedding other pieces of callable scripts is quite trivial.
And that almost works out-of-the-box, except for the fit_check_format() sanity check.
I realize this is a bit of a hack, but I do think it's somewhat elegant, and avoids inventing a whole lot of extra infrastructure for allowing one to embed larger scripts and invoke them from the shell. I am of course happy to put this exemption for gd->fdt_blob under a CONFIG_ knob if that is deemed necessary.
CI is half-way through (and past the sandbox testing that would exercise this) and seems happy:
https://github.com/u-boot/u-boot/pull/969
Rasmus Villemoes (2):
image-board.c: exempt gd->fdt_blob from fit_check_format() check
test: hook up test of allowing control DTB to act as FIT image
arch/sandbox/dts/sandbox-test1.sh | 4 ++++ arch/sandbox/dts/sandbox-test2.sh | 4 ++++ arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++ boot/image-board.c | 2 +- configs/sandbox_defconfig | 1 + test/py/tests/test_source.py | 12 ++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 arch/sandbox/dts/sandbox-test1.sh create mode 100644 arch/sandbox/dts/sandbox-test2.sh create mode 100644 arch/sandbox/dts/sandbox_scripts.dtsi
Signature · 1 line
2.54.0
PATCH 1/2 image-board.c: exempt gd->fdt_blob from fit_check_format() check
Having scripts embedded one way or the other in the U-Boot binary means they are automatically verified/trusted by whatever mechanism verifies U-Boot.
Writing those scripts in the built-in environment leads to backslatitis and missing or wrong quoting and is generally not very readable or maintainable.
Maintaining scripts in external files allows one
to have both syntax highlighting and to some extent apply shellcheck on it (though U-Boot's shell is of course not quite POSIX sh, so some '#shellcheck disable' directives are needed). Getting those into the U-Boot binary is then a matter of having a suitable .dtsi file such as
/ {
images {
default = "boot";
boot {
description = "Bootscript";
data = /incbin/("boot.sh");
type = "script";
compression = "none";
};
factory-reset {
description = "Script for performing factory reset";
data = /incbin/("factory-reset.sh");
type = "script";
compression = "none";
};
};
};and making that part of CONFIG_DEVICE_TREE_INCLUDES, so that U-Boot's control DTB effectively doubles as a FIT image containing a few "script" entries. At run-time, one's default bootcommand can then simply be
source ${fdtcontroladdr}:bootExcept of course that the control DTB is in fact not quite a FIT image. The lack of timestamp and description properties could potentially be worked around, but the no-@ check is not possible to get around. But since the control dtb is by definition trusted, we can just excempt that particular address from the strict check.
One can of course build an ordinary FIT image with those scripts. However, that requires extra steps in the boot command for loading that script from storage, requires one to use "configurations" for pointing at a single script to run, and signing the FIT image using the same key used for verifying the kernel. Moreover, in certain situations, such as bootstrapping/production, there is no place to load that FIT image from, and it is much simpler to just have the necessary scripts be part of the U-Boot image itself.
--- boot/image-board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
boot/image-board.c +1 -1
@@ -1037,7 +1037,7 @@ int image_locate_script(void *buf, int size, const char *fit_uname, goto exit_image_format; }else { fit_hdr = buf; -if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { +if (fit_hdr != gd->fdt_blob &&fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) {puts ("Bad FIT image format\n" );return 1 ; }
Signature · 1 line
2.54.0
Re: [PATCH 1/2] image-board.c: exempt gd->fdt_blob from fit_check_format() check
Hi Rasmus,
Quoted 16 lines · Rasmus Villemoes
image-board.c: exemptgd->fdt_blobfromfit_check_format()checkHaving scripts embedded one way or the other in the U-Boot binary means they are automatically verified/trusted by whatever mechanism verifies U-Boot.
Writing those scripts in the built-in environment leads to backslatitis and missing or wrong quoting and is generally not very readable or maintainable.
Maintaining scripts in external files allows one
to have both syntax highlighting and to some extent apply shellcheck on it (though U-Boot's shell is of course not quite POSIX sh, so some '#shellcheck disable' directives are needed). Getting those into the U-Boot binary is then a matter of having a suitable .dtsi file such as
Quoted 8 lines
/ { images { default = 'boot'; boot {[...]
boot/image-board.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Makes sense, and a nice feature.
boot/image-board.c int image_locate_script(void *buf, int size, const char *fit_uname, · line 1043
Quoted 10 lines
boot/image-board.c +1
-1@@ -1037,7 +1037,7 @@ int image_locate_script(void *buf, int size, const char *fit_uname, goto exit_image_format; }else { fit_hdr = buf; -if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { +if (fit_hdr != gd->fdt_blob &&fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) {puts ("Bad FIT image format\n" );return 1 ; }
Please add a code comment explaining why the control DTB is exempt - a future reader running git blame will be puzzled by the pointer comparison. Something like 'gd->fdt_blob has already been validated by the bootloader and is by definition trusted, so we skip the strict FIT format checks (no description/timestamp, presence of unit-addresses, ...) for that buffer'.
This also skips fdt_check_header() and fdt_check_full(). Fine for the control DTB, but please note in the commit message that more than the no-@ check is bypassed - the message currently singles out no-@ as 'not possible to get around', implying description/timestamp could be worked around in the .dtsi, when in fact those are skipped too.
Quoted 5 lines
Except of course that the control DTB is in fact not quite a FIT image. The lack of timestamp and description properties could potentially be worked around, but the no-@ check is not possible to get around. But since the control dtb is by definition trusted, we can just excempt that particular address from the strict check.
Typo: excempt -> exempt
boot/image-board.c int image_locate_script(void *buf, int size, const char *fit_uname, · line 1037
Quoted 3 lines
boot/image-board.c +1
-0@@ -1037,7 +1037,7 @@ int image_locate_script(void *buf, int size, const char *fit_uname, +if (fit_hdr != gd->fdt_blob &&fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) {
Would it be cleaner to push the trusted-FIT notion into fit_check_format() itself (e.g. a sibling fit_check_format_trusted() that skips the strict-format / no-@ pieces)? The pointer-equality test works but feels out of place in image_locate_script(), and the same need will likely show up the next time someone wants to source-from-DTB elsewhere, such as an FPGA image. What do you think?
Regards,
Simon
Re: [PATCH 1/2] image-board.c: exempt gd->fdt_blob from fit_check_format() check
Quoted 39 lines · Simon Glass
Hi Rasmus,
Quoted 16 lines · Rasmus Villemoes
image-board.c: exemptgd->fdt_blobfromfit_check_format()checkHaving scripts embedded one way or the other in the U-Boot binary means they are automatically verified/trusted by whatever mechanism verifies U-Boot.
Writing those scripts in the built-in environment leads to backslatitis and missing or wrong quoting and is generally not very readable or maintainable.
Maintaining scripts in external files allows one
to have both syntax highlighting and to some extent apply shellcheck on it (though U-Boot's shell is of course not quite POSIX sh, so some '#shellcheck disable' directives are needed). Getting those into the U-Boot binary is then a matter of having a suitable .dtsi file such asQuoted 8 lines
/ { images { default = 'boot'; boot {[...]
boot/image-board.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Makes sense, and a nice feature.
Quoted 9 lines
boot/image-board.c +1
-1@@ -1037,7 +1037,7 @@ int image_locate_script(void *buf, int size, const char *fit_uname, goto exit_image_format; }else { fit_hdr = buf; -if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { +if (fit_hdr != gd->fdt_blob &&fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) {puts ("Bad FIT image format\n" );return 1 ;
Quoted 8 lines
boot/image-board.c int image_locate_script(void *buf, int size, const char *fit_uname, · line 1043
Quoted 1 line
boot/image-board.c +0
-0}Please add a code comment explaining why the control DTB is exempt - a future reader running git blame will be puzzled by the pointer comparison. Something like '
gd->fdt_blobhas already been validated by the bootloader and is by definition trusted, so we skip the strict FIT format checks (no description/timestamp, presence of unit-addresses, ...) for that buffer'.
Yes, I agree this was too terse, it was mostly to demonstrate how little was actually needed to enable this use case.
Quoted 6 lines
Would it be cleaner to push the trusted-FIT notion into
fit_check_format()itself (e.g. a siblingfit_check_format_trusted()that skips the strict-format / no-@ pieces)? The pointer-equality test works but feels out of place inimage_locate_script(), and the same need will likely show up the next time someone wants to source-from-DTB elsewhere, such as an FPGA image. What do you think?
Yes, I agree it's cleaner to do the exemption inside fit_check_format(). I do want to exclude the timestamp/description sanity checks, as I don't really like to have to add such properties at the top level to the control DTB just to satisfy those sanity checks - I only mentioned that it would be possible to do so.
As for a comment, I'm not sure that's needed as much in v2 now that the check is
if (CONFIG_IS_ENABLED(CONTROL_DTB_AS_FIT) && fit == gd_fdt_blob()) return 0;
and git blame would show the added config option and the reference to the documentation.
I've added that after the basic fdt_check_header(fit), which really should never fail for the control DTB, but if it does, it's better that we don't continue trying to parse it as a FIT.
Rasmus
PATCH 2/2 test: hook up test of allowing control DTB to act as FIT image
In reply to Rasmus VillemoesAdd a test demonstrating how one can embed various scripts in the control DTB and verifying that the source command can be used with ${fdtcontroladdr}.
--- arch/sandbox/dts/sandbox-test1.sh | 4 ++++ arch/sandbox/dts/sandbox-test2.sh | 4 ++++ arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++ configs/sandbox_defconfig | 1 + test/py/tests/test_source.py | 12 ++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 arch/sandbox/dts/sandbox-test1.sh create mode 100644 arch/sandbox/dts/sandbox-test2.sh create mode 100644 arch/sandbox/dts/sandbox_scripts.dtsi
arch/sandbox/dts/sandbox-test1.sh new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +echo "aaa" +source ${fdtcontroladdr}:test2 +echo "ccc"
arch/sandbox/dts/sandbox-test2.sh new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +# Some comment. +echo "bbb"
arch/sandbox/dts/sandbox_scripts.dtsi new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/ { + images { + default = "test"; + test1 { + description = "Testscript"; + data = /incbin/("sandbox-test1.sh"); + type = "script"; + compression = "none"; + }; + test2 { + description = "Another testscript"; + data = /incbin/("sandbox-test2.sh"); + type = "script"; + compression = "none"; + }; + }; +};
configs/sandbox_defconfig +1 -0
@@ -154,6 +154,7 @@ CONFIG_CMD_SPAWN=y CONFIG_MAC_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y +CONFIG_DEVICE_TREE_INCLUDES="sandbox_scripts.dtsi" CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y CONFIG_ENV_IS_IN_EXT4=y
test/py/tests/test_source.py +12 -0
@@ -34,3 +34,15 @@ def test_source(ubman): ubman.run_command('fdt rm /images default') assert 'Fail' in ubman.run_command('source || echo Fail') assert 'Fail' in ubman.run_command('source \\# || echo Fail') + + output = ubman.run_command('source ${fdtcontroladdr}:test1') + assert 'aaa' in output + assert 'bbb' in output + assert 'ccc' in output + + output = ubman.run_command('source ${fdtcontroladdr}:test2') + assert 'aaa' not in output + assert 'bbb' in output + assert 'ccc' not in output + + assert 'Fail' in ubman.run_command('source ${fdtcontroladdr}:no-such-script || echo Fail')
Signature · 1 line
2.54.0
Re: [PATCH 2/2] test: hook up test of allowing control DTB to act as FIT image
Hi Rasmus,
Quoted 25 lines · Rasmus Villemoes
test: hook up test of allowing control DTB to act as FIT image
Add a test demonstrating how one can embed various scripts in the control DTB and verifying that the source command can be used with ${fdtcontroladdr}.
Signed-off-by Rasmus Villemoes <[email protected]>
arch/sandbox/dts/sandbox-test1.sh| 4 ++++arch/sandbox/dts/sandbox-test2.sh | 4 ++++ arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++ configs/sandbox_defconfig | 1 + test/py/tests/test_source.py | 12 ++++++++++++ 5 files changed, 39 insertions(+)arch/sandbox/dts/sandbox_scripts.dtsi +8
-0@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/ { + images { + default = 'test'; + test1 { + description = 'Testscript'; + data = /incbin/('sandbox-test1.sh'); + type = 'script';
arch/sandbox/dts/sandbox_scripts.dtsi line 18
Quoted 10 lines
arch/sandbox/dts/sandbox_scripts.dtsi +10
-0+ compression = 'none'; + }; + test2 { + description = "Another testscript"; + data = /incbin/('sandbox-test2.sh'); + type = 'script'; + compression = 'none'; + }; + }; +};
There is no image called 'test', so default = 'test' points at nothing. Did you mean test1? Fixing it would also let you exercise the no-uname case (see below).
test/py/tests/test_source.py def test_source(ubman): · line 44
Quoted 13 lines
test/py/tests/test_source.py +11
-0@@ -34,3 +34,15 @@ def test_source(ubman): + output = ubman.run_command('source ${fdtcontroladdr}:test1') + assert 'aaa' in output + assert 'bbb' in output + assert 'ccc' in output + + output = ubman.run_command('source ${fdtcontroladdr}:test2') + assert 'aaa' not in output + assert 'bbb' in output + assert 'ccc' not in output + + assert 'Fail' in ubman.run_command('source ${fdtcontroladdr}:no-such-script || echo Fail')
The cover letter calls out 'source ${fdtcontroladdr}' (no name, falling through to /images/default) as the headline use case, but nothing here exercises it. Please add a case for that once default points at a real image.
arch/sandbox/dts/sandbox-test1.sh line 4
Quoted 6 lines
arch/sandbox/dts/sandbox-test1.sh +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +echo 'aaa' +source ${fdtcontroladdr}:test2 +echo 'ccc'
The commit message is very terse for three new files plus a defconfig change. Please mention that the test also verifies recursive sourcing from the control DTB (test1 invoking test2), since that is a non-trivial property worth flagging.
Also, could you add to doc/ ?
Regards,
Simon
Re: [PATCH 2/2] test: hook up test of allowing control DTB to act as FIT image
Quoted 34 lines · Simon Glass
Hi Rasmus,
Quoted 31 lines · Rasmus Villemoes
test: hook up test of allowing control DTB to act as FIT image
Add a test demonstrating how one can embed various scripts in the control DTB and verifying that the source command can be used with ${fdtcontroladdr}.
Signed-off-by Rasmus Villemoes <[email protected]>
arch/sandbox/dts/sandbox-test1.sh| 4 ++++arch/sandbox/dts/sandbox-test2.sh | 4 ++++ arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++ configs/sandbox_defconfig | 1 + test/py/tests/test_source.py | 12 ++++++++++++ 5 files changed, 39 insertions(+)arch/sandbox/dts/sandbox_scripts.dtsi +14
-0@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/ { + images { + default = 'test'; + test1 { + description = 'Testscript'; + data = /incbin/('sandbox-test1.sh'); + type = 'script'; + compression = 'none'; + }; + test2 { + description = "Another testscript"; + data = /incbin/('sandbox-test2.sh'); + type = 'script';
Quoted 8 lines
arch/sandbox/dts/sandbox_scripts.dtsi line 17
Quoted 4 lines
arch/sandbox/dts/sandbox_scripts.dtsi +4
-0+ compression = 'none'; + }; + }; +};There is no image called 'test', so default = 'test' points at nothing. Did you mean test1? Fixing it would also let you exercise the no-uname case (see below).
Good catch, thanks! I mixed this up with the .dtsi I used for the actual board I was testing this on.
Quoted 10 lines
Quoted 10 lines
test/py/tests/test_source.py +8
-0@@ -34,3 +34,15 @@ def test_source(ubman): + output = ubman.run_command('source ${fdtcontroladdr}:test1') + assert 'aaa' in output + assert 'bbb' in output + assert 'ccc' in output + + output = ubman.run_command('source ${fdtcontroladdr}:test2') + assert 'aaa' not in output + assert 'bbb' in output
Quoted 8 lines
test/py/tests/test_source.py def test_source(ubman): · line 48
Quoted 3 lines
test/py/tests/test_source.py +3
-0+ assert 'ccc' not in output + + assert 'Fail' in ubman.run_command('source ${fdtcontroladdr}:no-such-script || echo Fail')The cover letter calls out 'source ${fdtcontroladdr}' (no name, falling through to /images/default) as the headline use case, but nothing here exercises it. Please add a case for that once default points at a real image.
Done.
Quoted 11 lines
arch/sandbox/dts/sandbox-test1.sh line 4
Quoted 6 lines
arch/sandbox/dts/sandbox-test1.sh +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +echo 'aaa' +source ${fdtcontroladdr}:test2 +echo 'ccc'The commit message is very terse for three new files plus a defconfig change. Please mention that the test also verifies recursive sourcing from the control DTB (test1 invoking test2), since that is a non-trivial property worth flagging.
Agreed, done.
Quoted 1 line
Also, could you add to doc/ ?
Absolutely.
Thanks,
Rasmus
Hi Rasmus,
Quoted 3 lines · Rasmus Villemoes
The commit message for patch 1 explains what it is I'd like to be able to do, but here's some more background:
For reference:
"""
Writing those scripts in the built-in environment leads to backslatitis and missing or wrong quoting and is generally not very readable or maintainable.
"""
Quoted 60 lines
For a long time, we've embedded the boot script in the U-Boot binary by building a bootscript.itb, and using a .dtsi like
/ { config { bootscript = /incbin/("/path/to/bootscript.itb"); }; };which in turn is mentioned in
CONFIG_DEVICE_TREE_INCLUDES, that bootscript.itb FIT image has been embedded in U-Boot's control dtb. Running that was then a matter of doingfdt addr ${fdtcontroladdr} && fdt get addr bsaddr /config bootscript && source ${bsaddr}There are a couple of advantage of having the bootscript (and other script logic) embedded in the U-Boot binary. First, there's no need to figure out some separate partition to store the script in, and making sure that gets updated whenever the bootloader itself does. Second, one doesn't need to worry about verifying the script; whatever steps one needs to take to implement secure boot for U-Boot itself will by necessity also cover the control dtb (if nothing else then because that's where the public key for the kernel verification lives).
Now with the stricter requirements of libfdt starting from v2026.04, the above command no longer worked, or only half the time, because the embedded FIT image may not land on an 8-byte aligned address. So that line had to be changed a little (line breaks added)
fdt addr ${fdtcontroladdr} && fdt get addr bsaddr /config bootscript && fdt get size bssize /config bootscript && cp.b ${bsaddr} ${loadaddr} ${bssize} && source ${loadaddr}which is getting quite unwieldy.
Then it struck me that one could perhaps simplify all of this quite a
lot: Cut out the intermediate bootscript.itb, just create a .dtsi which directly puts a /images node inside the control dtb/ { images { default = "bootscript"; bootscript { description = "Boot script"; data = /incbin/("/path/to/bootscript.sh"); type = "script"; compression = "none"; }; }; };and treat the control dtb itself as a FIT image; so the command to put in $bootcmd becomes simply
source ${fdtcontroladdr}:bootscriptand embedding other pieces of callable scripts is quite trivial.
Quoted 8 lines
And that almost works out-of-the-box, except for the
fit_check_format()sanity check.I realize this is a bit of a hack, but I do think it's somewhat elegant, and avoids inventing a whole lot of extra infrastructure for allowing one to embed larger scripts and invoke them from the shell. I am of course happy to put this exemption for
gd->fdt_blobunder aCONFIG_knob if that is deemed necessary.
Have you tried to use the text-based environment mechanism as described in https://docs.u-boot.org/en/latest/usage/environment.html#text-based-environment? (I've learned about this only very recently with the Apple devices being migrated to it)
Cheers,
Quentin
Quoted 16 lines · Quentin Schulz
Hi Rasmus,
Quoted 3 lines · Rasmus Villemoes
The commit message for patch 1 explains what it is I'd like to be able to do, but here's some more background:
For reference:
"""
Writing those scripts in the built-in environment leads to backslatitis and missing or wrong quoting and is generally not very readable or maintainable.
"""
Quoted 6 lines
Have you tried to use the text-based environment mechanism as described in
https://docs.u-boot.org/en/latest/usage/environment.html#text-based-environment?
(I've learned about this only very recently with the Apple devices being migrated to it)
Hi Quentin
Thanks for the suggestion. However, not only do I know about that concept, I'm the author of f3d8f7dd73a ("Allow providing default environment from file") which is a slightly different mechanism from the one you refer to (and predates it by a few years), and which we've been using ever since.
While both represent a definite improvement in the handling of the _environment variables_ over definining it as a giant C string, it is still not a very good way of writing whole scripts.
So the "text-based environment" method does allow you to (and encouarages) indentation, but you don't get your editor's help to do the if/while/... nesting properly because it's not a real script, and you can't run shellcheck on those embedded snippets.
Moreover, while it _looks_ like a normal, commands-terminate-at-newline, script, the stuff you put in those env variables must have all individual commands terminated by a semicolon. Which to some extent makes it even worse, because that is extremely easy to forget or overlook. Imagine something like
if something something ; then
echo "yay";
go_on_to_other_stuff; else
echo "uh oh, something failed" <----
handle_that_error;
fi
Writing "scripts" in an env variable that can be called with "run foo" is a bit like having to write normal shell scripts in a one-liner one can pass to "sh -c '...'".
So no, I don't that's really a useful substitute for having a way to properly embed real scripts in U-Boot.
Rasmus
Hi Rasmus,
Quoted 1 line · Rasmus Villemoes
RFC: allow the control DTB to act as a FIT image
Thanks for the write-up. Makes sense to me.
A couple of series-level concerns beyond the per-patch comments.
First, this needs documentation. The control DTB doubling as a FIT image, and 'source ${fdtcontroladdr}:foo' becoming a supported idiom, deserves a short page under doc/usage/ covering how to set up CONFIG_DEVICE_TREE_INCLUDES with an 'images' node, the constraints (script type, compression none, etc.) and the security argument from the cover letter.
Quoted 2 lines
I am of course happy to put this exemption for
gd->fdt_blobunder aCONFIG_knob if that is deemed necessary.
Please decide this now rather than leaving it open. My preference is a Kconfig option (default n) so boards keep the strict fit_check_format() behaviour unless they opt in. That also gives a natural home for the doc/usage/ page and makes it discoverable via menuconfig. What do you think?
Regards,
Simon
Hi Simon,
Quoted 7 lines · Simon Glass
Hi Rasmus,
Quoted 1 line · Rasmus Villemoes
RFC: allow the control DTB to act as a FIT image
Thanks for the write-up. Makes sense to me.
Thanks, and thanks for the nice review.
Quoted 8 lines
A couple of series-level concerns beyond the per-patch comments.
First, this needs documentation. The control DTB doubling as a FIT image, and 'source ${fdtcontroladdr}:foo' becoming a supported idiom, deserves a short page under doc/usage/ covering how to set up
CONFIG_DEVICE_TREE_INCLUDESwith an 'images' node, the constraints (script type, compression none, etc.) and the security argument from the cover letter.
Completely agreed. I'll add a section below "External .dtsi fragments" in control.rst.
Quoted 8 lines
Quoted 2 lines
I am of course happy to put this exemption for
gd->fdt_blobunder aCONFIG_knob if that is deemed necessary.Please decide this now rather than leaving it open. My preference is a
Kconfigoption (default n) so boards keep the strictfit_check_format()behaviour unless they opt in. That also gives a natural home for the doc/usage/ page and makes it discoverable via menuconfig. What do you think?
I've added a CONFIG_CONTROL_DTB_AS_FIT option (as always, naming is the hardest part), with a short help text and a pointer to control.rst for further details.
I'll respond to the per-patch comments and then send v2 shortly.
Rasmus